Skip to content

Commit aec7136

Browse files
committed
PHPLIB-532: Sync spec tests for retryable writes
1 parent 8060d72 commit aec7136

18 files changed

+1792
-22
lines changed
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
{
2+
"runOn": [
3+
{
4+
"minServerVersion": "4.3.1",
5+
"topology": [
6+
"replicaset",
7+
"sharded"
8+
]
9+
}
10+
],
11+
"data": [
12+
{
13+
"_id": 1,
14+
"x": 11
15+
},
16+
{
17+
"_id": 2,
18+
"x": 22
19+
}
20+
],
21+
"tests": [
22+
{
23+
"description": "BulkWrite succeeds with RetryableWriteError from server",
24+
"failPoint": {
25+
"configureFailPoint": "failCommand",
26+
"mode": {
27+
"times": 1
28+
},
29+
"data": {
30+
"failCommands": [
31+
"update"
32+
],
33+
"errorCode": 112,
34+
"errorLabels": [
35+
"RetryableWriteError"
36+
]
37+
}
38+
},
39+
"operation": {
40+
"name": "bulkWrite",
41+
"arguments": {
42+
"requests": [
43+
{
44+
"name": "deleteOne",
45+
"arguments": {
46+
"filter": {
47+
"_id": 1
48+
}
49+
}
50+
},
51+
{
52+
"name": "insertOne",
53+
"arguments": {
54+
"document": {
55+
"_id": 3,
56+
"x": 33
57+
}
58+
}
59+
},
60+
{
61+
"name": "updateOne",
62+
"arguments": {
63+
"filter": {
64+
"_id": 2
65+
},
66+
"update": {
67+
"$inc": {
68+
"x": 1
69+
}
70+
}
71+
}
72+
}
73+
],
74+
"options": {
75+
"ordered": true
76+
}
77+
}
78+
},
79+
"outcome": {
80+
"result": {
81+
"deletedCount": 1,
82+
"insertedCount": 1,
83+
"insertedIds": {
84+
"1": 3
85+
},
86+
"matchedCount": 1,
87+
"modifiedCount": 1,
88+
"upsertedCount": 0,
89+
"upsertedIds": {}
90+
},
91+
"collection": {
92+
"data": [
93+
{
94+
"_id": 2,
95+
"x": 23
96+
},
97+
{
98+
"_id": 3,
99+
"x": 33
100+
}
101+
]
102+
}
103+
}
104+
},
105+
{
106+
"description": "BulkWrite fails if server does not return RetryableWriteError",
107+
"failPoint": {
108+
"configureFailPoint": "failCommand",
109+
"mode": {
110+
"times": 1
111+
},
112+
"data": {
113+
"failCommands": [
114+
"update"
115+
],
116+
"errorCode": 11600,
117+
"errorLabels": []
118+
}
119+
},
120+
"operation": {
121+
"name": "bulkWrite",
122+
"arguments": {
123+
"requests": [
124+
{
125+
"name": "deleteOne",
126+
"arguments": {
127+
"filter": {
128+
"_id": 1
129+
}
130+
}
131+
},
132+
{
133+
"name": "insertOne",
134+
"arguments": {
135+
"document": {
136+
"_id": 3,
137+
"x": 33
138+
}
139+
}
140+
},
141+
{
142+
"name": "updateOne",
143+
"arguments": {
144+
"filter": {
145+
"_id": 2
146+
},
147+
"update": {
148+
"$inc": {
149+
"x": 1
150+
}
151+
}
152+
}
153+
}
154+
],
155+
"options": {
156+
"ordered": true
157+
}
158+
}
159+
},
160+
"outcome": {
161+
"error": true,
162+
"result": {
163+
"errorLabelsOmit": [
164+
"RetryableWriteError"
165+
]
166+
},
167+
"collection": {
168+
"data": [
169+
{
170+
"_id": 2,
171+
"x": 22
172+
},
173+
{
174+
"_id": 3,
175+
"x": 33
176+
}
177+
]
178+
}
179+
}
180+
}
181+
]
182+
}

