...

Text file src/go.mongodb.org/mongo-driver/testdata/retryable-writes/legacy/updateOne.json

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

     1{
     2  "runOn": [
     3    {
     4      "minServerVersion": "3.6",
     5      "topology": [
     6        "replicaset"
     7      ]
     8    }
     9  ],
    10  "data": [
    11    {
    12      "_id": 1,
    13      "x": 11
    14    },
    15    {
    16      "_id": 2,
    17      "x": 22
    18    }
    19  ],
    20  "tests": [
    21    {
    22      "description": "UpdateOne is committed on first attempt",
    23      "failPoint": {
    24        "configureFailPoint": "onPrimaryTransactionalWrite",
    25        "mode": {
    26          "times": 1
    27        }
    28      },
    29      "operation": {
    30        "name": "updateOne",
    31        "arguments": {
    32          "filter": {
    33            "_id": 1
    34          },
    35          "update": {
    36            "$inc": {
    37              "x": 1
    38            }
    39          }
    40        }
    41      },
    42      "outcome": {
    43        "result": {
    44          "matchedCount": 1,
    45          "modifiedCount": 1,
    46          "upsertedCount": 0
    47        },
    48        "collection": {
    49          "data": [
    50            {
    51              "_id": 1,
    52              "x": 12
    53            },
    54            {
    55              "_id": 2,
    56              "x": 22
    57            }
    58          ]
    59        }
    60      }
    61    },
    62    {
    63      "description": "UpdateOne is not committed on first attempt",
    64      "failPoint": {
    65        "configureFailPoint": "onPrimaryTransactionalWrite",
    66        "mode": {
    67          "times": 1
    68        },
    69        "data": {
    70          "failBeforeCommitExceptionCode": 1
    71        }
    72      },
    73      "operation": {
    74        "name": "updateOne",
    75        "arguments": {
    76          "filter": {
    77            "_id": 1
    78          },
    79          "update": {
    80            "$inc": {
    81              "x": 1
    82            }
    83          }
    84        }
    85      },
    86      "outcome": {
    87        "result": {
    88          "matchedCount": 1,
    89          "modifiedCount": 1,
    90          "upsertedCount": 0
    91        },
    92        "collection": {
    93          "data": [
    94            {
    95              "_id": 1,
    96              "x": 12
    97            },
    98            {
    99              "_id": 2,
   100              "x": 22
   101            }
   102          ]
   103        }
   104      }
   105    },
   106    {
   107      "description": "UpdateOne is never committed",
   108      "failPoint": {
   109        "configureFailPoint": "onPrimaryTransactionalWrite",
   110        "mode": {
   111          "times": 2
   112        },
   113        "data": {
   114          "failBeforeCommitExceptionCode": 1
   115        }
   116      },
   117      "operation": {
   118        "name": "updateOne",
   119        "arguments": {
   120          "filter": {
   121            "_id": 1
   122          },
   123          "update": {
   124            "$inc": {
   125              "x": 1
   126            }
   127          }
   128        }
   129      },
   130      "outcome": {
   131        "error": true,
   132        "collection": {
   133          "data": [
   134            {
   135              "_id": 1,
   136              "x": 11
   137            },
   138            {
   139              "_id": 2,
   140              "x": 22
   141            }
   142          ]
   143        }
   144      }
   145    },
   146    {
   147      "description": "UpdateOne with upsert is committed on first attempt",
   148      "failPoint": {
   149        "configureFailPoint": "onPrimaryTransactionalWrite",
   150        "mode": {
   151          "times": 1
   152        }
   153      },
   154      "operation": {
   155        "name": "updateOne",
   156        "arguments": {
   157          "filter": {
   158            "_id": 3,
   159            "x": 33
   160          },
   161          "update": {
   162            "$inc": {
   163              "x": 1
   164            }
   165          },
   166          "upsert": true
   167        }
   168      },
   169      "outcome": {
   170        "result": {
   171          "matchedCount": 0,
   172          "modifiedCount": 0,
   173          "upsertedCount": 1,
   174          "upsertedId": 3
   175        },
   176        "collection": {
   177          "data": [
   178            {
   179              "_id": 1,
   180              "x": 11
   181            },
   182            {
   183              "_id": 2,
   184              "x": 22
   185            },
   186            {
   187              "_id": 3,
   188              "x": 34
   189            }
   190          ]
   191        }
   192      }
   193    },
   194    {
   195      "description": "UpdateOne with upsert is not committed on first attempt",
   196      "failPoint": {
   197        "configureFailPoint": "onPrimaryTransactionalWrite",
   198        "mode": {
   199          "times": 1
   200        },
   201        "data": {
   202          "failBeforeCommitExceptionCode": 1
   203        }
   204      },
   205      "operation": {
   206        "name": "updateOne",
   207        "arguments": {
   208          "filter": {
   209            "_id": 3,
   210            "x": 33
   211          },
   212          "update": {
   213            "$inc": {
   214              "x": 1
   215            }
   216          },
   217          "upsert": true
   218        }
   219      },
   220      "outcome": {
   221        "result": {
   222          "matchedCount": 0,
   223          "modifiedCount": 0,
   224          "upsertedCount": 1,
   225          "upsertedId": 3
   226        },
   227        "collection": {
   228          "data": [
   229            {
   230              "_id": 1,
   231              "x": 11
   232            },
   233            {
   234              "_id": 2,
   235              "x": 22
   236            },
   237            {
   238              "_id": 3,
   239              "x": 34
   240            }
   241          ]
   242        }
   243      }
   244    },
   245    {
   246      "description": "UpdateOne with upsert is never committed",
   247      "failPoint": {
   248        "configureFailPoint": "onPrimaryTransactionalWrite",
   249        "mode": {
   250          "times": 2
   251        },
   252        "data": {
   253          "failBeforeCommitExceptionCode": 1
   254        }
   255      },
   256      "operation": {
   257        "name": "updateOne",
   258        "arguments": {
   259          "filter": {
   260            "_id": 3,
   261            "x": 33
   262          },
   263          "update": {
   264            "$inc": {
   265              "x": 1
   266            }
   267          },
   268          "upsert": true
   269        }
   270      },
   271      "outcome": {
   272        "error": true,
   273        "collection": {
   274          "data": [
   275            {
   276              "_id": 1,
   277              "x": 11
   278            },
   279            {
   280              "_id": 2,
   281              "x": 22
   282            }
   283          ]
   284        }
   285      }
   286    }
   287  ]
   288}

View as plain text