# Integration tests for HDFS Repository plugin
#
# Actually perform a snapshot to hdfs
#
---
"take snapshot":
  # Create repository
  - do:
      snapshot.create_repository:
        repository: test_snapshot_repository
        body:
          type: hdfs
          settings:
            uri: "hdfs://localhost:9998"
            path: "/user/elasticsearch/test/snapshot"
            security:
              principal: "elasticsearch@BUILD.ELASTIC.CO"

  # Create index
  - do:
      indices.create:
        index: test_index
        body:
          settings:
            number_of_shards:   1
            number_of_replicas: 1

  # Create snapshot
  - do:
      snapshot.create:
        repository: test_snapshot_repository
        snapshot: test_snapshot
        wait_for_completion: true

  - match: { snapshot.snapshot: test_snapshot }
  - match: { snapshot.state : SUCCESS }
  - match: { snapshot.shards.successful: 1 }
  - match: { snapshot.shards.failed : 0 }

  # Remove our snapshot
  - do: 
      snapshot.delete:
        repository: test_snapshot_repository
        snapshot: test_snapshot

  # Remove our repository
  - do:
     snapshot.delete_repository:
       repository: test_snapshot_repository

