...

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

View as plain text