...

Text file src/go.mongodb.org/mongo-driver/testdata/retryable-writes/unified/bulkWrite-serverErrors.yml

Documentation: go.mongodb.org/mongo-driver/testdata/retryable-writes/unified

     1description: "retryable-writes bulkWrite serverErrors"
     2
     3schemaVersion: "1.0"
     4
     5runOnRequirements:
     6  - minServerVersion: "3.6"
     7    topologies: [ replicaset ]
     8
     9createEntities:
    10  - client:
    11      id: &client0 client0
    12      useMultipleMongoses: false
    13      observeEvents: [ commandStartedEvent ]
    14  - database:
    15      id: &database0 database0
    16      client: *client0
    17      databaseName: &databaseName retryable-writes-tests
    18  - collection:
    19      id: &collection0 collection0
    20      database: *database0
    21      collectionName: &collectionName coll
    22
    23initialData:
    24  - collectionName: *collectionName
    25    databaseName: *databaseName
    26    documents:
    27      - { _id: 1, x: 11 }
    28      - { _id: 2, x: 22 }
    29
    30tests:
    31  - description: "BulkWrite succeeds after retryable writeConcernError in first batch"
    32    runOnRequirements:
    33      - minServerVersion: "4.0"
    34        topologies: [ replicaset ]
    35      - minServerVersion: "4.1.7"
    36        topologies: [ sharded-replicaset ]
    37    operations:
    38      - name: failPoint
    39        object: testRunner
    40        arguments:
    41          client: *client0
    42          failPoint:
    43            configureFailPoint: failCommand
    44            mode: { times: 1 }
    45            data:
    46              failCommands: [ insert ]
    47              errorLabels: [RetryableWriteError] # top-level error labels
    48              writeConcernError:
    49                code: 91 # ShutdownInProgress
    50                errmsg: "Replication is being shut down"
    51      - name: bulkWrite
    52        object: *collection0
    53        arguments:
    54          requests:
    55            - insertOne:
    56                document: { _id: 3, x: 33 }
    57            - deleteOne:
    58                filter: { _id: 2 }
    59        expectResult:
    60          deletedCount: 1
    61          insertedCount: 1
    62          matchedCount: 0
    63          modifiedCount: 0
    64          upsertedCount: 0
    65          insertedIds: { $$unsetOrMatches: { 0: 3 } }
    66          upsertedIds: { }
    67    expectEvents:
    68      - client: *client0
    69        events:
    70          - commandStartedEvent:
    71              command:
    72                insert: *collectionName
    73                documents: [{ _id: 3, x: 33 }]
    74              commandName: insert
    75              databaseName: *databaseName
    76          - commandStartedEvent:
    77              command:
    78                insert: *collectionName
    79                documents: [{ _id: 3, x: 33 }]
    80              commandName: insert
    81              databaseName: *databaseName
    82          - commandStartedEvent:
    83              command:
    84                delete: *collectionName
    85                deletes:
    86                  -
    87                    q: { _id: 2 }
    88                    limit: 1
    89              commandName: delete
    90              databaseName: *databaseName
    91    outcome:
    92      - collectionName: *collectionName
    93        databaseName: *databaseName
    94        documents:
    95          - { _id: 1, x: 11 }
    96          - { _id: 3, x: 33 }  # The write was still applied

View as plain text