...

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

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

     1# Test SDAM error handling.
     2runOn:
     3    # This test requires retryable writes, failCommand appName, and
     4    # failCommand blockConnection with closeConnection:true (SERVER-53512).
     5    - minServerVersion: "4.9"
     6      topology: ["replicaset", "sharded"]
     7
     8database_name: &database_name "sdam-tests"
     9collection_name: &collection_name "pool-cleared-error"
    10
    11data: []
    12
    13tests:
    14  - description: PoolClearedError does not mark server unknown
    15    clientOptions:
    16      retryWrites: true
    17      maxPoolSize: 1
    18      appname: poolClearedErrorTest
    19    operations:
    20      # Perform an operation to ensure the node is discovered.
    21      - name: insertOne
    22        object: collection
    23        arguments:
    24          document:
    25            _id: 1
    26      # Configure the next insert to fail with a network error which will
    27      # clear the pool leaving it paused until the server is rediscovered.
    28      - name: configureFailPoint
    29        object: testRunner
    30        arguments:
    31          failPoint:
    32            configureFailPoint: failCommand
    33            mode: { times: 1 }
    34            data:
    35                failCommands: ["insert"]
    36                blockConnection: true
    37                blockTimeMS: 100
    38                closeConnection: true
    39                appName: poolClearedErrorTest
    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      - name: startThread
    50        object: testRunner
    51        arguments:
    52          name: thread3
    53      - name: startThread
    54        object: testRunner
    55        arguments:
    56          name: thread4
    57      - name: startThread
    58        object: testRunner
    59        arguments:
    60          name: thread5
    61      - name: startThread
    62        object: testRunner
    63        arguments:
    64          name: thread6
    65      # Perform concurrent insert operations. The first one to execute will
    66      # fail with a network error, mark the server Unknown, clear the pool,
    67      # and retry.
    68      # The other operations will either:
    69      # - Notice the pool is paused, fail with a PoolClearedError, and retry.
    70      # - Or block waiting in server selection until the server is
    71      #   rediscovered.
    72      #
    73      # Note that this test does not guarantee that a PoolClearedError will be
    74      # raised but it is likely since the initial insert is delayed.
    75      - name: runOnThread
    76        object: testRunner
    77        arguments:
    78          name: thread1
    79          operation:
    80            name: insertOne
    81            object: collection
    82            arguments:
    83              document:
    84                _id: 2
    85      - name: runOnThread
    86        object: testRunner
    87        arguments:
    88          name: thread2
    89          operation:
    90            name: insertOne
    91            object: collection
    92            arguments:
    93              document:
    94                _id: 3
    95      - name: runOnThread
    96        object: testRunner
    97        arguments:
    98          name: thread3
    99          operation:
   100            name: insertOne
   101            object: collection
   102            arguments:
   103              document:
   104                _id: 4
   105      - name: runOnThread
   106        object: testRunner
   107        arguments:
   108          name: thread4
   109          operation:
   110            name: insertOne
   111            object: collection
   112            arguments:
   113              document:
   114                _id: 5
   115      - name: runOnThread
   116        object: testRunner
   117        arguments:
   118          name: thread5
   119          operation:
   120            name: insertOne
   121            object: collection
   122            arguments:
   123              document:
   124                _id: 6
   125      - name: runOnThread
   126        object: testRunner
   127        arguments:
   128          name: thread6
   129          operation:
   130            name: insertOne
   131            object: collection
   132            arguments:
   133              document:
   134                _id: 7
   135      # Stop threads.
   136      - name: waitForThread
   137        object: testRunner
   138        arguments:
   139          name: thread1
   140      - name: waitForThread
   141        object: testRunner
   142        arguments:
   143          name: thread2
   144      - name: waitForThread
   145        object: testRunner
   146        arguments:
   147          name: thread3
   148      - name: waitForThread
   149        object: testRunner
   150        arguments:
   151          name: thread4
   152      - name: waitForThread
   153        object: testRunner
   154        arguments:
   155          name: thread5
   156      - name: waitForThread
   157        object: testRunner
   158        arguments:
   159          name: thread6
   160      # The first shutdown error should mark the server Unknown and then clear
   161      # the pool.
   162      - name: waitForEvent
   163        object: testRunner
   164        arguments:
   165          event: ServerMarkedUnknownEvent
   166          count: 1
   167      - name: waitForEvent
   168        object: testRunner
   169        arguments:
   170          event: PoolClearedEvent
   171          count: 1
   172      # Perform an operation to ensure the node still useable.
   173      - name: insertOne
   174        object: collection
   175        arguments:
   176          document:
   177            _id: 8
   178      # Assert the server was marked Unknown and pool was cleared exactly once.
   179      - name: assertEventCount
   180        object: testRunner
   181        arguments:
   182          event: ServerMarkedUnknownEvent
   183          count: 1
   184      - name: assertEventCount
   185        object: testRunner
   186        arguments:
   187          event: PoolClearedEvent
   188          count: 1
   189
   190    # Order of operations is non-deterministic so we cannot check events.
   191    outcome:
   192      collection:
   193        data:
   194          - {_id: 1}
   195          - {_id: 2}
   196          - {_id: 3}
   197          - {_id: 4}
   198          - {_id: 5}
   199          - {_id: 6}
   200          - {_id: 7}
   201          - {_id: 8}

View as plain text