...

Text file src/go.mongodb.org/mongo-driver/testdata/convenient-transactions/commit.json

Documentation: go.mongodb.org/mongo-driver/testdata/convenient-transactions

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

View as plain text