Skip to content

Commit fbd2946

Browse files
committed
PHPLIB-1330: Sync tests for failCommand errorLabels reqs
Synced with mongodb/specifications@5fc23f4 Updates retryable writes prose test 3 to relocate the errorLabels field when configuring a fail point. Fixes prose test numbering, which dates back to f236312. Updates the prose test requirement per mongodb/specifications@0d67e87, which was missed in the original PHPLIB commit. Some spec tests are dependent on outstanding issues: command-monitoring/find.json (PHPLIB-1080) and valid-pass/entity-commandCursor.json (PHPLIB-1077)
1 parent 7c13b7c commit fbd2946

37 files changed

+5861
-5642
lines changed

tests/SpecTests/RetryableWritesSpecTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,17 @@ public function provideTests()
8080
}
8181

8282
/**
83-
* Prose test 1: when encountering a NoWritesPerformed error after an error with a RetryableWriteError label
83+
* Prose test 3: when encountering a NoWritesPerformed error after an error with a RetryableWriteError label
8484
*/
8585
public function testNoWritesPerformedErrorReturnsOriginalError(): void
8686
{
8787
if (! $this->isReplicaSet()) {
8888
$this->markTestSkipped('Test only applies to replica sets');
8989
}
9090

91-
$this->skipIfServerVersion('<', '4.4.0', 'NoWritesPerformed error label is only supported on MongoDB 4.4+');
91+
/* Note: the NoWritesPerformed label was introduced in MongoDB 6.1
92+
* (SERVER-66479), but the test can still be run on earlier versions. */
93+
$this->skipIfServerVersion('<', '6.0.0', 'Test should only be run for MongoDB 6.0+');
9294

9395
$client = self::createTestClient(null, ['retryWrites' => true]);
9496

@@ -97,11 +99,9 @@ public function testNoWritesPerformedErrorReturnsOriginalError(): void
9799
'configureFailPoint' => 'failCommand',
98100
'mode' => ['times' => 1],
99101
'data' => [
100-
'writeConcernError' => [
101-
'code' => self::SHUTDOWN_IN_PROGRESS,
102-
'errorLabels' => ['RetryableWriteError'],
103-
],
104102
'failCommands' => ['insert'],
103+
'errorLabels' => ['RetryableWriteError'],
104+
'writeConcernError' => ['code' => self::SHUTDOWN_IN_PROGRESS],
105105
],
106106
]);
107107

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

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,175 @@
178178
]
179179
}
180180
}
181+
},
182+
{
183+
"description": "BulkWrite succeeds after PrimarySteppedDown",
184+
"failPoint": {
185+
"configureFailPoint": "failCommand",
186+
"mode": {
187+
"times": 1
188+
},
189+
"data": {
190+
"failCommands": [
191+
"update"
192+
],
193+
"errorCode": 189,
194+
"errorLabels": [
195+
"RetryableWriteError"
196+
]
197+
}
198+
},
199+
"operation": {
200+
"name": "bulkWrite",
201+
"arguments": {
202+
"requests": [
203+
{
204+
"name": "deleteOne",
205+
"arguments": {
206+
"filter": {
207+
"_id": 1
208+
}
209+
}
210+
},
211+
{
212+
"name": "insertOne",
213+
"arguments": {
214+
"document": {
215+
"_id": 3,
216+
"x": 33
217+
}
218+
}
219+
},
220+
{
221+
"name": "updateOne",
222+
"arguments": {
223+
"filter": {
224+
"_id": 2
225+
},
226+
"update": {
227+
"$inc": {
228+
"x": 1
229+
}
230+
}
231+
}
232+
}
233+
],
234+
"options": {
235+
"ordered": true
236+
}
237+
}
238+
},
239+
"outcome": {
240+
"result": {
241+
"deletedCount": 1,
242+
"insertedCount": 1,
243+
"insertedIds": {
244+
"1": 3
245+
},
246+
"matchedCount": 1,
247+
"modifiedCount": 1,
248+
"upsertedCount": 0,
249+
"upsertedIds": {}
250+
},
251+
"collection": {
252+
"data": [
253+
{
254+
"_id": 2,
255+
"x": 23
256+
},
257+
{
258+
"_id": 3,
259+
"x": 33
260+
}
261+
]
262+
}
263+
}
264+
},
265+
{
266+
"description": "BulkWrite succeeds after WriteConcernError ShutdownInProgress",
267+
"failPoint": {
268+
"configureFailPoint": "failCommand",
269+
"mode": {
270+
"times": 1
271+
},
272+
"data": {
273+
"failCommands": [
274+
"insert"
275+
],
276+
"errorLabels": [
277+
"RetryableWriteError"
278+
],
279+
"writeConcernError": {
280+
"code": 91,
281+
"errmsg": "Replication is being shut down"
282+
}
283+
}
284+
},
285+
"operation": {
286+
"name": "bulkWrite",
287+
"arguments": {
288+
"requests": [
289+
{
290+
"name": "deleteOne",
291+
"arguments": {
292+
"filter": {
293+
"_id": 1
294+
}
295+
}
296+
},
297+
{
298+
"name": "insertOne",
299+
"arguments": {
300+
"document": {
301+
"_id": 3,
302+
"x": 33
303+
}
304+
}
305+
},
306+
{
307+
"name": "updateOne",
308+
"arguments": {
309+
"filter": {
310+
"_id": 2
311+
},
312+
"update": {
313+
"$inc": {
314+
"x": 1
315+
}
316+
}
317+
}
318+
}
319+
],
320+
"options": {
321+
"ordered": true
322+
}
323+
}
324+
},
325+
"outcome": {
326+
"result": {
327+
"deletedCount": 1,
328+
"insertedCount": 1,
329+
"insertedIds": {
330+
"1": 3
331+
},
332+
"matchedCount": 1,
333+
"modifiedCount": 1,
334+
"upsertedCount": 0,
335+
"upsertedIds": {}
336+
},
337+
"collection": {
338+
"data": [
339+
{
340+
"_id": 2,
341+
"x": 23
342+
},
343+
{
344+
"_id": 3,
345+
"x": 33
346+
}
347+
]
348+
}
349+
}
181350
}
182351
]
183352
}

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

