...

Text file src/go.mongodb.org/mongo-driver/testdata/versioned-api/transaction-handling.json

Documentation: go.mongodb.org/mongo-driver/testdata/versioned-api

     1{
     2  "description": "Transaction handling",
     3  "schemaVersion": "1.1",
     4  "runOnRequirements": [
     5    {
     6      "minServerVersion": "4.9",
     7      "topologies": [
     8        "replicaset",
     9        "sharded-replicaset",
    10        "load-balanced"
    11      ]
    12    }
    13  ],
    14  "createEntities": [
    15    {
    16      "client": {
    17        "id": "client",
    18        "observeEvents": [
    19          "commandStartedEvent"
    20        ],
    21        "serverApi": {
    22          "version": "1"
    23        }
    24      }
    25    },
    26    {
    27      "database": {
    28        "id": "database",
    29        "client": "client",
    30        "databaseName": "versioned-api-tests"
    31      }
    32    },
    33    {
    34      "collection": {
    35        "id": "collection",
    36        "database": "database",
    37        "collectionName": "test"
    38      }
    39    },
    40    {
    41      "session": {
    42        "id": "session",
    43        "client": "client"
    44      }
    45    }
    46  ],
    47  "_yamlAnchors": {
    48    "versions": [
    49      {
    50        "apiVersion": "1",
    51        "apiStrict": {
    52          "$$unsetOrMatches": false
    53        },
    54        "apiDeprecationErrors": {
    55          "$$unsetOrMatches": false
    56        }
    57      }
    58    ]
    59  },
    60  "initialData": [
    61    {
    62      "collectionName": "test",
    63      "databaseName": "versioned-api-tests",
    64      "documents": [
    65        {
    66          "_id": 1,
    67          "x": 11
    68        },
    69        {
    70          "_id": 2,
    71          "x": 22
    72        },
    73        {
    74          "_id": 3,
    75          "x": 33
    76        },
    77        {
    78          "_id": 4,
    79          "x": 44
    80        },
    81        {
    82          "_id": 5,
    83          "x": 55
    84        }
    85      ]
    86    }
    87  ],
    88  "tests": [
    89    {
    90      "description": "All commands in a transaction declare an API version",
    91      "runOnRequirements": [
    92        {
    93          "topologies": [
    94            "replicaset",
    95            "sharded-replicaset",
    96            "load-balanced"
    97          ]
    98        }
    99      ],
   100      "operations": [
   101        {
   102          "name": "startTransaction",
   103          "object": "session"
   104        },
   105        {
   106          "name": "insertOne",
   107          "object": "collection",
   108          "arguments": {
   109            "session": "session",
   110            "document": {
   111              "_id": 6,
   112              "x": 66
   113            }
   114          },
   115          "expectResult": {
   116            "$$unsetOrMatches": {
   117              "insertedId": {
   118                "$$unsetOrMatches": 6
   119              }
   120            }
   121          }
   122        },
   123        {
   124          "name": "insertOne",
   125          "object": "collection",
   126          "arguments": {
   127            "session": "session",
   128            "document": {
   129              "_id": 7,
   130              "x": 77
   131            }
   132          },
   133          "expectResult": {
   134            "$$unsetOrMatches": {
   135              "insertedId": {
   136                "$$unsetOrMatches": 7
   137              }
   138            }
   139          }
   140        },
   141        {
   142          "name": "commitTransaction",
   143          "object": "session"
   144        }
   145      ],
   146      "expectEvents": [
   147        {
   148          "client": "client",
   149          "events": [
   150            {
   151              "commandStartedEvent": {
   152                "command": {
   153                  "insert": "test",
   154                  "documents": [
   155                    {
   156                      "_id": 6,
   157                      "x": 66
   158                    }
   159                  ],
   160                  "lsid": {
   161                    "$$sessionLsid": "session"
   162                  },
   163                  "startTransaction": true,
   164                  "apiVersion": "1",
   165                  "apiStrict": {
   166                    "$$unsetOrMatches": false
   167                  },
   168                  "apiDeprecationErrors": {
   169                    "$$unsetOrMatches": false
   170                  }
   171                }
   172              }
   173            },
   174            {
   175              "commandStartedEvent": {
   176                "command": {
   177                  "insert": "test",
   178                  "documents": [
   179                    {
   180                      "_id": 7,
   181                      "x": 77
   182                    }
   183                  ],
   184                  "lsid": {
   185                    "$$sessionLsid": "session"
   186                  },
   187                  "apiVersion": "1",
   188                  "apiStrict": {
   189                    "$$unsetOrMatches": false
   190                  },
   191                  "apiDeprecationErrors": {
   192                    "$$unsetOrMatches": false
   193                  }
   194                }
   195              }
   196            },
   197            {
   198              "commandStartedEvent": {
   199                "command": {
   200                  "commitTransaction": 1,
   201                  "lsid": {
   202                    "$$sessionLsid": "session"
   203                  },
   204                  "apiVersion": "1",
   205                  "apiStrict": {
   206                    "$$unsetOrMatches": false
   207                  },
   208                  "apiDeprecationErrors": {
   209                    "$$unsetOrMatches": false
   210                  }
   211                }
   212              }
   213            }
   214          ]
   215        }
   216      ]
   217    },
   218    {
   219      "description": "abortTransaction includes an API version",
   220      "runOnRequirements": [
   221        {
   222          "topologies": [
   223            "replicaset",
   224            "sharded-replicaset",
   225            "load-balanced"
   226          ]
   227        }
   228      ],
   229      "operations": [
   230        {
   231          "name": "startTransaction",
   232          "object": "session"
   233        },
   234        {
   235          "name": "insertOne",
   236          "object": "collection",
   237          "arguments": {
   238            "session": "session",
   239            "document": {
   240              "_id": 6,
   241              "x": 66
   242            }
   243          },
   244          "expectResult": {
   245            "$$unsetOrMatches": {
   246              "insertedId": {
   247                "$$unsetOrMatches": 6
   248              }
   249            }
   250          }
   251        },
   252        {
   253          "name": "insertOne",
   254          "object": "collection",
   255          "arguments": {
   256            "session": "session",
   257            "document": {
   258              "_id": 7,
   259              "x": 77
   260            }
   261          },
   262          "expectResult": {
   263            "$$unsetOrMatches": {
   264              "insertedId": {
   265                "$$unsetOrMatches": 7
   266              }
   267            }
   268          }
   269        },
   270        {
   271          "name": "abortTransaction",
   272          "object": "session"
   273        }
   274      ],
   275      "expectEvents": [
   276        {
   277          "client": "client",
   278          "events": [
   279            {
   280              "commandStartedEvent": {
   281                "command": {
   282                  "insert": "test",
   283                  "documents": [
   284                    {
   285                      "_id": 6,
   286                      "x": 66
   287                    }
   288                  ],
   289                  "lsid": {
   290                    "$$sessionLsid": "session"
   291                  },
   292                  "startTransaction": true,
   293                  "apiVersion": "1",
   294                  "apiStrict": {
   295                    "$$unsetOrMatches": false
   296                  },
   297                  "apiDeprecationErrors": {
   298                    "$$unsetOrMatches": false
   299                  }
   300                }
   301              }
   302            },
   303            {
   304              "commandStartedEvent": {
   305                "command": {
   306                  "insert": "test",
   307                  "documents": [
   308                    {
   309                      "_id": 7,
   310                      "x": 77
   311                    }
   312                  ],
   313                  "lsid": {
   314                    "$$sessionLsid": "session"
   315                  },
   316                  "apiVersion": "1",
   317                  "apiStrict": {
   318                    "$$unsetOrMatches": false
   319                  },
   320                  "apiDeprecationErrors": {
   321                    "$$unsetOrMatches": false
   322                  }
   323                }
   324              }
   325            },
   326            {
   327              "commandStartedEvent": {
   328                "command": {
   329                  "abortTransaction": 1,
   330                  "lsid": {
   331                    "$$sessionLsid": "session"
   332                  },
   333                  "apiVersion": "1",
   334                  "apiStrict": {
   335                    "$$unsetOrMatches": false
   336                  },
   337                  "apiDeprecationErrors": {
   338                    "$$unsetOrMatches": false
   339                  }
   340                }
   341              }
   342            }
   343          ]
   344        }
   345      ]
   346    }
   347  ]
   348}

View as plain text