{
  "description": "standalone-logging",
  "schemaVersion": "1.14",
  "runOnRequirements": [
    {
      "topologies": [
        "single"
      ]
    }
  ],
  "createEntities": [
    {
      "client": {
        "id": "client",
        "uriOptions": {
          "retryWrites": false,
          "heartbeatFrequencyMS": 500,
          "appName": "loggingClient",
          "serverSelectionTimeoutMS": 2000
        },
        "observeLogMessages": {
          "serverSelection": "debug"
        },
        "observeEvents": [
          "serverDescriptionChangedEvent",
          "topologyDescriptionChangedEvent"
        ]
      }
    },
    {
      "database": {
        "id": "database",
        "client": "client",
        "databaseName": "logging-tests"
      }
    },
    {
      "collection": {
        "id": "collection",
        "database": "database",
        "collectionName": "server-selection"
      }
    },
    {
      "client": {
        "id": "failPointClient"
      }
    }
  ],
  "tests": [
    {
      "description": "A successful operation",
      "operations": [
        {
          "name": "waitForEvent",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "topologyDescriptionChangedEvent": {}
            },
            "count": 2
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "document": {
              "x": 1
            }
          }
        }
      ],
      "expectLogMessages": [
        {
          "client": "client",
          "messages": [
            {
              "level": "debug",
              "component": "serverSelection",
              "data": {
                "message": "Server selection started",
                "selector": {
                  "$$exists": true
                },
                "operation": "insert",
                "topologyDescription": {
                  "$$exists": true
                }
              }
            },
            {
              "level": "debug",
              "component": "serverSelection",
              "data": {
                "message": "Server selection succeeded",
                "selector": {
                  "$$exists": true
                },
                "operation": "insert",
                "topologyDescription": {
                  "$$exists": true
                },
                "serverHost": {
                  "$$type": "string"
                },
                "serverPort": {
                  "$$type": [
                    "int",
                    "long"
                  ]
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "Failure due to unreachable server",
      "runOnRequirements": [
        {
          "minServerVersion": "4.4"
        }
      ],
      "operations": [
        {
          "name": "failPoint",
          "object": "testRunner",
          "arguments": {
            "client": "failPointClient",
            "failPoint": {
              "configureFailPoint": "failCommand",
              "mode": "alwaysOn",
              "data": {
                "failCommands": [
                  "hello",
                  "ismaster"
                ],
                "appName": "loggingClient",
                "closeConnection": true
              }
            }
          }
        },
        {
          "name": "waitForEvent",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "serverDescriptionChangedEvent": {
                "newDescription": {
                  "type": "Unknown"
                }
              }
            },
            "count": 1
          }
        },
        {
          "name": "insertOne",
          "object": "collection",
          "arguments": {
            "document": {
              "x": 1
            }
          },
          "expectError": {
            "isClientError": true
          }
        }
      ],
      "expectLogMessages": [
        {
          "client": "client",
          "messages": [
            {
              "level": "debug",
              "component": "serverSelection",
              "data": {
                "message": "Server selection started",
                "selector": {
                  "$$exists": true
                },
                "operation": "insert",
                "topologyDescription": {
                  "$$exists": true
                }
              }
            },
            {
              "level": "info",
              "component": "serverSelection",
              "data": {
                "message": "Waiting for suitable server to become available",
                "selector": {
                  "$$exists": true
                },
                "operation": "insert",
                "topologyDescription": {
                  "$$exists": true
                },
                "remainingTimeMS": {
                  "$$type": [
                    "int",
                    "long"
                  ]
                }
              }
            },
            {
              "level": "debug",
              "component": "serverSelection",
              "data": {
                "message": "Server selection failed",
                "selector": {
                  "$$exists": true
                },
                "operation": "insert",
                "topologyDescription": {
                  "$$exists": true
                },
                "failure": {
                  "$$exists": true
                }
              }
            }
          ]
        }
      ]
    }
  ]
}
