...

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

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

     1runOn:
     2    -
     3        minServerVersion: "3.6"
     4        topology: ["replicaset"]
     5
     6data:
     7    - { _id: 1, x: 11 }
     8
     9tests:
    10    -
    11        description: "InsertMany succeeds after one network error"
    12        failPoint:
    13            configureFailPoint: onPrimaryTransactionalWrite
    14            mode: { times: 1 }
    15        operation:
    16            name: "insertMany"
    17            arguments:
    18                documents:
    19                    - { _id: 2, x: 22 }
    20                    - { _id: 3, x: 33 }
    21                options: { ordered: true }
    22        outcome:
    23            result:
    24                insertedIds: { 0: 2, 1: 3 }
    25            collection:
    26                data:
    27                    - { _id: 1, x: 11 }
    28                    - { _id: 2, x: 22 }
    29                    - { _id: 3, x: 33 }
    30    -
    31        description: "InsertMany with unordered execution"
    32        failPoint:
    33            configureFailPoint: onPrimaryTransactionalWrite
    34            mode: { times: 1 }
    35        operation:
    36            name: "insertMany"
    37            arguments:
    38                documents:
    39                    - { _id: 2, x: 22 }
    40                    - { _id: 3, x: 33 }
    41                options: { ordered: false }
    42        outcome:
    43            result:
    44                insertedIds: { 0: 2, 1: 3 }
    45            collection:
    46                data:
    47                    - { _id: 1, x: 11 }
    48                    - { _id: 2, x: 22 }
    49                    - { _id: 3, x: 33 }
    50    -
    51        description: "InsertMany fails after multiple network errors"
    52        failPoint:
    53            # Normally, a mongod will insert the documents as a batch with a
    54            # single commit. If this fails, mongod may try to insert each
    55            # document one at a time depending on the failure. Therefore our
    56            # single insert command may trigger the failpoint twice on each
    57            # driver attempt. This test permanently enables the fail point to
    58            # ensure the retry attempt always fails.
    59            configureFailPoint: onPrimaryTransactionalWrite
    60            mode: "alwaysOn"
    61            data: { failBeforeCommitExceptionCode: 1 }
    62        operation:
    63            name: "insertMany"
    64            arguments:
    65                documents:
    66                    - { _id: 2, x: 22 }
    67                    - { _id: 3, x: 33 }
    68                    - { _id: 4, x: 44 }
    69                options: { ordered: true }
    70        outcome:
    71            error: true
    72            collection:
    73                data:
    74                    - { _id: 1, x: 11 }

View as plain text