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: "Download succeeds on first attempt"
27        operations:
28            - &retryable_operation
29                name: download
30                object: gridfsbucket
31                arguments: { id: { "$oid" : "000000000000000000000001" } }
32        expectations:
33            -  &retryable_command_started_event
34                command_started_event:
35                    command:
36                        find: fs.files
37                        filter: { _id: {$oid : "000000000000000000000001" }}
38                    database_name: *database_name
39            -  &find_chunks_command_started_event
40                command_started_event:
41                    command:
42                        find: fs.chunks
43                        filter: { files_id: {$oid : "000000000000000000000001" }}
44                        sort: { n: 1 }
45                    database_name: *database_name
46    -
47        description: "Download succeeds on second attempt"
48        failPoint: &failCommand_failPoint
49            configureFailPoint: failCommand
50            mode: { times: 1 }
51            data:
52                failCommands: [find]
53                closeConnection: true
54        operations: [*retryable_operation]
55        expectations:
56             - *retryable_command_started_event
57             - *retryable_command_started_event
58             - *find_chunks_command_started_event
59    -
60        description: "Download fails on first attempt"
61        clientOptions:
62            retryReads: false
63        failPoint: *failCommand_failPoint
64        operations:
65            - &retryable_operation_fails
66                <<: *retryable_operation
67                error: true
68        expectations:
69             - *retryable_command_started_event
70    -
71        description: "Download fails on second attempt"
72        failPoint:
73            <<: *failCommand_failPoint
74            mode: { times: 2 }
75        operations: [*retryable_operation_fails]
76        expectations:
77             - *retryable_command_started_event
78             - *retryable_command_started_event
79
80