Skip to content

Commit b47cf2e

Browse files
author
Divjot Arora
authored
GODRIVER-1931 Sync new cursors and SDAM LB tests (#655)
1 parent 66e01fd commit b47cf2e

File tree

4 files changed

+319
-2
lines changed

4 files changed

+319
-2
lines changed

data/load-balancers/cursors.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,81 @@
11481148
]
11491149
}
11501150
]
1151+
},
1152+
{
1153+
"description": "change streams pin to a connection",
1154+
"operations": [
1155+
{
1156+
"name": "createChangeStream",
1157+
"object": "collection0",
1158+
"arguments": {
1159+
"pipeline": []
1160+
},
1161+
"saveResultAsEntity": "changeStream0"
1162+
},
1163+
{
1164+
"name": "assertNumberConnectionsCheckedOut",
1165+
"object": "testRunner",
1166+
"arguments": {
1167+
"client": "client0",
1168+
"connections": 1
1169+
}
1170+
},
1171+
{
1172+
"name": "close",
1173+
"object": "changeStream0"
1174+
},
1175+
{
1176+
"name": "assertNumberConnectionsCheckedOut",
1177+
"object": "testRunner",
1178+
"arguments": {
1179+
"client": "client0",
1180+
"connections": 0
1181+
}
1182+
}
1183+
],
1184+
"expectEvents": [
1185+
{
1186+
"client": "client0",
1187+
"events": [
1188+
{
1189+
"commandStartedEvent": {
1190+
"commandName": "aggregate"
1191+
}
1192+
},
1193+
{
1194+
"commandSucceededEvent": {
1195+
"commandName": "aggregate"
1196+
}
1197+
},
1198+
{
1199+
"commandStartedEvent": {
1200+
"commandName": "killCursors"
1201+
}
1202+
},
1203+
{
1204+
"commandSucceededEvent": {
1205+
"commandName": "killCursors"
1206+
}
1207+
}
1208+
]
1209+
},
1210+
{
1211+
"client": "client0",
1212+
"eventType": "cmap",
1213+
"events": [
1214+
{
1215+
"connectionReadyEvent": {}
1216+
},
1217+
{
1218+
"connectionCheckedOutEvent": {}
1219+
},
1220+
{
1221+
"connectionCheckedInEvent": {}
1222+
}
1223+
]
1224+
}
1225+
]
11511226
}
11521227
]
11531228
}

data/load-balancers/cursors.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,3 +462,42 @@ tests:
462462
# Events for listIndexes and getMore.
463463
- connectionCheckedOutEvent: {}
464464
- connectionCheckedInEvent: {}
465+
466+
- description: change streams pin to a connection
467+
operations:
468+
- name: createChangeStream
469+
object: *collection0
470+
arguments:
471+
pipeline: []
472+
saveResultAsEntity: &changeStream0 changeStream0
473+
- name: assertNumberConnectionsCheckedOut
474+
object: testRunner
475+
arguments:
476+
client: *client0
477+
connections: 1
478+
- name: close
479+
object: *changeStream0
480+
- name: assertNumberConnectionsCheckedOut
481+
object: testRunner
482+
arguments:
483+
client: *client0
484+
connections: 0
485+
expectEvents:
486+
- client: *client0
487+
events:
488+
- commandStartedEvent:
489+
commandName: aggregate
490+
- commandSucceededEvent:
491+
commandName: aggregate
492+
- commandStartedEvent:
493+
commandName: killCursors
494+
- commandSucceededEvent:
495+
commandName: killCursors
496+
- client: *client0
497+
eventType: cmap
498+
events:
499+
# Events for creating the change stream.
500+
- connectionReadyEvent: {}
501+
- connectionCheckedOutEvent: {}
502+
# Events for closing the change stream.
503+
- connectionCheckedInEvent: {}

data/load-balancers/sdam-error-handling.json

