...

Text file src/go.mongodb.org/mongo-driver/testdata/server-discovery-and-monitoring/integration/find-network-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-network-error"
     8
     9data: &data
    10  - {_id: 1}
    11  - {_id: 2}
    12
    13tests:
    14  - description: Reset server and pool after network error on find
    15    failPoint:
    16      configureFailPoint: failCommand
    17      mode: { times: 1 }
    18      data:
    19          failCommands: ["find"]
    20          closeConnection: true
    21          appName: findNetworkErrorTest
    22    clientOptions:
    23      retryWrites: false
    24      retryReads: false
    25      appname: findNetworkErrorTest
    26    operations:
    27      - name: find
    28        object: collection
    29        arguments:
    30          filter:
    31            _id: 1
    32        error: true
    33      - name: waitForEvent
    34        object: testRunner
    35        arguments:
    36          event: ServerMarkedUnknownEvent
    37          count: 1
    38      - name: waitForEvent
    39        object: testRunner
    40        arguments:
    41          event: PoolClearedEvent
    42          count: 1
    43      # Perform another operation to ensure the node is rediscovered.
    44      - name: insertMany
    45        object: collection
    46        arguments:
    47          documents:
    48            - _id: 5
    49            - _id: 6
    50      # Assert the server was marked Unknown and pool was cleared exactly once.
    51      - name: assertEventCount
    52        object: testRunner
    53        arguments:
    54          event: ServerMarkedUnknownEvent
    55          count: 1
    56      - name: assertEventCount
    57        object: testRunner
    58        arguments:
    59          event: PoolClearedEvent
    60          count: 1
    61
    62    expectations:
    63      - command_started_event:
    64          command:
    65            find: *collection_name
    66          command_name: find
    67          database_name: *database_name
    68      - command_started_event:
    69          command:
    70            insert: *collection_name
    71            documents:
    72              - _id: 5
    73              - _id: 6
    74          command_name: insert
    75          database_name: *database_name
    76
    77    outcome:
    78      collection:
    79        data:
    80          - {_id: 1}
    81          - {_id: 2}
    82          - {_id: 5}
    83          - {_id: 6}

View as plain text