| 1 |
description: "poc-transactions-convenient-api" |
| 2 |
|
| 3 |
schemaVersion: "1.0" |
| 4 |
|
| 5 |
runOnRequirements: |
| 6 |
- minServerVersion: "4.0" |
| 7 |
topologies: [ replicaset ] |
| 8 |
- minServerVersion: "4.1.8" |
| 9 |
topologies: [ sharded-replicaset ] |
| 10 |
|
| 11 |
createEntities: |
| 12 |
- client: |
| 13 |
id: &client0 client0 |
| 14 |
useMultipleMongoses: true |
| 15 |
observeEvents: [ commandStartedEvent ] |
| 16 |
- client: |
| 17 |
id: &client1 client1 |
| 18 |
uriOptions: |
| 19 |
readConcernLevel: local |
| 20 |
w: 1 |
| 21 |
useMultipleMongoses: true |
| 22 |
observeEvents: [ commandStartedEvent ] |
| 23 |
- database: |
| 24 |
id: &database0 database0 |
| 25 |
client: *client0 |
| 26 |
databaseName: &databaseName transaction-tests |
| 27 |
- database: |
| 28 |
id: &database1 database1 |
| 29 |
client: *client1 |
| 30 |
databaseName: *databaseName |
| 31 |
- collection: |
| 32 |
id: &collection0 collection0 |
| 33 |
database: *database0 |
| 34 |
collectionName: &collectionName test |
| 35 |
- collection: |
| 36 |
id: &collection1 collection1 |
| 37 |
database: *database1 |
| 38 |
collectionName: *collectionName |
| 39 |
- session: |
| 40 |
id: &session0 session0 |
| 41 |
client: *client0 |
| 42 |
- session: |
| 43 |
id: &session1 session1 |
| 44 |
client: *client1 |
| 45 |
- session: |
| 46 |
id: &session2 session2 |
| 47 |
client: *client0 |
| 48 |
sessionOptions: |
| 49 |
defaultTransactionOptions: |
| 50 |
readConcern: { level: majority } |
| 51 |
writeConcern: { w: 1 } |
| 52 |
|
| 53 |
initialData: |
| 54 |
- collectionName: *collectionName |
| 55 |
databaseName: *databaseName |
| 56 |
documents: [] |
| 57 |
|
| 58 |
tests: |
| 59 |
- description: "withTransaction and no transaction options set" |
| 60 |
operations: |
| 61 |
- name: withTransaction |
| 62 |
object: *session0 |
| 63 |
arguments: |
| 64 |
callback: |
| 65 |
- name: insertOne |
| 66 |
object: *collection0 |
| 67 |
arguments: |
| 68 |
session: *session0 |
| 69 |
document: { _id: 1 } |
| 70 |
expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } } |
| 71 |
expectEvents: |
| 72 |
- client: *client0 |
| 73 |
events: |
| 74 |
- commandStartedEvent: |
| 75 |
command: |
| 76 |
insert: *collectionName |
| 77 |
documents: [ { _id: 1 } ] |
| 78 |
ordered: true |
| 79 |
lsid: { $$sessionLsid: *session0 } |
| 80 |
txnNumber: 1 |
| 81 |
startTransaction: true |
| 82 |
autocommit: false |
| 83 |
# omitted fields |
| 84 |
readConcern: { $$exists: false } |
| 85 |
writeConcern: { $$exists: false } |
| 86 |
commandName: insert |
| 87 |
databaseName: *databaseName |
| 88 |
- commandStartedEvent: |
| 89 |
command: |
| 90 |
commitTransaction: 1 |
| 91 |
lsid: { $$sessionLsid: *session0 } |
| 92 |
txnNumber: 1 |
| 93 |
autocommit: false |
| 94 |
# omitted fields |
| 95 |
readConcern: { $$exists: false } |
| 96 |
startTransaction: { $$exists: false } |
| 97 |
writeConcern: { $$exists: false } |
| 98 |
commandName: commitTransaction |
| 99 |
databaseName: admin |
| 100 |
outcome: &outcome |
| 101 |
- collectionName: *collectionName |
| 102 |
databaseName: *databaseName |
| 103 |
documents: |
| 104 |
- { _id: 1 } |
| 105 |
|
| 106 |
- description: "withTransaction inherits transaction options from client" |
| 107 |
operations: |
| 108 |
- name: withTransaction |
| 109 |
object: *session1 |
| 110 |
arguments: |
| 111 |
callback: |
| 112 |
- name: insertOne |
| 113 |
object: *collection1 |
| 114 |
arguments: |
| 115 |
session: *session1 |
| 116 |
document: { _id: 1 } |
| 117 |
expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } } |
| 118 |
expectEvents: |
| 119 |
- client: *client1 |
| 120 |
events: |
| 121 |
- commandStartedEvent: |
| 122 |
command: |
| 123 |
insert: *collectionName |
| 124 |
documents: [ { _id: 1 } ] |
| 125 |
ordered: true |
| 126 |
lsid: { $$sessionLsid: *session1 } |
| 127 |
txnNumber: 1 |
| 128 |
startTransaction: true |
| 129 |
autocommit: false |
| 130 |
readConcern: { level: local } |
| 131 |
# omitted fields |
| 132 |
writeConcern: { $$exists: false } |
| 133 |
commandName: insert |
| 134 |
databaseName: *databaseName |
| 135 |
- commandStartedEvent: |
| 136 |
command: |
| 137 |
commitTransaction: 1 |
| 138 |
lsid: { $$sessionLsid: *session1 } |
| 139 |
txnNumber: 1 |
| 140 |
autocommit: false |
| 141 |
writeConcern: { w: 1 } |
| 142 |
# omitted fields |
| 143 |
readConcern: { $$exists: false } |
| 144 |
startTransaction: { $$exists: false } |
| 145 |
commandName: commitTransaction |
| 146 |
databaseName: admin |
| 147 |
outcome: *outcome |
| 148 |
|
| 149 |
- description: "withTransaction inherits transaction options from defaultTransactionOptions" |
| 150 |
operations: |
| 151 |
- name: withTransaction |
| 152 |
object: *session2 |
| 153 |
arguments: |
| 154 |
callback: |
| 155 |
- name: insertOne |
| 156 |
object: *collection0 |
| 157 |
arguments: |
| 158 |
session: *session2 |
| 159 |
document: { _id: 1 } |
| 160 |
expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } } |
| 161 |
expectEvents: |
| 162 |
- client: *client0 |
| 163 |
events: |
| 164 |
- commandStartedEvent: |
| 165 |
command: |
| 166 |
insert: *collectionName |
| 167 |
documents: [ { _id: 1 } ] |
| 168 |
ordered: true |
| 169 |
lsid: { $$sessionLsid: *session2 } |
| 170 |
txnNumber: 1 |
| 171 |
startTransaction: true |
| 172 |
autocommit: false |
| 173 |
readConcern: { level: majority } |
| 174 |
# omitted fields |
| 175 |
writeConcern: { $$exists: false } |
| 176 |
commandName: insert |
| 177 |
databaseName: *databaseName |
| 178 |
- commandStartedEvent: |
| 179 |
command: |
| 180 |
commitTransaction: 1 |
| 181 |
lsid: { $$sessionLsid: *session2 } |
| 182 |
txnNumber: 1 |
| 183 |
autocommit: false |
| 184 |
writeConcern: { w: 1 } |
| 185 |
# omitted fields |
| 186 |
readConcern: { $$exists: false } |
| 187 |
startTransaction: { $$exists: false } |
| 188 |
commandName: commitTransaction |
| 189 |
databaseName: admin |
| 190 |
outcome: *outcome |
| 191 |
|
| 192 |
- description: "withTransaction explicit transaction options" |
| 193 |
operations: |
| 194 |
- name: withTransaction |
| 195 |
object: *session0 |
| 196 |
arguments: |
| 197 |
callback: |
| 198 |
- name: insertOne |
| 199 |
object: *collection0 |
| 200 |
arguments: |
| 201 |
session: *session0 |
| 202 |
document: { _id: 1 } |
| 203 |
expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } } |
| 204 |
readConcern: { level: majority } |
| 205 |
writeConcern: { w: 1 } |
| 206 |
expectEvents: |
| 207 |
- client: *client0 |
| 208 |
events: |
| 209 |
- commandStartedEvent: |
| 210 |
command: |
| 211 |
insert: *collectionName |
| 212 |
documents: [ { _id: 1 } ] |
| 213 |
ordered: true |
| 214 |
lsid: { $$sessionLsid: *session0 } |
| 215 |
txnNumber: 1 |
| 216 |
startTransaction: true |
| 217 |
autocommit: false |
| 218 |
readConcern: { level: majority } |
| 219 |
# omitted fields |
| 220 |
writeConcern: { $$exists: false } |
| 221 |
commandName: insert |
| 222 |
databaseName: *databaseName |
| 223 |
- commandStartedEvent: |
| 224 |
command: |
| 225 |
commitTransaction: 1 |
| 226 |
lsid: { $$sessionLsid: *session0 } |
| 227 |
txnNumber: 1 |
| 228 |
autocommit: false |
| 229 |
writeConcern: { w: 1 } |
| 230 |
# omitted fields |
| 231 |
readConcern: { $$exists: false } |
| 232 |
startTransaction: { $$exists: false } |
| 233 |
commandName: commitTransaction |
| 234 |
databaseName: admin |
| 235 |
outcome: *outcome |