description: "estimatedDocumentCount" schemaVersion: "1.0" createEntities: - client: id: &client0 client0 useMultipleMongoses: false # Avoid setting fail points with multiple mongoses uriOptions: { retryReads: false } # Avoid retrying fail points with closeConnection observeEvents: [ commandStartedEvent ] - database: id: &database0 database0 client: *client0 databaseName: &database0Name edc-tests - collection: id: &collection0 collection0 database: *database0 collectionName: &collection0Name coll0 - collection: # Nonexistent collection intentionally omitted from initialData id: &collection1 collection1 database: *database0 collectionName: &collection1Name coll1 initialData: - collectionName: *collection0Name databaseName: *database0Name documents: - { _id: 1, x: 11 } - { _id: 2, x: 22 } - { _id: 3, x: 33 } tests: - description: "estimatedDocumentCount uses $collStats on 4.9.0 or greater" runOnRequirements: - minServerVersion: "4.9.0" operations: - name: estimatedDocumentCount object: *collection0 expectResult: 3 expectEvents: - client: *client0 events: - commandStartedEvent: command: aggregate: *collection0Name pipeline: &pipeline - $collStats: { count: {} } - $group: { _id: 1, n: { $sum: $count }} commandName: aggregate databaseName: *database0Name - description: "estimatedDocumentCount with maxTimeMS on 4.9.0 or greater" runOnRequirements: - minServerVersion: "4.9.0" operations: - name: estimatedDocumentCount object: *collection0 arguments: maxTimeMS: 6000 expectResult: 3 expectEvents: - client: *client0 events: - commandStartedEvent: command: aggregate: *collection0Name pipeline: &pipeline - $collStats: { count: {} } - $group: { _id: 1, n: { $sum: $count }} maxTimeMS: 6000 commandName: aggregate databaseName: *database0Name - description: "estimatedDocumentCount on non-existent collection on 4.9.0 or greater" runOnRequirements: - minServerVersion: "4.9.0" operations: - name: estimatedDocumentCount object: *collection1 expectResult: 0 expectEvents: - client: *client0 events: - commandStartedEvent: command: aggregate: *collection1Name pipeline: &pipeline - $collStats: { count: {} } - $group: { _id: 1, n: { $sum: $count }} commandName: aggregate databaseName: *database0Name - description: "estimatedDocumentCount errors correctly on 4.9.0 or greater--command error" runOnRequirements: - minServerVersion: "4.9.0" operations: - name: failPoint object: testRunner arguments: client: *client0 failPoint: configureFailPoint: failCommand mode: { times: 1 } data: failCommands: [ aggregate ] errorCode: 8 # UnknownError - name: estimatedDocumentCount object: *collection0 expectError: errorCode: 8 # UnknownError expectEvents: - client: *client0 events: - commandStartedEvent: command: aggregate: *collection0Name pipeline: &pipeline - $collStats: { count: {} } - $group: { _id: 1, n: { $sum: $count }} commandName: aggregate databaseName: *database0Name - description: "estimatedDocumentCount errors correctly on 4.9.0 or greater--socket error" runOnRequirements: - minServerVersion: "4.9.0" operations: - name: failPoint object: testRunner arguments: client: *client0 failPoint: configureFailPoint: failCommand mode: { times: 1 } data: failCommands: [ aggregate ] closeConnection: true - name: estimatedDocumentCount object: *collection0 expectError: isError: true expectEvents: - client: *client0 events: - commandStartedEvent: command: aggregate: *collection0Name pipeline: &pipeline - $collStats: { count: {} } - $group: { _id: 1, n: { $sum: $count }} commandName: aggregate databaseName: *database0Name - description: "estimatedDocumentCount uses count on less than 4.9.0" runOnRequirements: - maxServerVersion: "4.8.99" operations: - name: estimatedDocumentCount object: *collection0 expectResult: 3 expectEvents: - client: *client0 events: - commandStartedEvent: command: count: *collection0Name commandName: count databaseName: *database0Name - description: "estimatedDocumentCount with maxTimeMS on less than 4.9.0" runOnRequirements: - maxServerVersion: "4.8.99" operations: - name: estimatedDocumentCount object: *collection0 arguments: maxTimeMS: 6000 expectResult: 3 expectEvents: - client: *client0 events: - commandStartedEvent: command: count: *collection0Name maxTimeMS: 6000 commandName: count databaseName: *database0Name - description: "estimatedDocumentCount on non-existent collection on less than 4.9.0" runOnRequirements: - maxServerVersion: "4.8.99" operations: - name: estimatedDocumentCount object: *collection1 expectResult: 0 expectEvents: - client: *client0 events: - commandStartedEvent: command: count: *collection1Name commandName: count databaseName: *database0Name - description: "estimatedDocumentCount errors correctly on less than 4.9.0--command error" runOnRequirements: - minServerVersion: "4.0.0" maxServerVersion: "4.8.99" topologies: [ single, replicaset ] - minServerVersion: "4.2.0" maxServerVersion: "4.8.99" topologies: [ sharded ] operations: - name: failPoint object: testRunner arguments: client: *client0 failPoint: configureFailPoint: failCommand mode: { times: 1 } data: failCommands: [ count ] errorCode: 8 # UnknownError - name: estimatedDocumentCount object: *collection0 expectError: errorCode: 8 # UnknownError expectEvents: - client: *client0 events: - commandStartedEvent: command: count: *collection0Name commandName: count databaseName: *database0Name - description: "estimatedDocumentCount errors correctly on less than 4.9.0--socket error" runOnRequirements: - minServerVersion: "4.0.0" maxServerVersion: "4.8.99" topologies: [ single, replicaset ] - minServerVersion: "4.2.0" maxServerVersion: "4.8.99" 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: *collection0Name commandName: count databaseName: *database0Name