1runOn:
2    -
3        minServerVersion: "4.0"
4        topology: ["single", "replicaset"]
5    -
6        minServerVersion: "4.1.7"
7        topology: ["sharded"]
8
9database_name: &database_name "retryable-reads-tests"
10collection_name: &collection_name "coll"
11
12data:
13    - {_id: 1, x: 11}
14    - {_id: 2, x: 22}
15    - {_id: 3, x: 33}
16
17tests:
18    -
19        description: "Distinct succeeds after InterruptedAtShutdown"
20        failPoint: &failCommand_failPoint
21            configureFailPoint: failCommand
22            mode: { times: 1 }
23            data: { failCommands: [distinct], errorCode: 11600 }
24        operations:
25            - &retryable_operation_succeeds
26                <<: &retryable_operation
27                    name: distinct
28                    object: collection
29                    arguments: { fieldName: "x", filter: { _id: { $gt: 1 } } }
30                result:
31                    - 22
32                    - 33
33        expectations:
34            - &retryable_command_started_event
35                command_started_event:
36                    command:
37                        distinct: *collection_name
38                        key: "x"
39                        query:
40                          _id: {$gt: 1}
41                    database_name: *database_name
42            - *retryable_command_started_event
43    -
44        description: "Distinct succeeds after InterruptedDueToReplStateChange"
45        failPoint:
46            <<: *failCommand_failPoint
47            data: { failCommands: [distinct], errorCode: 11602 }
48        operations: [*retryable_operation_succeeds]
49        expectations:
50             - *retryable_command_started_event
51             - *retryable_command_started_event
52    -
53        description: "Distinct succeeds after NotMaster"
54        failPoint:
55            <<: *failCommand_failPoint
56            data: { failCommands: [distinct], errorCode: 10107 }
57        operations: [*retryable_operation_succeeds]
58        expectations:
59             - *retryable_command_started_event
60             - *retryable_command_started_event
61    -
62        description: "Distinct succeeds after NotMasterNoSlaveOk"
63        failPoint:
64            <<: *failCommand_failPoint
65            data: { failCommands: [distinct], errorCode: 13435 }
66        operations: [*retryable_operation_succeeds]
67        expectations:
68             - *retryable_command_started_event
69             - *retryable_command_started_event
70    -
71        description: "Distinct succeeds after NotMasterOrSecondary"
72        failPoint:
73            <<: *failCommand_failPoint
74            data: { failCommands: [distinct], errorCode: 13436 }
75        operations: [*retryable_operation_succeeds]
76        expectations:
77             - *retryable_command_started_event
78             - *retryable_command_started_event
79    -
80        description: "Distinct succeeds after PrimarySteppedDown"
81        failPoint:
82            <<: *failCommand_failPoint
83            data: { failCommands: [distinct], errorCode: 189 }
84        operations: [*retryable_operation_succeeds]
85        expectations:
86             - *retryable_command_started_event
87             - *retryable_command_started_event
88    -
89        description: "Distinct succeeds after ShutdownInProgress"
90        failPoint:
91            <<: *failCommand_failPoint
92            data: { failCommands: [distinct], errorCode: 91 }
93        operations: [*retryable_operation_succeeds]
94        expectations:
95             - *retryable_command_started_event
96             - *retryable_command_started_event
97    -
98        description: "Distinct succeeds after HostNotFound"
99        failPoint:
100            <<: *failCommand_failPoint
101            data: { failCommands: [distinct], errorCode: 7 }
102        operations: [*retryable_operation_succeeds]
103        expectations:
104             - *retryable_command_started_event
105             - *retryable_command_started_event
106    -
107        description: "Distinct succeeds after HostUnreachable"
108        failPoint:
109            <<: *failCommand_failPoint
110            data: { failCommands: [distinct], errorCode: 6 }
111        operations: [*retryable_operation_succeeds]
112        expectations:
113             - *retryable_command_started_event
114             - *retryable_command_started_event
115    -
116        description: "Distinct succeeds after NetworkTimeout"
117        failPoint:
118            <<: *failCommand_failPoint
119            data: { failCommands: [distinct], errorCode: 89 }
120        operations: [*retryable_operation_succeeds]
121        expectations:
122             - *retryable_command_started_event
123             - *retryable_command_started_event
124    -
125        description: "Distinct succeeds after SocketException"
126        failPoint:
127            <<: *failCommand_failPoint
128            data: { failCommands: [distinct], errorCode: 9001 }
129        operations: [*retryable_operation_succeeds]
130        expectations:
131             - *retryable_command_started_event
132             - *retryable_command_started_event
133    -
134        description: "Distinct fails after two NotMaster errors"
135        failPoint:
136            <<: *failCommand_failPoint
137            mode: { times: 2 }
138            data: { failCommands: [distinct], errorCode: 10107 }
139        operations:
140            - &retryable_operation_fails
141                <<: *retryable_operation
142                error: true
143        expectations:
144             - *retryable_command_started_event
145             - *retryable_command_started_event
146    -
147        description: "Distinct fails after NotMaster when retryReads is false"
148        clientOptions:
149            retryReads: false
150        failPoint:
151            <<: *failCommand_failPoint
152            data: { failCommands: [distinct], errorCode: 10107 }
153        operations: [*retryable_operation_fails]
154        expectations:
155             - *retryable_command_started_event
156
157