Skip to content

Commit c9996fb

Browse files
committed
test(retryableWrites): sync retryableWrites tests
Fixes NODE-1706 Fixes NODE-1714
1 parent 953d4f9 commit c9996fb

9 files changed

+158
-3
lines changed

test/functional/spec/retryable-writes/README.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ the cluster.
2424
Server Fail Point
2525
=================
2626

27-
The tests depend on a server fail point, ``onPrimaryTransactionalWrite``, which
27+
Some tests depend on a server fail point, ``onPrimaryTransactionalWrite``, which
2828
allows us to force a network error before the server would return a write result
2929
to the client. The fail point also allows control whether the server will
3030
successfully commit the write via its ``failBeforeCommitExceptionCode`` option.
@@ -140,8 +140,8 @@ Each YAML file has the following keys:
140140

141141
- ``clientOptions``: Parameters to pass to MongoClient().
142142

143-
- ``failPoint``: The ``configureFailPoint`` command document to run to
144-
configure a fail point on the primary server. Drivers must ensure that
143+
- ``failPoint`` (optional): The ``configureFailPoint`` command document to run
144+
to configure a fail point on the primary server. Drivers must ensure that
145145
``configureFailPoint`` is the first field in the command.
146146

147147
- ``operation``: Document describing the operation to be executed. The

