{
  "description": "updateOne-errorLabels",
  "schemaVersion": "1.3",
  "runOnRequirements": [
    {
      "minServerVersion": "4.3.1",
      "topologies": [
        "replicaset",
        "sharded",
        "load-balanced"
      ]
    }
  ],
  "createEntities": [
    {
      "client": {
        "id": "client0",
        "useMultipleMongoses": false
      }
    },
    {
      "database": {
        "id": "database0",
        "client": "client0",
        "databaseName": "retryable-writes-tests"
      }
    },
    {
      "collection": {
        "id": "collection0",
        "database": "database0",
        "collectionName": "coll"
      }
    }
  ],
  "initialData": [
    {
      "collectionName": "coll",
      "databaseName": "retryable-writes-tests",
      "documents": [
        {
          "_id": 1,
          "x": 11
        },
        {
          "_id": 2,
          "x": 22
        }
      ]
    }
  ],
  "tests": [
    {
      "description": "UpdateOne succeeds with RetryableWriteError from server",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "client0",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 1
              },
              "data": {
                "failCommands": [
                  "update"
                ],
                "errorCode": 112,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "object": "collection0",
          "name": "updateOne",
          "arguments": {
            "filter": {
              "_id": 1
            },
            "update": {
              "$inc": {
                "x": 1
              }
            }
          },
          "expectResult": {
            "matchedCount": 1,
            "modifiedCount": 1,
            "upsertedCount": 0
          }
        }
      ],
      "outcome": [
        {
          "collectionName": "coll",
          "databaseName": "retryable-writes-tests",
          "documents": [
            {
              "_id": 1,
              "x": 12
            },
            {
              "_id": 2,
              "x": 22
            }
          ]
        }
      ]
    },
    {
      "description": "UpdateOne fails if server does not return RetryableWriteError",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "client0",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 1
              },
              "data": {
                "failCommands": [
                  "update"
                ],
                "errorCode": 11600,
                "errorLabels": []
              }
            }
          }
        },
        {
          "object": "collection0",
          "name": "updateOne",
          "arguments": {
            "filter": {
              "_id": 1
            },
            "update": {
              "$inc": {
                "x": 1
              }
            }
          },
          "expectError": {
            "isError": true,
            "errorLabelsOmit": [
              "RetryableWriteError"
            ]
          }
        }
      ],
      "outcome": [
        {
          "collectionName": "coll",
          "databaseName": "retryable-writes-tests",
          "documents": [
            {
              "_id": 1,
              "x": 11
            },
            {
              "_id": 2,
              "x": 22
            }
          ]
        }
      ]
    },
    {
      "description": "UpdateOne succeeds after PrimarySteppedDown",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "client0",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 1
              },
              "data": {
                "failCommands": [
                  "update"
                ],
                "errorCode": 189,
                "errorLabels": [
                  "RetryableWriteError"
                ]
              }
            }
          }
        },
        {
          "object": "collection0",
          "name": "updateOne",
          "arguments": {
            "filter": {
              "_id": 1
            },
            "update": {
              "$inc": {
                "x": 1
              }
            }
          },
          "expectResult": {
            "matchedCount": 1,
            "modifiedCount": 1,
            "upsertedCount": 0
          }
        }
      ],
      "outcome": [
        {
          "collectionName": "coll",
          "databaseName": "retryable-writes-tests",
          "documents": [
            {
              "_id": 1,
              "x": 12
            },
            {
              "_id": 2,
              "x": 22
            }
          ]
        }
      ]
    },
    {
      "description": "UpdateOne succeeds after WriteConcernError ShutdownInProgress",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "client0",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 1
              },
              "data": {
                "failCommands": [
                  "update"
                ],
                "errorLabels": [
                  "RetryableWriteError"
                ],
                "writeConcernError": {
                  "code": 91,
                  "errmsg": "Replication is being shut down"
                }
              }
            }
          }
        },
        {
          "object": "collection0",
          "name": "updateOne",
          "arguments": {
            "filter": {
              "_id": 1
            },
            "update": {
              "$inc": {
                "x": 1
              }
            }
          },
          "expectResult": {
            "matchedCount": 1,
            "modifiedCount": 1,
            "upsertedCount": 0
          }
        }
      ],
      "outcome": [
        {
          "collectionName": "coll",
          "databaseName": "retryable-writes-tests",
          "documents": [
            {
              "_id": 1,
              "x": 12
            },
            {
              "_id": 2,
              "x": 22
            }
          ]
        }
      ]
    }
  ]
}
