bson/testdata/crud/unified/estimatedDocumentCount.json
2025-03-17 20:58:26 +01:00

358 lines
7.9 KiB
JSON

{
"description": "estimatedDocumentCount",
"schemaVersion": "1.0",
"createEntities": [
{
"client": {
"id": "client0",
"useMultipleMongoses": false,
"uriOptions": {
"retryReads": false
},
"observeEvents": [
"commandStartedEvent"
]
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "edc-tests"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "coll0"
}
},
{
"collection": {
"id": "collection1",
"database": "database0",
"collectionName": "coll1"
}
},
{
"collection": {
"id": "collection0View",
"database": "database0",
"collectionName": "coll0view"
}
}
],
"initialData": [
{
"collectionName": "coll0",
"databaseName": "edc-tests",
"documents": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
],
"tests": [
{
"description": "estimatedDocumentCount always uses count",
"operations": [
{
"name": "estimatedDocumentCount",
"object": "collection0",
"expectResult": 3
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"count": "coll0"
},
"commandName": "count",
"databaseName": "edc-tests"
}
}
]
}
]
},
{
"description": "estimatedDocumentCount with maxTimeMS",
"operations": [
{
"name": "estimatedDocumentCount",
"object": "collection0",
"arguments": {
"maxTimeMS": 6000
},
"expectResult": 3
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"count": "coll0",
"maxTimeMS": 6000
},
"commandName": "count",
"databaseName": "edc-tests"
}
}
]
}
]
},
{
"description": "estimatedDocumentCount on non-existent collection",
"operations": [
{
"name": "estimatedDocumentCount",
"object": "collection1",
"expectResult": 0
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"count": "coll1"
},
"commandName": "count",
"databaseName": "edc-tests"
}
}
]
}
]
},
{
"description": "estimatedDocumentCount errors correctly--command error",
"runOnRequirements": [
{
"minServerVersion": "4.0.0",
"topologies": [
"single",
"replicaset"
]
},
{
"minServerVersion": "4.2.0",
"topologies": [
"sharded"
]
}
],
"operations": [
{
"name": "failPoint",
"object": "testRunner",
"arguments": {
"client": "client0",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"count"
],
"errorCode": 8
}
}
}
},
{
"name": "estimatedDocumentCount",
"object": "collection0",
"expectError": {
"errorCode": 8
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"count": "coll0"
},
"commandName": "count",
"databaseName": "edc-tests"
}
}
]
}
]
},
{
"description": "estimatedDocumentCount errors correctly--socket error",
"runOnRequirements": [
{
"minServerVersion": "4.0.0",
"topologies": [
"single",
"replicaset"
]
},
{
"minServerVersion": "4.2.0",
"topologies": [
"sharded"
]
}
],
"operations": [
{
"name": "failPoint",
"object": "testRunner",
"arguments": {
"client": "client0",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"count"
],
"closeConnection": true
}
}
}
},
{
"name": "estimatedDocumentCount",
"object": "collection0",
"expectError": {
"isError": true
}
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"count": "coll0"
},
"commandName": "count",
"databaseName": "edc-tests"
}
}
]
}
]
},
{
"description": "estimatedDocumentCount works correctly on views",
"runOnRequirements": [
{
"minServerVersion": "3.4.0"
}
],
"operations": [
{
"name": "dropCollection",
"object": "database0",
"arguments": {
"collection": "coll0view"
}
},
{
"name": "createCollection",
"object": "database0",
"arguments": {
"collection": "coll0view",
"viewOn": "coll0",
"pipeline": [
{
"$match": {
"_id": {
"$gt": 1
}
}
}
]
}
},
{
"name": "estimatedDocumentCount",
"object": "collection0View",
"expectResult": 2
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"drop": "coll0view"
},
"commandName": "drop",
"databaseName": "edc-tests"
}
},
{
"commandStartedEvent": {
"command": {
"create": "coll0view",
"viewOn": "coll0",
"pipeline": [
{
"$match": {
"_id": {
"$gt": 1
}
}
}
]
},
"commandName": "create",
"databaseName": "edc-tests"
}
},
{
"commandStartedEvent": {
"command": {
"count": "coll0view"
},
"commandName": "count",
"databaseName": "edc-tests"
}
}
]
}
]
}
]
}