mongo-python-driver/test/transactions/commit.json
Shane Harvey 0967c7ed6c Add startTransaction:true to the start of all transactions
Also add autocommit:false to all commands in transactions.
2018-04-16 09:57:45 -04:00

252 lines
5.8 KiB
JSON

{
"data": [],
"tests": [
{
"description": "commit",
"operations": [
{
"name": "startTransaction",
"arguments": {
"session": "session0"
}
},
{
"name": "insertOne",
"arguments": {
"document": {
"_id": 1
},
"session": "session0"
},
"result": {
"insertedId": 1
}
},
{
"name": "commitTransaction",
"arguments": {
"session": "session0"
}
},
{
"name": "startTransaction",
"arguments": {
"session": "session0"
}
},
{
"name": "insertOne",
"arguments": {
"document": {
"_id": 2
},
"session": "session0"
},
"result": {
"insertedId": 2
}
},
{
"name": "commitTransaction",
"arguments": {
"session": "session0"
}
}
],
"expectations": [
{
"command_started_event": {
"command": {
"insert": "test",
"documents": [
{
"_id": 1
}
],
"ordered": true,
"readConcern": {
"level": "snapshot"
},
"lsid": "session0",
"txnNumber": {
"$numberLong": "1"
},
"stmtId": 0,
"startTransaction": true,
"autocommit": false,
"writeConcern": null
},
"command_name": "insert",
"database_name": "transaction-tests"
}
},
{
"command_started_event": {
"command": {
"commitTransaction": 1,
"lsid": "session0",
"txnNumber": {
"$numberLong": "1"
},
"stmtId": 1,
"startTransaction": null,
"autocommit": false,
"writeConcern": null
},
"command_name": "commitTransaction",
"database_name": "admin"
}
},
{
"command_started_event": {
"command": {
"insert": "test",
"documents": [
{
"_id": 2
}
],
"ordered": true,
"readConcern": {
"level": "snapshot",
"afterClusterTime": 42
},
"lsid": "session0",
"txnNumber": {
"$numberLong": "2"
},
"stmtId": 0,
"startTransaction": true,
"autocommit": false,
"writeConcern": null
},
"command_name": "insert",
"database_name": "transaction-tests"
}
},
{
"command_started_event": {
"command": {
"commitTransaction": 1,
"lsid": "session0",
"txnNumber": {
"$numberLong": "2"
},
"stmtId": 1,
"startTransaction": null,
"autocommit": false,
"writeConcern": null
},
"command_name": "commitTransaction",
"database_name": "admin"
}
}
],
"outcome": {
"collection": {
"data": [
{
"_id": 1
},
{
"_id": 2
}
]
}
}
},
{
"description": "two commits in a row",
"operations": [
{
"name": "startTransaction",
"arguments": {
"session": "session0"
}
},
{
"name": "insertOne",
"arguments": {
"document": {
"_id": 1
},
"session": "session0"
},
"result": {
"insertedId": 1
}
},
{
"name": "commitTransaction",
"arguments": {
"session": "session0"
}
},
{
"name": "commitTransaction",
"arguments": {
"session": "session0"
},
"result": {
"errorContains": "no transaction started"
}
}
],
"expectations": [
{
"command_started_event": {
"command": {
"insert": "test",
"documents": [
{
"_id": 1
}
],
"ordered": true,
"readConcern": {
"level": "snapshot"
},
"lsid": "session0",
"txnNumber": {
"$numberLong": "1"
},
"stmtId": 0,
"startTransaction": true,
"autocommit": false,
"writeConcern": null
},
"command_name": "insert",
"database_name": "transaction-tests"
}
},
{
"command_started_event": {
"command": {
"commitTransaction": 1,
"lsid": "session0",
"txnNumber": {
"$numberLong": "1"
},
"stmtId": 1,
"startTransaction": null,
"autocommit": false,
"writeConcern": null
},
"command_name": "commitTransaction",
"database_name": "admin"
}
}
],
"outcome": {
"collection": {
"data": [
{
"_id": 1
}
]
}
}
}
]
}