1{ 2 "runOn": [ 3 { 4 "minServerVersion": "4.0", 5 "topology": [ 6 "replicaset" 7 ] 8 }, 9 { 10 "minServerVersion": "4.1.8", 11 "topology": [ 12 "sharded" 13 ] 14 } 15 ], 16 "database_name": "transaction-tests", 17 "collection_name": "test", 18 "data": [], 19 "tests": [ 20 { 21 "description": "default readPreference", 22 "operations": [ 23 { 24 "name": "startTransaction", 25 "object": "session0" 26 }, 27 { 28 "name": "insertMany", 29 "object": "collection", 30 "arguments": { 31 "documents": [ 32 { 33 "_id": 1 34 }, 35 { 36 "_id": 2 37 }, 38 { 39 "_id": 3 40 }, 41 { 42 "_id": 4 43 } 44 ], 45 "session": "session0" 46 }, 47 "result": { 48 "insertedIds": { 49 "0": 1, 50 "1": 2, 51 "2": 3, 52 "3": 4 53 } 54 } 55 }, 56 { 57 "name": "aggregate", 58 "object": "collection", 59 "collectionOptions": { 60 "readPreference": { 61 "mode": "Secondary" 62 } 63 }, 64 "arguments": { 65 "session": "session0", 66 "pipeline": [ 67 { 68 "$match": { 69 "_id": 1 70 } 71 }, 72 { 73 "$count": "count" 74 } 75 ] 76 }, 77 "result": [ 78 { 79 "count": 1 80 } 81 ] 82 }, 83 { 84 "name": "find", 85 "object": "collection", 86 "collectionOptions": { 87 "readPreference": { 88 "mode": "Secondary" 89 } 90 }, 91 "arguments": { 92 "session": "session0", 93 "batchSize": 3 94 }, 95 "result": [ 96 { 97 "_id": 1 98 }, 99 { 100 "_id": 2 101 }, 102 { 103 "_id": 3 104 }, 105 { 106 "_id": 4 107 } 108 ] 109 }, 110 { 111 "name": "aggregate", 112 "object": "collection", 113 "collectionOptions": { 114 "readPreference": { 115 "mode": "Secondary" 116 } 117 }, 118 "arguments": { 119 "pipeline": [ 120 { 121 "$project": { 122 "_id": 1 123 } 124 } 125 ], 126 "batchSize": 3, 127 "session": "session0" 128 }, 129 "result": [ 130 { 131 "_id": 1 132 }, 133 { 134 "_id": 2 135 }, 136 { 137 "_id": 3 138 }, 139 { 140 "_id": 4 141 } 142 ] 143 }, 144 { 145 "name": "commitTransaction", 146 "object": "session0" 147 } 148 ], 149 "outcome": { 150 "collection": { 151 "data": [ 152 { 153 "_id": 1 154 }, 155 { 156 "_id": 2 157 }, 158 { 159 "_id": 3 160 }, 161 { 162 "_id": 4 163 } 164 ] 165 } 166 } 167 }, 168 { 169 "description": "primary readPreference", 170 "operations": [ 171 { 172 "name": "startTransaction", 173 "object": "session0", 174 "arguments": { 175 "options": { 176 "readPreference": { 177 "mode": "Primary" 178 } 179 } 180 } 181 }, 182 { 183 "name": "insertMany", 184 "object": "collection", 185 "arguments": { 186 "documents": [ 187 { 188 "_id": 1 189 }, 190 { 191 "_id": 2 192 }, 193 { 194 "_id": 3 195 }, 196 { 197 "_id": 4 198 } 199 ], 200 "session": "session0" 201 }, 202 "result": { 203 "insertedIds": { 204 "0": 1, 205 "1": 2, 206 "2": 3, 207 "3": 4 208 } 209 } 210 }, 211 { 212 "name": "aggregate", 213 "object": "collection", 214 "collectionOptions": { 215 "readPreference": { 216 "mode": "Secondary" 217 } 218 }, 219 "arguments": { 220 "session": "session0", 221 "pipeline": [ 222 { 223 "$match": { 224 "_id": 1 225 } 226 }, 227 { 228 "$count": "count" 229 } 230 ] 231 }, 232 "result": [ 233 { 234 "count": 1 235 } 236 ] 237 }, 238 { 239 "name": "find", 240 "object": "collection", 241 "collectionOptions": { 242 "readPreference": { 243 "mode": "Secondary" 244 } 245 }, 246 "arguments": { 247 "session": "session0", 248 "batchSize": 3 249 }, 250 "result": [ 251 { 252 "_id": 1 253 }, 254 { 255 "_id": 2 256 }, 257 { 258 "_id": 3 259 }, 260 { 261 "_id": 4 262 } 263 ] 264 }, 265 { 266 "name": "aggregate", 267 "object": "collection", 268 "collectionOptions": { 269 "readPreference": { 270 "mode": "Secondary" 271 } 272 }, 273 "arguments": { 274 "pipeline": [ 275 { 276 "$project": { 277 "_id": 1 278 } 279 } 280 ], 281 "batchSize": 3, 282 "session": "session0" 283 }, 284 "result": [ 285 { 286 "_id": 1 287 }, 288 { 289 "_id": 2 290 }, 291 { 292 "_id": 3 293 }, 294 { 295 "_id": 4 296 } 297 ] 298 }, 299 { 300 "name": "commitTransaction", 301 "object": "session0" 302 } 303 ], 304 "outcome": { 305 "collection": { 306 "data": [ 307 { 308 "_id": 1 309 }, 310 { 311 "_id": 2 312 }, 313 { 314 "_id": 3 315 }, 316 { 317 "_id": 4 318 } 319 ] 320 } 321 } 322 }, 323 { 324 "description": "secondary readPreference", 325 "operations": [ 326 { 327 "name": "startTransaction", 328 "object": "session0", 329 "arguments": { 330 "options": { 331 "readPreference": { 332 "mode": "Secondary" 333 } 334 } 335 } 336 }, 337 { 338 "name": "insertMany", 339 "object": "collection", 340 "arguments": { 341 "documents": [ 342 { 343 "_id": 1 344 }, 345 { 346 "_id": 2 347 }, 348 { 349 "_id": 3 350 }, 351 { 352 "_id": 4 353 } 354 ], 355 "session": "session0" 356 }, 357 "result": { 358 "insertedIds": { 359 "0": 1, 360 "1": 2, 361 "2": 3, 362 "3": 4 363 } 364 } 365 }, 366 { 367 "name": "aggregate", 368 "object": "collection", 369 "collectionOptions": { 370 "readPreference": { 371 "mode": "Primary" 372 } 373 }, 374 "arguments": { 375 "session": "session0", 376 "pipeline": [ 377 { 378 "$match": { 379 "_id": 1 380 } 381 }, 382 { 383 "$count": "count" 384 } 385 ] 386 }, 387 "result": { 388 "errorContains": "read preference in a transaction must be primary" 389 } 390 }, 391 { 392 "name": "find", 393 "object": "collection", 394 "collectionOptions": { 395 "readPreference": { 396 "mode": "Primary" 397 } 398 }, 399 "arguments": { 400 "session": "session0", 401 "batchSize": 3 402 }, 403 "result": { 404 "errorContains": "read preference in a transaction must be primary" 405 } 406 }, 407 { 408 "name": "aggregate", 409 "object": "collection", 410 "collectionOptions": { 411 "readPreference": { 412 "mode": "Primary" 413 } 414 }, 415 "arguments": { 416 "pipeline": [ 417 { 418 "$project": { 419 "_id": 1 420 } 421 } 422 ], 423 "batchSize": 3, 424 "session": "session0" 425 }, 426 "result": { 427 "errorContains": "read preference in a transaction must be primary" 428 } 429 }, 430 { 431 "name": "abortTransaction", 432 "object": "session0" 433 } 434 ], 435 "outcome": { 436 "collection": { 437 "data": [] 438 } 439 } 440 }, 441 { 442 "description": "primaryPreferred readPreference", 443 "operations": [ 444 { 445 "name": "startTransaction", 446 "object": "session0", 447 "arguments": { 448 "options": { 449 "readPreference": { 450 "mode": "PrimaryPreferred" 451 } 452 } 453 } 454 }, 455 { 456 "name": "insertMany", 457 "object": "collection", 458 "arguments": { 459 "documents": [ 460 { 461 "_id": 1 462 }, 463 { 464 "_id": 2 465 }, 466 { 467 "_id": 3 468 }, 469 { 470 "_id": 4 471 } 472 ], 473 "session": "session0" 474 }, 475 "result": { 476 "insertedIds": { 477 "0": 1, 478 "1": 2, 479 "2": 3, 480 "3": 4 481 } 482 } 483 }, 484 { 485 "name": "aggregate", 486 "object": "collection", 487 "collectionOptions": { 488 "readPreference": { 489 "mode": "Primary" 490 } 491 }, 492 "arguments": { 493 "session": "session0", 494 "pipeline": [ 495 { 496 "$match": { 497 "_id": 1 498 } 499 }, 500 { 501 "$count": "count" 502 } 503 ] 504 }, 505 "result": { 506 "errorContains": "read preference in a transaction must be primary" 507 } 508 }, 509 { 510 "name": "find", 511 "object": "collection", 512 "collectionOptions": { 513 "readPreference": { 514 "mode": "Primary" 515 } 516 }, 517 "arguments": { 518 "session": "session0", 519 "batchSize": 3 520 }, 521 "result": { 522 "errorContains": "read preference in a transaction must be primary" 523 } 524 }, 525 { 526 "name": "aggregate", 527 "object": "collection", 528 "collectionOptions": { 529 "readPreference": { 530 "mode": "Primary" 531 } 532 }, 533 "arguments": { 534 "pipeline": [ 535 { 536 "$project": { 537 "_id": 1 538 } 539 } 540 ], 541 "batchSize": 3, 542 "session": "session0" 543 }, 544 "result": { 545 "errorContains": "read preference in a transaction must be primary" 546 } 547 }, 548 { 549 "name": "abortTransaction", 550 "object": "session0" 551 } 552 ], 553 "outcome": { 554 "collection": { 555 "data": [] 556 } 557 } 558 }, 559 { 560 "description": "nearest readPreference", 561 "operations": [ 562 { 563 "name": "startTransaction", 564 "object": "session0", 565 "arguments": { 566 "options": { 567 "readPreference": { 568 "mode": "Nearest" 569 } 570 } 571 } 572 }, 573 { 574 "name": "insertMany", 575 "object": "collection", 576 "arguments": { 577 "documents": [ 578 { 579 "_id": 1 580 }, 581 { 582 "_id": 2 583 }, 584 { 585 "_id": 3 586 }, 587 { 588 "_id": 4 589 } 590 ], 591 "session": "session0" 592 }, 593 "result": { 594 "insertedIds": { 595 "0": 1, 596 "1": 2, 597 "2": 3, 598 "3": 4 599 } 600 } 601 }, 602 { 603 "name": "aggregate", 604 "object": "collection", 605 "collectionOptions": { 606 "readPreference": { 607 "mode": "Primary" 608 } 609 }, 610 "arguments": { 611 "session": "session0", 612 "pipeline": [ 613 { 614 "$match": { 615 "_id": 1 616 } 617 }, 618 { 619 "$count": "count" 620 } 621 ] 622 }, 623 "result": { 624 "errorContains": "read preference in a transaction must be primary" 625 } 626 }, 627 { 628 "name": "find", 629 "object": "collection", 630 "collectionOptions": { 631 "readPreference": { 632 "mode": "Primary" 633 } 634 }, 635 "arguments": { 636 "session": "session0", 637 "batchSize": 3 638 }, 639 "result": { 640 "errorContains": "read preference in a transaction must be primary" 641 } 642 }, 643 { 644 "name": "aggregate", 645 "object": "collection", 646 "collectionOptions": { 647 "readPreference": { 648 "mode": "Primary" 649 } 650 }, 651 "arguments": { 652 "pipeline": [ 653 { 654 "$project": { 655 "_id": 1 656 } 657 } 658 ], 659 "batchSize": 3, 660 "session": "session0" 661 }, 662 "result": { 663 "errorContains": "read preference in a transaction must be primary" 664 } 665 }, 666 { 667 "name": "abortTransaction", 668 "object": "session0" 669 } 670 ], 671 "outcome": { 672 "collection": { 673 "data": [] 674 } 675 } 676 }, 677 { 678 "description": "secondary write only", 679 "operations": [ 680 { 681 "name": "startTransaction", 682 "object": "session0", 683 "arguments": { 684 "options": { 685 "readPreference": { 686 "mode": "Secondary" 687 } 688 } 689 } 690 }, 691 { 692 "name": "insertOne", 693 "object": "collection", 694 "arguments": { 695 "session": "session0", 696 "document": { 697 "_id": 1 698 } 699 }, 700 "result": { 701 "insertedId": 1 702 } 703 }, 704 { 705 "name": "commitTransaction", 706 "object": "session0" 707 } 708 ], 709 "outcome": { 710 "collection": { 711 "data": [ 712 { 713 "_id": 1 714 } 715 ] 716 } 717 } 718 } 719 ] 720} 721