{
  "description": "hello-timeout",
  "schemaVersion": "1.4",
  "runOnRequirements": [
    {
      "minServerVersion": "4.4",
      "serverless": "forbid",
      "topologies": [
        "single",
        "replicaset",
        "sharded"
      ]
    }
  ],
  "createEntities": [
    {
      "client": {
        "id": "setupClient",
        "useMultipleMongoses": false
      }
    }
  ],
  "initialData": [
    {
      "collectionName": "hello-timeout",
      "databaseName": "sdam-tests",
      "documents": []
    }
  ],
  "tests": [
    {
      "description": "Network timeout on Monitor handshake",
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "setupClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 2
              },
              "data": {
                "failCommands": [
                  "hello",
                  "isMaster"
                ],
                "appName": "timeoutMonitorHandshakeTest",
                "blockConnection": true,
                "blockTimeMS": 1000
              }
            }
          }
        },
        {
          "name": "createEntities",
          "object": "testRunner",
          "arguments": {
            "entities": [
              {
                "client": {
                  "id": "client",
                  "useMultipleMongoses": false,
                  "observeEvents": [
                    "commandStartedEvent",
                    "serverDescriptionChangedEvent",
                    "poolClearedEvent"
                  ],
                  "uriOptions": {
                    "retryWrites": false,
                    "connectTimeoutMS": 250,
                    "heartbeatFrequencyMS": 500,
                    "appname": "timeoutMonitorHandshakeTest"
                  }
                }
              },
              {
                "database": {
                  "id": "database",
                  "client": "client",
                  "databaseName": "sdam-tests"
                }
              },
              {
                "collection": {
                  "id": "collection",
                  "database": "database",
                  "collectionName": "hello-timeout"
                }
              }
            ]
          }
        },
        {
          "name": "waitForEvent",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "serverDescriptionChangedEvent": {
                "newDescription": {
                  "type": "Unknown"
                }
              }
            },
            "count": 1
          }
        },
        {
          "name": "insertMany",
          "object": "collection",
          "arguments": {
            "documents": [
              {
                "_id": 1
              },
              {
                "_id": 2
              }
            ]
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "eventType": "command",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "hello-timeout",
                  "documents": [
                    {
                      "_id": 1
                    },
                    {
                      "_id": 2
                    }
                  ]
                },
                "commandName": "insert",
                "databaseName": "sdam-tests"
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "hello-timeout",
          "databaseName": "sdam-tests",
          "documents": [
            {
              "_id": 1
            },
            {
              "_id": 2
            }
          ]
        }
      ]
    },
    {
      "description": "Network timeout on Monitor check",
      "operations": [
        {
          "name": "createEntities",
          "object": "testRunner",
          "arguments": {
            "entities": [
              {
                "client": {
                  "id": "client",
                  "useMultipleMongoses": false,
                  "observeEvents": [
                    "commandStartedEvent",
                    "serverDescriptionChangedEvent",
                    "poolClearedEvent"
                  ],
                  "uriOptions": {
                    "retryWrites": false,
                    "connectTimeoutMS": 750,
                    "heartbeatFrequencyMS": 500,
                    "appname": "timeoutMonitorCheckTest"
                  }
                }
              },
              {
                "database": {
                  "id": "database",
                  "client": "client",
                  "databaseName": "sdam-tests"
                }
              },
              {
                "collection": {
                  "id": "collection",
                  "database": "database",
                  "collectionName": "hello-timeout"
                }
              }
            ]
          }
        },
        {
          "name": "insertMany",
          "object": "collection",
          "arguments": {
            "documents": [
              {
                "_id": 1
              },
              {
                "_id": 2
              }
            ]
          }
        },
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": {
                "times": 4
              },
              "data": {
                "failCommands": [
                  "hello",
                  "isMaster"
                ],
                "appName": "timeoutMonitorCheckTest",
                "blockConnection": true,
                "blockTimeMS": 1000
              }
            },
            "client": "setupClient"
          }
        },
        {
          "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": "insertMany",
          "object": "collection",
          "arguments": {
            "documents": [
              {
                "_id": 3
              },
              {
                "_id": 4
              }
            ]
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "eventType": "command",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "hello-timeout",
                  "documents": [
                    {
                      "_id": 1
                    },
                    {
                      "_id": 2
                    }
                  ]
                },
                "commandName": "insert",
                "databaseName": "sdam-tests"
              }
            },
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "hello-timeout",
                  "documents": [
                    {
                      "_id": 3
                    },
                    {
                      "_id": 4
                    }
                  ]
                },
                "commandName": "insert",
                "databaseName": "sdam-tests"
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "hello-timeout",
          "databaseName": "sdam-tests",
          "documents": [
            {
              "_id": 1
            },
            {
              "_id": 2
            },
            {
              "_id": 3
            },
            {
              "_id": 4
            }
          ]
        }
      ]
    },
    {
      "description": "Driver extends timeout while streaming",
      "operations": [
        {
          "name": "createEntities",
          "object": "testRunner",
          "arguments": {
            "entities": [
              {
                "client": {
                  "id": "client",
                  "observeEvents": [
                    "commandStartedEvent",
                    "serverDescriptionChangedEvent",
                    "poolClearedEvent"
                  ],
                  "uriOptions": {
                    "retryWrites": false,
                    "connectTimeoutMS": 250,
                    "heartbeatFrequencyMS": 500,
                    "appname": "extendsTimeoutTest"
                  }
                }
              },
              {
                "database": {
                  "id": "database",
                  "client": "client",
                  "databaseName": "sdam-tests"
                }
              },
              {
                "collection": {
                  "id": "collection",
                  "database": "database",
                  "collectionName": "hello-timeout"
                }
              }
            ]
          }
        },
        {
          "name": "insertMany",
          "object": "collection",
          "arguments": {
            "documents": [
              {
                "_id": 1
              },
              {
                "_id": 2
              }
            ]
          }
        },
        {
          "name": "wait",
          "object": "testRunner",
          "arguments": {
            "ms": 2000
          }
        },
        {
          "name": "insertMany",
          "object": "collection",
          "arguments": {
            "documents": [
              {
                "_id": 3
              },
              {
                "_id": 4
              }
            ]
          }
        },
        {
          "name": "assertEventCount",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "serverDescriptionChangedEvent": {
                "newDescription": {
                  "type": "Unknown"
                }
              }
            },
            "count": 0
          }
        },
        {
          "name": "assertEventCount",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "poolClearedEvent": {}
            },
            "count": 0
          }
        }
      ],
      "expectEvents": [
        {
          "client": "client",
          "eventType": "command",
          "events": [
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "hello-timeout",
                  "documents": [
                    {
                      "_id": 1
                    },
                    {
                      "_id": 2
                    }
                  ]
                },
                "commandName": "insert",
                "databaseName": "sdam-tests"
              }
            },
            {
              "commandStartedEvent": {
                "command": {
                  "insert": "hello-timeout",
                  "documents": [
                    {
                      "_id": 3
                    },
                    {
                      "_id": 4
                    }
                  ]
                },
                "commandName": "insert",
                "databaseName": "sdam-tests"
              }
            }
          ]
        }
      ],
      "outcome": [
        {
          "collectionName": "hello-timeout",
          "databaseName": "sdam-tests",
          "documents": [
            {
              "_id": 1
            },
            {
              "_id": 2
            },
            {
              "_id": 3
            },
            {
              "_id": 4
            }
          ]
        }
      ]
    }
  ]
}