test/functional/spec/retryable-writes/bulkWrite-serverErrors.json

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"outcome": {
7272
"result": {
7373
"deletedCount": 1,
74+
"insertedCount": 1,
7475
"insertedIds": {
7576
"1": 3
7677
},
@@ -156,6 +157,7 @@
156157
"outcome": {
157158
"result": {
158159
"deletedCount": 1,
160+
"insertedCount": 1,
159161
"insertedIds": {
160162
"1": 3
161163
},

test/functional/spec/retryable-writes/bulkWrite-serverErrors.yml

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ tests:
3737
outcome:
3838
result:
3939
deletedCount: 1
40+
insertedCount: 1
4041
insertedIds: { 1: 3 }
4142
matchedCount: 1
4243
modifiedCount: 1
@@ -79,6 +80,7 @@ tests:
7980
outcome:
8081
result:
8182
deletedCount: 1
83+
insertedCount: 1
8284
insertedIds: { 1: 3 }
8385
matchedCount: 1
8486
modifiedCount: 1

test/functional/spec/retryable-writes/bulkWrite.json

+10
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"outcome": {
6262
"result": {
6363
"deletedCount": 1,
64+
"insertedCount": 1,
6465
"insertedIds": {
6566
"0": 2
6667
},
@@ -178,6 +179,7 @@
178179
"outcome": {
179180
"result": {
180181
"deletedCount": 1,
182+
"insertedCount": 3,
181183
"insertedIds": {
182184
"0": 2,
183185
"2": 3,
@@ -271,6 +273,7 @@
271273
"outcome": {
272274
"result": {
273275
"deletedCount": 0,
276+
"insertedCount": 1,
274277
"insertedIds": {
275278
"0": 2
276279
},
@@ -352,6 +355,7 @@
352355
"outcome": {
353356
"result": {
354357
"deletedCount": 0,
358+
"insertedCount": 1,
355359
"insertedIds": {
356360
"0": 2
357361
},
@@ -416,6 +420,7 @@
416420
"outcome": {
417421
"result": {
418422
"deletedCount": 0,
423+
"insertedCount": 2,
419424
"insertedIds": {
420425
"0": 2,
421426
"1": 3
@@ -501,6 +506,7 @@
501506
"error": true,
502507
"result": {
503508
"deletedCount": 0,
509+
"insertedCount": 0,
504510
"insertedIds": {},
505511
"matchedCount": 0,
506512
"modifiedCount": 0,
@@ -575,6 +581,7 @@
575581
"error": true,
576582
"result": {
577583
"deletedCount": 0,
584+
"insertedCount": 1,
578585
"insertedIds": {
579586
"0": 2
580587
},
@@ -660,6 +667,7 @@
660667
"error": true,
661668
"result": {
662669
"deletedCount": 0,
670+
"insertedCount": 1,
663671
"insertedIds": {
664672
"1": 2
665673
},
@@ -726,6 +734,7 @@
726734
"outcome": {
727735
"result": {
728736
"deletedCount": 1,
737+
"insertedCount": 1,
729738
"insertedIds": {
730739
"1": 2
731740
},
@@ -793,6 +802,7 @@
793802
"outcome": {
794803
"result": {
795804
"deletedCount": 0,
805+
"insertedCount": 1,
796806
"insertedIds": {
797807
"1": 2
798808
},

test/functional/spec/retryable-writes/bulkWrite.yml

+10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ tests:
3232
outcome:
3333
result:
3434
deletedCount: 1
35+
insertedCount: 1
3536
insertedIds: { 0: 2 }
3637
matchedCount: 1
3738
modifiedCount: 1
@@ -90,6 +91,7 @@ tests:
9091
outcome:
9192
result:
9293
deletedCount: 1
94+
insertedCount: 3
9395
insertedIds: { 0: 2, 2: 3, 4: 5 }
9496
matchedCount: 2
9597
modifiedCount: 2
@@ -130,6 +132,7 @@ tests:
130132
outcome:
131133
result:
132134
deletedCount: 0
135+
insertedCount: 1
133136
insertedIds: { 0: 2 }
134137
matchedCount: 2
135138
modifiedCount: 2
@@ -168,6 +171,7 @@ tests:
168171
outcome:
169172
result:
170173
deletedCount: 0
174+
insertedCount: 1
171175
insertedIds: { 0: 2 }
172176
matchedCount: 2
173177
modifiedCount: 2
@@ -200,6 +204,7 @@ tests:
200204
outcome:
201205
result:
202206
deletedCount: 0
207+
insertedCount: 2
203208
insertedIds: { 0: 2, 1: 3 }
204209
matchedCount: 0
205210
modifiedCount: 0
@@ -240,6 +245,7 @@ tests:
240245
error: true
241246
result:
242247
deletedCount: 0
248+
insertedCount: 0
243249
insertedIds: { }
244250
matchedCount: 0
245251
modifiedCount: 0
@@ -278,6 +284,7 @@ tests:
278284
error: true
279285
result:
280286
deletedCount: 0
287+
insertedCount: 1
281288
insertedIds: { 0: 2 }
282289
matchedCount: 0
283290
modifiedCount: 0
@@ -318,6 +325,7 @@ tests:
318325
error: true
319326
result:
320327
deletedCount: 0
328+
insertedCount: 1
321329
insertedIds: { 1: 2 }
322330
matchedCount: 1
323331
modifiedCount: 1
@@ -355,6 +363,7 @@ tests:
355363
outcome:
356364
result:
357365
deletedCount: 1
366+
insertedCount: 1
358367
insertedIds: { 1: 2 }
359368
matchedCount: 0
360369
modifiedCount: 0
@@ -392,6 +401,7 @@ tests:
392401
outcome:
393402
result:
394403
deletedCount: 0
404+
insertedCount: 1
395405
insertedIds: { 1: 2 }
396406
matchedCount: 1
397407
modifiedCount: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"data": [
3+
{
4+
"_id": 1,
5+
"x": 11
6+
},
7+
{
8+
"_id": 2,
9+
"x": 22
10+
}
11+
],
12+
"minServerVersion": "3.6",
13+
"tests": [
14+
{
15+
"description": "DeleteMany ignores retryWrites",
16+
"clientOptions": {
17+
"retryWrites": true
18+
},
19+
"operation": {
20+
"name": "deleteMany",
21+
"arguments": {
22+
"filter": {}
23+
}
24+
},
25+
"outcome": {
26+
"result": {
27+
"deletedCount": 2
28+
},
29+
"collection": {
30+
"data": []
31+
}
32+
}
33+
}
34+
]
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
data:
2+
- { _id: 1, x: 11 }
3+
- { _id: 2, x: 22 }
4+
5+
minServerVersion: '3.6'
6+
7+
tests:
8+
-
9+
description: "DeleteMany ignores retryWrites"
10+
clientOptions:
11+
retryWrites: true
12+
operation:
13+
name: "deleteMany"
14+
arguments:
15+
filter: { }
16+
outcome:
17+
result:
18+
deletedCount: 2
19+
collection:
20+
data: []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"data": [
3+
{
4+
"_id": 1,
5+
"x": 11
6+
},
7+
{
8+
"_id": 2,
9+
"x": 22
10+
}
11+
],
12+
"minServerVersion": "3.6",
13+
"tests": [
14+
{
15+
"description": "UpdateMany ignores retryWrites",
16+
"clientOptions": {
17+
"retryWrites": true
18+
},
19+
"operation": {
20+
"name": "updateMany",
21+
"arguments": {
22+
"filter": {},
23+
"update": {
24+
"$inc": {
25+
"x": 1
26+
}
27+
}
28+
}
29+
},
30+
"outcome": {
31+
"result": {
32+
"matchedCount": 2,
33+
"modifiedCount": 2,
34+
"upsertedCount": 0
35+
},
36+
"collection": {
37+
"data": [
38+
{
39+
"_id": 1,
40+
"x": 12
41+
},
42+
{
43+
"_id": 2,
44+
"x": 23
45+
}
46+
]
47+
}
48+
}
49+
}
50+
]
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
data:
2+
- { _id: 1, x: 11 }
3+
- { _id: 2, x: 22 }
4+
5+
minServerVersion: '3.6'
6+
7+
tests:
8+
-
9+
description: "UpdateMany ignores retryWrites"
10+
clientOptions:
11+
retryWrites: true
12+
operation:
13+
name: "updateMany"
14+
arguments:
15+
filter: { }
16+
update: { $inc: { x : 1 }}
17+
outcome:
18+
result:
19+
matchedCount: 2
20+
modifiedCount: 2
21+
upsertedCount: 0
22+
collection:
23+
data:
24+
- { _id: 1, x: 12 }
25+
- { _id: 2, x: 23 }

0 commit comments

Comments
 (0)