{
  "description": "server-selection-logging",
  "schemaVersion": "1.13",
  "runOnRequirements": [
    {
      "topologies": [
        "load-balanced"
      ]
    }
  ],
  "createEntities": [
    {
      "client": {
        "id": "client",
        "uriOptions": {
          "heartbeatFrequencyMS": 500
        },
        "observeLogMessages": {
          "serverSelection": "debug"
        },
        "observeEvents": [
          "serverDescriptionChangedEvent"
        ]
      }
    },
    {
      "database": {
        "id": "database",
        "client": "client",
        "databaseName": "logging-tests"
      }
    },
    {
      "collection": {
        "id": "collection",
        "database": "database",
        "collectionName": "server-selection"
      }
    }
  ],
  "tests": [
    {
      "description": "A successful operation - load balanced cluster",
      "operations": [
        {
          "name": "waitForEvent",
          "object": "testRunner",
          "arguments": {
            "client": "client",
            "event": {
              "serverDescriptionChangedEvent": {
                "newDescription": {
                  "type": "LoadBalancer"
                }
              }
            },
            "count": 1
          }
        },
        {
          "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
                }
              }
            }
          ]
        }
      ]
    }
  ]
}
