...

Text file src/go.mongodb.org/mongo-driver/testdata/server-discovery-and-monitoring/integration/hello-command-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.9"
     5
     6database_name: &database_name "sdam-tests"
     7collection_name: &collection_name "hello-command-error"
     8
     9data: []
    10
    11tests:
    12  - description: Command error on Monitor handshake
    13    # Configure the initial handshake to fail with a command error.
    14    # Use times: 2 so that the RTT hello fails as well.
    15    failPoint:
    16      configureFailPoint: failCommand
    17      mode: { times: 2 }
    18      data:
    19          failCommands: ["hello", "isMaster"]
    20          appName: commandErrorHandshakeTest
    21          closeConnection: false
    22          errorCode: 91 # ShutdownInProgress
    23    clientOptions:
    24      retryWrites: false
    25      connectTimeoutMS: 250
    26      heartbeatFrequencyMS: 500
    27      appname: commandErrorHandshakeTest
    28    operations:
    29      # The command error on the initial handshake should mark the server
    30      # Unknown (emitting a ServerDescriptionChangedEvent) and clear the pool.
    31      - name: waitForEvent
    32        object: testRunner
    33        arguments:
    34          event: ServerMarkedUnknownEvent
    35          count: 1
    36      # Perform an operation to ensure the node is discovered.
    37      - name: insertMany
    38        object: collection
    39        arguments:
    40          documents:
    41            - _id: 1
    42            - _id: 2
    43      # We cannot assert the server was marked Unknown and pool was cleared an
    44      # exact number of times because the RTT hello may or may not have
    45      # triggered this failpoint as well.
    46      # - name: assertEventCount
    47      #   object: testRunner
    48      #   arguments:
    49      #     event: ServerMarkedUnknownEvent
    50      #     count: 1
    51      # - name: assertEventCount
    52      #   object: testRunner
    53      #   arguments:
    54      #     event: PoolClearedEvent
    55      #     count: 1
    56
    57    expectations:
    58      - command_started_event:
    59          command:
    60            insert: *collection_name
    61            documents:
    62              - _id: 1
    63              - _id: 2
    64          command_name: insert
    65          database_name: *database_name
    66
    67    outcome:
    68      collection:
    69        data:
    70          - {_id: 1}
    71          - {_id: 2}
    72
    73  - description: Command error on Monitor check
    74    clientOptions:
    75      retryWrites: false
    76      connectTimeoutMS: 1000
    77      heartbeatFrequencyMS: 500
    78      appname: commandErrorCheckTest
    79    operations:
    80      # Perform an operation to ensure the node is discovered.
    81      - name: insertMany
    82        object: collection
    83        arguments:
    84          documents:
    85            - _id: 1
    86            - _id: 2
    87      # Configure the next streaming hello check to fail with a command error.
    88      # Use "times: 4" to increase the probability that the Monitor check fails
    89      # since the RTT hello may trigger this failpoint one or many times as
    90      # well.
    91      - name: configureFailPoint
    92        object: testRunner
    93        arguments:
    94          failPoint:
    95            configureFailPoint: failCommand
    96            mode: { times: 4 }
    97            data:
    98                failCommands: ["hello", "isMaster"]
    99                appName: commandErrorCheckTest
   100                closeConnection: false
   101                blockConnection: true
   102                blockTimeMS: 750
   103                errorCode: 91 # ShutdownInProgress
   104      # The command error on the next check should mark the server Unknown and
   105      # clear the pool.
   106      - name: waitForEvent
   107        object: testRunner
   108        arguments:
   109          event: ServerMarkedUnknownEvent
   110          count: 1
   111      - name: waitForEvent
   112        object: testRunner
   113        arguments:
   114          event: PoolClearedEvent
   115          count: 1
   116      # Perform an operation to ensure the node is rediscovered.
   117      - name: insertMany
   118        object: collection
   119        arguments:
   120          documents:
   121            - _id: 3
   122            - _id: 4
   123      # We cannot assert the server was marked Unknown and pool was cleared an
   124      # exact number of times because the RTT hello may have triggered this
   125      # failpoint one or many times as well.
   126
   127    expectations:
   128      - command_started_event:
   129          command:
   130            insert: *collection_name
   131            documents:
   132              - _id: 1
   133              - _id: 2
   134          command_name: insert
   135          database_name: *database_name
   136      - command_started_event:
   137          command:
   138            insert: *collection_name
   139            documents:
   140              - _id: 3
   141              - _id: 4
   142          command_name: insert
   143          database_name: *database_name
   144
   145    outcome:
   146      collection:
   147        data:
   148          - {_id: 1}
   149          - {_id: 2}
   150          - {_id: 3}
   151          - {_id: 4}

View as plain text