1{
2 "description": "driver-sessions-dirty-session-errors",
3 "schemaVersion": "1.0",
4 "runOnRequirements": [
5 {
6 "minServerVersion": "4.0",
7 "topologies": [
8 "replicaset"
9 ]
10 },
11 {
12 "minServerVersion": "4.1.8",
13 "topologies": [
14 "sharded-replicaset"
15 ]
16 }
17 ],
18 "createEntities": [
19 {
20 "client": {
21 "id": "client0",
22 "useMultipleMongoses": false,
23 "observeEvents": [
24 "commandStartedEvent"
25 ]
26 }
27 },
28 {
29 "database": {
30 "id": "database0",
31 "client": "client0",
32 "databaseName": "session-tests"
33 }
34 },
35 {
36 "collection": {
37 "id": "collection0",
38 "database": "database0",
39 "collectionName": "test"
40 }
41 },
42 {
43 "session": {
44 "id": "session0",
45 "client": "client0"
46 }
47 }
48 ],
49 "initialData": [
50 {
51 "collectionName": "test",
52 "databaseName": "session-tests",
53 "documents": [
54 {
55 "_id": 1
56 }
57 ]
58 }
59 ],
60 "tests": [
61 {
62 "description": "Dirty explicit session is discarded (insert)",
63 "operations": [
64 {
65 "name": "failPoint",
66 "object": "testRunner",
67 "arguments": {
68 "client": "client0",
69 "failPoint": {
70 "configureFailPoint": "failCommand",
71 "mode": {
72 "times": 1
73 },
74 "data": {
75 "failCommands": [
76 "insert"
77 ],
78 "closeConnection": true
79 }
80 }
81 }
82 },
83 {
84 "name": "assertSessionNotDirty",
85 "object": "testRunner",
86 "arguments": {
87 "session": "session0"
88 }
89 },
90 {
91 "name": "insertOne",
92 "object": "collection0",
93 "arguments": {
94 "session": "session0",
95 "document": {
96 "_id": 2
97 }
98 },
99 "expectResult": {
100 "$$unsetOrMatches": {
101 "insertedId": {
102 "$$unsetOrMatches": 2
103 }
104 }
105 }
106 },
107 {
108 "name": "assertSessionDirty",
109 "object": "testRunner",
110 "arguments": {
111 "session": "session0"
112 }
113 },
114 {
115 "name": "insertOne",
116 "object": "collection0",
117 "arguments": {
118 "session": "session0",
119 "document": {
120 "_id": 3
121 }
122 },
123 "expectResult": {
124 "$$unsetOrMatches": {
125 "insertedId": {
126 "$$unsetOrMatches": 3
127 }
128 }
129 }
130 },
131 {
132 "name": "assertSessionDirty",
133 "object": "testRunner",
134 "arguments": {
135 "session": "session0"
136 }
137 },
138 {
139 "name": "endSession",
140 "object": "session0"
141 },
142 {
143 "name": "find",
144 "object": "collection0",
145 "arguments": {
146 "filter": {
147 "_id": -1
148 }
149 },
150 "expectResult": []
151 },
152 {
153 "name": "assertDifferentLsidOnLastTwoCommands",
154 "object": "testRunner",
155 "arguments": {
156 "client": "client0"
157 }
158 }
159 ],
160 "expectEvents": [
161 {
162 "client": "client0",
163 "events": [
164 {
165 "commandStartedEvent": {
166 "command": {
167 "insert": "test",
168 "documents": [
169 {
170 "_id": 2
171 }
172 ],
173 "ordered": true,
174 "lsid": {
175 "$$sessionLsid": "session0"
176 },
177 "txnNumber": 1
178 },
179 "commandName": "insert",
180 "databaseName": "session-tests"
181 }
182 },
183 {
184 "commandStartedEvent": {
185 "command": {
186 "insert": "test",
187 "documents": [
188 {
189 "_id": 2
190 }
191 ],
192 "ordered": true,
193 "lsid": {
194 "$$sessionLsid": "session0"
195 },
196 "txnNumber": 1
197 },
198 "commandName": "insert",
199 "databaseName": "session-tests"
200 }
201 },
202 {
203 "commandStartedEvent": {
204 "command": {
205 "insert": "test",
206 "documents": [
207 {
208 "_id": 3
209 }
210 ],
211 "ordered": true,
212 "lsid": {
213 "$$sessionLsid": "session0"
214 },
215 "txnNumber": 2
216 },
217 "commandName": "insert",
218 "databaseName": "session-tests"
219 }
220 },
221 {
222 "commandStartedEvent": {
223 "command": {
224 "find": "test",
225 "filter": {
226 "_id": -1
227 },
228 "lsid": {
229 "$$type": "object"
230 }
231 },
232 "commandName": "find",
233 "databaseName": "session-tests"
234 }
235 }
236 ]
237 }
238 ],
239 "outcome": [
240 {
241 "collectionName": "test",
242 "databaseName": "session-tests",
243 "documents": [
244 {
245 "_id": 1
246 },
247 {
248 "_id": 2
249 },
250 {
251 "_id": 3
252 }
253 ]
254 }
255 ]
256 },
257 {
258 "description": "Dirty explicit session is discarded (findAndModify)",
259 "operations": [
260 {
261 "name": "failPoint",
262 "object": "testRunner",
263 "arguments": {
264 "client": "client0",
265 "failPoint": {
266 "configureFailPoint": "failCommand",
267 "mode": {
268 "times": 1
269 },
270 "data": {
271 "failCommands": [
272 "findAndModify"
273 ],
274 "closeConnection": true
275 }
276 }
277 }
278 },
279 {
280 "name": "assertSessionNotDirty",
281 "object": "testRunner",
282 "arguments": {
283 "session": "session0"
284 }
285 },
286 {
287 "name": "findOneAndUpdate",
288 "object": "collection0",
289 "arguments": {
290 "session": "session0",
291 "filter": {
292 "_id": 1
293 },
294 "update": {
295 "$inc": {
296 "x": 1
297 }
298 },
299 "returnDocument": "Before"
300 },
301 "expectResult": {
302 "_id": 1
303 }
304 },
305 {
306 "name": "assertSessionDirty",
307 "object": "testRunner",
308 "arguments": {
309 "session": "session0"
310 }
311 },
312 {
313 "name": "endSession",
314 "object": "session0"
315 },
316 {
317 "name": "find",
318 "object": "collection0",
319 "arguments": {
320 "filter": {
321 "_id": -1
322 }
323 },
324 "expectResult": []
325 },
326 {
327 "name": "assertDifferentLsidOnLastTwoCommands",
328 "object": "testRunner",
329 "arguments": {
330 "client": "client0"
331 }
332 }
333 ],
334 "expectEvents": [
335 {
336 "client": "client0",
337 "events": [
338 {
339 "commandStartedEvent": {
340 "command": {
341 "findAndModify": "test",
342 "query": {
343 "_id": 1
344 },
345 "update": {
346 "$inc": {
347 "x": 1
348 }
349 },
350 "new": false,
351 "lsid": {
352 "$$sessionLsid": "session0"
353 },
354 "txnNumber": 1,
355 "readConcern": {
356 "$$exists": false
357 },
358 "writeConcern": {
359 "$$exists": false
360 }
361 },
362 "commandName": "findAndModify",
363 "databaseName": "session-tests"
364 }
365 },
366 {
367 "commandStartedEvent": {
368 "command": {
369 "findAndModify": "test",
370 "query": {
371 "_id": 1
372 },
373 "update": {
374 "$inc": {
375 "x": 1
376 }
377 },
378 "new": false,
379 "lsid": {
380 "$$sessionLsid": "session0"
381 },
382 "txnNumber": 1,
383 "readConcern": {
384 "$$exists": false
385 },
386 "writeConcern": {
387 "$$exists": false
388 }
389 },
390 "commandName": "findAndModify",
391 "databaseName": "session-tests"
392 }
393 },
394 {
395 "commandStartedEvent": {
396 "command": {
397 "find": "test",
398 "filter": {
399 "_id": -1
400 },
401 "lsid": {
402 "$$type": "object"
403 }
404 },
405 "commandName": "find",
406 "databaseName": "session-tests"
407 }
408 }
409 ]
410 }
411 ],
412 "outcome": [
413 {
414 "collectionName": "test",
415 "databaseName": "session-tests",
416 "documents": [
417 {
418 "_id": 1,
419 "x": 1
420 }
421 ]
422 }
423 ]
424 },
425 {
426 "description": "Dirty implicit session is discarded (insert)",
427 "operations": [
428 {
429 "name": "failPoint",
430 "object": "testRunner",
431 "arguments": {
432 "client": "client0",
433 "failPoint": {
434 "configureFailPoint": "failCommand",
435 "mode": {
436 "times": 1
437 },
438 "data": {
439 "failCommands": [
440 "insert"
441 ],
442 "closeConnection": true
443 }
444 }
445 }
446 },
447 {
448 "name": "insertOne",
449 "object": "collection0",
450 "arguments": {
451 "document": {
452 "_id": 2
453 }
454 },
455 "expectResult": {
456 "$$unsetOrMatches": {
457 "insertedId": {
458 "$$unsetOrMatches": 2
459 }
460 }
461 }
462 },
463 {
464 "name": "find",
465 "object": "collection0",
466 "arguments": {
467 "filter": {
468 "_id": -1
469 }
470 },
471 "expectResult": []
472 },
473 {
474 "name": "assertDifferentLsidOnLastTwoCommands",
475 "object": "testRunner",
476 "arguments": {
477 "client": "client0"
478 }
479 }
480 ],
481 "expectEvents": [
482 {
483 "client": "client0",
484 "events": [
485 {
486 "commandStartedEvent": {
487 "command": {
488 "insert": "test",
489 "documents": [
490 {
491 "_id": 2
492 }
493 ],
494 "ordered": true,
495 "lsid": {
496 "$$type": "object"
497 },
498 "txnNumber": 1
499 },
500 "commandName": "insert",
501 "databaseName": "session-tests"
502 }
503 },
504 {
505 "commandStartedEvent": {
506 "command": {
507 "insert": "test",
508 "documents": [
509 {
510 "_id": 2
511 }
512 ],
513 "ordered": true,
514 "lsid": {
515 "$$type": "object"
516 },
517 "txnNumber": 1
518 },
519 "commandName": "insert",
520 "databaseName": "session-tests"
521 }
522 },
523 {
524 "commandStartedEvent": {
525 "command": {
526 "find": "test",
527 "filter": {
528 "_id": -1
529 },
530 "lsid": {
531 "$$type": "object"
532 }
533 },
534 "commandName": "find",
535 "databaseName": "session-tests"
536 }
537 }
538 ]
539 }
540 ],
541 "outcome": [
542 {
543 "collectionName": "test",
544 "databaseName": "session-tests",
545 "documents": [
546 {
547 "_id": 1
548 },
549 {
550 "_id": 2
551 }
552 ]
553 }
554 ]
555 },
556 {
557 "description": "Dirty implicit session is discarded (findAndModify)",
558 "operations": [
559 {
560 "name": "failPoint",
561 "object": "testRunner",
562 "arguments": {
563 "client": "client0",
564 "failPoint": {
565 "configureFailPoint": "failCommand",
566 "mode": {
567 "times": 1
568 },
569 "data": {
570 "failCommands": [
571 "findAndModify"
572 ],
573 "closeConnection": true
574 }
575 }
576 }
577 },
578 {
579 "name": "findOneAndUpdate",
580 "object": "collection0",
581 "arguments": {
582 "filter": {
583 "_id": 1
584 },
585 "update": {
586 "$inc": {
587 "x": 1
588 }
589 },
590 "returnDocument": "Before"
591 },
592 "expectResult": {
593 "_id": 1
594 }
595 },
596 {
597 "name": "find",
598 "object": "collection0",
599 "arguments": {
600 "filter": {
601 "_id": -1
602 }
603 },
604 "expectResult": []
605 },
606 {
607 "name": "assertDifferentLsidOnLastTwoCommands",
608 "object": "testRunner",
609 "arguments": {
610 "client": "client0"
611 }
612 }
613 ],
614 "expectEvents": [
615 {
616 "client": "client0",
617 "events": [
618 {
619 "commandStartedEvent": {
620 "command": {
621 "findAndModify": "test",
622 "query": {
623 "_id": 1
624 },
625 "update": {
626 "$inc": {
627 "x": 1
628 }
629 },
630 "new": false,
631 "lsid": {
632 "$$type": "object"
633 },
634 "txnNumber": 1,
635 "readConcern": {
636 "$$exists": false
637 },
638 "writeConcern": {
639 "$$exists": false
640 }
641 },
642 "commandName": "findAndModify",
643 "databaseName": "session-tests"
644 }
645 },
646 {
647 "commandStartedEvent": {
648 "command": {
649 "findAndModify": "test",
650 "query": {
651 "_id": 1
652 },
653 "update": {
654 "$inc": {
655 "x": 1
656 }
657 },
658 "new": false,
659 "lsid": {
660 "$$type": "object"
661 },
662 "txnNumber": 1,
663 "readConcern": {
664 "$$exists": false
665 },
666 "writeConcern": {
667 "$$exists": false
668 }
669 },
670 "commandName": "findAndModify",
671 "databaseName": "session-tests"
672 }
673 },
674 {
675 "commandStartedEvent": {
676 "command": {
677 "find": "test",
678 "filter": {
679 "_id": -1
680 },
681 "lsid": {
682 "$$type": "object"
683 }
684 },
685 "commandName": "find",
686 "databaseName": "session-tests"
687 }
688 }
689 ]
690 }
691 ],
692 "outcome": [
693 {
694 "collectionName": "test",
695 "databaseName": "session-tests",
696 "documents": [
697 {
698 "_id": 1,
699 "x": 1
700 }
701 ]
702 }
703 ]
704 },
705 {
706 "description": "Dirty implicit session is discarded (read returning cursor)",
707 "operations": [
708 {
709 "name": "failPoint",
710 "object": "testRunner",
711 "arguments": {
712 "client": "client0",
713 "failPoint": {
714 "configureFailPoint": "failCommand",
715 "mode": {
716 "times": 1
717 },
718 "data": {
719 "failCommands": [
720 "aggregate"
721 ],
722 "closeConnection": true
723 }
724 }
725 }
726 },
727 {
728 "name": "aggregate",
729 "object": "collection0",
730 "arguments": {
731 "pipeline": [
732 {
733 "$project": {
734 "_id": 1
735 }
736 }
737 ]
738 },
739 "expectResult": [
740 {
741 "_id": 1
742 }
743 ]
744 },
745 {
746 "name": "find",
747 "object": "collection0",
748 "arguments": {
749 "filter": {
750 "_id": -1
751 }
752 },
753 "expectResult": []
754 },
755 {
756 "name": "assertDifferentLsidOnLastTwoCommands",
757 "object": "testRunner",
758 "arguments": {
759 "client": "client0"
760 }
761 }
762 ],
763 "expectEvents": [
764 {
765 "client": "client0",
766 "events": [
767 {
768 "commandStartedEvent": {
769 "command": {
770 "aggregate": "test",
771 "pipeline": [
772 {
773 "$project": {
774 "_id": 1
775 }
776 }
777 ],
778 "lsid": {
779 "$$type": "object"
780 }
781 },
782 "commandName": "aggregate",
783 "databaseName": "session-tests"
784 }
785 },
786 {
787 "commandStartedEvent": {
788 "command": {
789 "aggregate": "test",
790 "pipeline": [
791 {
792 "$project": {
793 "_id": 1
794 }
795 }
796 ],
797 "lsid": {
798 "$$type": "object"
799 }
800 },
801 "commandName": "aggregate",
802 "databaseName": "session-tests"
803 }
804 },
805 {
806 "commandStartedEvent": {
807 "command": {
808 "find": "test",
809 "filter": {
810 "_id": -1
811 },
812 "lsid": {
813 "$$type": "object"
814 }
815 },
816 "commandName": "find",
817 "databaseName": "session-tests"
818 }
819 }
820 ]
821 }
822 ],
823 "outcome": [
824 {
825 "collectionName": "test",
826 "databaseName": "session-tests",
827 "documents": [
828 {
829 "_id": 1
830 }
831 ]
832 }
833 ]
834 },
835 {
836 "description": "Dirty implicit session is discarded (read not returning cursor)",
837 "operations": [
838 {
839 "name": "failPoint",
840 "object": "testRunner",
841 "arguments": {
842 "client": "client0",
843 "failPoint": {
844 "configureFailPoint": "failCommand",
845 "mode": {
846 "times": 1
847 },
848 "data": {
849 "failCommands": [
850 "aggregate"
851 ],
852 "closeConnection": true
853 }
854 }
855 }
856 },
857 {
858 "name": "countDocuments",
859 "object": "collection0",
860 "arguments": {
861 "filter": {}
862 },
863 "expectResult": 1
864 },
865 {
866 "name": "find",
867 "object": "collection0",
868 "arguments": {
869 "filter": {
870 "_id": -1
871 }
872 },
873 "expectResult": []
874 },
875 {
876 "name": "assertDifferentLsidOnLastTwoCommands",
877 "object": "testRunner",
878 "arguments": {
879 "client": "client0"
880 }
881 }
882 ],
883 "expectEvents": [
884 {
885 "client": "client0",
886 "events": [
887 {
888 "commandStartedEvent": {
889 "command": {
890 "aggregate": "test",
891 "pipeline": [
892 {
893 "$match": {}
894 },
895 {
896 "$group": {
897 "_id": 1,
898 "n": {
899 "$sum": 1
900 }
901 }
902 }
903 ],
904 "lsid": {
905 "$$type": "object"
906 }
907 },
908 "commandName": "aggregate",
909 "databaseName": "session-tests"
910 }
911 },
912 {
913 "commandStartedEvent": {
914 "command": {
915 "aggregate": "test",
916 "pipeline": [
917 {
918 "$match": {}
919 },
920 {
921 "$group": {
922 "_id": 1,
923 "n": {
924 "$sum": 1
925 }
926 }
927 }
928 ],
929 "lsid": {
930 "$$type": "object"
931 }
932 },
933 "commandName": "aggregate",
934 "databaseName": "session-tests"
935 }
936 },
937 {
938 "commandStartedEvent": {
939 "command": {
940 "find": "test",
941 "filter": {
942 "_id": -1
943 },
944 "lsid": {
945 "$$type": "object"
946 }
947 },
948 "commandName": "find",
949 "databaseName": "session-tests"
950 }
951 }
952 ]
953 }
954 ],
955 "outcome": [
956 {
957 "collectionName": "test",
958 "databaseName": "session-tests",
959 "documents": [
960 {
961 "_id": 1
962 }
963 ]
964 }
965 ]
966 }
967 ]
968}
View as plain text