description: "operations ignore deprecated timeout options if timeoutMS is set"

schemaVersion: "1.9"

# Most tests in this file can be executed against any server version, but some tests execute operations that are only
# available on higher server versions (e.g. abortTransaction). To avoid too many special cases in templated tests, the
# min server version is set to 4.2 for all.
runOnRequirements:
  - minServerVersion: "4.2"
    topologies: ["replicaset", "sharded"]

createEntities:
  - client:
      id: &failPointClient failPointClient
      useMultipleMongoses: false

initialData:
  - collectionName: &collectionName coll
    databaseName: &databaseName test
    documents: []

tests:
  # For each operation, run these tests:
  #
  # 1. socketTimeoutMS is ignored if timeoutMS is set. The test creates a client with socketTimeoutMS=1, configures and
  # a failpoint to block the operation for 5ms, runs the operation with timeoutMS=10000, and expects it to succeed.
  #
  # 2. wTimeoutMS is ignored if timeoutMS is set. The test creates a client with wTimeoutMS=1, runs the operation with
  # timeoutMS=10000, expects the operation to succeed, and uses command monitoring expectations to assert that the
  # command sent to the server does not contain a writeConcern field.
  #
  # 3. If the operation supports maxTimeMS, it ignores maxTimeMS if timeoutMS is set. The test executes the operation
  # with timeoutMS=1000 and maxTimeMS=5000. It expects the operation to succeed and uses command monitoring expectations
  # to assert that the actual maxTimeMS value sent was less than or equal to 100, thereby asserting that it was
  # actually derived from timeoutMS.

  # Tests for commitTransaction. These are not included in the operations loop because the tests need to execute
  # additional "startTransaction" and "insertOne" operations to establish a server-side transaction. There is also one
  # additional test to assert that maxCommitTimeMS is ignored if timeoutMS is set.

  - description: "commitTransaction ignores socketTimeoutMS if timeoutMS is set"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  # This test uses 20 instead of 1 like other tests because socketTimeoutMS also applies to the
                  # operation done to start the server-side transaction and it needs time to succeed.
                  socketTimeoutMS: 20
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents: ["aggregate"]
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["commitTransaction"]
              blockConnection: true
              blockTimeMS: 5
      - name: startTransaction
        object: *session
      - name: countDocuments
        object: *collection
        arguments:
          filter: {}
          session: *session
      - name: commitTransaction
        object: *session
        arguments:
          timeoutMS: 10000
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: commitTransaction
              databaseName: admin
              command:
                commitTransaction: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "commitTransaction ignores wTimeoutMS if timeoutMS is set"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents: ["aggregate"]
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - session:
                id: &session session
                client: *client
      - name: startTransaction
        object: *session
      - name: countDocuments
        object: *collection
        arguments:
          filter: {}
          session: *session
      - name: commitTransaction
        object: *session
        arguments:
          timeoutMS: 10000
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: commitTransaction
              databaseName: admin
              command:
                commitTransaction: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "commitTransaction ignores maxCommitTimeMS if timeoutMS is set"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents: ["aggregate"]
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - session:
                id: &session session
                client: *client
                sessionOptions:
                  defaultTransactionOptions:
                    maxCommitTimeMS: 5000
      - name: startTransaction
        object: *session
      - name: countDocuments
        object: *collection
        arguments:
          filter: {}
          session: *session
      - name: commitTransaction
        object: *session
        arguments:
          timeoutMS: &timeoutMS 1000
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: commitTransaction
              databaseName: admin
              command:
                commitTransaction: 1
                # Assert that the final maxTimeMS field is derived from timeoutMS, not maxCommitTimeMS.
                maxTimeMS: { $$lte: *timeoutMS }
  
  # Tests for abortTransaction. These are not included in the operations loop because the tests need to execute
  # additional "startTransaction" and "insertOne" operations to establish a server-side transaction.

  - description: "abortTransaction ignores socketTimeoutMS if timeoutMS is set"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  # This test uses 20 instead of 1 like other tests because socketTimeoutMS also applies to the
                  # operation done to start the server-side transaction and it needs time to succeed.
                  socketTimeoutMS: 20
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents: ["aggregate"]
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["abortTransaction"]
              blockConnection: true
              blockTimeMS: 5
      - name: startTransaction
        object: *session
      - name: countDocuments
        object: *collection
        arguments:
          filter: {}
          session: *session
      - name: abortTransaction
        object: *session
        arguments:
          timeoutMS: 10000
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: abortTransaction
              databaseName: admin
              command:
                abortTransaction: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "abortTransaction ignores wTimeoutMS if timeoutMS is set"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents: ["aggregate"]
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - session:
                id: &session session
                client: *client
      - name: startTransaction
        object: *session
      - name: countDocuments
        object: *collection
        arguments:
          filter: {}
          session: *session
      - name: abortTransaction
        object: *session
        arguments:
          timeoutMS: 10000
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: abortTransaction
              databaseName: admin
              command:
                abortTransaction: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  # Tests for withTransaction. These are not included in the operations loop because the command monitoring
  # expectations contain multiple commands. There is also one additional test to assert that maxCommitTimeMS is ignored
  # if timeoutMS is set.

  - description: "withTransaction ignores socketTimeoutMS if timeoutMS is set"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  # This test uses 20 instead of 1 like other tests because socketTimeoutMS also applies to the
                  # operation done to start the server-side transaction and it needs time to succeed.
                  socketTimeoutMS: 20
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["commitTransaction"]
              blockConnection: true
              blockTimeMS: 5
      - name: withTransaction
        object: *session
        arguments:
          timeoutMS: 10000
          callback:
            - name: countDocuments
              object: *collection
              arguments:
                filter: {}
                session: *session
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
          - commandStartedEvent:
              commandName: commitTransaction
              databaseName: admin
              command:
                commitTransaction: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "withTransaction ignores wTimeoutMS if timeoutMS is set"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - session:
                id: &session session
                client: *client
      - name: withTransaction
        object: *session
        arguments:
          timeoutMS: 10000
          callback:
            - name: countDocuments
              object: *collection
              arguments:
                filter: {}
                session: *session
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }
          - commandStartedEvent:
              commandName: commitTransaction
              databaseName: admin
              command:
                commitTransaction: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "withTransaction ignores maxCommitTimeMS if timeoutMS is set"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - session:
                id: &session session
                client: *client
                sessionOptions:
                  defaultTransactionOptions:
                    maxCommitTimeMS: 5000
      - name: withTransaction
        object: *session
        arguments:
          timeoutMS: &timeoutMS 1000
          callback:
            - name: countDocuments
              object: *collection
              arguments:
                filter: {}
                session: *session
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }
          - commandStartedEvent:
              commandName: commitTransaction
              databaseName: admin
              command:
                commitTransaction: 1
                # Assert that the final maxTimeMS field is derived from timeoutMS, not maxCommitTimeMS.
                maxTimeMS: { $$lte: *timeoutMS }

  # Tests for operations that can be generated.

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - listDatabases on client"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listDatabases"]
              blockConnection: true
              blockTimeMS: 5
      - name: listDatabases
        object: *client
        arguments:
          timeoutMS: 100000
          filter: {}
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - listDatabases on client"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: listDatabases
        object: *client
        arguments:
          timeoutMS: 100000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listDatabases
              databaseName: admin
              command:
                listDatabases: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - listDatabaseNames on client"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listDatabases"]
              blockConnection: true
              blockTimeMS: 5
      - name: listDatabaseNames
        object: *client
        arguments:
          timeoutMS: 100000
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - listDatabaseNames on client"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: listDatabaseNames
        object: *client
        arguments:
          timeoutMS: 100000
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listDatabases
              databaseName: admin
              command:
                listDatabases: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - createChangeStream on client"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 5
      - name: createChangeStream
        object: *client
        arguments:
          timeoutMS: 100000
          pipeline: []
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - createChangeStream on client"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: createChangeStream
        object: *client
        arguments:
          timeoutMS: 100000
          pipeline: []
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: admin
              command:
                aggregate: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - aggregate on database"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 5
      - name: aggregate
        object: *database
        arguments:
          timeoutMS: 100000
          pipeline: [ { $listLocalSessions: {} }, { $limit: 1 } ]
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - aggregate on database"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: aggregate
        object: *database
        arguments:
          timeoutMS: 100000
          pipeline: [ { $listLocalSessions: {} }, { $limit: 1 } ]
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - aggregate on database"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: aggregate
        object: *database
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          pipeline: [ { $listLocalSessions: {} }, { $limit: 1 } ]
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: 1
                maxTimeMS: { $$lte: *timeoutMS }
  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - listCollections on database"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listCollections"]
              blockConnection: true
              blockTimeMS: 5
      - name: listCollections
        object: *database
        arguments:
          timeoutMS: 100000
          filter: {}
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - listCollections on database"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: listCollections
        object: *database
        arguments:
          timeoutMS: 100000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listCollections
              databaseName: *databaseName
              command:
                listCollections: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - listCollectionNames on database"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listCollections"]
              blockConnection: true
              blockTimeMS: 5
      - name: listCollectionNames
        object: *database
        arguments:
          timeoutMS: 100000
          filter: {}
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - listCollectionNames on database"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: listCollectionNames
        object: *database
        arguments:
          timeoutMS: 100000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listCollections
              databaseName: *databaseName
              command:
                listCollections: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - runCommand on database"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["ping"]
              blockConnection: true
              blockTimeMS: 5
      - name: runCommand
        object: *database
        arguments:
          timeoutMS: 100000
          command: { ping: 1 }
          commandName: ping
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - runCommand on database"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: runCommand
        object: *database
        arguments:
          timeoutMS: 100000
          command: { ping: 1 }
          commandName: ping
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: ping
              databaseName: *databaseName
              command:
                ping: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - createChangeStream on database"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 5
      - name: createChangeStream
        object: *database
        arguments:
          timeoutMS: 100000
          pipeline: []
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - createChangeStream on database"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: createChangeStream
        object: *database
        arguments:
          timeoutMS: 100000
          pipeline: []
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: 1
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - aggregate on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 5
      - name: aggregate
        object: *collection
        arguments:
          timeoutMS: 100000
          pipeline: []
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - aggregate on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: aggregate
        object: *collection
        arguments:
          timeoutMS: 100000
          pipeline: []
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - aggregate on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: aggregate
        object: *collection
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          pipeline: []
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                maxTimeMS: { $$lte: *timeoutMS }
  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - count on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["count"]
              blockConnection: true
              blockTimeMS: 5
      - name: count
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - count on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: count
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: count
              databaseName: *databaseName
              command:
                count: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - count on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: count
        object: *collection
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: count
              databaseName: *databaseName
              command:
                count: *collectionName
                maxTimeMS: { $$lte: *timeoutMS }
  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - countDocuments on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 5
      - name: countDocuments
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - countDocuments on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: countDocuments
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - estimatedDocumentCount on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["count"]
              blockConnection: true
              blockTimeMS: 5
      - name: estimatedDocumentCount
        object: *collection
        arguments:
          timeoutMS: 100000
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - estimatedDocumentCount on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: estimatedDocumentCount
        object: *collection
        arguments:
          timeoutMS: 100000
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: count
              databaseName: *databaseName
              command:
                count: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - estimatedDocumentCount on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: estimatedDocumentCount
        object: *collection
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: count
              databaseName: *databaseName
              command:
                count: *collectionName
                maxTimeMS: { $$lte: *timeoutMS }
  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - distinct on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["distinct"]
              blockConnection: true
              blockTimeMS: 5
      - name: distinct
        object: *collection
        arguments:
          timeoutMS: 100000
          fieldName: x
          filter: {}
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - distinct on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: distinct
        object: *collection
        arguments:
          timeoutMS: 100000
          fieldName: x
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: distinct
              databaseName: *databaseName
              command:
                distinct: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - distinct on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: distinct
        object: *collection
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          fieldName: x
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: distinct
              databaseName: *databaseName
              command:
                distinct: *collectionName
                maxTimeMS: { $$lte: *timeoutMS }
  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - find on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["find"]
              blockConnection: true
              blockTimeMS: 5
      - name: find
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - find on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: find
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - find on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: find
        object: *collection
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                maxTimeMS: { $$lte: *timeoutMS }
  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - findOne on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["find"]
              blockConnection: true
              blockTimeMS: 5
      - name: findOne
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - findOne on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: findOne
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - findOne on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: findOne
        object: *collection
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                maxTimeMS: { $$lte: *timeoutMS }
  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - listIndexes on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listIndexes"]
              blockConnection: true
              blockTimeMS: 5
      - name: listIndexes
        object: *collection
        arguments:
          timeoutMS: 100000
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - listIndexes on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: listIndexes
        object: *collection
        arguments:
          timeoutMS: 100000
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listIndexes
              databaseName: *databaseName
              command:
                listIndexes: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - listIndexNames on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["listIndexes"]
              blockConnection: true
              blockTimeMS: 5
      - name: listIndexNames
        object: *collection
        arguments:
          timeoutMS: 100000
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - listIndexNames on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: listIndexNames
        object: *collection
        arguments:
          timeoutMS: 100000
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: listIndexes
              databaseName: *databaseName
              command:
                listIndexes: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - createChangeStream on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["aggregate"]
              blockConnection: true
              blockTimeMS: 5
      - name: createChangeStream
        object: *collection
        arguments:
          timeoutMS: 100000
          pipeline: []
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - createChangeStream on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: createChangeStream
        object: *collection
        arguments:
          timeoutMS: 100000
          pipeline: []
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: aggregate
              databaseName: *databaseName
              command:
                aggregate: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - insertOne on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["insert"]
              blockConnection: true
              blockTimeMS: 5
      - name: insertOne
        object: *collection
        arguments:
          timeoutMS: 100000
          document: { x: 1 }
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - insertOne on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: insertOne
        object: *collection
        arguments:
          timeoutMS: 100000
          document: { x: 1 }
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: insert
              databaseName: *databaseName
              command:
                insert: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - insertMany on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["insert"]
              blockConnection: true
              blockTimeMS: 5
      - name: insertMany
        object: *collection
        arguments:
          timeoutMS: 100000
          documents:
            - { x: 1 }
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - insertMany on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: insertMany
        object: *collection
        arguments:
          timeoutMS: 100000
          documents:
            - { x: 1 }
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: insert
              databaseName: *databaseName
              command:
                insert: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - deleteOne on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["delete"]
              blockConnection: true
              blockTimeMS: 5
      - name: deleteOne
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - deleteOne on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: deleteOne
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: delete
              databaseName: *databaseName
              command:
                delete: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - deleteMany on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["delete"]
              blockConnection: true
              blockTimeMS: 5
      - name: deleteMany
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - deleteMany on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: deleteMany
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: delete
              databaseName: *databaseName
              command:
                delete: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - replaceOne on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["update"]
              blockConnection: true
              blockTimeMS: 5
      - name: replaceOne
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          replacement: { x: 1 }
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - replaceOne on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: replaceOne
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          replacement: { x: 1 }
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: update
              databaseName: *databaseName
              command:
                update: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - updateOne on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["update"]
              blockConnection: true
              blockTimeMS: 5
      - name: updateOne
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          update: { $set: { x: 1 } }
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - updateOne on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: updateOne
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          update: { $set: { x: 1 } }
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: update
              databaseName: *databaseName
              command:
                update: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - updateMany on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["update"]
              blockConnection: true
              blockTimeMS: 5
      - name: updateMany
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          update: { $set: { x: 1 } }
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - updateMany on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: updateMany
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          update: { $set: { x: 1 } }
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: update
              databaseName: *databaseName
              command:
                update: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - findOneAndDelete on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["findAndModify"]
              blockConnection: true
              blockTimeMS: 5
      - name: findOneAndDelete
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - findOneAndDelete on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: findOneAndDelete
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: findAndModify
              databaseName: *databaseName
              command:
                findAndModify: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - findOneAndDelete on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: findOneAndDelete
        object: *collection
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          filter: {}
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: findAndModify
              databaseName: *databaseName
              command:
                findAndModify: *collectionName
                maxTimeMS: { $$lte: *timeoutMS }
  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - findOneAndReplace on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["findAndModify"]
              blockConnection: true
              blockTimeMS: 5
      - name: findOneAndReplace
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          replacement: { x: 1 }
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - findOneAndReplace on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: findOneAndReplace
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          replacement: { x: 1 }
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: findAndModify
              databaseName: *databaseName
              command:
                findAndModify: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - findOneAndReplace on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: findOneAndReplace
        object: *collection
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          filter: {}
          replacement: { x: 1 }
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: findAndModify
              databaseName: *databaseName
              command:
                findAndModify: *collectionName
                maxTimeMS: { $$lte: *timeoutMS }
  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - findOneAndUpdate on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["findAndModify"]
              blockConnection: true
              blockTimeMS: 5
      - name: findOneAndUpdate
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          update: { $set: { x: 1 } }
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - findOneAndUpdate on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: findOneAndUpdate
        object: *collection
        arguments:
          timeoutMS: 100000
          filter: {}
          update: { $set: { x: 1 } }
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: findAndModify
              databaseName: *databaseName
              command:
                findAndModify: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - findOneAndUpdate on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: findOneAndUpdate
        object: *collection
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          filter: {}
          update: { $set: { x: 1 } }
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: findAndModify
              databaseName: *databaseName
              command:
                findAndModify: *collectionName
                maxTimeMS: { $$lte: *timeoutMS }
  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - bulkWrite on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["insert"]
              blockConnection: true
              blockTimeMS: 5
      - name: bulkWrite
        object: *collection
        arguments:
          timeoutMS: 100000
          requests:
            - insertOne:
                document: { _id: 1 }
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - bulkWrite on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: bulkWrite
        object: *collection
        arguments:
          timeoutMS: 100000
          requests:
            - insertOne:
                document: { _id: 1 }
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: insert
              databaseName: *databaseName
              command:
                insert: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - createIndex on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["createIndexes"]
              blockConnection: true
              blockTimeMS: 5
      - name: createIndex
        object: *collection
        arguments:
          timeoutMS: 100000
          keys: { x: 1 }
          name: "x_1"
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - createIndex on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: createIndex
        object: *collection
        arguments:
          timeoutMS: 100000
          keys: { x: 1 }
          name: "x_1"
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: createIndexes
              databaseName: *databaseName
              command:
                createIndexes: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - createIndex on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: createIndex
        object: *collection
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          keys: { x: 1 }
          name: "x_1"
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: createIndexes
              databaseName: *databaseName
              command:
                createIndexes: *collectionName
                maxTimeMS: { $$lte: *timeoutMS }
  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - dropIndex on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["dropIndexes"]
              blockConnection: true
              blockTimeMS: 5
      # Create the index first so dropIndex doesn't return IndexNotFound on
      # servers prior to 8.3.
      - name: createIndex 
        object: *collection
        arguments:
          keys: { x: 1 }
          timeoutMS: 100000
          name: "x_1"
      - name: dropIndex
        object: *collection
        arguments:
          timeoutMS: 100000
          name: "x_1"
  - description: "wTimeoutMS is ignored if timeoutMS is set - dropIndex on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      # Create the index first so dropIndex doesn't return IndexNotFound on
      # servers prior to 8.3.
      - name: createIndex
        object: *collection
        arguments:
          keys: { x: 1 }
          timeoutMS: 100000
          name: "x_1"
      - name: dropIndex
        object: *collection
        arguments:
          timeoutMS: 100000
          name: "x_1"
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: createIndexes
              databaseName: *databaseName

          - commandStartedEvent:
              commandName: dropIndexes
              databaseName: *databaseName
              command:
                dropIndexes: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - dropIndex on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      # Create the index first so dropIndex doesn't return IndexNotFound on
      # servers prior to 8.3.
      - name: createIndex 
        object: *collection
        arguments:
          keys: { x: 1 }
          name: "x_1"
      - name: dropIndex
        object: *collection
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          name: "x_1"
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: createIndexes
              databaseName: *databaseName

          - commandStartedEvent:
              commandName: dropIndexes
              databaseName: *databaseName
              command:
                dropIndexes: *collectionName
                maxTimeMS: { $$lte: *timeoutMS }
  
  - description: "socketTimeoutMS is ignored if timeoutMS is set - dropIndexes on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  socketTimeoutMS: 1
                useMultipleMongoses: false
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["dropIndexes"]
              blockConnection: true
              blockTimeMS: 5
      # Create the index first so dropIndex doesn't return IndexNotFound on
      # servers prior to 8.3.
      - name: createIndex 
        object: *collection
        arguments:
          keys: { x: 1 }
          name: "x_1"
          timeoutMS: 100000
      - name: dropIndexes
        object: *collection
        arguments:
          timeoutMS: 100000
          
        

  - description: "wTimeoutMS is ignored if timeoutMS is set - dropIndexes on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                uriOptions:
                  wTimeoutMS: 1
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: dropIndexes
        object: *collection
        arguments:
          timeoutMS: 100000
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: dropIndexes
              databaseName: *databaseName
              command:
                dropIndexes: *collectionName
                writeConcern: { $$exists: false }
                maxTimeMS: { $$type: ["int", "long"] }

  - description: "maxTimeMS is ignored if timeoutMS is set - dropIndexes on collection"
    operations:
      - name: createEntities
        object: testRunner
        arguments:
          entities:
            - client:
                id: &client client
                useMultipleMongoses: false
                observeEvents:
                  - commandStartedEvent
                ignoreCommandMonitoringEvents:
                  - killCursors
            - database:
                id: &database database
                client: *client
                databaseName: *databaseName
            - collection:
                id: &collection collection
                database: *database
                collectionName: *collectionName
            - bucket:
                id: &bucket bucket
                database: *database
            - session:
                id: &session session
                client: *client
      - name: dropIndexes
        object: *collection
        arguments:
          timeoutMS: &timeoutMS 1000
          maxTimeMS: 5000
          
        
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: dropIndexes
              databaseName: *databaseName
              command:
                dropIndexes: *collectionName
                maxTimeMS: { $$lte: *timeoutMS }
  
