Skip to content

Commit bcf2684

Browse files
authored
CSHARP-5342: Make sure ClientBulkWrite supports retryability properly (#1506)
1 parent 0abee49 commit bcf2684

15 files changed

+1845
-4
lines changed
Lines changed: 351 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,351 @@
1+
{
2+
"description": "client bulkWrite retryable writes with client errors",
3+
"schemaVersion": "1.21",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "8.0",
7+
"topologies": [
8+
"replicaset",
9+
"sharded",
10+
"load-balanced"
11+
],
12+
"serverless": "forbid"
13+
}
14+
],
15+
"createEntities": [
16+
{
17+
"client": {
18+
"id": "client0",
19+
"observeEvents": [
20+
"commandStartedEvent"
21+
],
22+
"useMultipleMongoses": false
23+
}
24+
},
25+
{
26+
"database": {
27+
"id": "database0",
28+
"client": "client0",
29+
"databaseName": "retryable-writes-tests"
30+
}
31+
},
32+
{
33+
"collection": {
34+
"id": "collection0",
35+
"database": "database0",
36+
"collectionName": "coll0"
37+
}
38+
}
39+
],
40+
"initialData": [
41+
{
42+
"collectionName": "coll0",
43+
"databaseName": "retryable-writes-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": "retryable-writes-tests.coll0"
62+
},
63+
"tests": [
64+
{
65+
"description": "client bulkWrite with one network error succeeds after retry",
66+
"operations": [
67+
{
68+
"object": "testRunner",
69+
"name": "failPoint",
70+
"arguments": {
71+
"client": "client0",
72+
"failPoint": {
73+
"configureFailPoint": "failCommand",
74+
"mode": {
75+
"times": 1
76+
},
77+
"data": {
78+
"failCommands": [
79+
"bulkWrite"
80+
],
81+
"closeConnection": true
82+
}
83+
}
84+
}
85+
},
86+
{
87+
"object": "client0",
88+
"name": "clientBulkWrite",
89+
"arguments": {
90+
"models": [
91+
{
92+
"insertOne": {
93+
"namespace": "retryable-writes-tests.coll0",
94+
"document": {
95+
"_id": 4,
96+
"x": 44
97+
}
98+
}
99+
}
100+
],
101+
"verboseResults": true
102+
},
103+
"expectResult": {
104+
"insertedCount": 1,
105+
"upsertedCount": 0,
106+
"matchedCount": 0,
107+
"modifiedCount": 0,
108+
"deletedCount": 0,
109+
"insertResults": {
110+
"0": {
111+
"insertedId": 4
112+
}
113+
},
114+
"updateResults": {},
115+
"deleteResults": {}
116+
}
117+
}
118+
],
119+
"expectEvents": [
120+
{
121+
"client": "client0",
122+
"events": [
123+
{
124+
"commandStartedEvent": {
125+
"commandName": "bulkWrite",
126+
"databaseName": "admin",
127+
"command": {
128+
"bulkWrite": 1,
129+
"errorsOnly": false,
130+
"ordered": true,
131+
"ops": [
132+
{
133+
"insert": 0,
134+
"document": {
135+
"_id": 4,
136+
"x": 44
137+
}
138+
}
139+
],
140+
"nsInfo": [
141+
{
142+
"ns": "retryable-writes-tests.coll0"
143+
}
144+
],
145+
"lsid": {
146+
"$$exists": true
147+
},
148+
"txnNumber": {
149+
"$$exists": true
150+
}
151+
}
152+
}
153+
},
154+
{
155+
"commandStartedEvent": {
156+
"commandName": "bulkWrite",
157+
"databaseName": "admin",
158+
"command": {
159+
"bulkWrite": 1,
160+
"errorsOnly": false,
161+
"ordered": true,
162+
"ops": [
163+
{
164+
"insert": 0,
165+
"document": {
166+
"_id": 4,
167+
"x": 44
168+
}
169+
}
170+
],
171+
"nsInfo": [
172+
{
173+
"ns": "retryable-writes-tests.coll0"
174+
}
175+
],
176+
"lsid": {
177+
"$$exists": true
178+
},
179+
"txnNumber": {
180+
"$$exists": true
181+
}
182+
}
183+
}
184+
}
185+
]
186+
}
187+
],
188+
"outcome": [
189+
{
190+
"collectionName": "coll0",
191+
"databaseName": "retryable-writes-tests",
192+
"documents": [
193+
{
194+
"_id": 1,
195+
"x": 11
196+
},
197+
{
198+
"_id": 2,
199+
"x": 22
200+
},
201+
{
202+
"_id": 3,
203+
"x": 33
204+
},
205+
{
206+
"_id": 4,
207+
"x": 44
208+
}
209+
]
210+
}
211+
]
212+
},
213+
{
214+
"description": "client bulkWrite with two network errors fails after retry",
215+
"operations": [
216+
{
217+
"object": "testRunner",
218+
"name": "failPoint",
219+
"arguments": {
220+
"client": "client0",
221+
"failPoint": {
222+
"configureFailPoint": "failCommand",
223+
"mode": {
224+
"times": 2
225+
},
226+
"data": {
227+
"failCommands": [
228+
"bulkWrite"
229+
],
230+
"closeConnection": true
231+
}
232+
}
233+
}
234+
},
235+
{
236+
"object": "client0",
237+
"name": "clientBulkWrite",
238+
"arguments": {
239+
"models": [
240+
{
241+
"insertOne": {
242+
"namespace": "retryable-writes-tests.coll0",
243+
"document": {
244+
"_id": 4,
245+
"x": 44
246+
}
247+
}
248+
}
249+
],
250+
"verboseResults": true
251+
},
252+
"expectError": {
253+
"isClientError": true,
254+
"errorLabelsContain": [
255+
"RetryableWriteError"
256+
]
257+
}
258+
}
259+
],
260+
"expectEvents": [
261+
{
262+
"client": "client0",
263+
"events": [
264+
{
265+
"commandStartedEvent": {
266+
"commandName": "bulkWrite",
267+
"databaseName": "admin",
268+
"command": {
269+
"bulkWrite": 1,
270+
"errorsOnly": false,
271+
"ordered": true,
272+
"ops": [
273+
{
274+
"insert": 0,
275+
"document": {
276+
"_id": 4,
277+
"x": 44
278+
}
279+
}
280+
],
281+
"nsInfo": [
282+
{
283+
"ns": "retryable-writes-tests.coll0"
284+
}
285+
],
286+
"lsid": {
287+
"$$exists": true
288+
},
289+
"txnNumber": {
290+
"$$exists": true
291+
}
292+
}
293+
}
294+
},
295+
{
296+
"commandStartedEvent": {
297+
"commandName": "bulkWrite",
298+
"databaseName": "admin",
299+
"command": {
300+
"bulkWrite": 1,
301+
"errorsOnly": false,
302+
"ordered": true,
303+
"ops": [
304+
{
305+
"insert": 0,
306+
"document": {
307+
"_id": 4,
308+
"x": 44
309+
}
310+
}
311+
],
312+
"nsInfo": [
313+
{
314+
"ns": "retryable-writes-tests.coll0"
315+
}
316+
],
317+
"lsid": {
318+
"$$exists": true
319+
},
320+
"txnNumber": {
321+
"$$exists": true
322+
}
323+
}
324+
}
325+
}
326+
]
327+
}
328+
],
329+
"outcome": [
330+
{
331+
"collectionName": "coll0",
332+
"databaseName": "retryable-writes-tests",
333+
"documents": [
334+
{
335+
"_id": 1,
336+
"x": 11
337+
},
338+
{
339+
"_id": 2,
340+
"x": 22
341+
},
342+
{
343+
"_id": 3,
344+
"x": 33
345+
}
346+
]
347+
}
348+
]
349+
}
350+
]
351+
}

0 commit comments

Comments
 (0)