Skip to content

Commit 568029a

Browse files
authored
DRIVERS-2525 Add a command logging test covering unacknowledged write behavior (#1366)
1 parent 1d5630d commit 568029a

File tree

2 files changed

+199
-0
lines changed

2 files changed

+199
-0
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{
2+
"description": "unacknowledged-write",
3+
"schemaVersion": "1.13",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client",
8+
"observeLogMessages": {
9+
"command": "debug"
10+
}
11+
}
12+
},
13+
{
14+
"database": {
15+
"id": "database",
16+
"client": "client",
17+
"databaseName": "logging-tests"
18+
}
19+
},
20+
{
21+
"collection": {
22+
"id": "collection",
23+
"database": "database",
24+
"collectionName": "logging-tests-collection",
25+
"collectionOptions": {
26+
"writeConcern": {
27+
"w": 0
28+
}
29+
}
30+
}
31+
}
32+
],
33+
"initialData": [
34+
{
35+
"collectionName": "logging-tests-collection",
36+
"databaseName": "logging-tests",
37+
"documents": [
38+
{
39+
"_id": 1
40+
}
41+
]
42+
}
43+
],
44+
"tests": [
45+
{
46+
"description": "An unacknowledged write generates a succeeded log message with ok: 1 reply",
47+
"operations": [
48+
{
49+
"name": "insertOne",
50+
"object": "collection",
51+
"arguments": {
52+
"document": {
53+
"_id": 2
54+
}
55+
}
56+
}
57+
],
58+
"expectLogMessages": [
59+
{
60+
"client": "client",
61+
"messages": [
62+
{
63+
"level": "debug",
64+
"component": "command",
65+
"data": {
66+
"message": "Command started",
67+
"databaseName": "logging-tests",
68+
"commandName": "insert",
69+
"command": {
70+
"$$matchAsDocument": {
71+
"$$matchAsRoot": {
72+
"insert": "logging-tests-collection",
73+
"$db": "logging-tests"
74+
}
75+
}
76+
},
77+
"requestId": {
78+
"$$type": [
79+
"int",
80+
"long"
81+
]
82+
},
83+
"serverHost": {
84+
"$$type": "string"
85+
},
86+
"serverPort": {
87+
"$$type": [
88+
"int",
89+
"long"
90+
]
91+
}
92+
}
93+
},
94+
{
95+
"level": "debug",
96+
"component": "command",
97+
"data": {
98+
"message": "Command succeeded",
99+
"commandName": "insert",
100+
"reply": {
101+
"$$matchAsDocument": {
102+
"ok": 1
103+
}
104+
},
105+
"requestId": {
106+
"$$type": [
107+
"int",
108+
"long"
109+
]
110+
},
111+
"serverHost": {
112+
"$$type": "string"
113+
},
114+
"serverPort": {
115+
"$$type": [
116+
"int",
117+
"long"
118+
]
119+
},
120+
"durationMS": {
121+
"$$type": [
122+
"double",
123+
"int",
124+
"long"
125+
]
126+
}
127+
}
128+
}
129+
]
130+
}
131+
]
132+
}
133+
]
134+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
description: "unacknowledged-write"
2+
3+
schemaVersion: "1.13"
4+
5+
createEntities:
6+
- client:
7+
id: &client client
8+
observeLogMessages:
9+
command: debug
10+
- database:
11+
id: &database database
12+
client: *client
13+
databaseName: &databaseName logging-tests
14+
- collection:
15+
id: &collection collection
16+
database: *database
17+
collectionName: &collectionName logging-tests-collection
18+
collectionOptions:
19+
writeConcern: { w: 0 }
20+
21+
initialData:
22+
- collectionName: *collectionName
23+
databaseName: *databaseName
24+
documents:
25+
- { _id: 1 }
26+
27+
tests:
28+
- description: "An unacknowledged write generates a succeeded log message with ok: 1 reply"
29+
operations:
30+
- name: insertOne
31+
object: *collection
32+
arguments:
33+
document: { _id: 2 }
34+
expectLogMessages:
35+
- client: *client
36+
messages:
37+
- level: debug
38+
component: command
39+
data:
40+
message: "Command started"
41+
databaseName: *databaseName
42+
commandName: insert
43+
command:
44+
$$matchAsDocument:
45+
$$matchAsRoot:
46+
insert: *collectionName
47+
$db: *databaseName
48+
requestId: { $$type: [int, long] }
49+
serverHost: { $$type: string }
50+
serverPort: { $$type: [int, long] }
51+
52+
- level: debug
53+
component: command
54+
data:
55+
message: "Command succeeded"
56+
commandName: insert
57+
reply:
58+
$$matchAsDocument:
59+
ok: 1
60+
requestId: { $$type: [int, long] }
61+
serverHost: { $$type: string }
62+
serverPort: { $$type: [int, long] }
63+
durationMS: { $$type: [double, int, long] }
64+
65+

0 commit comments

Comments
 (0)