{
  "description": "pool-cleared-on-min-pool-size-population-error",
  "schemaVersion": "1.4",
  "runOnRequirements": [
    {
      "minServerVersion": "4.4",
      "serverless": "forbid",
      "topologies": [
        "single"
      ]
    }
  ],
  "createEntities": [
    {
      "client": {
        "id": "setupClient",
        "useMultipleMongoses": false
      }
    }
  ],
  "tests": [
    {
      "description": "Pool is cleared on authentication error during minPoolSize population",
      "runOnRequirements": [
        {
          "auth": true
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "setupClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 1
              },
              "data": {
                "failCommands": [
                  "saslContinue"
                ],
                "appName": "authErrorTest",
                "errorCode": 18
              }
            }
          }
        },
        {
          "name": "createEntities",
          "object": "testRunner",
          "arguments": {
            "entities": [
              {
                "client": {
                  "id": "client",
                  "observeEvents": [
                    "connectionCreatedEvent",
                    "poolClearedEvent",
                    "connectionClosedEvent"
                  ],
                  "uriOptions": {
                    "appname": "authErrorTest",
                    "minPoolSize": 1
                  }
                }
              }
            ]
          }
        },
        {
          "name": "waitForEvent",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "poolClearedEvent": {}
            },
            "count": 1
          }
        },
        {
          "name": "waitForEvent",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "connectionClosedEvent": {}
            },
            "count": 1
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "eventType": "cmap",
          "events": [
            {
              "connectionCreatedEvent": {}
            },
            {
              "poolClearedEvent": {}
            },
            {
              "connectionClosedEvent": {}
            }
          ]
        }
      ]
    },
    {
      "description": "Pool is cleared on handshake error during minPoolSize population",
      "operations": [
        {
          "name": "createEntities",
          "object": "testRunner",
          "arguments": {
            "entities": [
              {
                "client": {
                  "id": "client",
                  "observeEvents": [
                    "topologyDescriptionChangedEvent",
                    "connectionCreatedEvent",
                    "poolClearedEvent",
                    "connectionClosedEvent",
                    "connectionReadyEvent"
                  ],
                  "uriOptions": {
                    "appname": "authErrorTest",
                    "minPoolSize": 5,
                    "maxConnecting": 1,
                    "serverMonitoringMode": "poll",
                    "heartbeatFrequencyMS": 1000000
                  }
                }
              }
            ]
          }
        },
        {
          "name": "waitForEvent",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "topologyDescriptionChangedEvent": {
                "previousDescription": {
                  "type": "Unknown"
                },
                "newDescription": {
                  "type": "Single"
                }
              }
            },
            "count": 1
          }
        },
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "setupClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 1
              },
              "data": {
                "failCommands": [
                  "hello",
                  "isMaster"
                ],
                "appName": "authErrorTest",
                "closeConnection": true
              }
            }
          }
        },
        {
          "name": "waitForEvent",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "poolClearedEvent": {}
            },
            "count": 1
          }
        },
        {
          "name": "waitForEvent",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "connectionClosedEvent": {}
            },
            "count": 1
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "eventType": "cmap",
          "events": [
            {
              "connectionCreatedEvent": {}
            },
            {
              "connectionReadyEvent": {}
            },
            {
              "connectionCreatedEvent": {}
            },
            {
              "poolClearedEvent": {}
            },
            {
              "connectionClosedEvent": {}
            }
          ]
        }
      ]
    }
  ]
}
