1runOn:
2    -
3        minServerVersion: "4.0"
4        topology: ["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
15tests:
16    -
17        description: "db.watch succeeds on first attempt"
18        operations:
19            - &retryable_operation
20                name: watch
21                object: database
22        expectations:
23            - &retryable_command_started_event
24                command_started_event:
25                    command:
26                        aggregate: 1
27                        cursor: {}
28                        pipeline: [ { $changeStream: { fullDocument: "default" } } ]
29                    database_name: *database_name
30    -
31        description: "db.watch succeeds on second attempt"
32        failPoint:  &failCommand_failPoint
33            configureFailPoint: failCommand
34            mode: { times: 1 }
35            data:
36                failCommands: [aggregate]
37                closeConnection: true
38        operations: [*retryable_operation]
39        expectations:
40             - *retryable_command_started_event
41             - *retryable_command_started_event
42    -
43        description: "db.watch fails on first attempt"
44        clientOptions:
45            retryReads: false
46        failPoint: *failCommand_failPoint
47        operations:
48            - &retryable_operation_fails
49                <<: *retryable_operation
50                error: true
51        expectations:
52             - *retryable_command_started_event
53    -
54        description: "db.watch fails on second attempt"
55        failPoint:
56            <<: *failCommand_failPoint
57            mode: { times: 2 }
58        operations: [*retryable_operation_fails]
59        expectations:
60             - *retryable_command_started_event
61             - *retryable_command_started_event
62