{ "description": "find", "schemaVersion": "1.15", "createEntities": [ { "client": { "id": "client", "observeEvents": [ "commandStartedEvent", "commandSucceededEvent", "commandFailedEvent" ] } }, { "database": { "id": "database", "client": "client", "databaseName": "command-monitoring-tests" } }, { "collection": { "id": "collection", "database": "database", "collectionName": "test" } } ], "_yamlAnchors": { "namespace": "command-monitoring-tests.test" }, "initialData": [ { "collectionName": "test", "databaseName": "command-monitoring-tests", "documents": [ { "_id": 1, "x": 11 }, { "_id": 2, "x": 22 }, { "_id": 3, "x": 33 }, { "_id": 4, "x": 44 }, { "_id": 5, "x": 55 } ] } ], "tests": [ { "description": "A successful find with no options", "operations": [ { "name": "find", "object": "collection", "arguments": { "filter": { "_id": 1 } } } ], "expectEvents": [ { "client": "client", "events": [ { "commandStartedEvent": { "command": { "find": "test", "filter": { "_id": 1 } }, "commandName": "find", "databaseName": "command-monitoring-tests" } }, { "commandSucceededEvent": { "reply": { "ok": 1, "cursor": { "id": 0, "ns": "command-monitoring-tests.test", "firstBatch": [ { "_id": 1, "x": 11 } ] } }, "commandName": "find", "databaseName": "command-monitoring-tests" } } ] } ] }, { "description": "A successful find with options", "operations": [ { "name": "find", "object": "collection", "arguments": { "filter": { "_id": { "$gt": 1 } }, "sort": { "x": -1 }, "projection": { "_id": 0, "x": 1 }, "skip": 2, "comment": "test", "hint": { "_id": 1 }, "max": { "_id": 6 }, "maxTimeMS": 6000, "min": { "_id": 0 } } } ], "expectEvents": [ { "client": "client", "events": [ { "commandStartedEvent": { "command": { "find": "test", "filter": { "_id": { "$gt": 1 } }, "sort": { "x": -1 }, "projection": { "_id": 0, "x": 1 }, "skip": 2, "comment": "test", "hint": { "_id": 1 }, "max": { "_id": 6 }, "maxTimeMS": 6000, "min": { "_id": 0 } }, "commandName": "find", "databaseName": "command-monitoring-tests" } }, { "commandSucceededEvent": { "reply": { "ok": 1, "cursor": { "id": 0, "ns": "command-monitoring-tests.test", "firstBatch": [ { "x": 33 }, { "x": 22 } ] } }, "commandName": "find", "databaseName": "command-monitoring-tests" } } ] } ] }, { "description": "A successful find with showRecordId and returnKey", "operations": [ { "name": "find", "object": "collection", "arguments": { "filter": {}, "sort": { "_id": 1 }, "showRecordId": true, "returnKey": true } } ], "expectEvents": [ { "client": "client", "events": [ { "commandStartedEvent": { "command": { "find": "test", "showRecordId": true, "returnKey": true }, "commandName": "find", "databaseName": "command-monitoring-tests" } }, { "commandSucceededEvent": { "reply": { "ok": 1, "cursor": { "id": 0, "ns": "command-monitoring-tests.test", "firstBatch": [ { "_id": 1 }, { "_id": 2 }, { "_id": 3 }, { "_id": 4 }, { "_id": 5 } ] } }, "commandName": "find", "databaseName": "command-monitoring-tests" } } ] } ] }, { "description": "A successful find with a getMore", "operations": [ { "name": "find", "object": "collection", "arguments": { "filter": { "_id": { "$gte": 1 } }, "sort": { "_id": 1 }, "batchSize": 3 } } ], "expectEvents": [ { "client": "client", "events": [ { "commandStartedEvent": { "command": { "find": "test", "filter": { "_id": { "$gte": 1 } }, "sort": { "_id": 1 }, "batchSize": 3 }, "commandName": "find", "databaseName": "command-monitoring-tests" } }, { "commandSucceededEvent": { "reply": { "ok": 1, "cursor": { "id": { "$$type": [ "int", "long" ] }, "ns": "command-monitoring-tests.test", "firstBatch": [ { "_id": 1, "x": 11 }, { "_id": 2, "x": 22 }, { "_id": 3, "x": 33 } ] } }, "commandName": "find", "databaseName": "command-monitoring-tests" } }, { "commandStartedEvent": { "command": { "getMore": { "$$type": [ "int", "long" ] }, "collection": "test", "batchSize": 3 }, "commandName": "getMore", "databaseName": "command-monitoring-tests" } }, { "commandSucceededEvent": { "reply": { "ok": 1, "cursor": { "id": 0, "ns": "command-monitoring-tests.test", "nextBatch": [ { "_id": 4, "x": 44 }, { "_id": 5, "x": 55 } ] } }, "commandName": "getMore", "databaseName": "command-monitoring-tests" } } ] } ] }, { "description": "A successful find event with a getmore and the server kills the cursor (<= 4.4)", "runOnRequirements": [ { "minServerVersion": "3.1", "maxServerVersion": "4.4.99", "topologies": [ "single", "replicaset" ] } ], "operations": [ { "name": "find", "object": "collection", "arguments": { "filter": { "_id": { "$gte": 1 } }, "sort": { "_id": 1 }, "batchSize": 3, "limit": 4 } } ], "expectEvents": [ { "client": "client", "events": [ { "commandStartedEvent": { "command": { "find": "test", "filter": { "_id": { "$gte": 1 } }, "sort": { "_id": 1 }, "batchSize": 3, "limit": 4 }, "commandName": "find", "databaseName": "command-monitoring-tests" } }, { "commandSucceededEvent": { "reply": { "ok": 1, "cursor": { "id": { "$$type": [ "int", "long" ] }, "ns": "command-monitoring-tests.test", "firstBatch": [ { "_id": 1, "x": 11 }, { "_id": 2, "x": 22 }, { "_id": 3, "x": 33 } ] } }, "commandName": "find", "databaseName": "command-monitoring-tests" } }, { "commandStartedEvent": { "command": { "getMore": { "$$type": [ "int", "long" ] }, "collection": "test", "batchSize": 1 }, "commandName": "getMore", "databaseName": "command-monitoring-tests" } }, { "commandSucceededEvent": { "reply": { "ok": 1, "cursor": { "id": 0, "ns": "command-monitoring-tests.test", "nextBatch": [ { "_id": 4, "x": 44 } ] } }, "commandName": "getMore", "databaseName": "command-monitoring-tests" } } ] } ] }, { "description": "A failed find event", "operations": [ { "name": "find", "object": "collection", "arguments": { "filter": { "$or": true } }, "expectError": { "isClientError": false } } ], "expectEvents": [ { "client": "client", "events": [ { "commandStartedEvent": { "command": { "find": "test", "filter": { "$or": true } }, "commandName": "find", "databaseName": "command-monitoring-tests" } }, { "commandFailedEvent": { "commandName": "find", "databaseName": "command-monitoring-tests" } } ] } ] } ] }