mongo-python-driver/test/csot/convenient-transactions.json
Shane Harvey 890cd26e1a
PYTHON-3288 Implement client side operation timeout (#954)
Add timeoutMS URI option and MongoClient keyword argument.
Add provisional/beta pymongo.timeout() api to set a deadline for a block of operations.
2022-06-06 15:36:52 -04:00

192 lines
4.3 KiB
JSON

{
"description": "timeoutMS behaves correctly for the withTransaction API",
"schemaVersion": "1.9",
"runOnRequirements": [
{
"minServerVersion": "4.4",
"topologies": [
"replicaset",
"sharded-replicaset"
]
}
],
"createEntities": [
{
"client": {
"id": "failPointClient",
"useMultipleMongoses": false
}
},
{
"client": {
"id": "client",
"uriOptions": {
"timeoutMS": 50
},
"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
}
}
]
}
}
],
"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": 30
}
}
}
},
{
"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"
]
}
}
}
}
]
}
]
}
]
}