mongo-python-driver/test/csot/convenient-transactions.json

212 lines
4.9 KiB
JSON

{
"description": "timeoutMS behaves correctly for the withTransaction API",
"schemaVersion": "1.26",
"runOnRequirements": [
{
"minServerVersion": "4.4",
"topologies": [
"replicaset",
"sharded"
]
}
],
"createEntities": [
{
"client": {
"id": "failPointClient",
"useMultipleMongoses": false
}
},
{
"client": {
"id": "client",
"uriOptions": {
"timeoutMS": 500,
"minPoolSize": 1
},
"awaitMinPoolSizeMS": 10000,
"useMultipleMongoses": false,
"observeEvents": [
"commandStartedEvent"
]
}
},
{
"database": {
"id": "database",
"client": "client",
"databaseName": "test"
}
},
{
"collection": {
"id": "collection",
"database": "database",
"collectionName": "coll"
}
},
{
"session": {
"id": "session",
"client": "client"
}
}
],
"initialData": [
{
"collectionName": "coll",
"databaseName": "test",
"documents": []
}
],
"tests": [
{
"description": "withTransaction raises a client-side error if timeoutMS is overridden inside the callback",
"operations": [
{
"name": "withTransaction",
"object": "session",
"arguments": {
"callback": [
{
"name": "insertOne",
"object": "collection",
"arguments": {
"document": {
"_id": 1
},
"session": "session",
"timeoutMS": 100
},
"expectError": {
"isClientError": true
}
}
]
},
"expectError": {
"isClientError": true
}
}
],
"expectEvents": [
{
"client": "client",
"events": []
}
]
},
{
"description": "timeoutMS is not refreshed for each operation in the callback",
"operations": [
{
"name": "failPoint",
"object": "testRunner",
"arguments": {
"client": "failPointClient",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 2
},
"data": {
"failCommands": [
"insert"
],
"blockConnection": true,
"blockTimeMS": 300
}
}
}
},
{
"name": "withTransaction",
"object": "session",
"arguments": {
"callback": [
{
"name": "insertOne",
"object": "collection",
"arguments": {
"document": {
"_id": 1
},
"session": "session"
}
},
{
"name": "insertOne",
"object": "collection",
"arguments": {
"document": {
"_id": 2
},
"session": "session"
},
"expectError": {
"isTimeoutError": true
}
}
]
},
"expectError": {
"isTimeoutError": true
}
}
],
"expectEvents": [
{
"client": "client",
"events": [
{
"commandStartedEvent": {
"commandName": "insert",
"databaseName": "test",
"command": {
"insert": "coll",
"maxTimeMS": {
"$$type": [
"int",
"long"
]
}
}
}
},
{
"commandStartedEvent": {
"commandName": "insert",
"databaseName": "test",
"command": {
"insert": "coll",
"maxTimeMS": {
"$$type": [
"int",
"long"
]
}
}
}
},
{
"commandStartedEvent": {
"commandName": "abortTransaction",
"databaseName": "admin",
"command": {
"abortTransaction": 1,
"maxTimeMS": {
"$$type": [
"int",
"long"
]
}
}
}
}
]
}
]
}
]
}