1{
2  "runOn": [
3    {
4      "minServerVersion": "4.0",
5      "topology": [
6        "replicaset"
7      ]
8    },
9    {
10      "minServerVersion": "4.1.7",
11      "topology": [
12        "sharded"
13      ]
14    }
15  ],
16  "database_name": "retryable-reads-tests",
17  "collection_name": "coll",
18  "data": [
19    {
20      "_id": 1,
21      "x": 11
22    },
23    {
24      "_id": 2,
25      "x": 22
26    },
27    {
28      "_id": 3,
29      "x": 33
30    }
31  ],
32  "tests": [
33    {
34      "description": "client.watch succeeds after InterruptedAtShutdown",
35      "failPoint": {
36        "configureFailPoint": "failCommand",
37        "mode": {
38          "times": 1
39        },
40        "data": {
41          "failCommands": [
42            "aggregate"
43          ],
44          "errorCode": 11600
45        }
46      },
47      "operations": [
48        {
49          "name": "watch",
50          "object": "client"
51        }
52      ],
53      "expectations": [
54        {
55          "command_started_event": {
56            "command": {
57              "aggregate": 1,
58              "cursor": {},
59              "pipeline": [
60                {
61                  "$changeStream": {
62                    "fullDocument": "default",
63                    "allChangesForCluster": true
64                  }
65                }
66              ]
67            },
68            "database_name": "admin"
69          }
70        },
71        {
72          "command_started_event": {
73            "command": {
74              "aggregate": 1,
75              "cursor": {},
76              "pipeline": [
77                {
78                  "$changeStream": {
79                    "fullDocument": "default",
80                    "allChangesForCluster": true
81                  }
82                }
83              ]
84            },
85            "database_name": "admin"
86          }
87        }
88      ]
89    },
90    {
91      "description": "client.watch succeeds after InterruptedDueToReplStateChange",
92      "failPoint": {
93        "configureFailPoint": "failCommand",
94        "mode": {
95          "times": 1
96        },
97        "data": {
98          "failCommands": [
99            "aggregate"
100          ],
101          "errorCode": 11602
102        }
103      },
104      "operations": [
105        {
106          "name": "watch",
107          "object": "client"
108        }
109      ],
110      "expectations": [
111        {
112          "command_started_event": {
113            "command": {
114              "aggregate": 1,
115              "cursor": {},
116              "pipeline": [
117                {
118                  "$changeStream": {
119                    "fullDocument": "default",
120                    "allChangesForCluster": true
121                  }
122                }
123              ]
124            },
125            "database_name": "admin"
126          }
127        },
128        {
129          "command_started_event": {
130            "command": {
131              "aggregate": 1,
132              "cursor": {},
133              "pipeline": [
134                {
135                  "$changeStream": {
136                    "fullDocument": "default",
137                    "allChangesForCluster": true
138                  }
139                }
140              ]
141            },
142            "database_name": "admin"
143          }
144        }
145      ]
146    },
147    {
148      "description": "client.watch succeeds after NotMaster",
149      "failPoint": {
150        "configureFailPoint": "failCommand",
151        "mode": {
152          "times": 1
153        },
154        "data": {
155          "failCommands": [
156            "aggregate"
157          ],
158          "errorCode": 10107
159        }
160      },
161      "operations": [
162        {
163          "name": "watch",
164          "object": "client"
165        }
166      ],
167      "expectations": [
168        {
169          "command_started_event": {
170            "command": {
171              "aggregate": 1,
172              "cursor": {},
173              "pipeline": [
174                {
175                  "$changeStream": {
176                    "fullDocument": "default",
177                    "allChangesForCluster": true
178                  }
179                }
180              ]
181            },
182            "database_name": "admin"
183          }
184        },
185        {
186          "command_started_event": {
187            "command": {
188              "aggregate": 1,
189              "cursor": {},
190              "pipeline": [
191                {
192                  "$changeStream": {
193                    "fullDocument": "default",
194                    "allChangesForCluster": true
195                  }
196                }
197              ]
198            },
199            "database_name": "admin"
200          }
201        }
202      ]
203    },
204    {
205      "description": "client.watch succeeds after NotMasterNoSlaveOk",
206      "failPoint": {
207        "configureFailPoint": "failCommand",
208        "mode": {
209          "times": 1
210        },
211        "data": {
212          "failCommands": [
213            "aggregate"
214          ],
215          "errorCode": 13435
216        }
217      },
218      "operations": [
219        {
220          "name": "watch",
221          "object": "client"
222        }
223      ],
224      "expectations": [
225        {
226          "command_started_event": {
227            "command": {
228              "aggregate": 1,
229              "cursor": {},
230              "pipeline": [
231                {
232                  "$changeStream": {
233                    "fullDocument": "default",
234                    "allChangesForCluster": true
235                  }
236                }
237              ]
238            },
239            "database_name": "admin"
240          }
241        },
242        {
243          "command_started_event": {
244            "command": {
245              "aggregate": 1,
246              "cursor": {},
247              "pipeline": [
248                {
249                  "$changeStream": {
250                    "fullDocument": "default",
251                    "allChangesForCluster": true
252                  }
253                }
254              ]
255            },
256            "database_name": "admin"
257          }
258        }
259      ]
260    },
261    {
262      "description": "client.watch succeeds after NotMasterOrSecondary",
263      "failPoint": {
264        "configureFailPoint": "failCommand",
265        "mode": {
266          "times": 1
267        },
268        "data": {
269          "failCommands": [
270            "aggregate"
271          ],
272          "errorCode": 13436
273        }
274      },
275      "operations": [
276        {
277          "name": "watch",
278          "object": "client"
279        }
280      ],
281      "expectations": [
282        {
283          "command_started_event": {
284            "command": {
285              "aggregate": 1,
286              "cursor": {},
287              "pipeline": [
288                {
289                  "$changeStream": {
290                    "fullDocument": "default",
291                    "allChangesForCluster": true
292                  }
293                }
294              ]
295            },
296            "database_name": "admin"
297          }
298        },
299        {
300          "command_started_event": {
301            "command": {
302              "aggregate": 1,
303              "cursor": {},
304              "pipeline": [
305                {
306                  "$changeStream": {
307                    "fullDocument": "default",
308                    "allChangesForCluster": true
309                  }
310                }
311              ]
312            },
313            "database_name": "admin"
314          }
315        }
316      ]
317    },
318    {
319      "description": "client.watch succeeds after PrimarySteppedDown",
320      "failPoint": {
321        "configureFailPoint": "failCommand",
322        "mode": {
323          "times": 1
324        },
325        "data": {
326          "failCommands": [
327            "aggregate"
328          ],
329          "errorCode": 189
330        }
331      },
332      "operations": [
333        {
334          "name": "watch",
335          "object": "client"
336        }
337      ],
338      "expectations": [
339        {
340          "command_started_event": {
341            "command": {
342              "aggregate": 1,
343              "cursor": {},
344              "pipeline": [
345                {
346                  "$changeStream": {
347                    "fullDocument": "default",
348                    "allChangesForCluster": true
349                  }
350                }
351              ]
352            },
353            "database_name": "admin"
354          }
355        },
356        {
357          "command_started_event": {
358            "command": {
359              "aggregate": 1,
360              "cursor": {},
361              "pipeline": [
362                {
363                  "$changeStream": {
364                    "fullDocument": "default",
365                    "allChangesForCluster": true
366                  }
367                }
368              ]
369            },
370            "database_name": "admin"
371          }
372        }
373      ]
374    },
375    {
376      "description": "client.watch succeeds after ShutdownInProgress",
377      "failPoint": {
378        "configureFailPoint": "failCommand",
379        "mode": {
380          "times": 1
381        },
382        "data": {
383          "failCommands": [
384            "aggregate"
385          ],
386          "errorCode": 91
387        }
388      },
389      "operations": [
390        {
391          "name": "watch",
392          "object": "client"
393        }
394      ],
395      "expectations": [
396        {
397          "command_started_event": {
398            "command": {
399              "aggregate": 1,
400              "cursor": {},
401              "pipeline": [
402                {
403                  "$changeStream": {
404                    "fullDocument": "default",
405                    "allChangesForCluster": true
406                  }
407                }
408              ]
409            },
410            "database_name": "admin"
411          }
412        },
413        {
414          "command_started_event": {
415            "command": {
416              "aggregate": 1,
417              "cursor": {},
418              "pipeline": [
419                {
420                  "$changeStream": {
421                    "fullDocument": "default",
422                    "allChangesForCluster": true
423                  }
424                }
425              ]
426            },
427            "database_name": "admin"
428          }
429        }
430      ]
431    },
432    {
433      "description": "client.watch succeeds after HostNotFound",
434      "failPoint": {
435        "configureFailPoint": "failCommand",
436        "mode": {
437          "times": 1
438        },
439        "data": {
440          "failCommands": [
441            "aggregate"
442          ],
443          "errorCode": 7
444        }
445      },
446      "operations": [
447        {
448          "name": "watch",
449          "object": "client"
450        }
451      ],
452      "expectations": [
453        {
454          "command_started_event": {
455            "command": {
456              "aggregate": 1,
457              "cursor": {},
458              "pipeline": [
459                {
460                  "$changeStream": {
461                    "fullDocument": "default",
462                    "allChangesForCluster": true
463                  }
464                }
465              ]
466            },
467            "database_name": "admin"
468          }
469        },
470        {
471          "command_started_event": {
472            "command": {
473              "aggregate": 1,
474              "cursor": {},
475              "pipeline": [
476                {
477                  "$changeStream": {
478                    "fullDocument": "default",
479                    "allChangesForCluster": true
480                  }
481                }
482              ]
483            },
484            "database_name": "admin"
485          }
486        }
487      ]
488    },
489    {
490      "description": "client.watch succeeds after HostUnreachable",
491      "failPoint": {
492        "configureFailPoint": "failCommand",
493        "mode": {
494          "times": 1
495        },
496        "data": {
497          "failCommands": [
498            "aggregate"
499          ],
500          "errorCode": 6
501        }
502      },
503      "operations": [
504        {
505          "name": "watch",
506          "object": "client"
507        }
508      ],
509      "expectations": [
510        {
511          "command_started_event": {
512            "command": {
513              "aggregate": 1,
514              "cursor": {},
515              "pipeline": [
516                {
517                  "$changeStream": {
518                    "fullDocument": "default",
519                    "allChangesForCluster": true
520                  }
521                }
522              ]
523            },
524            "database_name": "admin"
525          }
526        },
527        {
528          "command_started_event": {
529            "command": {
530              "aggregate": 1,
531              "cursor": {},
532              "pipeline": [
533                {
534                  "$changeStream": {
535                    "fullDocument": "default",
536                    "allChangesForCluster": true
537                  }
538                }
539              ]
540            },
541            "database_name": "admin"
542          }
543        }
544      ]
545    },
546    {
547      "description": "client.watch succeeds after NetworkTimeout",
548      "failPoint": {
549        "configureFailPoint": "failCommand",
550        "mode": {
551          "times": 1
552        },
553        "data": {
554          "failCommands": [
555            "aggregate"
556          ],
557          "errorCode": 89
558        }
559      },
560      "operations": [
561        {
562          "name": "watch",
563          "object": "client"
564        }
565      ],
566      "expectations": [
567        {
568          "command_started_event": {
569            "command": {
570              "aggregate": 1,
571              "cursor": {},
572              "pipeline": [
573                {
574                  "$changeStream": {
575                    "fullDocument": "default",
576                    "allChangesForCluster": true
577                  }
578                }
579              ]
580            },
581            "database_name": "admin"
582          }
583        },
584        {
585          "command_started_event": {
586            "command": {
587              "aggregate": 1,
588              "cursor": {},
589              "pipeline": [
590                {
591                  "$changeStream": {
592                    "fullDocument": "default",
593                    "allChangesForCluster": true
594                  }
595                }
596              ]
597            },
598            "database_name": "admin"
599          }
600        }
601      ]
602    },
603    {
604      "description": "client.watch succeeds after SocketException",
605      "failPoint": {
606        "configureFailPoint": "failCommand",
607        "mode": {
608          "times": 1
609        },
610        "data": {
611          "failCommands": [
612            "aggregate"
613          ],
614          "errorCode": 9001
615        }
616      },
617      "operations": [
618        {
619          "name": "watch",
620          "object": "client"
621        }
622      ],
623      "expectations": [
624        {
625          "command_started_event": {
626            "command": {
627              "aggregate": 1,
628              "cursor": {},
629              "pipeline": [
630                {
631                  "$changeStream": {
632                    "fullDocument": "default",
633                    "allChangesForCluster": true
634                  }
635                }
636              ]
637            },
638            "database_name": "admin"
639          }
640        },
641        {
642          "command_started_event": {
643            "command": {
644              "aggregate": 1,
645              "cursor": {},
646              "pipeline": [
647                {
648                  "$changeStream": {
649                    "fullDocument": "default",
650                    "allChangesForCluster": true
651                  }
652                }
653              ]
654            },
655            "database_name": "admin"
656          }
657        }
658      ]
659    },
660    {
661      "description": "client.watch fails after two NotMaster errors",
662      "failPoint": {
663        "configureFailPoint": "failCommand",
664        "mode": {
665          "times": 2
666        },
667        "data": {
668          "failCommands": [
669            "aggregate"
670          ],
671          "errorCode": 10107
672        }
673      },
674      "operations": [
675        {
676          "name": "watch",
677          "object": "client",
678          "error": true
679        }
680      ],
681      "expectations": [
682        {
683          "command_started_event": {
684            "command": {
685              "aggregate": 1,
686              "cursor": {},
687              "pipeline": [
688                {
689                  "$changeStream": {
690                    "fullDocument": "default",
691                    "allChangesForCluster": true
692                  }
693                }
694              ]
695            },
696            "database_name": "admin"
697          }
698        },
699        {
700          "command_started_event": {
701            "command": {
702              "aggregate": 1,
703              "cursor": {},
704              "pipeline": [
705                {
706                  "$changeStream": {
707                    "fullDocument": "default",
708                    "allChangesForCluster": true
709                  }
710                }
711              ]
712            },
713            "database_name": "admin"
714          }
715        }
716      ]
717    },
718    {
719      "description": "client.watch fails after NotMaster when retryReads is false",
720      "clientOptions": {
721        "retryReads": false
722      },
723      "failPoint": {
724        "configureFailPoint": "failCommand",
725        "mode": {
726          "times": 1
727        },
728        "data": {
729          "failCommands": [
730            "aggregate"
731          ],
732          "errorCode": 10107
733        }
734      },
735      "operations": [
736        {
737          "name": "watch",
738          "object": "client",
739          "error": true
740        }
741      ],
742      "expectations": [
743        {
744          "command_started_event": {
745            "command": {
746              "aggregate": 1,
747              "cursor": {},
748              "pipeline": [
749                {
750                  "$changeStream": {
751                    "fullDocument": "default",
752                    "allChangesForCluster": true
753                  }
754                }
755              ]
756            },
757            "database_name": "admin"
758          }
759        }
760      ]
761    }
762  ]
763}
764