Skip to content

Commit 75077dd

Browse files
authored
CSHARP-5300: Specify how to handle unacknowledged bulk writes (#1505)
1 parent bcf2684 commit 75077dd

File tree

5 files changed

+474
-0
lines changed

5 files changed

+474
-0
lines changed
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
{
2+
"description": "unacknowledged-client-bulkWrite",
3+
"schemaVersion": "1.7",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "8.0",
7+
"serverless": "forbid"
8+
}
9+
],
10+
"createEntities": [
11+
{
12+
"client": {
13+
"id": "client",
14+
"useMultipleMongoses": false,
15+
"observeEvents": [
16+
"commandStartedEvent",
17+
"commandSucceededEvent",
18+
"commandFailedEvent"
19+
],
20+
"uriOptions": {
21+
"w": 0
22+
}
23+
}
24+
},
25+
{
26+
"database": {
27+
"id": "database",
28+
"client": "client",
29+
"databaseName": "command-monitoring-tests"
30+
}
31+
},
32+
{
33+
"collection": {
34+
"id": "collection",
35+
"database": "database",
36+
"collectionName": "test"
37+
}
38+
}
39+
],
40+
"initialData": [
41+
{
42+
"collectionName": "test",
43+
"databaseName": "command-monitoring-tests",
44+
"documents": [
45+
{
46+
"_id": 1,
47+
"x": 11
48+
},
49+
{
50+
"_id": 2,
51+
"x": 22
52+
},
53+
{
54+
"_id": 3,
55+
"x": 33
56+
}
57+
]
58+
}
59+
],
60+
"_yamlAnchors": {
61+
"namespace": "command-monitoring-tests.test"
62+
},
63+
"tests": [
64+
{
65+
"description": "A successful mixed client bulkWrite",
66+
"operations": [
67+
{
68+
"object": "client",
69+
"name": "clientBulkWrite",
70+
"arguments": {
71+
"models": [
72+
{
73+
"insertOne": {
74+
"namespace": "command-monitoring-tests.test",
75+
"document": {
76+
"_id": 4,
77+
"x": 44
78+
}
79+
}
80+
},
81+
{
82+
"updateOne": {
83+
"namespace": "command-monitoring-tests.test",
84+
"filter": {
85+
"_id": 3
86+
},
87+
"update": {
88+
"$set": {
89+
"x": 333
90+
}
91+
}
92+
}
93+
}
94+
],
95+
"ordered": false
96+
},
97+
"expectResult": {
98+
"insertedCount": {
99+
"$$unsetOrMatches": 0
100+
},
101+
"upsertedCount": {
102+
"$$unsetOrMatches": 0
103+
},
104+
"matchedCount": {
105+
"$$unsetOrMatches": 0
106+
},
107+
"modifiedCount": {
108+
"$$unsetOrMatches": 0
109+
},
110+
"deletedCount": {
111+
"$$unsetOrMatches": 0
112+
},
113+
"insertResults": {
114+
"$$unsetOrMatches": {}
115+
},
116+
"updateResults": {
117+
"$$unsetOrMatches": {}
118+
},
119+
"deleteResults": {
120+
"$$unsetOrMatches": {}
121+
}
122+
}
123+
},
124+
{
125+
"object": "collection",
126+
"name": "find",
127+
"arguments": {
128+
"filter": {}
129+
},
130+
"expectResult": [
131+
{
132+
"_id": 1,
133+
"x": 11
134+
},
135+
{
136+
"_id": 2,
137+
"x": 22
138+
},
139+
{
140+
"_id": 3,
141+
"x": 333
142+
},
143+
{
144+
"_id": 4,
145+
"x": 44
146+
}
147+
]
148+
}
149+
],
150+
"expectEvents": [
151+
{
152+
"client": "client",
153+
"ignoreExtraEvents": true,
154+
"events": [
155+
{
156+
"commandStartedEvent": {
157+
"commandName": "bulkWrite",
158+
"databaseName": "admin",
159+
"command": {
160+
"bulkWrite": 1,
161+
"errorsOnly": true,
162+
"ordered": false,
163+
"ops": [
164+
{
165+
"insert": 0,
166+
"document": {
167+
"_id": 4,
168+
"x": 44
169+
}
170+
},
171+
{
172+
"update": 0,
173+
"filter": {
174+
"_id": 3
175+
},
176+
"updateMods": {
177+
"$set": {
178+
"x": 333
179+
}
180+
},
181+
"multi": false
182+
}
183+
],
184+
"nsInfo": [
185+
{
186+
"ns": "command-monitoring-tests.test"
187+
}
188+
]
189+
}
190+
}
191+
},
192+
{
193+
"commandSucceededEvent": {
194+
"commandName": "bulkWrite",
195+
"reply": {
196+
"ok": 1,
197+
"nInserted": {
198+
"$$exists": false
199+
},
200+
"nMatched": {
201+
"$$exists": false
202+
},
203+
"nModified": {
204+
"$$exists": false
205+
},
206+
"nUpserted": {
207+
"$$exists": false
208+
},
209+
"nDeleted": {
210+
"$$exists": false
211+
}
212+
}
213+
}
214+
}
215+
]
216+
}
217+
]
218+
}
219+
]
220+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
description: "unacknowledged-client-bulkWrite"
2+
3+
schemaVersion: "1.7"
4+
5+
runOnRequirements:
6+
- minServerVersion: "8.0"
7+
serverless: forbid
8+
9+
createEntities:
10+
- client:
11+
id: &client client
12+
useMultipleMongoses: false
13+
observeEvents:
14+
- commandStartedEvent
15+
- commandSucceededEvent
16+
- commandFailedEvent
17+
uriOptions:
18+
w: 0
19+
- database:
20+
id: &database database
21+
client: *client
22+
databaseName: &databaseName command-monitoring-tests
23+
- collection:
24+
id: &collection collection
25+
database: *database
26+
collectionName: &collectionName test
27+
28+
initialData:
29+
- collectionName: *collectionName
30+
databaseName: *databaseName
31+
documents:
32+
- { _id: 1, x: 11 }
33+
- { _id: 2, x: 22 }
34+
- { _id: 3, x: 33 }
35+
36+
_yamlAnchors:
37+
namespace: &namespace "command-monitoring-tests.test"
38+
39+
tests:
40+
- description: 'A successful mixed client bulkWrite'
41+
operations:
42+
- object: *client
43+
name: clientBulkWrite
44+
arguments:
45+
models:
46+
- insertOne:
47+
namespace: *namespace
48+
document: { _id: 4, x: 44 }
49+
- updateOne:
50+
namespace: *namespace
51+
filter: { _id: 3 }
52+
update: { $set: { x: 333 } }
53+
ordered: false
54+
expectResult:
55+
insertedCount:
56+
$$unsetOrMatches: 0
57+
upsertedCount:
58+
$$unsetOrMatches: 0
59+
matchedCount:
60+
$$unsetOrMatches: 0
61+
modifiedCount:
62+
$$unsetOrMatches: 0
63+
deletedCount:
64+
$$unsetOrMatches: 0
65+
insertResults:
66+
$$unsetOrMatches: {}
67+
updateResults:
68+
$$unsetOrMatches: {}
69+
deleteResults:
70+
$$unsetOrMatches: {}
71+
# Force completion of the w:0 write by executing a find on the same connection
72+
- object: *collection
73+
name: find
74+
arguments:
75+
filter: {}
76+
expectResult:
77+
- { _id: 1, x: 11 }
78+
- { _id: 2, x: 22 }
79+
- { _id: 3, x: 333 }
80+
- { _id: 4, x: 44 }
81+
82+
expectEvents:
83+
-
84+
client: *client
85+
ignoreExtraEvents: true
86+
events:
87+
- commandStartedEvent:
88+
commandName: bulkWrite
89+
databaseName: admin
90+
command:
91+
bulkWrite: 1
92+
errorsOnly: true
93+
ordered: false
94+
ops:
95+
- insert: 0
96+
document: { _id: 4, x: 44 }
97+
- update: 0
98+
filter: { _id: 3 }
99+
updateMods: { $set: { x: 333 } }
100+
multi: false
101+
nsInfo:
102+
- ns: *namespace
103+
- commandSucceededEvent:
104+
commandName: bulkWrite
105+
reply:
106+
ok: 1
107+
nInserted: { $$exists: false }
108+
nMatched: { $$exists: false }
109+
nModified: { $$exists: false }
110+
nUpserted: { $$exists: false }
111+
nDeleted: { $$exists: false }

