...

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

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

     1runOn:
     2    - minServerVersion: "4.3.1"
     3      topology: ["replicaset", "sharded", "load-balanced"]
     4
     5data:
     6    - { _id: 1, x: 11 }
     7    - { _id: 2, x: 22 }
     8
     9tests:
    10    - description: "BulkWrite succeeds with RetryableWriteError from server"
    11      failPoint:
    12          configureFailPoint: failCommand
    13          mode: { times: 1 }
    14          data:
    15              failCommands: ["update"]
    16              errorCode: 112 # WriteConflict, not a retryable error code
    17              errorLabels: ["RetryableWriteError"] # Override server behavior: send RetryableWriteError label with non-retryable error code
    18      operation:
    19          name: "bulkWrite"
    20          arguments:
    21              requests:
    22                  - name: "deleteOne"
    23                    arguments:
    24                        filter: { _id: 1 }
    25                  - name: "insertOne"
    26                    arguments:
    27                        document: { _id: 3, x: 33 }
    28                  - name: "updateOne"
    29                    arguments:
    30                        filter: { _id: 2 }
    31                        update: { $inc: { x: 1 } }
    32              options: { ordered: true }
    33      outcome: # Driver retries operation and it succeeds
    34          result:
    35              deletedCount: 1
    36              insertedCount: 1
    37              insertedIds: { 1: 3 }
    38              matchedCount: 1
    39              modifiedCount: 1
    40              upsertedCount: 0
    41              upsertedIds: {}
    42          collection:
    43              data:
    44                  - { _id: 2, x: 23 }
    45                  - { _id: 3, x: 33 }
    46
    47    - description: "BulkWrite fails if server does not return RetryableWriteError"
    48      failPoint:
    49          configureFailPoint: failCommand
    50          mode: { times: 1 }
    51          data:
    52              failCommands: ["update"]
    53              errorCode: 11600 # InterruptedAtShutdown, normally a retryable error code
    54              errorLabels: []  # Override server behavior: do not send RetryableWriteError label with retryable code
    55      operation:
    56          name: "bulkWrite"
    57          arguments:
    58              requests:
    59                  - name: "deleteOne"
    60                    arguments:
    61                        filter: { _id: 1 }
    62                  - name: "insertOne"
    63                    arguments:
    64                        document: { _id: 3, x: 33 }
    65                  - name: "updateOne"
    66                    arguments:
    67                        filter: { _id: 2 }
    68                        update: { $inc: { x: 1 } }
    69              options: { ordered: true }
    70      outcome:
    71          error: true # Driver does not retry operation because there was no RetryableWriteError label on response
    72          result:
    73              errorLabelsOmit: ["RetryableWriteError"]
    74          collection:
    75              data:
    76                  - { _id: 2, x: 22 }
    77                  - { _id: 3, x: 33 }

View as plain text