{
  "description": "command-logging",
  "schemaVersion": "1.13",
  "createEntities": [
    {
      "client": {
        "id": "client",
        "observeLogMessages": {
          "command": "debug"
        }
      }
    },
    {
      "database": {
        "id": "database",
        "client": "client",
        "databaseName": "logging-tests"
      }
    },
    {
      "collection": {
        "id": "collection",
        "database": "database",
        "collectionName": "logging-tests-collection"
      }
    }
  ],
  "initialData": [
    {
      "collectionName": "logging-tests-collection",
      "databaseName": "logging-tests",
      "documents": [
        {
          "_id": 1,
          "x": 11
        }
      ]
    }
  ],
  "tests": [
    {
      "description": "A successful command",
      "operations": [
        {
          "name": "runCommand",
          "object": "database",
          "arguments": {
            "command": {
              "ping": 1
            },
            "commandName": "ping"
          }
        }
      ],
      "expectLogMessages": [
        {
          "client": "client",
          "messages": [
            {
              "level": "debug",
              "component": "command",
              "data": {
                "message": "Command started",
                "databaseName": "logging-tests",
                "commandName": "ping",
                "command": {
                  "$$matchAsDocument": {
                    "$$matchAsRoot": {
                      "ping": 1,
                      "$db": "logging-tests"
                    }
                  }
                },
                "requestId": {
                  "$$type": [
                    "int",
                    "long"
                  ]
                },
                "serverHost": {
                  "$$type": "string"
                },
                "serverPort": {
                  "$$type": [
                    "int",
                    "long"
                  ]
                }
              }
            },
            {
              "level": "debug",
              "component": "command",
              "data": {
                "message": "Command succeeded",
                "databaseName": "logging-tests",
                "commandName": "ping",
                "reply": {
                  "$$type": "string"
                },
                "requestId": {
                  "$$type": [
                    "int",
                    "long"
                  ]
                },
                "serverHost": {
                  "$$type": "string"
                },
                "serverPort": {
                  "$$type": [
                    "int",
                    "long"
                  ]
                },
                "durationMS": {
                  "$$type": [
                    "double",
                    "int",
                    "long"
                  ]
                }
              }
            }
          ]
        }
      ]
    },
    {
      "description": "A failed command",
      "operations": [
        {
          "name": "find",
          "object": "collection",
          "arguments": {
            "filter": {
              "$or": true
            }
          },
          "expectError": {
            "isClientError": false
          }
        }
      ],
      "expectLogMessages": [
        {
          "client": "client",
          "messages": [
            {
              "level": "debug",
              "component": "command",
              "data": {
                "message": "Command started",
                "databaseName": "logging-tests",
                "commandName": "find",
                "command": {
                  "$$type": "string"
                },
                "requestId": {
                  "$$type": [
                    "int",
                    "long"
                  ]
                },
                "serverHost": {
                  "$$type": "string"
                },
                "serverPort": {
                  "$$type": [
                    "int",
                    "long"
                  ]
                }
              }
            },
            {
              "level": "debug",
              "component": "command",
              "data": {
                "message": "Command failed",
                "databaseName": "logging-tests",
                "commandName": "find",
                "failure": {
                  "$$exists": true
                },
                "requestId": {
                  "$$type": [
                    "int",
                    "long"
                  ]
                },
                "serverHost": {
                  "$$type": "string"
                },
                "serverPort": {
                  "$$type": [
                    "int",
                    "long"
                  ]
                },
                "durationMS": {
                  "$$type": [
                    "double",
                    "int",
                    "long"
                  ]
                }
              }
            }
          ]
        }
      ]
    }
  ]
}