specifications/crud/tests/unified/client-bulkWrite-errors.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,64 @@
450450
}
451451
}
452452
]
453+
},
454+
{
455+
"description": "Requesting unacknowledged write with verboseResults is a client-side error",
456+
"operations": [
457+
{
458+
"name": "clientBulkWrite",
459+
"object": "client0",
460+
"arguments": {
461+
"models": [
462+
{
463+
"insertOne": {
464+
"namespace": "crud-tests.coll0",
465+
"document": {
466+
"_id": 10
467+
}
468+
}
469+
}
470+
],
471+
"verboseResults": true,
472+
"ordered": false,
473+
"writeConcern": {
474+
"w": 0
475+
}
476+
},
477+
"expectError": {
478+
"isClientError": true,
479+
"errorContains": "Cannot request unacknowledged write concern and verbose results"
480+
}
481+
}
482+
]
483+
},
484+
{
485+
"description": "Requesting unacknowledged write with ordered is a client-side error",
486+
"operations": [
487+
{
488+
"name": "clientBulkWrite",
489+
"object": "client0",
490+
"arguments": {
491+
"models": [
492+
{
493+
"insertOne": {
494+
"namespace": "crud-tests.coll0",
495+
"document": {
496+
"_id": 10
497+
}
498+
}
499+
}
500+
],
501+
"writeConcern": {
502+
"w": 0
503+
}
504+
},
505+
"expectError": {
506+
"isClientError": true,
507+
"errorContains": "Cannot request unacknowledged write concern and ordered writes"
508+
}
509+
}
510+
]
453511
}
454512
]
455513
}

0 commit comments

Comments
 (0)