1{
2 "description": "find",
3 "schemaVersion": "1.15",
4 "createEntities": [
5 {
6 "client": {
7 "id": "client",
8 "observeEvents": [
9 "commandStartedEvent",
10 "commandSucceededEvent",
11 "commandFailedEvent"
12 ]
13 }
14 },
15 {
16 "database": {
17 "id": "database",
18 "client": "client",
19 "databaseName": "command-monitoring-tests"
20 }
21 },
22 {
23 "collection": {
24 "id": "collection",
25 "database": "database",
26 "collectionName": "test"
27 }
28 }
29 ],
30 "_yamlAnchors": {
31 "namespace": "command-monitoring-tests.test"
32 },
33 "initialData": [
34 {
35 "collectionName": "test",
36 "databaseName": "command-monitoring-tests",
37 "documents": [
38 {
39 "_id": 1,
40 "x": 11
41 },
42 {
43 "_id": 2,
44 "x": 22
45 },
46 {
47 "_id": 3,
48 "x": 33
49 },
50 {
51 "_id": 4,
52 "x": 44
53 },
54 {
55 "_id": 5,
56 "x": 55
57 }
58 ]
59 }
60 ],
61 "tests": [
62 {
63 "description": "A successful find with no options",
64 "operations": [
65 {
66 "name": "find",
67 "object": "collection",
68 "arguments": {
69 "filter": {
70 "_id": 1
71 }
72 }
73 }
74 ],
75 "expectEvents": [
76 {
77 "client": "client",
78 "events": [
79 {
80 "commandStartedEvent": {
81 "command": {
82 "find": "test",
83 "filter": {
84 "_id": 1
85 }
86 },
87 "commandName": "find",
88 "databaseName": "command-monitoring-tests"
89 }
90 },
91 {
92 "commandSucceededEvent": {
93 "reply": {
94 "ok": 1,
95 "cursor": {
96 "id": 0,
97 "ns": "command-monitoring-tests.test",
98 "firstBatch": [
99 {
100 "_id": 1,
101 "x": 11
102 }
103 ]
104 }
105 },
106 "commandName": "find",
107 "databaseName": "command-monitoring-tests"
108 }
109 }
110 ]
111 }
112 ]
113 },
114 {
115 "description": "A successful find with options",
116 "operations": [
117 {
118 "name": "find",
119 "object": "collection",
120 "arguments": {
121 "filter": {
122 "_id": {
123 "$gt": 1
124 }
125 },
126 "sort": {
127 "x": -1
128 },
129 "projection": {
130 "_id": 0,
131 "x": 1
132 },
133 "skip": 2,
134 "comment": "test",
135 "hint": {
136 "_id": 1
137 },
138 "max": {
139 "_id": 6
140 },
141 "maxTimeMS": 6000,
142 "min": {
143 "_id": 0
144 }
145 }
146 }
147 ],
148 "expectEvents": [
149 {
150 "client": "client",
151 "events": [
152 {
153 "commandStartedEvent": {
154 "command": {
155 "find": "test",
156 "filter": {
157 "_id": {
158 "$gt": 1
159 }
160 },
161 "sort": {
162 "x": -1
163 },
164 "projection": {
165 "_id": 0,
166 "x": 1
167 },
168 "skip": 2,
169 "comment": "test",
170 "hint": {
171 "_id": 1
172 },
173 "max": {
174 "_id": 6
175 },
176 "maxTimeMS": 6000,
177 "min": {
178 "_id": 0
179 }
180 },
181 "commandName": "find",
182 "databaseName": "command-monitoring-tests"
183 }
184 },
185 {
186 "commandSucceededEvent": {
187 "reply": {
188 "ok": 1,
189 "cursor": {
190 "id": 0,
191 "ns": "command-monitoring-tests.test",
192 "firstBatch": [
193 {
194 "x": 33
195 },
196 {
197 "x": 22
198 }
199 ]
200 }
201 },
202 "commandName": "find",
203 "databaseName": "command-monitoring-tests"
204 }
205 }
206 ]
207 }
208 ]
209 },
210 {
211 "description": "A successful find with showRecordId and returnKey",
212 "operations": [
213 {
214 "name": "find",
215 "object": "collection",
216 "arguments": {
217 "filter": {},
218 "sort": {
219 "_id": 1
220 },
221 "showRecordId": true,
222 "returnKey": true
223 }
224 }
225 ],
226 "expectEvents": [
227 {
228 "client": "client",
229 "events": [
230 {
231 "commandStartedEvent": {
232 "command": {
233 "find": "test",
234 "showRecordId": true,
235 "returnKey": true
236 },
237 "commandName": "find",
238 "databaseName": "command-monitoring-tests"
239 }
240 },
241 {
242 "commandSucceededEvent": {
243 "reply": {
244 "ok": 1,
245 "cursor": {
246 "id": 0,
247 "ns": "command-monitoring-tests.test",
248 "firstBatch": [
249 {
250 "_id": 1
251 },
252 {
253 "_id": 2
254 },
255 {
256 "_id": 3
257 },
258 {
259 "_id": 4
260 },
261 {
262 "_id": 5
263 }
264 ]
265 }
266 },
267 "commandName": "find",
268 "databaseName": "command-monitoring-tests"
269 }
270 }
271 ]
272 }
273 ]
274 },
275 {
276 "description": "A successful find with a getMore",
277 "operations": [
278 {
279 "name": "find",
280 "object": "collection",
281 "arguments": {
282 "filter": {
283 "_id": {
284 "$gte": 1
285 }
286 },
287 "sort": {
288 "_id": 1
289 },
290 "batchSize": 3
291 }
292 }
293 ],
294 "expectEvents": [
295 {
296 "client": "client",
297 "events": [
298 {
299 "commandStartedEvent": {
300 "command": {
301 "find": "test",
302 "filter": {
303 "_id": {
304 "$gte": 1
305 }
306 },
307 "sort": {
308 "_id": 1
309 },
310 "batchSize": 3
311 },
312 "commandName": "find",
313 "databaseName": "command-monitoring-tests"
314 }
315 },
316 {
317 "commandSucceededEvent": {
318 "reply": {
319 "ok": 1,
320 "cursor": {
321 "id": {
322 "$$type": [
323 "int",
324 "long"
325 ]
326 },
327 "ns": "command-monitoring-tests.test",
328 "firstBatch": [
329 {
330 "_id": 1,
331 "x": 11
332 },
333 {
334 "_id": 2,
335 "x": 22
336 },
337 {
338 "_id": 3,
339 "x": 33
340 }
341 ]
342 }
343 },
344 "commandName": "find",
345 "databaseName": "command-monitoring-tests"
346 }
347 },
348 {
349 "commandStartedEvent": {
350 "command": {
351 "getMore": {
352 "$$type": [
353 "int",
354 "long"
355 ]
356 },
357 "collection": "test",
358 "batchSize": 3
359 },
360 "commandName": "getMore",
361 "databaseName": "command-monitoring-tests"
362 }
363 },
364 {
365 "commandSucceededEvent": {
366 "reply": {
367 "ok": 1,
368 "cursor": {
369 "id": 0,
370 "ns": "command-monitoring-tests.test",
371 "nextBatch": [
372 {
373 "_id": 4,
374 "x": 44
375 },
376 {
377 "_id": 5,
378 "x": 55
379 }
380 ]
381 }
382 },
383 "commandName": "getMore",
384 "databaseName": "command-monitoring-tests"
385 }
386 }
387 ]
388 }
389 ]
390 },
391 {
392 "description": "A successful find event with a getmore and the server kills the cursor (<= 4.4)",
393 "runOnRequirements": [
394 {
395 "minServerVersion": "3.1",
396 "maxServerVersion": "4.4.99",
397 "topologies": [
398 "single",
399 "replicaset"
400 ]
401 }
402 ],
403 "operations": [
404 {
405 "name": "find",
406 "object": "collection",
407 "arguments": {
408 "filter": {
409 "_id": {
410 "$gte": 1
411 }
412 },
413 "sort": {
414 "_id": 1
415 },
416 "batchSize": 3,
417 "limit": 4
418 }
419 }
420 ],
421 "expectEvents": [
422 {
423 "client": "client",
424 "events": [
425 {
426 "commandStartedEvent": {
427 "command": {
428 "find": "test",
429 "filter": {
430 "_id": {
431 "$gte": 1
432 }
433 },
434 "sort": {
435 "_id": 1
436 },
437 "batchSize": 3,
438 "limit": 4
439 },
440 "commandName": "find",
441 "databaseName": "command-monitoring-tests"
442 }
443 },
444 {
445 "commandSucceededEvent": {
446 "reply": {
447 "ok": 1,
448 "cursor": {
449 "id": {
450 "$$type": [
451 "int",
452 "long"
453 ]
454 },
455 "ns": "command-monitoring-tests.test",
456 "firstBatch": [
457 {
458 "_id": 1,
459 "x": 11
460 },
461 {
462 "_id": 2,
463 "x": 22
464 },
465 {
466 "_id": 3,
467 "x": 33
468 }
469 ]
470 }
471 },
472 "commandName": "find",
473 "databaseName": "command-monitoring-tests"
474 }
475 },
476 {
477 "commandStartedEvent": {
478 "command": {
479 "getMore": {
480 "$$type": [
481 "int",
482 "long"
483 ]
484 },
485 "collection": "test",
486 "batchSize": 1
487 },
488 "commandName": "getMore",
489 "databaseName": "command-monitoring-tests"
490 }
491 },
492 {
493 "commandSucceededEvent": {
494 "reply": {
495 "ok": 1,
496 "cursor": {
497 "id": 0,
498 "ns": "command-monitoring-tests.test",
499 "nextBatch": [
500 {
501 "_id": 4,
502 "x": 44
503 }
504 ]
505 }
506 },
507 "commandName": "getMore",
508 "databaseName": "command-monitoring-tests"
509 }
510 }
511 ]
512 }
513 ]
514 },
515 {
516 "description": "A failed find event",
517 "operations": [
518 {
519 "name": "find",
520 "object": "collection",
521 "arguments": {
522 "filter": {
523 "$or": true
524 }
525 },
526 "expectError": {
527 "isClientError": false
528 }
529 }
530 ],
531 "expectEvents": [
532 {
533 "client": "client",
534 "events": [
535 {
536 "commandStartedEvent": {
537 "command": {
538 "find": "test",
539 "filter": {
540 "$or": true
541 }
542 },
543 "commandName": "find",
544 "databaseName": "command-monitoring-tests"
545 }
546 },
547 {
548 "commandFailedEvent": {
549 "commandName": "find",
550 "databaseName": "command-monitoring-tests"
551 }
552 }
553 ]
554 }
555 ]
556 }
557 ]
558}
View as plain text