description: "command"

schemaVersion: "1.0"

createEntities:
  - client:
      id: &client client
      observeEvents:
        - commandStartedEvent
        - commandSucceededEvent
        - commandFailedEvent
  - database:
      id: &database database
      client: *client
      databaseName: &databaseName command-monitoring-tests
  - collection:
      id: &collection collection
      database: *database
      collectionName: &collectionName test

initialData:
  - collectionName: *collectionName
    databaseName: *databaseName
    documents:
      - { _id: 1, x: 11 }

tests:
  - description: "A successful command"
    operations:
      - name: runCommand
        object: *database
        arguments:
          command: { ping: 1 }
          commandName: ping
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              command:
                ping: 1
              commandName: ping
              databaseName: *databaseName
          - commandSucceededEvent:
              reply:
                ok: 1
              commandName: ping

# The legacy "A failed command event" test was removed in the test conversion, as the
# behavior when a command fails is already covered by the test "A failed find event"
# in find.yml.
