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