...

Text file src/go.mongodb.org/mongo-driver/testdata/unified-test-format/valid-pass/poc-transactions.json

Documentation: go.mongodb.org/mongo-driver/testdata/unified-test-format/valid-pass

     1{
     2  "description": "poc-transactions",
     3  "schemaVersion": "1.0",
     4  "runOnRequirements": [
     5    {
     6      "minServerVersion": "4.0",
     7      "topologies": [
     8        "replicaset"
     9      ]
    10    },
    11    {
    12      "minServerVersion": "4.1.8",
    13      "topologies": [
    14        "sharded-replicaset"
    15      ]
    16    }
    17  ],
    18  "createEntities": [
    19    {
    20      "client": {
    21        "id": "client0",
    22        "observeEvents": [
    23          "commandStartedEvent"
    24        ]
    25      }
    26    },
    27    {
    28      "database": {
    29        "id": "database0",
    30        "client": "client0",
    31        "databaseName": "transaction-tests"
    32      }
    33    },
    34    {
    35      "collection": {
    36        "id": "collection0",
    37        "database": "database0",
    38        "collectionName": "test"
    39      }
    40    },
    41    {
    42      "session": {
    43        "id": "session0",
    44        "client": "client0"
    45      }
    46    }
    47  ],
    48  "initialData": [
    49    {
    50      "collectionName": "test",
    51      "databaseName": "transaction-tests",
    52      "documents": []
    53    }
    54  ],
    55  "tests": [
    56    {
    57      "description": "Client side error in command starting transaction",
    58      "operations": [
    59        {
    60          "name": "startTransaction",
    61          "object": "session0"
    62        },
    63        {
    64          "name": "updateOne",
    65          "object": "collection0",
    66          "arguments": {
    67            "session": "session0",
    68            "filter": {
    69              "_id": 1
    70            },
    71            "update": {
    72              "x": 1
    73            }
    74          },
    75          "expectError": {
    76            "isClientError": true
    77          }
    78        },
    79        {
    80          "name": "assertSessionTransactionState",
    81          "object": "testRunner",
    82          "arguments": {
    83            "session": "session0",
    84            "state": "starting"
    85          }
    86        }
    87      ]
    88    },
    89    {
    90      "description": "explicitly create collection using create command",
    91      "runOnRequirements": [
    92        {
    93          "minServerVersion": "4.3.4",
    94          "topologies": [
    95            "replicaset",
    96            "sharded-replicaset"
    97          ]
    98        }
    99      ],
   100      "operations": [
   101        {
   102          "name": "dropCollection",
   103          "object": "database0",
   104          "arguments": {
   105            "collection": "test"
   106          }
   107        },
   108        {
   109          "name": "startTransaction",
   110          "object": "session0"
   111        },
   112        {
   113          "name": "createCollection",
   114          "object": "database0",
   115          "arguments": {
   116            "session": "session0",
   117            "collection": "test"
   118          }
   119        },
   120        {
   121          "name": "assertCollectionNotExists",
   122          "object": "testRunner",
   123          "arguments": {
   124            "databaseName": "transaction-tests",
   125            "collectionName": "test"
   126          }
   127        },
   128        {
   129          "name": "commitTransaction",
   130          "object": "session0"
   131        },
   132        {
   133          "name": "assertCollectionExists",
   134          "object": "testRunner",
   135          "arguments": {
   136            "databaseName": "transaction-tests",
   137            "collectionName": "test"
   138          }
   139        }
   140      ],
   141      "expectEvents": [
   142        {
   143          "client": "client0",
   144          "events": [
   145            {
   146              "commandStartedEvent": {
   147                "command": {
   148                  "drop": "test",
   149                  "writeConcern": {
   150                    "$$exists": false
   151                  }
   152                },
   153                "commandName": "drop",
   154                "databaseName": "transaction-tests"
   155              }
   156            },
   157            {
   158              "commandStartedEvent": {
   159                "command": {
   160                  "create": "test",
   161                  "lsid": {
   162                    "$$sessionLsid": "session0"
   163                  },
   164                  "txnNumber": 1,
   165                  "startTransaction": true,
   166                  "autocommit": false,
   167                  "writeConcern": {
   168                    "$$exists": false
   169                  }
   170                },
   171                "commandName": "create",
   172                "databaseName": "transaction-tests"
   173              }
   174            },
   175            {
   176              "commandStartedEvent": {
   177                "command": {
   178                  "commitTransaction": 1,
   179                  "lsid": {
   180                    "$$sessionLsid": "session0"
   181                  },
   182                  "txnNumber": 1,
   183                  "startTransaction": {
   184                    "$$exists": false
   185                  },
   186                  "autocommit": false,
   187                  "writeConcern": {
   188                    "$$exists": false
   189                  }
   190                },
   191                "commandName": "commitTransaction",
   192                "databaseName": "admin"
   193              }
   194            }
   195          ]
   196        }
   197      ]
   198    },
   199    {
   200      "description": "create index on a non-existing collection",
   201      "runOnRequirements": [
   202        {
   203          "minServerVersion": "4.3.4",
   204          "topologies": [
   205            "replicaset",
   206            "sharded-replicaset"
   207          ]
   208        }
   209      ],
   210      "operations": [
   211        {
   212          "name": "dropCollection",
   213          "object": "database0",
   214          "arguments": {
   215            "collection": "test"
   216          }
   217        },
   218        {
   219          "name": "startTransaction",
   220          "object": "session0"
   221        },
   222        {
   223          "name": "createIndex",
   224          "object": "collection0",
   225          "arguments": {
   226            "session": "session0",
   227            "name": "x_1",
   228            "keys": {
   229              "x": 1
   230            }
   231          }
   232        },
   233        {
   234          "name": "assertIndexNotExists",
   235          "object": "testRunner",
   236          "arguments": {
   237            "databaseName": "transaction-tests",
   238            "collectionName": "test",
   239            "indexName": "x_1"
   240          }
   241        },
   242        {
   243          "name": "commitTransaction",
   244          "object": "session0"
   245        },
   246        {
   247          "name": "assertIndexExists",
   248          "object": "testRunner",
   249          "arguments": {
   250            "databaseName": "transaction-tests",
   251            "collectionName": "test",
   252            "indexName": "x_1"
   253          }
   254        }
   255      ],
   256      "expectEvents": [
   257        {
   258          "client": "client0",
   259          "events": [
   260            {
   261              "commandStartedEvent": {
   262                "command": {
   263                  "drop": "test",
   264                  "writeConcern": {
   265                    "$$exists": false
   266                  }
   267                },
   268                "commandName": "drop",
   269                "databaseName": "transaction-tests"
   270              }
   271            },
   272            {
   273              "commandStartedEvent": {
   274                "command": {
   275                  "createIndexes": "test",
   276                  "indexes": [
   277                    {
   278                      "name": "x_1",
   279                      "key": {
   280                        "x": 1
   281                      }
   282                    }
   283                  ],
   284                  "lsid": {
   285                    "$$sessionLsid": "session0"
   286                  },
   287                  "txnNumber": 1,
   288                  "startTransaction": true,
   289                  "autocommit": false,
   290                  "writeConcern": {
   291                    "$$exists": false
   292                  }
   293                },
   294                "commandName": "createIndexes",
   295                "databaseName": "transaction-tests"
   296              }
   297            },
   298            {
   299              "commandStartedEvent": {
   300                "command": {
   301                  "commitTransaction": 1,
   302                  "lsid": {
   303                    "$$sessionLsid": "session0"
   304                  },
   305                  "txnNumber": 1,
   306                  "startTransaction": {
   307                    "$$exists": false
   308                  },
   309                  "autocommit": false,
   310                  "writeConcern": {
   311                    "$$exists": false
   312                  }
   313                },
   314                "commandName": "commitTransaction",
   315                "databaseName": "admin"
   316              }
   317            }
   318          ]
   319        }
   320      ]
   321    }
   322  ]
   323}

View as plain text