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