1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
description: "sessions inherit timeoutMS from their parent MongoClient"
schemaVersion: "1.9"
runOnRequirements:
- minServerVersion: "4.4"
topologies: ["replicaset", "sharded"]
createEntities:
- client:
id: &failPointClient failPointClient
useMultipleMongoses: false
- client:
id: &client client
uriOptions:
timeoutMS: 50
useMultipleMongoses: false
observeEvents:
- commandStartedEvent
- commandSucceededEvent
- commandFailedEvent
- database:
id: &database database
client: *client
databaseName: &databaseName test
- collection:
id: &collection collection
database: *database
collectionName: &collectionName coll
- session:
id: &session session
client: *client
initialData:
- collectionName: *collectionName
databaseName: *databaseName
documents: []
tests:
# Drivers ignore errors from abortTransaction, so the tests in this file use commandSucceededEvent and
# commandFailedEvent events to assert success/failure.
- description: "timeoutMS applied to commitTransaction"
operations:
- name: failPoint
object: testRunner
arguments:
client: *failPointClient
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: ["commitTransaction"]
blockConnection: true
blockTimeMS: 60
- name: startTransaction
object: *session
- name: insertOne
object: *collection
arguments:
session: *session
document: { _id: 1 }
- name: commitTransaction
object: *session
expectError:
isTimeoutError: true
expectEvents:
- client: *client
events:
- commandStartedEvent:
commandName: insert
databaseName: *databaseName
command:
insert: *collectionName
- commandSucceededEvent:
commandName: insert
- commandStartedEvent:
commandName: commitTransaction
databaseName: admin
command:
commitTransaction: 1
maxTimeMS: { $$type: ["int", "long"] }
- commandFailedEvent:
commandName: commitTransaction
- description: "timeoutMS applied to abortTransaction"
operations:
- name: failPoint
object: testRunner
arguments:
client: *failPointClient
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: ["abortTransaction"]
blockConnection: true
blockTimeMS: 60
- name: startTransaction
object: *session
- name: insertOne
object: *collection
arguments:
session: *session
document: { _id: 1 }
- name: abortTransaction
object: *session
expectEvents:
- client: *client
events:
- commandStartedEvent:
commandName: insert
databaseName: *databaseName
command:
insert: *collectionName
- commandSucceededEvent:
commandName: insert
- commandStartedEvent:
commandName: abortTransaction
databaseName: admin
command:
abortTransaction: 1
maxTimeMS: { $$type: ["int", "long"] }
- commandFailedEvent:
commandName: abortTransaction
- description: "timeoutMS applied to withTransaction"
operations:
- name: failPoint
object: testRunner
arguments:
client: *failPointClient
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: ["insert"]
blockConnection: true
blockTimeMS: 60
- name: withTransaction
object: *session
arguments:
callback:
- name: insertOne
object: *collection
arguments:
session: *session
document: { _id: 1 }
expectError:
isTimeoutError: true
expectError:
isTimeoutError: true
expectEvents:
- client: *client
events:
# Because the insert expects an error and gets an error, it technically succeeds, so withTransaction will
# try to run commitTransaction. This will fail client-side, though, because the timeout has already expired,
# so no command is sent.
- commandStartedEvent:
commandName: insert
databaseName: *databaseName
command:
insert: *collectionName
# withTransaction specifies timeoutMS for each operation in the callback that uses the session, so the
# insert command should have a maxTimeMS field.
maxTimeMS: { $$type: ["int", "long"] }
- commandFailedEvent:
commandName: insert
|