# Tests in this file are generated from override-operation-timeoutMS.yml.template.

description: "timeoutMS can be overridden for an operation"

schemaVersion: "1.9"

runOnRequirements:
  - minServerVersion: "4.4"
    topologies: ["replicaset", "sharded"]

createEntities:
  - client:
      id: &failPointClient failPointClient
      useMultipleMongoses: false
  - client:
      id: &client client
      uriOptions:
        timeoutMS: 10
      useMultipleMongoses: false
      observeEvents:
        - commandStartedEvent
      ignoreCommandMonitoringEvents:
        - killCursors
  - database:
      id: &database database
      client: *client
      databaseName: &databaseName test
  - collection:
      id: &collection collection
      database: *database
      collectionName: &collectionName coll

initialData:
  - collectionName: *collectionName
    databaseName: *databaseName
    documents: []

tests:
  # For each level operation, we execute two tests:
  #
  # 1. timeoutMS can be overridden to a non-zero value for an operation. Each test executes an operation using one of
  # the entities defined above with an overridden timeoutMS=1000 and configures a fail point to block the operation for
  # 15ms so the operation succeeds.
  #
  # 2. timeoutMS can be overridden to 0 for an operation. Each test executes an operation using the entities defined
  # above with an overridden timeoutMS=0 so the operation succeeds.

  - description: "timeoutMS can be configured for an operation - listDatabases on client"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listDatabases"]
              blockConnection: true
              blockTimeMS: 15
      - name: listDatabases
        object: *client
        arguments:
          timeoutMS: 1000
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listDatabases
              databaseName: admin
              command:
                listDatabases: 1
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - listDatabases on client"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listDatabases"]
              blockConnection: true
              blockTimeMS: 15
      - name: listDatabases
        object: *client
        arguments:
          timeoutMS: 0
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listDatabases
              databaseName: admin
              command:
                listDatabases: 1
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - listDatabaseNames on client"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listDatabases"]
              blockConnection: true
              blockTimeMS: 15
      - name: listDatabaseNames
        object: *client
        arguments:
          timeoutMS: 1000


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listDatabases
              databaseName: admin
              command:
                listDatabases: 1
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - listDatabaseNames on client"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listDatabases"]
              blockConnection: true
              blockTimeMS: 15
      - name: listDatabaseNames
        object: *client
        arguments:
          timeoutMS: 0


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listDatabases
              databaseName: admin
              command:
                listDatabases: 1
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - createChangeStream on client"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 15
      - name: createChangeStream
        object: *client
        arguments:
          timeoutMS: 1000
          pipeline: []


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: admin
              command:
                aggregate: 1
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - createChangeStream on client"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 15
      - name: createChangeStream
        object: *client
        arguments:
          timeoutMS: 0
          pipeline: []


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: admin
              command:
                aggregate: 1
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - aggregate on database"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 15
      - name: aggregate
        object: *database
        arguments:
          timeoutMS: 1000
          pipeline: [ { $listLocalSessions: {} }, { $limit: 1 } ]


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: 1
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - aggregate on database"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 15
      - name: aggregate
        object: *database
        arguments:
          timeoutMS: 0
          pipeline: [ { $listLocalSessions: {} }, { $limit: 1 } ]


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: 1
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - listCollections on database"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listCollections"]
              blockConnection: true
              blockTimeMS: 15
      - name: listCollections
        object: *database
        arguments:
          timeoutMS: 1000
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listCollections
              databaseName: *databaseName
              command:
                listCollections: 1
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - listCollections on database"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listCollections"]
              blockConnection: true
              blockTimeMS: 15
      - name: listCollections
        object: *database
        arguments:
          timeoutMS: 0
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listCollections
              databaseName: *databaseName
              command:
                listCollections: 1
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - listCollectionNames on database"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listCollections"]
              blockConnection: true
              blockTimeMS: 15
      - name: listCollectionNames
        object: *database
        arguments:
          timeoutMS: 1000
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listCollections
              databaseName: *databaseName
              command:
                listCollections: 1
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - listCollectionNames on database"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listCollections"]
              blockConnection: true
              blockTimeMS: 15
      - name: listCollectionNames
        object: *database
        arguments:
          timeoutMS: 0
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listCollections
              databaseName: *databaseName
              command:
                listCollections: 1
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - runCommand on database"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["ping"]
              blockConnection: true
              blockTimeMS: 15
      - name: runCommand
        object: *database
        arguments:
          timeoutMS: 1000
          command: { ping: 1 }
          commandName: ping


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: ping
              databaseName: *databaseName
              command:
                ping: 1
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - runCommand on database"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["ping"]
              blockConnection: true
              blockTimeMS: 15
      - name: runCommand
        object: *database
        arguments:
          timeoutMS: 0
          command: { ping: 1 }
          commandName: ping


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: ping
              databaseName: *databaseName
              command:
                ping: 1
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - createChangeStream on database"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 15
      - name: createChangeStream
        object: *database
        arguments:
          timeoutMS: 1000
          pipeline: []


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: 1
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - createChangeStream on database"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 15
      - name: createChangeStream
        object: *database
        arguments:
          timeoutMS: 0
          pipeline: []


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: 1
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - aggregate on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 15
      - name: aggregate
        object: *collection
        arguments:
          timeoutMS: 1000
          pipeline: []


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - aggregate on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 15
      - name: aggregate
        object: *collection
        arguments:
          timeoutMS: 0
          pipeline: []


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - count on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["count"]
              blockConnection: true
              blockTimeMS: 15
      - name: count
        object: *collection
        arguments:
          timeoutMS: 1000
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: count
              databaseName: *databaseName
              command:
                count: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - count on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["count"]
              blockConnection: true
              blockTimeMS: 15
      - name: count
        object: *collection
        arguments:
          timeoutMS: 0
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: count
              databaseName: *databaseName
              command:
                count: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - countDocuments on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 15
      - name: countDocuments
        object: *collection
        arguments:
          timeoutMS: 1000
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - countDocuments on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 15
      - name: countDocuments
        object: *collection
        arguments:
          timeoutMS: 0
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - estimatedDocumentCount on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["count"]
              blockConnection: true
              blockTimeMS: 15
      - name: estimatedDocumentCount
        object: *collection
        arguments:
          timeoutMS: 1000


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: count
              databaseName: *databaseName
              command:
                count: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - estimatedDocumentCount on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["count"]
              blockConnection: true
              blockTimeMS: 15
      - name: estimatedDocumentCount
        object: *collection
        arguments:
          timeoutMS: 0


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: count
              databaseName: *databaseName
              command:
                count: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - distinct on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["distinct"]
              blockConnection: true
              blockTimeMS: 15
      - name: distinct
        object: *collection
        arguments:
          timeoutMS: 1000
          fieldName: x
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: distinct
              databaseName: *databaseName
              command:
                distinct: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - distinct on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["distinct"]
              blockConnection: true
              blockTimeMS: 15
      - name: distinct
        object: *collection
        arguments:
          timeoutMS: 0
          fieldName: x
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: distinct
              databaseName: *databaseName
              command:
                distinct: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - find on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["find"]
              blockConnection: true
              blockTimeMS: 15
      - name: find
        object: *collection
        arguments:
          timeoutMS: 1000
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - find on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["find"]
              blockConnection: true
              blockTimeMS: 15
      - name: find
        object: *collection
        arguments:
          timeoutMS: 0
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - findOne on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["find"]
              blockConnection: true
              blockTimeMS: 15
      - name: findOne
        object: *collection
        arguments:
          timeoutMS: 1000
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - findOne on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["find"]
              blockConnection: true
              blockTimeMS: 15
      - name: findOne
        object: *collection
        arguments:
          timeoutMS: 0
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - listIndexes on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listIndexes"]
              blockConnection: true
              blockTimeMS: 15
      - name: listIndexes
        object: *collection
        arguments:
          timeoutMS: 1000


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listIndexes
              databaseName: *databaseName
              command:
                listIndexes: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - listIndexes on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listIndexes"]
              blockConnection: true
              blockTimeMS: 15
      - name: listIndexes
        object: *collection
        arguments:
          timeoutMS: 0


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listIndexes
              databaseName: *databaseName
              command:
                listIndexes: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - listIndexNames on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listIndexes"]
              blockConnection: true
              blockTimeMS: 15
      - name: listIndexNames
        object: *collection
        arguments:
          timeoutMS: 1000


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listIndexes
              databaseName: *databaseName
              command:
                listIndexes: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - listIndexNames on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listIndexes"]
              blockConnection: true
              blockTimeMS: 15
      - name: listIndexNames
        object: *collection
        arguments:
          timeoutMS: 0


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listIndexes
              databaseName: *databaseName
              command:
                listIndexes: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - createChangeStream on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 15
      - name: createChangeStream
        object: *collection
        arguments:
          timeoutMS: 1000
          pipeline: []


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - createChangeStream on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 15
      - name: createChangeStream
        object: *collection
        arguments:
          timeoutMS: 0
          pipeline: []


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - insertOne on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["insert"]
              blockConnection: true
              blockTimeMS: 15
      - name: insertOne
        object: *collection
        arguments:
          timeoutMS: 1000
          document: { x: 1 }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: insert
              databaseName: *databaseName
              command:
                insert: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - insertOne on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["insert"]
              blockConnection: true
              blockTimeMS: 15
      - name: insertOne
        object: *collection
        arguments:
          timeoutMS: 0
          document: { x: 1 }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: insert
              databaseName: *databaseName
              command:
                insert: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - insertMany on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["insert"]
              blockConnection: true
              blockTimeMS: 15
      - name: insertMany
        object: *collection
        arguments:
          timeoutMS: 1000
          documents:
            - { x: 1 }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: insert
              databaseName: *databaseName
              command:
                insert: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - insertMany on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["insert"]
              blockConnection: true
              blockTimeMS: 15
      - name: insertMany
        object: *collection
        arguments:
          timeoutMS: 0
          documents:
            - { x: 1 }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: insert
              databaseName: *databaseName
              command:
                insert: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - deleteOne on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["delete"]
              blockConnection: true
              blockTimeMS: 15
      - name: deleteOne
        object: *collection
        arguments:
          timeoutMS: 1000
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: delete
              databaseName: *databaseName
              command:
                delete: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - deleteOne on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["delete"]
              blockConnection: true
              blockTimeMS: 15
      - name: deleteOne
        object: *collection
        arguments:
          timeoutMS: 0
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: delete
              databaseName: *databaseName
              command:
                delete: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - deleteMany on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["delete"]
              blockConnection: true
              blockTimeMS: 15
      - name: deleteMany
        object: *collection
        arguments:
          timeoutMS: 1000
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: delete
              databaseName: *databaseName
              command:
                delete: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - deleteMany on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["delete"]
              blockConnection: true
              blockTimeMS: 15
      - name: deleteMany
        object: *collection
        arguments:
          timeoutMS: 0
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: delete
              databaseName: *databaseName
              command:
                delete: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - replaceOne on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["update"]
              blockConnection: true
              blockTimeMS: 15
      - name: replaceOne
        object: *collection
        arguments:
          timeoutMS: 1000
          filter: {}
          replacement: { x: 1 }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: update
              databaseName: *databaseName
              command:
                update: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - replaceOne on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["update"]
              blockConnection: true
              blockTimeMS: 15
      - name: replaceOne
        object: *collection
        arguments:
          timeoutMS: 0
          filter: {}
          replacement: { x: 1 }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: update
              databaseName: *databaseName
              command:
                update: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - updateOne on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["update"]
              blockConnection: true
              blockTimeMS: 15
      - name: updateOne
        object: *collection
        arguments:
          timeoutMS: 1000
          filter: {}
          update: { $set: { x: 1 } }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: update
              databaseName: *databaseName
              command:
                update: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - updateOne on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["update"]
              blockConnection: true
              blockTimeMS: 15
      - name: updateOne
        object: *collection
        arguments:
          timeoutMS: 0
          filter: {}
          update: { $set: { x: 1 } }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: update
              databaseName: *databaseName
              command:
                update: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - updateMany on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["update"]
              blockConnection: true
              blockTimeMS: 15
      - name: updateMany
        object: *collection
        arguments:
          timeoutMS: 1000
          filter: {}
          update: { $set: { x: 1 } }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: update
              databaseName: *databaseName
              command:
                update: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - updateMany on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["update"]
              blockConnection: true
              blockTimeMS: 15
      - name: updateMany
        object: *collection
        arguments:
          timeoutMS: 0
          filter: {}
          update: { $set: { x: 1 } }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: update
              databaseName: *databaseName
              command:
                update: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - findOneAndDelete on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["findAndModify"]
              blockConnection: true
              blockTimeMS: 15
      - name: findOneAndDelete
        object: *collection
        arguments:
          timeoutMS: 1000
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: findAndModify
              databaseName: *databaseName
              command:
                findAndModify: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - findOneAndDelete on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["findAndModify"]
              blockConnection: true
              blockTimeMS: 15
      - name: findOneAndDelete
        object: *collection
        arguments:
          timeoutMS: 0
          filter: {}


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: findAndModify
              databaseName: *databaseName
              command:
                findAndModify: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - findOneAndReplace on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["findAndModify"]
              blockConnection: true
              blockTimeMS: 15
      - name: findOneAndReplace
        object: *collection
        arguments:
          timeoutMS: 1000
          filter: {}
          replacement: { x: 1 }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: findAndModify
              databaseName: *databaseName
              command:
                findAndModify: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - findOneAndReplace on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["findAndModify"]
              blockConnection: true
              blockTimeMS: 15
      - name: findOneAndReplace
        object: *collection
        arguments:
          timeoutMS: 0
          filter: {}
          replacement: { x: 1 }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: findAndModify
              databaseName: *databaseName
              command:
                findAndModify: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - findOneAndUpdate on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["findAndModify"]
              blockConnection: true
              blockTimeMS: 15
      - name: findOneAndUpdate
        object: *collection
        arguments:
          timeoutMS: 1000
          filter: {}
          update: { $set: { x: 1 } }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: findAndModify
              databaseName: *databaseName
              command:
                findAndModify: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - findOneAndUpdate on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["findAndModify"]
              blockConnection: true
              blockTimeMS: 15
      - name: findOneAndUpdate
        object: *collection
        arguments:
          timeoutMS: 0
          filter: {}
          update: { $set: { x: 1 } }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: findAndModify
              databaseName: *databaseName
              command:
                findAndModify: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - bulkWrite on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["insert"]
              blockConnection: true
              blockTimeMS: 15
      - name: bulkWrite
        object: *collection
        arguments:
          timeoutMS: 1000
          requests:
            - insertOne:
                document: { _id: 1 }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: insert
              databaseName: *databaseName
              command:
                insert: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - bulkWrite on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["insert"]
              blockConnection: true
              blockTimeMS: 15
      - name: bulkWrite
        object: *collection
        arguments:
          timeoutMS: 0
          requests:
            - insertOne:
                document: { _id: 1 }


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: insert
              databaseName: *databaseName
              command:
                insert: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - createIndex on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["createIndexes"]
              blockConnection: true
              blockTimeMS: 15
      - name: createIndex
        object: *collection
        arguments:
          timeoutMS: 1000
          keys: { x: 1 }
          name: "x_1"


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: createIndexes
              databaseName: *databaseName
              command:
                createIndexes: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - createIndex on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["createIndexes"]
              blockConnection: true
              blockTimeMS: 15
      - name: createIndex
        object: *collection
        arguments:
          timeoutMS: 0
          keys: { x: 1 }
          name: "x_1"


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: createIndexes
              databaseName: *databaseName
              command:
                createIndexes: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - dropIndex on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["dropIndexes"]
              blockConnection: true
              blockTimeMS: 15
      - name: dropIndex
        object: *collection
        arguments:
          timeoutMS: 1000
          name: "x_1"

        expectError:
          isTimeoutError: false  # IndexNotFound
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: dropIndexes
              databaseName: *databaseName
              command:
                dropIndexes: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - dropIndex on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["dropIndexes"]
              blockConnection: true
              blockTimeMS: 15
      - name: dropIndex
        object: *collection
        arguments:
          timeoutMS: 0
          name: "x_1"

        expectError:
          isTimeoutError: false  # IndexNotFound
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: dropIndexes
              databaseName: *databaseName
              command:
                dropIndexes: *collectionName
                maxTimeMS: { $$exists: false }
  - description: "timeoutMS can be configured for an operation - dropIndexes on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["dropIndexes"]
              blockConnection: true
              blockTimeMS: 15
      - name: dropIndexes
        object: *collection
        arguments:
          timeoutMS: 1000


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: dropIndexes
              databaseName: *databaseName
              command:
                dropIndexes: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
  - description: "timeoutMS can be set to 0 for an operation - dropIndexes on collection"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["dropIndexes"]
              blockConnection: true
              blockTimeMS: 15
      - name: dropIndexes
        object: *collection
        arguments:
          timeoutMS: 0


    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: dropIndexes
              databaseName: *databaseName
              command:
                dropIndexes: *collectionName
                maxTimeMS: { $$exists: false }
