{
  "description": "cancel-server-check",
  "schemaVersion": "1.4",
  "runOnRequirements": [
    {
      "minServerVersion": "4.0",
      "topologies": [
        "replicaset"
      ],
      "serverless": "forbid"
    },
    {
      "minServerVersion": "4.2",
      "topologies": [
        "sharded"
      ],
      "serverless": "forbid"
    }
  ],
  "createEntities": [
    {
      "client": {
        "id": "setupClient",
        "useMultipleMongoses": false
      }
    }
  ],
  "initialData": [
    {
      "collectionName": "cancel-server-check",
      "databaseName": "sdam-tests",
      "documents": []
    }
  ],
  "tests": [
    {
      "description": "Cancel server check",
      "operations": [
        {
          "name": "createEntities",
          "object": "testRunner",
          "arguments": {
            "entities": [
              {
                "client": {
                  "id": "client",
                  "useMultipleMongoses": false,
                  "observeEvents": [
                    "serverDescriptionChangedEvent",
                    "poolClearedEvent"
                  ],
                  "uriOptions": {
                    "retryWrites": true,
                    "heartbeatFrequencyMS": 10000,
                    "serverSelectionTimeoutMS": 5000,
                    "appname": "cancelServerCheckTest"
                  }
                }
              },
              {
                "database": {
                  "id": "database",
                  "client": "client",
                  "databaseName": "sdam-tests"
                }
              },
              {
                "collection": {
                  "id": "collection",
                  "database": "database",
                  "collectionName": "cancel-server-check"
                }
              }
            ]
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "document": {
              "_id": 1
            }
          }
        },
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 1
              },
              "data": {
                "failCommands": [
                  "insert"
                ],
                "closeConnection": true
              }
            },
            "client": "setupClient"
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "document": {
              "_id": 2
            }
          },
          "expectResult": {
            "insertedId": 2
          }
        },
        {
          "name": "waitForEvent",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "serverDescriptionChangedEvent": {
                "newDescription": {
                  "type": "Unknown"
                }
              }
            },
            "count": 1
          }
        },
        {
          "name": "waitForEvent",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "poolClearedEvent": {}
            },
            "count": 1
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "document": {
              "_id": 3
            }
          },
          "expectResult": {
            "insertedId": 3
          }
        },
        {
          "name": "assertEventCount",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "serverDescriptionChangedEvent": {
                "newDescription": {
                  "type": "Unknown"
                }
              }
            },
            "count": 1
          }
        },
        {
          "name": "assertEventCount",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "poolClearedEvent": {}
            },
            "count": 1
          }
        }
      ],
      "outcome": [
        {
          "collectionName": "cancel-server-check",
          "databaseName": "sdam-tests",
          "documents": [
            {
              "_id": 1
            },
            {
              "_id": 2
            },
            {
              "_id": 3
            }
          ]
        }
      ]
    }
  ]
}