tests/SpecTests/retryable-writes/bulkWrite-serverErrors.json

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535
"failCommands": [
3636
"update"
3737
],
38-
"errorCode": 189
38+
"errorCode": 189,
39+
"errorLabels": [
40+
"RetryableWriteError"
41+
]
3942
}
4043
},
4144
"operation": {
@@ -117,7 +120,10 @@
117120
],
118121
"writeConcernError": {
119122
"code": 91,
120-
"errmsg": "Replication is being shut down"
123+
"errmsg": "Replication is being shut down",
124+
"errorLabels": [
125+
"RetryableWriteError"
126+
]
121127
}
122128
}
123129
},
@@ -186,6 +192,81 @@
186192
]
187193
}
188194
}
195+
},
196+
{
197+
"description": "BulkWrite fails with a RetryableWriteError label after two connection failures",
198+
"failPoint": {
199+
"configureFailPoint": "failCommand",
200+
"mode": {
201+
"times": 2
202+
},
203+
"data": {
204+
"failCommands": [
205+
"update"
206+
],
207+
"closeConnection": true
208+
}
209+
},
210+
"operation": {
211+
"name": "bulkWrite",
212+
"arguments": {
213+
"requests": [
214+
{
215+
"name": "deleteOne",
216+
"arguments": {
217+
"filter": {
218+
"_id": 1
219+
}
220+
}
221+
},
222+
{
223+
"name": "insertOne",
224+
"arguments": {
225+
"document": {
226+
"_id": 3,
227+
"x": 33
228+
}
229+
}
230+
},
231+
{
232+
"name": "updateOne",
233+
"arguments": {
234+
"filter": {
235+
"_id": 2
236+
},
237+
"update": {
238+
"$inc": {
239+
"x": 1
240+
}
241+
}
242+
}
243+
}
244+
],
245+
"options": {
246+
"ordered": true
247+
}
248+
}
249+
},
250+
"outcome": {
251+
"error": true,
252+
"result": {
253+
"errorLabelsContain": [
254+
"RetryableWriteError"
255+
]
256+
},
257+
"collection": {
258+
"data": [
259+
{
260+
"_id": 2,
261+
"x": 22
262+
},
263+
{
264+
"_id": 3,
265+
"x": 33
266+
}
267+
]
268+
}
269+
}
189270
}
190271
]
191272
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"runOn": [
3+
{
4+
"minServerVersion": "4.3.1",
5+
"topology": [
6+
"replicaset",
7+
"sharded"
8+
]
9+
}
10+
],
11+
"data": [
12+
{
13+
"_id": 1,
14+
"x": 11
15+
},
16+
{
17+
"_id": 2,
18+
"x": 22
19+
}
20+
],
21+
"tests": [
22+
{
23+
"description": "DeleteOne succeeds with RetryableWriteError from server",
24+
"failPoint": {
25+
"configureFailPoint": "failCommand",
26+
"mode": {
27+
"times": 1
28+
},
29+
"data": {
30+
"failCommands": [
31+
"delete"
32+
],
33+
"errorCode": 112,
34+
"errorLabels": [
35+
"RetryableWriteError"
36+
]
37+
}
38+
},
39+
"operation": {
40+
"name": "deleteOne",
41+
"arguments": {
42+
"filter": {
43+
"_id": 1
44+
}
45+
}
46+
},
47+
"outcome": {
48+
"result": {
49+
"deletedCount": 1
50+
},
51+
"collection": {
52+
"data": [
53+
{
54+
"_id": 2,
55+
"x": 22
56+
}
57+
]
58+
}
59+
}
60+
},
61+
{
62+
"description": "DeleteOne fails if server does not return RetryableWriteError",
63+
"failPoint": {
64+
"configureFailPoint": "failCommand",
65+
"mode": {
66+
"times": 1
67+
},
68+
"data": {
69+
"failCommands": [
70+
"delete"
71+
],
72+
"errorCode": 11600,
73+
"errorLabels": []
74+
}
75+
},
76+
"operation": {
77+
"name": "deleteOne",
78+
"arguments": {
79+
"filter": {
80+
"_id": 1
81+
}
82+
}
83+
},
84+
"outcome": {
85+
"error": true,
86+
"result": {
87+
"errorLabelsOmit": [
88+
"RetryableWriteError"
89+
]
90+
},
91+
"collection": {
92+
"data": [
93+
{
94+
"_id": 1,
95+
"x": 11
96+
},
97+
{
98+
"_id": 2,
99+
"x": 22
100+
}
101+
]
102+
}
103+
}
104+
}
105+
]
106+
}

0 commit comments

Comments
 (0)