| 1 |
|
| 2 |
|
| 3 |
runOn: |
| 4 |
- |
| 5 |
minServerVersion: "4.0" |
| 6 |
topology: ["replicaset"] |
| 7 |
- |
| 8 |
minServerVersion: "4.1.8" |
| 9 |
topology: ["sharded"] |
| 10 |
|
| 11 |
database_name: &database_name "transaction-tests" |
| 12 |
collection_name: &collection_name "test" |
| 13 |
|
| 14 |
data: &data |
| 15 |
- _id: 0 |
| 16 |
|
| 17 |
tests: |
| 18 |
- description: commit with majority |
| 19 |
operations: |
| 20 |
- name: startTransaction |
| 21 |
object: session0 |
| 22 |
arguments: |
| 23 |
options: |
| 24 |
writeConcern: |
| 25 |
w: majority |
| 26 |
- name: insertOne |
| 27 |
object: collection |
| 28 |
arguments: |
| 29 |
session: session0 |
| 30 |
document: |
| 31 |
_id: 1 |
| 32 |
result: |
| 33 |
insertedId: 1 |
| 34 |
- &commitTransaction |
| 35 |
name: commitTransaction |
| 36 |
object: session0 |
| 37 |
|
| 38 |
expectations: |
| 39 |
- &insertOneEvent |
| 40 |
command_started_event: |
| 41 |
command: |
| 42 |
insert: *collection_name |
| 43 |
documents: |
| 44 |
- _id: 1 |
| 45 |
ordered: true |
| 46 |
<<: &transactionCommandArgs |
| 47 |
lsid: session0 |
| 48 |
txnNumber: |
| 49 |
$numberLong: "1" |
| 50 |
startTransaction: true |
| 51 |
autocommit: false |
| 52 |
readConcern: |
| 53 |
writeConcern: |
| 54 |
command_name: insert |
| 55 |
database_name: *database_name |
| 56 |
- command_started_event: |
| 57 |
command: |
| 58 |
commitTransaction: 1 |
| 59 |
lsid: session0 |
| 60 |
txnNumber: |
| 61 |
$numberLong: "1" |
| 62 |
startTransaction: |
| 63 |
autocommit: false |
| 64 |
writeConcern: |
| 65 |
w: majority |
| 66 |
command_name: commitTransaction |
| 67 |
database_name: admin |
| 68 |
|
| 69 |
outcome: |
| 70 |
collection: |
| 71 |
data: |
| 72 |
- _id: 0 |
| 73 |
- _id: 1 |
| 74 |
|
| 75 |
- description: commit with default |
| 76 |
|
| 77 |
operations: |
| 78 |
- &startTransaction |
| 79 |
name: startTransaction |
| 80 |
object: session0 |
| 81 |
- name: insertOne |
| 82 |
object: collection |
| 83 |
arguments: |
| 84 |
session: session0 |
| 85 |
document: |
| 86 |
_id: 1 |
| 87 |
result: |
| 88 |
insertedId: 1 |
| 89 |
- *commitTransaction |
| 90 |
|
| 91 |
expectations: |
| 92 |
- command_started_event: |
| 93 |
command: |
| 94 |
insert: *collection_name |
| 95 |
documents: |
| 96 |
- _id: 1 |
| 97 |
ordered: true |
| 98 |
<<: *transactionCommandArgs |
| 99 |
command_name: insert |
| 100 |
database_name: *database_name |
| 101 |
- &commitWithDefaultWCEvent |
| 102 |
command_started_event: |
| 103 |
command: |
| 104 |
commitTransaction: 1 |
| 105 |
lsid: session0 |
| 106 |
txnNumber: |
| 107 |
$numberLong: "1" |
| 108 |
startTransaction: |
| 109 |
autocommit: false |
| 110 |
writeConcern: |
| 111 |
command_name: commitTransaction |
| 112 |
database_name: admin |
| 113 |
|
| 114 |
outcome: |
| 115 |
collection: |
| 116 |
data: |
| 117 |
- _id: 0 |
| 118 |
- _id: 1 |
| 119 |
|
| 120 |
- description: abort with majority |
| 121 |
|
| 122 |
operations: |
| 123 |
- name: startTransaction |
| 124 |
object: session0 |
| 125 |
arguments: |
| 126 |
options: |
| 127 |
writeConcern: |
| 128 |
w: majority |
| 129 |
- name: insertOne |
| 130 |
object: collection |
| 131 |
arguments: |
| 132 |
session: session0 |
| 133 |
document: |
| 134 |
_id: 1 |
| 135 |
result: |
| 136 |
insertedId: 1 |
| 137 |
- name: abortTransaction |
| 138 |
object: session0 |
| 139 |
|
| 140 |
expectations: |
| 141 |
- command_started_event: |
| 142 |
command: |
| 143 |
insert: *collection_name |
| 144 |
documents: |
| 145 |
- _id: 1 |
| 146 |
ordered: true |
| 147 |
<<: *transactionCommandArgs |
| 148 |
command_name: insert |
| 149 |
database_name: *database_name |
| 150 |
- command_started_event: |
| 151 |
command: |
| 152 |
abortTransaction: 1 |
| 153 |
lsid: session0 |
| 154 |
txnNumber: |
| 155 |
$numberLong: "1" |
| 156 |
startTransaction: |
| 157 |
autocommit: false |
| 158 |
writeConcern: |
| 159 |
w: majority |
| 160 |
command_name: abortTransaction |
| 161 |
database_name: admin |
| 162 |
|
| 163 |
outcome: |
| 164 |
collection: |
| 165 |
data: *data |
| 166 |
|
| 167 |
- description: abort with default |
| 168 |
|
| 169 |
operations: |
| 170 |
- name: startTransaction |
| 171 |
object: session0 |
| 172 |
- name: insertOne |
| 173 |
object: collection |
| 174 |
arguments: |
| 175 |
session: session0 |
| 176 |
document: |
| 177 |
_id: 1 |
| 178 |
result: |
| 179 |
insertedId: 1 |
| 180 |
- name: abortTransaction |
| 181 |
object: session0 |
| 182 |
|
| 183 |
expectations: |
| 184 |
- command_started_event: |
| 185 |
command: |
| 186 |
insert: *collection_name |
| 187 |
documents: |
| 188 |
- _id: 1 |
| 189 |
ordered: true |
| 190 |
<<: *transactionCommandArgs |
| 191 |
command_name: insert |
| 192 |
database_name: *database_name |
| 193 |
- command_started_event: |
| 194 |
command: |
| 195 |
abortTransaction: 1 |
| 196 |
lsid: session0 |
| 197 |
txnNumber: |
| 198 |
$numberLong: "1" |
| 199 |
startTransaction: |
| 200 |
autocommit: false |
| 201 |
writeConcern: |
| 202 |
command_name: abortTransaction |
| 203 |
database_name: admin |
| 204 |
|
| 205 |
outcome: |
| 206 |
collection: |
| 207 |
data: *data |
| 208 |
|
| 209 |
- description: start with unacknowledged write concern |
| 210 |
|
| 211 |
operations: |
| 212 |
- name: startTransaction |
| 213 |
object: session0 |
| 214 |
arguments: |
| 215 |
options: |
| 216 |
writeConcern: |
| 217 |
w: 0 |
| 218 |
result: |
| 219 |
|
| 220 |
errorContains: transactions do not support unacknowledged write concern |
| 221 |
|
| 222 |
- description: start with implicit unacknowledged write concern |
| 223 |
|
| 224 |
clientOptions: |
| 225 |
w: 0 |
| 226 |
|
| 227 |
operations: |
| 228 |
- name: startTransaction |
| 229 |
object: session0 |
| 230 |
result: |
| 231 |
|
| 232 |
errorContains: transactions do not support unacknowledged write concern |
| 233 |
|
| 234 |
- description: unacknowledged write concern coll insertOne |
| 235 |
|
| 236 |
operations: |
| 237 |
- *startTransaction |
| 238 |
- name: insertOne |
| 239 |
<<: &collection_w0 |
| 240 |
object: collection |
| 241 |
collectionOptions: |
| 242 |
writeConcern: { w: 0 } |
| 243 |
arguments: |
| 244 |
session: session0 |
| 245 |
document: |
| 246 |
_id: 1 |
| 247 |
result: |
| 248 |
insertedId: 1 |
| 249 |
- *commitTransaction |
| 250 |
|
| 251 |
expectations: |
| 252 |
- *insertOneEvent |
| 253 |
- *commitWithDefaultWCEvent |
| 254 |
|
| 255 |
outcome: |
| 256 |
collection: |
| 257 |
data: |
| 258 |
- _id: 0 |
| 259 |
- _id: 1 |
| 260 |
|
| 261 |
- description: unacknowledged write concern coll insertMany |
| 262 |
|
| 263 |
operations: |
| 264 |
- *startTransaction |
| 265 |
- name: insertMany |
| 266 |
<<: *collection_w0 |
| 267 |
arguments: |
| 268 |
session: session0 |
| 269 |
documents: |
| 270 |
- _id: 1 |
| 271 |
- _id: 2 |
| 272 |
result: |
| 273 |
insertedIds: {0: 1, 1: 2} |
| 274 |
- *commitTransaction |
| 275 |
|
| 276 |
expectations: |
| 277 |
- command_started_event: |
| 278 |
command: |
| 279 |
insert: *collection_name |
| 280 |
documents: |
| 281 |
- _id: 1 |
| 282 |
- _id: 2 |
| 283 |
ordered: true |
| 284 |
<<: *transactionCommandArgs |
| 285 |
command_name: insert |
| 286 |
database_name: *database_name |
| 287 |
- *commitWithDefaultWCEvent |
| 288 |
|
| 289 |
outcome: |
| 290 |
collection: |
| 291 |
data: |
| 292 |
- _id: 0 |
| 293 |
- _id: 1 |
| 294 |
- _id: 2 |
| 295 |
|
| 296 |
- description: unacknowledged write concern coll bulkWrite |
| 297 |
|
| 298 |
operations: |
| 299 |
- *startTransaction |
| 300 |
- name: bulkWrite |
| 301 |
<<: *collection_w0 |
| 302 |
arguments: |
| 303 |
session: session0 |
| 304 |
requests: |
| 305 |
- name: insertOne |
| 306 |
arguments: |
| 307 |
document: {_id: 1} |
| 308 |
result: |
| 309 |
deletedCount: 0 |
| 310 |
insertedCount: 1 |
| 311 |
insertedIds: {0: 1} |
| 312 |
matchedCount: 0 |
| 313 |
modifiedCount: 0 |
| 314 |
upsertedCount: 0 |
| 315 |
upsertedIds: {} |
| 316 |
- *commitTransaction |
| 317 |
|
| 318 |
expectations: |
| 319 |
- *insertOneEvent |
| 320 |
- *commitWithDefaultWCEvent |
| 321 |
|
| 322 |
outcome: |
| 323 |
collection: |
| 324 |
data: |
| 325 |
- _id: 0 |
| 326 |
- _id: 1 |
| 327 |
|
| 328 |
|
| 329 |
- description: unacknowledged write concern coll deleteOne |
| 330 |
|
| 331 |
operations: |
| 332 |
- *startTransaction |
| 333 |
- name: deleteOne |
| 334 |
<<: *collection_w0 |
| 335 |
arguments: |
| 336 |
session: session0 |
| 337 |
filter: |
| 338 |
_id: 0 |
| 339 |
result: |
| 340 |
deletedCount: 1 |
| 341 |
- *commitTransaction |
| 342 |
|
| 343 |
expectations: |
| 344 |
- command_started_event: |
| 345 |
command: |
| 346 |
delete: *collection_name |
| 347 |
deletes: |
| 348 |
- q: {_id: 0} |
| 349 |
limit: 1 |
| 350 |
ordered: true |
| 351 |
<<: *transactionCommandArgs |
| 352 |
command_name: delete |
| 353 |
database_name: *database_name |
| 354 |
- *commitWithDefaultWCEvent |
| 355 |
|
| 356 |
outcome: |
| 357 |
collection: |
| 358 |
data: [] |
| 359 |
|
| 360 |
- description: unacknowledged write concern coll deleteMany |
| 361 |
|
| 362 |
operations: |
| 363 |
- *startTransaction |
| 364 |
- name: deleteMany |
| 365 |
<<: *collection_w0 |
| 366 |
arguments: |
| 367 |
session: session0 |
| 368 |
filter: |
| 369 |
_id: 0 |
| 370 |
result: |
| 371 |
deletedCount: 1 |
| 372 |
- *commitTransaction |
| 373 |
|
| 374 |
expectations: |
| 375 |
- command_started_event: |
| 376 |
command: |
| 377 |
delete: *collection_name |
| 378 |
deletes: |
| 379 |
- q: {_id: 0} |
| 380 |
limit: 0 |
| 381 |
ordered: true |
| 382 |
<<: *transactionCommandArgs |
| 383 |
command_name: delete |
| 384 |
database_name: *database_name |
| 385 |
- *commitWithDefaultWCEvent |
| 386 |
|
| 387 |
outcome: |
| 388 |
collection: |
| 389 |
data: [] |
| 390 |
|
| 391 |
- description: unacknowledged write concern coll updateOne |
| 392 |
|
| 393 |
operations: |
| 394 |
- *startTransaction |
| 395 |
- name: updateOne |
| 396 |
<<: *collection_w0 |
| 397 |
arguments: |
| 398 |
session: session0 |
| 399 |
filter: {_id: 0} |
| 400 |
update: |
| 401 |
$inc: {x: 1} |
| 402 |
upsert: true |
| 403 |
result: |
| 404 |
matchedCount: 1 |
| 405 |
modifiedCount: 1 |
| 406 |
upsertedCount: 0 |
| 407 |
- *commitTransaction |
| 408 |
|
| 409 |
expectations: |
| 410 |
- command_started_event: |
| 411 |
command: |
| 412 |
update: *collection_name |
| 413 |
updates: |
| 414 |
- q: {_id: 0} |
| 415 |
u: {$inc: {x: 1}} |
| 416 |
upsert: true |
| 417 |
ordered: true |
| 418 |
<<: *transactionCommandArgs |
| 419 |
command_name: update |
| 420 |
database_name: *database_name |
| 421 |
- *commitWithDefaultWCEvent |
| 422 |
|
| 423 |
outcome: |
| 424 |
collection: |
| 425 |
data: |
| 426 |
- {_id: 0, x: 1} |
| 427 |
|
| 428 |
- description: unacknowledged write concern coll updateMany |
| 429 |
|
| 430 |
operations: |
| 431 |
- *startTransaction |
| 432 |
- name: updateMany |
| 433 |
<<: *collection_w0 |
| 434 |
arguments: |
| 435 |
session: session0 |
| 436 |
filter: {_id: 0} |
| 437 |
update: |
| 438 |
$inc: {x: 1} |
| 439 |
upsert: true |
| 440 |
result: |
| 441 |
matchedCount: 1 |
| 442 |
modifiedCount: 1 |
| 443 |
upsertedCount: 0 |
| 444 |
- *commitTransaction |
| 445 |
|
| 446 |
expectations: |
| 447 |
- command_started_event: |
| 448 |
command: |
| 449 |
update: *collection_name |
| 450 |
updates: |
| 451 |
- q: {_id: 0} |
| 452 |
u: {$inc: {x: 1}} |
| 453 |
multi: true |
| 454 |
upsert: true |
| 455 |
ordered: true |
| 456 |
<<: *transactionCommandArgs |
| 457 |
command_name: update |
| 458 |
database_name: *database_name |
| 459 |
- *commitWithDefaultWCEvent |
| 460 |
|
| 461 |
outcome: |
| 462 |
collection: |
| 463 |
data: |
| 464 |
- {_id: 0, x: 1} |
| 465 |
|
| 466 |
- description: unacknowledged write concern coll findOneAndDelete |
| 467 |
|
| 468 |
operations: |
| 469 |
- *startTransaction |
| 470 |
- name: findOneAndDelete |
| 471 |
<<: *collection_w0 |
| 472 |
arguments: |
| 473 |
session: session0 |
| 474 |
filter: {_id: 0} |
| 475 |
result: {_id: 0} |
| 476 |
- *commitTransaction |
| 477 |
|
| 478 |
expectations: |
| 479 |
- command_started_event: |
| 480 |
command: |
| 481 |
findAndModify: *collection_name |
| 482 |
query: {_id: 0} |
| 483 |
remove: True |
| 484 |
<<: *transactionCommandArgs |
| 485 |
command_name: findAndModify |
| 486 |
database_name: *database_name |
| 487 |
- *commitWithDefaultWCEvent |
| 488 |
|
| 489 |
outcome: |
| 490 |
collection: |
| 491 |
data: [] |
| 492 |
|
| 493 |
- description: unacknowledged write concern coll findOneAndReplace |
| 494 |
|
| 495 |
operations: |
| 496 |
- *startTransaction |
| 497 |
- name: findOneAndReplace |
| 498 |
<<: *collection_w0 |
| 499 |
arguments: |
| 500 |
session: session0 |
| 501 |
filter: {_id: 0} |
| 502 |
replacement: {x: 1} |
| 503 |
returnDocument: Before |
| 504 |
result: {_id: 0} |
| 505 |
- *commitTransaction |
| 506 |
|
| 507 |
expectations: |
| 508 |
- command_started_event: |
| 509 |
command: |
| 510 |
findAndModify: *collection_name |
| 511 |
query: {_id: 0} |
| 512 |
update: {x: 1} |
| 513 |
new: false |
| 514 |
<<: *transactionCommandArgs |
| 515 |
command_name: findAndModify |
| 516 |
database_name: *database_name |
| 517 |
- *commitWithDefaultWCEvent |
| 518 |
|
| 519 |
outcome: |
| 520 |
collection: |
| 521 |
data: |
| 522 |
- {_id: 0, x: 1} |
| 523 |
|
| 524 |
- description: unacknowledged write concern coll findOneAndUpdate |
| 525 |
|
| 526 |
operations: |
| 527 |
- *startTransaction |
| 528 |
- name: findOneAndUpdate |
| 529 |
<<: *collection_w0 |
| 530 |
arguments: |
| 531 |
session: session0 |
| 532 |
filter: {_id: 0} |
| 533 |
update: |
| 534 |
$inc: {x: 1} |
| 535 |
returnDocument: Before |
| 536 |
result: {_id: 0} |
| 537 |
- *commitTransaction |
| 538 |
|
| 539 |
expectations: |
| 540 |
- command_started_event: |
| 541 |
command: |
| 542 |
findAndModify: *collection_name |
| 543 |
query: {_id: 0} |
| 544 |
update: {$inc: {x: 1}} |
| 545 |
new: false |
| 546 |
<<: *transactionCommandArgs |
| 547 |
command_name: findAndModify |
| 548 |
database_name: *database_name |
| 549 |
- *commitWithDefaultWCEvent |
| 550 |
|
| 551 |
outcome: |
| 552 |
collection: |
| 553 |
data: |
| 554 |
- {_id: 0, x: 1} |