{
  "description": "find-shutdown-error",
  "schemaVersion": "1.4",
  "runOnRequirements": [
    {
      "minServerVersion": "4.4",
      "serverless": "forbid",
      "topologies": [
        "single",
        "replicaset",
        "sharded"
      ]
    }
  ],
  "createEntities": [
    {
      "client": {
        "id": "setupClient",
        "useMultipleMongoses": false
      }
    }
  ],
  "initialData": [
    {
      "collectionName": "find-shutdown-error",
      "databaseName": "sdam-tests",
      "documents": []
    }
  ],
  "tests": [
    {
      "description": "Concurrent shutdown error on find",
      "operations": [
        {
          "name": "createEntities",
          "object": "testRunner",
          "arguments": {
            "entities": [
              {
                "client": {
                  "id": "client",
                  "useMultipleMongoses": false,
                  "uriOptions": {
                    "retryWrites": false,
                    "retryReads": false,
                    "heartbeatFrequencyMS": 500,
                    "appname": "shutdownErrorFindTest"
                  },
                  "observeEvents": [
                    "serverDescriptionChangedEvent",
                    "poolClearedEvent"
                  ]
                }
              },
              {
                "database": {
                  "id": "database",
                  "client": "client",
                  "databaseName": "sdam-tests"
                }
              },
              {
                "collection": {
                  "id": "collection",
                  "database": "database",
                  "collectionName": "find-shutdown-error"
                }
              }
            ]
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "document": {
              "_id": 1
            }
          }
        },
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "find"
                ],
                "appName": "shutdownErrorFindTest",
                "errorCode": 91,
                "blockConnection": true,
                "blockTimeMS": 500
              }
            },
            "client": "setupClient"
          }
        },
        {
          "name": "createEntities",
          "object": "testRunner",
          "arguments": {
            "entities": [
              {
                "thread": {
                  "id": "thread0"
                }
              },
              {
                "thread": {
                  "id": "thread1"
                }
              }
            ]
          }
        },
        {
          "name": "runOnThread",
          "object": "testRunner",
          "arguments": {
            "thread": "thread0",
            "operation": {
              "name": "find",
              "object": "collection",
              "arguments": {
                "filter": {
                  "_id": 1
                }
              },
              "expectError": {
                "isError": true
              }
            }
          }
        },
        {
          "name": "runOnThread",
          "object": "testRunner",
          "arguments": {
            "thread": "thread1",
            "operation": {
              "name": "find",
              "object": "collection",
              "arguments": {
                "filter": {
                  "_id": 1
                }
              },
              "expectError": {
                "isError": true
              }
            }
          }
        },
        {
          "name": "waitForThread",
          "object": "testRunner",
          "arguments": {
            "thread": "thread0"
          }
        },
        {
          "name": "waitForThread",
          "object": "testRunner",
          "arguments": {
            "thread": "thread1"
          }
        },
        {
          "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": 4
            }
          }
        },
        {
          "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": "find-shutdown-error",
          "databaseName": "sdam-tests",
          "documents": [
            {
              "_id": 1
            },
            {
              "_id": 4
            }
          ]
        }
      ]
    }
  ]
}
