File: cancel-server-check.yml

package info (click to toggle)
golang-mongodb-mongo-driver 1.8.1%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 18,500 kB
  • sloc: perl: 533; ansic: 491; python: 432; makefile: 187; sh: 72
file content (96 lines) | stat: -rw-r--r-- 2,999 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Test SDAM error handling.
runOn:
  # General failCommand requirements (this file does not use appName
  # with failCommand).
  - minServerVersion: "4.0"
    topology: ["replicaset"]
  - minServerVersion: "4.2"
    topology: ["sharded"]

database_name: &database_name "sdam-tests"
collection_name: &collection_name "cancel-server-check"

data: []

tests:
  - description: Cancel server check
    clientOptions:
      retryWrites: true
      heartbeatFrequencyMS: 10000
      # Server selection timeout MUST be less than heartbeatFrequencyMS for
      # this test. This setting ensures that the retried insert will fail
      # after 5 seconds if the driver does not properly cancel the in progress
      # check.
      serverSelectionTimeoutMS: 5000
      appname: cancelServerCheckTest
    operations:
      # Perform an operation to ensure the node is discovered.
      - name: insertOne
        object: collection
        arguments:
          document:
            _id: 1
      # Configure the next inserts to fail with a non-timeout network error.
      # This should:
      # 1) Mark the server Unknown
      # 2) Clear the connection pool
      # 3) Cancel the in progress hello or legacy hello check and close the Monitor
      #    connection
      # 4) The write will be then we retried, server selection will request an
      #    immediate check, and block for ~500ms until the next Monitor check
      #    proceeds.
      # 5) The write will succeed on the second attempt.
      - name: configureFailPoint
        object: testRunner
        arguments:
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
                failCommands: ["insert"]
                closeConnection: True
      - name: insertOne
        object: collection
        arguments:
          document:
            _id: 2
        result:
          insertedId: 2
      # The first error should mark the server Unknown and then clear the pool.
      - name: waitForEvent
        object: testRunner
        arguments:
          event: ServerMarkedUnknownEvent
          count: 1
      - name: waitForEvent
        object: testRunner
        arguments:
          event: PoolClearedEvent
          count: 1
      # Perform another operation to ensure the node still selectable.
      - name: insertOne
        object: collection
        arguments:
          document:
            _id: 3
        result:
          insertedId: 3
      # Assert the server was marked Unknown and pool was cleared exactly once.
      - name: assertEventCount
        object: testRunner
        arguments:
          event: ServerMarkedUnknownEvent
          count: 1
      - name: assertEventCount
        object: testRunner
        arguments:
          event: PoolClearedEvent
          count: 1

    # Order of operations is non-deterministic so we cannot check events.
    outcome:
      collection:
        data:
          - {_id: 1}
          - {_id: 2}
          - {_id: 3}