forked from mongodb/mongo-php-library
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip Sync converted transactions-convenient-api tests
POC for mongodb/specifications#1505
- Loading branch information
Showing
11 changed files
with
5,337 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
344 changes: 344 additions & 0 deletions
344
tests/UnifiedSpecTests/transactions-convenient-api/callback-aborts.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,344 @@ | ||
{ | ||
"description": "callback-aborts", | ||
"schemaVersion": "1.3", | ||
"runOnRequirements": [ | ||
{ | ||
"minServerVersion": "4.0", | ||
"topologies": [ | ||
"replicaset" | ||
] | ||
}, | ||
{ | ||
"minServerVersion": "4.1.8", | ||
"topologies": [ | ||
"sharded", | ||
"load-balanced" | ||
] | ||
} | ||
], | ||
"createEntities": [ | ||
{ | ||
"client": { | ||
"id": "client0", | ||
"useMultipleMongoses": true, | ||
"observeEvents": [ | ||
"commandStartedEvent" | ||
] | ||
} | ||
}, | ||
{ | ||
"database": { | ||
"id": "database0", | ||
"client": "client0", | ||
"databaseName": "withTransaction-tests" | ||
} | ||
}, | ||
{ | ||
"collection": { | ||
"id": "collection0", | ||
"database": "database0", | ||
"collectionName": "test" | ||
} | ||
}, | ||
{ | ||
"session": { | ||
"id": "session0", | ||
"client": "client0" | ||
} | ||
} | ||
], | ||
"initialData": [ | ||
{ | ||
"collectionName": "test", | ||
"databaseName": "withTransaction-tests", | ||
"documents": [] | ||
} | ||
], | ||
"tests": [ | ||
{ | ||
"description": "withTransaction succeeds if callback aborts", | ||
"operations": [ | ||
{ | ||
"name": "withTransaction", | ||
"object": "session0", | ||
"arguments": { | ||
"callback": [ | ||
{ | ||
"name": "insertOne", | ||
"object": "collection0", | ||
"arguments": { | ||
"session": "session0", | ||
"document": { | ||
"_id": 1 | ||
} | ||
}, | ||
"expectResult": { | ||
"$$unsetOrMatches": { | ||
"insertedId": { | ||
"$$unsetOrMatches": 1 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "abortTransaction", | ||
"object": "session0" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"expectEvents": [ | ||
{ | ||
"client": "client0", | ||
"events": [ | ||
{ | ||
"commandStartedEvent": { | ||
"command": { | ||
"insert": "test", | ||
"documents": [ | ||
{ | ||
"_id": 1 | ||
} | ||
], | ||
"ordered": true, | ||
"lsid": { | ||
"$$sessionLsid": "session0" | ||
}, | ||
"txnNumber": { | ||
"$numberLong": "1" | ||
}, | ||
"startTransaction": true, | ||
"autocommit": false, | ||
"readConcern": { | ||
"$$exists": false | ||
}, | ||
"writeConcern": { | ||
"$$exists": false | ||
} | ||
}, | ||
"commandName": "insert", | ||
"databaseName": "withTransaction-tests" | ||
} | ||
}, | ||
{ | ||
"commandStartedEvent": { | ||
"command": { | ||
"abortTransaction": 1, | ||
"lsid": { | ||
"$$sessionLsid": "session0" | ||
}, | ||
"txnNumber": { | ||
"$numberLong": "1" | ||
}, | ||
"autocommit": false, | ||
"readConcern": { | ||
"$$exists": false | ||
}, | ||
"startTransaction": { | ||
"$$exists": false | ||
}, | ||
"writeConcern": { | ||
"$$exists": false | ||
} | ||
}, | ||
"commandName": "abortTransaction", | ||
"databaseName": "admin" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"outcome": [ | ||
{ | ||
"collectionName": "test", | ||
"databaseName": "withTransaction-tests", | ||
"documents": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "withTransaction succeeds if callback aborts with no ops", | ||
"operations": [ | ||
{ | ||
"name": "withTransaction", | ||
"object": "session0", | ||
"arguments": { | ||
"callback": [ | ||
{ | ||
"name": "abortTransaction", | ||
"object": "session0" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"expectEvents": [ | ||
{ | ||
"client": "client0", | ||
"events": [] | ||
} | ||
], | ||
"outcome": [ | ||
{ | ||
"collectionName": "test", | ||
"databaseName": "withTransaction-tests", | ||
"documents": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "withTransaction still succeeds if callback aborts and runs extra op", | ||
"operations": [ | ||
{ | ||
"name": "withTransaction", | ||
"object": "session0", | ||
"arguments": { | ||
"callback": [ | ||
{ | ||
"name": "insertOne", | ||
"object": "collection0", | ||
"arguments": { | ||
"session": "session0", | ||
"document": { | ||
"_id": 1 | ||
} | ||
}, | ||
"expectResult": { | ||
"$$unsetOrMatches": { | ||
"insertedId": { | ||
"$$unsetOrMatches": 1 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "abortTransaction", | ||
"object": "session0" | ||
}, | ||
{ | ||
"name": "insertOne", | ||
"object": "collection0", | ||
"arguments": { | ||
"session": "session0", | ||
"document": { | ||
"_id": 2 | ||
} | ||
}, | ||
"expectResult": { | ||
"$$unsetOrMatches": { | ||
"insertedId": { | ||
"$$unsetOrMatches": 2 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"expectEvents": [ | ||
{ | ||
"client": "client0", | ||
"events": [ | ||
{ | ||
"commandStartedEvent": { | ||
"command": { | ||
"insert": "test", | ||
"documents": [ | ||
{ | ||
"_id": 1 | ||
} | ||
], | ||
"ordered": true, | ||
"lsid": { | ||
"$$sessionLsid": "session0" | ||
}, | ||
"txnNumber": { | ||
"$numberLong": "1" | ||
}, | ||
"startTransaction": true, | ||
"autocommit": false, | ||
"readConcern": { | ||
"$$exists": false | ||
}, | ||
"writeConcern": { | ||
"$$exists": false | ||
} | ||
}, | ||
"commandName": "insert", | ||
"databaseName": "withTransaction-tests" | ||
} | ||
}, | ||
{ | ||
"commandStartedEvent": { | ||
"command": { | ||
"abortTransaction": 1, | ||
"lsid": { | ||
"$$sessionLsid": "session0" | ||
}, | ||
"txnNumber": { | ||
"$numberLong": "1" | ||
}, | ||
"autocommit": false, | ||
"readConcern": { | ||
"$$exists": false | ||
}, | ||
"startTransaction": { | ||
"$$exists": false | ||
}, | ||
"writeConcern": { | ||
"$$exists": false | ||
} | ||
}, | ||
"commandName": "abortTransaction", | ||
"databaseName": "admin" | ||
} | ||
}, | ||
{ | ||
"commandStartedEvent": { | ||
"command": { | ||
"insert": "test", | ||
"documents": [ | ||
{ | ||
"_id": 2 | ||
} | ||
], | ||
"ordered": true, | ||
"lsid": { | ||
"$$sessionLsid": "session0" | ||
}, | ||
"autocommit": { | ||
"$$exists": false | ||
}, | ||
"readConcern": { | ||
"$$exists": false | ||
}, | ||
"startTransaction": { | ||
"$$exists": false | ||
}, | ||
"writeConcern": { | ||
"$$exists": false | ||
} | ||
}, | ||
"commandName": "insert", | ||
"databaseName": "withTransaction-tests" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"outcome": [ | ||
{ | ||
"collectionName": "test", | ||
"databaseName": "withTransaction-tests", | ||
"documents": [ | ||
{ | ||
"_id": 2 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.