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"
10bucket_name: "fs"
11
12data:
13    fs.files:
14        -
15            _id: { $oid : "000000000000000000000001" }
16            length: 1
17            chunkSize: 4
18            uploadDate: { $date : "1970-01-01T00:00:00.000Z" }
19            filename: abc
20            metadata: {}
21    fs.chunks:
22        - { _id: { $oid: "000000000000000000000002" }, files_id: { $oid: "000000000000000000000001" }, n: 0, data: { $binary: { base64: "EQ==", subType: "00" } } }
23
24tests:
25    -
26        description: "DownloadByName succeeds after InterruptedAtShutdown"
27        failPoint: &failCommand_failPoint
28            configureFailPoint: failCommand
29            mode: { times: 1 }
30            data: { failCommands: [find], errorCode: 11600 }
31        operations:
32            - &retryable_operation
33                name: download_by_name
34                object: gridfsbucket
35                arguments:
36                    filename: abc
37        expectations:
38            - &retryable_command_started_event
39                command_started_event:
40                    command:
41                        find: fs.files
42                        filter: { filename : "abc" }
43                    database_name: *database_name
44            - *retryable_command_started_event
45            - &find_chunks_command_started_event
46                command_started_event:
47                    command:
48                        find: fs.chunks
49                        filter: { files_id: { $oid : "000000000000000000000001" }}
50                        sort: { n: 1 }
51                    database_name: *database_name
52    -
53        description: "DownloadByName succeeds after InterruptedDueToReplStateChange"
54        failPoint:
55            <<: *failCommand_failPoint
56            data: { failCommands: [find], errorCode: 11602 }
57        operations: [*retryable_operation]
58        expectations:
59             - *retryable_command_started_event
60             - *retryable_command_started_event
61             - *find_chunks_command_started_event
62    -
63        description: "DownloadByName succeeds after NotMaster"
64        failPoint:
65            <<: *failCommand_failPoint
66            data: { failCommands: [find], errorCode: 10107 }
67        operations: [*retryable_operation]
68        expectations:
69             - *retryable_command_started_event
70             - *retryable_command_started_event
71             - *find_chunks_command_started_event
72    -
73        description: "DownloadByName succeeds after NotMasterNoSlaveOk"
74        failPoint:
75            <<: *failCommand_failPoint
76            data: { failCommands: [find], errorCode: 13435 }
77        operations: [*retryable_operation]
78        expectations:
79             - *retryable_command_started_event
80             - *retryable_command_started_event
81             - *find_chunks_command_started_event
82    -
83        description: "DownloadByName succeeds after NotMasterOrSecondary"
84        failPoint:
85            <<: *failCommand_failPoint
86            data: { failCommands: [find], errorCode: 13436 }
87        operations: [*retryable_operation]
88        expectations:
89             - *retryable_command_started_event
90             - *retryable_command_started_event
91             - *find_chunks_command_started_event
92    -
93        description: "DownloadByName succeeds after PrimarySteppedDown"
94        failPoint:
95            <<: *failCommand_failPoint
96            data: { failCommands: [find], errorCode: 189 }
97        operations: [*retryable_operation]
98        expectations:
99             - *retryable_command_started_event
100             - *retryable_command_started_event
101             - *find_chunks_command_started_event
102    -
103        description: "DownloadByName succeeds after ShutdownInProgress"
104        failPoint:
105            <<: *failCommand_failPoint
106            data: { failCommands: [find], errorCode: 91 }
107        operations: [*retryable_operation]
108        expectations:
109             - *retryable_command_started_event
110             - *retryable_command_started_event
111             - *find_chunks_command_started_event
112    -
113        description: "DownloadByName succeeds after HostNotFound"
114        failPoint:
115            <<: *failCommand_failPoint
116            data: { failCommands: [find], errorCode: 7 }
117        operations: [*retryable_operation]
118        expectations:
119             - *retryable_command_started_event
120             - *retryable_command_started_event
121             - *find_chunks_command_started_event
122    -
123        description: "DownloadByName succeeds after HostUnreachable"
124        failPoint:
125            <<: *failCommand_failPoint
126            data: { failCommands: [find], errorCode: 6 }
127        operations: [*retryable_operation]
128        expectations:
129             - *retryable_command_started_event
130             - *retryable_command_started_event
131             - *find_chunks_command_started_event
132    -
133        description: "DownloadByName succeeds after NetworkTimeout"
134        failPoint:
135            <<: *failCommand_failPoint
136            data: { failCommands: [find], errorCode: 89 }
137        operations: [*retryable_operation]
138        expectations:
139             - *retryable_command_started_event
140             - *retryable_command_started_event
141             - *find_chunks_command_started_event
142    -
143        description: "DownloadByName succeeds after SocketException"
144        failPoint:
145            <<: *failCommand_failPoint
146            data: { failCommands: [find], errorCode: 9001 }
147        operations: [*retryable_operation]
148        expectations:
149             - *retryable_command_started_event
150             - *retryable_command_started_event
151             - *find_chunks_command_started_event
152    -
153        description: "DownloadByName fails after two NotMaster errors"
154        failPoint:
155            <<: *failCommand_failPoint
156            mode: { times: 2 }
157            data: { failCommands: [find], errorCode: 10107 }
158        operations:
159            - &retryable_operation_fails
160                <<: *retryable_operation
161                error: true
162        expectations:
163             - *retryable_command_started_event
164             - *retryable_command_started_event
165    -
166        description: "DownloadByName fails after NotMaster when retryReads is false"
167        clientOptions:
168            retryReads: false
169        failPoint:
170            <<: *failCommand_failPoint
171            data: { failCommands: [find], errorCode: 10107 }
172        operations: [*retryable_operation_fails]
173        expectations:
174             - *retryable_command_started_event