Lines changed: 132 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,17 @@
9696
{
9797
"collectionName": "singleColl",
9898
"databaseName": "singleDB",
99-
"documents": []
99+
"documents": [
100+
{
101+
"_id": 1
102+
},
103+
{
104+
"_id": 2
105+
},
106+
{
107+
"_id": 3
108+
}
109+
]
100110
},
101111
{
102112
"collectionName": "multiColl",
@@ -372,6 +382,127 @@
372382
]
373383
}
374384
]
385+
},
386+
{
387+
"description": "stale errors are ignored",
388+
"operations": [
389+
{
390+
"name": "failPoint",
391+
"object": "testRunner",
392+
"arguments": {
393+
"client": "failPointClient",
394+
"failPoint": {
395+
"configureFailPoint": "failCommand",
396+
"mode": {
397+
"times": 2
398+
},
399+
"data": {
400+
"failCommands": [
401+
"getMore"
402+
],
403+
"closeConnection": true
404+
}
405+
}
406+
}
407+
},
408+
{
409+
"name": "createFindCursor",
410+
"object": "singleColl",
411+
"arguments": {
412+
"filter": {},
413+
"batchSize": 2
414+
},
415+
"saveResultAsEntity": "cursor0"
416+
},
417+
{
418+
"name": "createFindCursor",
419+
"object": "singleColl",
420+
"arguments": {
421+
"filter": {},
422+
"batchSize": 2
423+
},
424+
"saveResultAsEntity": "cursor1"
425+
},
426+
{
427+
"name": "iterateUntilDocumentOrError",
428+
"object": "cursor0"
429+
},
430+
{
431+
"name": "iterateUntilDocumentOrError",
432+
"object": "cursor0"
433+
},
434+
{
435+
"name": "iterateUntilDocumentOrError",
436+
"object": "cursor0",
437+
"expectError": {
438+
"isClientError": true
439+
}
440+
},
441+
{
442+
"name": "close",
443+
"object": "cursor0"
444+
},
445+
{
446+
"name": "iterateUntilDocumentOrError",
447+
"object": "cursor1"
448+
},
449+
{
450+
"name": "iterateUntilDocumentOrError",
451+
"object": "cursor1"
452+
},
453+
{
454+
"name": "iterateUntilDocumentOrError",
455+
"object": "cursor1",
456+
"expectError": {
457+
"isClientError": true
458+
}
459+
},
460+
{
461+
"name": "close",
462+
"object": "cursor1"
463+
}
464+
],
465+
"expectEvents": [
466+
{
467+
"client": "singleClient",
468+
"eventType": "cmap",
469+
"events": [
470+
{
471+
"connectionCreatedEvent": {}
472+
},
473+
{
474+
"connectionReadyEvent": {}
475+
},
476+
{
477+
"connectionCheckedOutEvent": {}
478+
},
479+
{
480+
"connectionCreatedEvent": {}
481+
},
482+
{
483+
"connectionReadyEvent": {}
484+
},
485+
{
486+
"connectionCheckedOutEvent": {}
487+
},
488+
{
489+
"poolClearedEvent": {}
490+
},
491+
{
492+
"connectionCheckedInEvent": {}
493+
},
494+
{
495+
"connectionClosedEvent": {}
496+
},
497+
{
498+
"connectionCheckedInEvent": {}
499+
},
500+
{
501+
"connectionClosedEvent": {}
502+
}
503+
]
504+
}
505+
]
375506
}
376507
]
377508
}

data/load-balancers/sdam-error-handling.yml

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ createEntities:
5252
initialData:
5353
- collectionName: *singleCollName
5454
databaseName: *singleDBName
55-
documents: []
55+
documents:
56+
- _id: 1
57+
- _id: 2
58+
- _id: 3
5659
- collectionName: *multiCollName
5760
databaseName: *multiDBName
5861
documents:
@@ -196,3 +199,72 @@ tests:
196199
reason: error
197200
- connectionCheckOutFailedEvent:
198201
reason: connectionError
202+
203+
- description: stale errors are ignored
204+
operations:
205+
- name: failPoint
206+
object: testRunner
207+
arguments:
208+
client: *failPointClient
209+
failPoint:
210+
configureFailPoint: failCommand
211+
mode: { times: 2 }
212+
data:
213+
failCommands: [getMore]
214+
closeConnection: true
215+
# Force two connections to be checked out from the pool.
216+
- name: createFindCursor
217+
object: *singleColl
218+
arguments:
219+
filter: {}
220+
batchSize: 2
221+
saveResultAsEntity: &cursor0 cursor0
222+
- name: createFindCursor
223+
object: *singleColl
224+
arguments:
225+
filter: {}
226+
batchSize: 2
227+
saveResultAsEntity: &cursor1 cursor1
228+
# Iterate cursor0 three times to force a network error.
229+
- name: iterateUntilDocumentOrError
230+
object: *cursor0
231+
- name: iterateUntilDocumentOrError
232+
object: *cursor0
233+
- name: iterateUntilDocumentOrError
234+
object: *cursor0
235+
expectError:
236+
isClientError: true
237+
- name: close
238+
object: *cursor0
239+
# Iterate cursor1 three times to force a network error.
240+
- name: iterateUntilDocumentOrError
241+
object: *cursor1
242+
- name: iterateUntilDocumentOrError
243+
object: *cursor1
244+
- name: iterateUntilDocumentOrError
245+
object: *cursor1
246+
expectError:
247+
isClientError: true
248+
- name: close
249+
object: *cursor1
250+
expectEvents:
251+
- client: *singleClient
252+
eventType: cmap
253+
events:
254+
# Events for creating both cursors.
255+
- connectionCreatedEvent: {}
256+
- connectionReadyEvent: {}
257+
- connectionCheckedOutEvent: {}
258+
- connectionCreatedEvent: {}
259+
- connectionReadyEvent: {}
260+
- connectionCheckedOutEvent: {}
261+
# Events for iterating and closing the first cursor. The failed
262+
# getMore should cause a poolClearedEvent to be published.
263+
- poolClearedEvent: {}
264+
- connectionCheckedInEvent: {}
265+
- connectionClosedEvent: {}
266+
# Events for iterating and closing the second cursor. The failed
267+
# getMore should not clear the pool because the connection's
268+
# generation number is stale.
269+
- connectionCheckedInEvent: {}
270+
- connectionClosedEvent: {}

0 commit comments

Comments
 (0)