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