Lines changed: 0 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -25,175 +25,6 @@
2525
}
2626
],
2727
"tests": [
28-
{
29-
"description": "BulkWrite succeeds after PrimarySteppedDown",
30-
"failPoint": {
31-
"configureFailPoint": "failCommand",
32-
"mode": {
33-
"times": 1
34-
},
35-
"data": {
36-
"failCommands": [
37-
"update"
38-
],
39-
"errorCode": 189,
40-
"errorLabels": [
41-
"RetryableWriteError"
42-
]
43-
}
44-
},
45-
"operation": {
46-
"name": "bulkWrite",
47-
"arguments": {
48-
"requests": [
49-
{
50-
"name": "deleteOne",
51-
"arguments": {
52-
"filter": {
53-
"_id": 1
54-
}
55-
}
56-
},
57-
{
58-
"name": "insertOne",
59-
"arguments": {
60-
"document": {
61-
"_id": 3,
62-
"x": 33
63-
}
64-
}
65-
},
66-
{
67-
"name": "updateOne",
68-
"arguments": {
69-
"filter": {
70-
"_id": 2
71-
},
72-
"update": {
73-
"$inc": {
74-
"x": 1
75-
}
76-
}
77-
}
78-
}
79-
],
80-
"options": {
81-
"ordered": true
82-
}
83-
}
84-
},
85-
"outcome": {
86-
"result": {
87-
"deletedCount": 1,
88-
"insertedCount": 1,
89-
"insertedIds": {
90-
"1": 3
91-
},
92-
"matchedCount": 1,
93-
"modifiedCount": 1,
94-
"upsertedCount": 0,
95-
"upsertedIds": {}
96-
},
97-
"collection": {
98-
"data": [
99-
{
100-
"_id": 2,
101-
"x": 23
102-
},
103-
{
104-
"_id": 3,
105-
"x": 33
106-
}
107-
]
108-
}
109-
}
110-
},
111-
{
112-
"description": "BulkWrite succeeds after WriteConcernError ShutdownInProgress",
113-
"failPoint": {
114-
"configureFailPoint": "failCommand",
115-
"mode": {
116-
"times": 1
117-
},
118-
"data": {
119-
"failCommands": [
120-
"insert"
121-
],
122-
"errorLabels": [
123-
"RetryableWriteError"
124-
],
125-
"writeConcernError": {
126-
"code": 91,
127-
"errmsg": "Replication is being shut down"
128-
}
129-
}
130-
},
131-
"operation": {
132-
"name": "bulkWrite",
133-
"arguments": {
134-
"requests": [
135-
{
136-
"name": "deleteOne",
137-
"arguments": {
138-
"filter": {
139-
"_id": 1
140-
}
141-
}
142-
},
143-
{
144-
"name": "insertOne",
145-
"arguments": {
146-
"document": {
147-
"_id": 3,
148-
"x": 33
149-
}
150-
}
151-
},
152-
{
153-
"name": "updateOne",
154-
"arguments": {
155-
"filter": {
156-
"_id": 2
157-
},
158-
"update": {
159-
"$inc": {
160-
"x": 1
161-
}
162-
}
163-
}
164-
}
165-
],
166-
"options": {
167-
"ordered": true
168-
}
169-
}
170-
},
171-
"outcome": {
172-
"result": {
173-
"deletedCount": 1,
174-
"insertedCount": 1,
175-
"insertedIds": {
176-
"1": 3
177-
},
178-
"matchedCount": 1,
179-
"modifiedCount": 1,
180-
"upsertedCount": 0,
181-
"upsertedIds": {}
182-
},
183-
"collection": {
184-
"data": [
185-
{
186-
"_id": 2,
187-
"x": 23
188-
},
189-
{
190-
"_id": 3,
191-
"x": 33
192-
}
193-
]
194-
}
195-
}
196-
},
19728
{
19829
"description": "BulkWrite fails with a RetryableWriteError label after two connection failures",
19930
"failPoint": {

0 commit comments

Comments
 (0)