...

Text file src/go.mongodb.org/mongo-driver/testdata/client-side-operations-timeout/error-transformations.yml

Documentation: go.mongodb.org/mongo-driver/testdata/client-side-operations-timeout

     1description: "MaxTimeMSExpired server errors are transformed into a custom timeout error"
     2
     3schemaVersion: "1.9"
     4
     5# failCommand is available on 4.0 for replica sets and 4.2 for sharded clusters.
     6runOnRequirements:
     7  - minServerVersion: "4.0"
     8    topologies: ["replicaset"]
     9  - minServerVersion: "4.2"
    10    topologies: ["replicaset", "sharded"]
    11
    12createEntities:
    13  - client:
    14      id: &failPointClient failPointClient
    15      useMultipleMongoses: false
    16  - client:
    17      id: &client client
    18      uriOptions:
    19        timeoutMS: 50
    20      useMultipleMongoses: false
    21      observeEvents:
    22        - commandStartedEvent
    23  - database:
    24      id: &database database
    25      client: *client
    26      databaseName: &databaseName test
    27  - collection:
    28      id: &collection collection
    29      database: *database
    30      collectionName: &collectionName coll
    31
    32initialData:
    33  - collectionName: *collectionName
    34    databaseName: *databaseName
    35    documents: []
    36
    37tests:
    38  # A server response like {ok: 0, code: 50, ...} is transformed.
    39  - description: "basic MaxTimeMSExpired error is transformed"
    40    operations:
    41      - name: failPoint
    42        object: testRunner
    43        arguments:
    44          client: *failPointClient
    45          failPoint:
    46            configureFailPoint: failCommand
    47            mode: { times: 1 }
    48            data:
    49              failCommands: ["insert"]
    50              errorCode: 50
    51      - name: insertOne
    52        object: *collection
    53        arguments:
    54          document: { _id: 1 }
    55        expectError:
    56          isTimeoutError: true
    57    expectEvents:
    58      - client: *client
    59        events:
    60          - commandStartedEvent:
    61              commandName: insert
    62              databaseName: *databaseName
    63              command:
    64                insert: *collectionName
    65                maxTimeMS: { $$type: ["int", "long"] }
    66
    67  # A server response like {ok: 1, writeConcernError: {code: 50, ...}} is transformed.
    68  - description: "write concern error MaxTimeMSExpired is transformed"
    69    operations:
    70      - name: failPoint
    71        object: testRunner
    72        arguments:
    73          client: *failPointClient
    74          failPoint:
    75            configureFailPoint: failCommand
    76            mode: { times: 1 }
    77            data:
    78              failCommands: ["insert"]
    79              writeConcernError:
    80                code: 50
    81                errmsg: "maxTimeMS expired"
    82      - name: insertOne
    83        object: *collection
    84        arguments:
    85          document: { _id: 1 }
    86        expectError:
    87          isTimeoutError: true
    88    expectEvents:
    89      - client: *client
    90        events:
    91          - commandStartedEvent:
    92              commandName: insert
    93              databaseName: *databaseName
    94              command:
    95                insert: *collectionName
    96                maxTimeMS: { $$type: ["int", "long"] }

View as plain text