...

Text file src/go.mongodb.org/mongo-driver/testdata/server-discovery-and-monitoring/integration/insert-shutdown-error.yml

Documentation: go.mongodb.org/mongo-driver/testdata/server-discovery-and-monitoring/integration

     1# Test SDAM error handling.
     2runOn:
     3    # failCommand appName requirements
     4    - minServerVersion: "4.4"
     5
     6database_name: &database_name "sdam-tests"
     7collection_name: &collection_name "insert-shutdown-error"
     8
     9data: []
    10
    11tests:
    12  - description: Concurrent shutdown error on insert
    13    clientOptions:
    14      retryWrites: false
    15      heartbeatFrequencyMS: 500
    16      appname: shutdownErrorInsertTest
    17    operations:
    18      # Perform an operation to ensure the node is discovered.
    19      - name: insertOne
    20        object: collection
    21        arguments:
    22          document:
    23            _id: 1
    24      # Configure the next two inserts to fail with a non-timeout shutdown
    25      # errors. Block the connection for 500ms to ensure both operations check
    26      # out connections from the same pool generation.
    27      - name: configureFailPoint
    28        object: testRunner
    29        arguments:
    30          failPoint:
    31            configureFailPoint: failCommand
    32            mode: { times: 2 }
    33            data:
    34                failCommands: ["insert"]
    35                appName: shutdownErrorInsertTest
    36                errorCode: 91
    37                blockConnection: true
    38                blockTimeMS: 500
    39      # Start threads.
    40      - name: startThread
    41        object: testRunner
    42        arguments:
    43          name: thread1
    44      - name: startThread
    45        object: testRunner
    46        arguments:
    47          name: thread2
    48      # Perform concurrent insert operations. Both fail with shutdown errors.
    49      - name: runOnThread
    50        object: testRunner
    51        arguments:
    52          name: thread1
    53          operation:
    54            name: insertOne
    55            object: collection
    56            arguments:
    57              document:
    58                _id: 2
    59            error: true
    60      - name: runOnThread
    61        object: testRunner
    62        arguments:
    63          name: thread2
    64          operation:
    65            name: insertOne
    66            object: collection
    67            arguments:
    68              document:
    69                _id: 3
    70            error: true
    71      # Stop threads.
    72      - name: waitForThread
    73        object: testRunner
    74        arguments:
    75          name: thread1
    76      - name: waitForThread
    77        object: testRunner
    78        arguments:
    79          name: thread2
    80      # The first shutdown error should mark the server Unknown and then clear
    81      # the pool.
    82      - name: waitForEvent
    83        object: testRunner
    84        arguments:
    85          event: ServerMarkedUnknownEvent
    86          count: 1
    87      - name: waitForEvent
    88        object: testRunner
    89        arguments:
    90          event: PoolClearedEvent
    91          count: 1
    92      # Perform an operation to ensure the node is rediscovered.
    93      - name: insertOne
    94        object: collection
    95        arguments:
    96          document:
    97            _id: 4
    98      # Assert the server was marked Unknown and pool was cleared exactly once.
    99      - name: assertEventCount
   100        object: testRunner
   101        arguments:
   102          event: ServerMarkedUnknownEvent
   103          count: 1
   104      - name: assertEventCount
   105        object: testRunner
   106        arguments:
   107          event: PoolClearedEvent
   108          count: 1
   109
   110    # Order of operations is non-deterministic so we cannot check events.
   111    outcome:
   112      collection:
   113        data:
   114          - {_id: 1}
   115          - {_id: 4}

View as plain text