Skip to content

Commit e1f00b7

Browse files
update all tests - including new getMore tests
1 parent 6b108b7 commit e1f00b7

9 files changed

+270
-10
lines changed

test/spec/client-backpressure/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ be manually implemented by each driver.
1616

1717
Drivers should test that retries do not occur immediately when a SystemOverloadedError is encountered.
1818

19-
1. let `client` be a `MongoClient`
20-
2. let `collection` be a collection
19+
1. Let `client` be a `MongoClient`
20+
2. Let `collection` be a collection
2121
3. Now, run transactions without backoff:
2222
1. Configure the random number generator used for jitter to always return `0` -- this effectively disables backoff.
2323

@@ -28,14 +28,14 @@ Drivers should test that retries do not occur immediately when a SystemOverloade
2828
configureFailPoint: 'failCommand',
2929
mode: 'alwaysOn',
3030
data: {
31-
failCommands: ['insert'],
32-
errorCode: 2,
33-
errorLabels: ['SystemOverloadedError', 'RetryableError']
31+
failCommands: ['insert'],
32+
errorCode: 2,
33+
errorLabels: ['SystemOverloadedError', 'RetryableError']
3434
}
3535
}
3636
```
3737

38-
3. Execute the following command. Expect that the command errors. Measure the duration of the command execution.
38+
3. Execute the document `{ a: 1 }`. Expect that the command errors. Measure the duration of the command execution.
3939

4040
```javascript
4141
const start = performance.now();

