...
1# Test SDAM error handling.
2runOn:
3 # General failCommand requirements (this file does not use appName
4 # with failCommand).
5 - minServerVersion: "4.0"
6 topology: ["replicaset"]
7 - minServerVersion: "4.2"
8 topology: ["sharded"]
9
10database_name: &database_name "sdam-tests"
11collection_name: &collection_name "cancel-server-check"
12
13data: []
14
15tests:
16 - description: Cancel server check
17 clientOptions:
18 retryWrites: true
19 heartbeatFrequencyMS: 10000
20 # Server selection timeout MUST be less than heartbeatFrequencyMS for
21 # this test. This setting ensures that the retried insert will fail
22 # after 5 seconds if the driver does not properly cancel the in progress
23 # check.
24 serverSelectionTimeoutMS: 5000
25 appname: cancelServerCheckTest
26 operations:
27 # Perform an operation to ensure the node is discovered.
28 - name: insertOne
29 object: collection
30 arguments:
31 document:
32 _id: 1
33 # Configure the next inserts to fail with a non-timeout network error.
34 # This should:
35 # 1) Mark the server Unknown
36 # 2) Clear the connection pool
37 # 3) Cancel the in progress hello or legacy hello check and close the Monitor
38 # connection
39 # 4) The write will be then we retried, server selection will request an
40 # immediate check, and block for ~500ms until the next Monitor check
41 # proceeds.
42 # 5) The write will succeed on the second attempt.
43 - name: configureFailPoint
44 object: testRunner
45 arguments:
46 failPoint:
47 configureFailPoint: failCommand
48 mode: { times: 1 }
49 data:
50 failCommands: ["insert"]
51 closeConnection: True
52 - name: insertOne
53 object: collection
54 arguments:
55 document:
56 _id: 2
57 result:
58 insertedId: 2
59 # The first error should mark the server Unknown and then clear the pool.
60 - name: waitForEvent
61 object: testRunner
62 arguments:
63 event: ServerMarkedUnknownEvent
64 count: 1
65 - name: waitForEvent
66 object: testRunner
67 arguments:
68 event: PoolClearedEvent
69 count: 1
70 # Perform another operation to ensure the node still selectable.
71 - name: insertOne
72 object: collection
73 arguments:
74 document:
75 _id: 3
76 result:
77 insertedId: 3
78 # Assert the server was marked Unknown and pool was cleared exactly once.
79 - name: assertEventCount
80 object: testRunner
81 arguments:
82 event: ServerMarkedUnknownEvent
83 count: 1
84 - name: assertEventCount
85 object: testRunner
86 arguments:
87 event: PoolClearedEvent
88 count: 1
89
90 # Order of operations is non-deterministic so we cannot check events.
91 outcome:
92 collection:
93 data:
94 - {_id: 1}
95 - {_id: 2}
96 - {_id: 3}
View as plain text