test/spec/client-backpressure/backpressure-retry-loop.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
}
5959
}
6060
],
61+
"_yamlAnchors": {
62+
"bulWriteInsertNamespace": "retryable-writes-tests.coll"
63+
},
6164
"tests": [
6265
{
6366
"description": "client.listDatabases retries using operation loop",

test/spec/client-backpressure/backpressure-retry-loop.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@ createEntities:
3737
database:
3838
id: &database database
3939
client: *client
40-
databaseName: &database_name retryable-writes-tests
40+
databaseName: *database_name
4141

4242
-
4343
collection:
4444
id: &collection collection
4545
database: *database
4646
collectionName: *collection_name
4747

48+
_yamlAnchors:
49+
bulWriteInsertNamespace: &client_bulk_write_ns retryable-writes-tests.coll
50+
4851
tests:
4952

5053
-
@@ -219,7 +222,7 @@ tests:
219222
arguments:
220223
models:
221224
- insertOne:
222-
namespace: retryable-writes-tests.coll
225+
namespace: *client_bulk_write_ns
223226
document: { _id: 8, x: 88 }
224227

225228
expectEvents:

test/spec/client-backpressure/backpressure-retry-loop.yml.template

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@ createEntities:
3737
database:
3838
id: &database database
3939
client: *client
40-
databaseName: &database_name retryable-writes-tests
40+
databaseName: *database_name
4141

4242
-
4343
collection:
4444
id: &collection collection
4545
database: *database
4646
collectionName: *collection_name
4747

48+
_yamlAnchors:
49+
bulWriteInsertNamespace: &client_bulk_write_ns retryable-writes-tests.coll
50+
4851
tests:
4952
{% for operation in operations %}
5053
-

test/spec/client-backpressure/backpressure-retry-max-attempts.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
}
4545
}
4646
],
47+
"_yamlAnchors": {
48+
"bulkWriteInsertNamespace": "retryable-writes-tests.coll"
49+
},
4750
"initialData": [
4851
{
4952
"collectionName": "coll",

test/spec/client-backpressure/backpressure-retry-max-attempts.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ createEntities:
3232
database: *database
3333
collectionName: &collection_name coll
3434

35+
_yamlAnchors:
36+
bulkWriteInsertNamespace: &client_bulk_write_ns retryable-writes-tests.coll
37+
3538
initialData:
3639
-
3740
collectionName: *collection_name
@@ -232,7 +235,7 @@ tests:
232235
arguments:
233236
models:
234237
- insertOne:
235-
namespace: retryable-writes-tests.coll
238+
namespace: *client_bulk_write_ns
236239
document: { _id: 8, x: 88 }
237240
expectError:
238241
isError: true

test/spec/client-backpressure/backpressure-retry-max-attempts.yml.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ createEntities:
3232
database: *database
3333
collectionName: &collection_name coll
3434

35+
_yamlAnchors:
36+
bulkWriteInsertNamespace: &client_bulk_write_ns retryable-writes-tests.coll
37+
3538
initialData:
3639
-
3740
collectionName: *collection_name
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
{
2+
"description": "getMore-retries-backpressure",
3+
"schemaVersion": "1.3",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"observeEvents": [
9+
"commandStartedEvent",
10+
"commandFailedEvent",
11+
"commandSucceededEvent"
12+
]
13+
}
14+
},
15+
{
16+
"client": {
17+
"id": "failPointClient"
18+
}
19+
},
20+
{
21+
"database": {
22+
"id": "db",
23+
"client": "client0",
24+
"databaseName": "default"
25+
}
26+
},
27+
{
28+
"collection": {
29+
"id": "coll",
30+
"database": "db",
31+
"collectionName": "default"
32+
}
33+
}
34+
],
35+
"initialData": [
36+
{
37+
"databaseName": "default",
38+
"collectionName": "default",
39+
"documents": [
40+
{
41+
"a": 1
42+
},
43+
{
44+
"a": 2
45+
},
46+
{
47+
"a": 3
48+
}
49+
]
50+
}
51+
],
52+
"tests": [
53+
{
54+
"description": "getMores are retried",
55+
"operations": [
56+
{
57+
"name": "failPoint",
58+
"object": "testRunner",
59+
"arguments": {
60+
"client": "failPointClient",
61+
"failPoint": {
62+
"configureFailPoint": "failCommand",
63+
"mode": {
64+
"times": 3
65+
},
66+
"data": {
67+
"failCommands": [
68+
"getMore"
69+
],
70+
"errorLabels": [
71+
"RetryableError",
72+
"SystemOverloadedError"
73+
],
74+
"errorCode": 2
75+
}
76+
}
77+
}
78+
},
79+
{
80+
"name": "find",
81+
"arguments": {
82+
"batchSize": 2,
83+
"filter": {},
84+
"sort": {
85+
"a": 1
86+
}
87+
},
88+
"object": "coll",
89+
"expectResult": [
90+
{
91+
"a": 1
92+
},
93+
{
94+
"a": 2
95+
},
96+
{
97+
"a": 3
98+
}
99+
]
100+
}
101+
],
102+
"expectEvents": [
103+
{
104+
"client": "client0",
105+
"events": [
106+
{
107+
"commandStartedEvent": {
108+
"commandName": "find"
109+
}
110+
},
111+
{
112+
"commandSucceededEvent": {
113+
"commandName": "find"
114+
}
115+
},
116+
{
117+
"commandStartedEvent": {
118+
"commandName": "getMore"
119+
}
120+
},
121+
{
122+
"commandFailedEvent": {
123+
"commandName": "getMore"
124+
}
125+
},
126+
{
127+
"commandStartedEvent": {
128+
"commandName": "getMore"
129+
}
130+
},
131+
{
132+
"commandFailedEvent": {
133+
"commandName": "getMore"
134+
}
135+
},
136+
{
137+
"commandStartedEvent": {
138+
"commandName": "getMore"
139+
}
140+
},
141+
{
142+
"commandFailedEvent": {
143+
"commandName": "getMore"
144+
}
145+
},
146+
{
147+
"commandStartedEvent": {
148+
"commandName": "getMore"
149+
}
150+
},
151+
{
152+
"commandSucceededEvent": {
153+
"commandName": "getMore"
154+
}
155+
}
156+
]
157+
}
158+
]
159+
}
160+
]
161+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
description: getMore-retries-backpressure
2+
schemaVersion: "1.3"
3+
4+
createEntities:
5+
- client:
6+
id: &client client0
7+
observeEvents:
8+
- commandStartedEvent
9+
- commandFailedEvent
10+
- commandSucceededEvent
11+
- client:
12+
id: &failPointClient failPointClient
13+
- database:
14+
id: db
15+
client: *client
16+
databaseName: &dbName default
17+
- collection:
18+
id: &collection coll
19+
database: db
20+
collectionName: &collectionName default
21+
initialData:
22+
- databaseName: *dbName
23+
collectionName: *collectionName
24+
documents:
25+
- { a: 1 }
26+
- { a: 2 }
27+
- { a: 3 }
28+
29+
tests:
30+
- description: "getMores are retried"
31+
operations:
32+
- name: failPoint
33+
object: testRunner
34+
arguments:
35+
client: *failPointClient
36+
failPoint:
37+
configureFailPoint: failCommand
38+
mode: { times: 3 }
39+
data:
40+
failCommands: [getMore]
41+
errorLabels: [RetryableError, SystemOverloadedError]
42+
errorCode: 2
43+
44+
- name: find
45+
arguments:
46+
batchSize: 2
47+
filter: {}
48+
# ensure stable ordering of result documents
49+
sort: { a: 1 }
50+
object: *collection
51+
expectResult:
52+
- { a: 1 }
53+
- { a: 2 }
54+
- { a: 3 }
55+
expectEvents:
56+
- client: *client
57+
events:
58+
- commandStartedEvent:
59+
commandName: find
60+
- commandSucceededEvent:
61+
commandName: find
62+
# first attempt
63+
- commandStartedEvent:
64+
commandName: getMore
65+
- commandFailedEvent:
66+
commandName: getMore
67+
# second attempt
68+
- commandStartedEvent:
69+
commandName: getMore
70+
- commandFailedEvent:
71+
commandName: getMore
72+
# third attempt
73+
- commandStartedEvent:
74+
commandName: getMore
75+
- commandFailedEvent:
76+
commandName: getMore
77+
# success
78+
- commandStartedEvent:
79+
commandName: getMore
80+
- commandSucceededEvent:
81+
commandName: getMore

0 commit comments

Comments
 (0)