# Integration tests for HDFS Repository plugin
#
# Tests retrieving information about snapshot
#
---
"Get a snapshot":
  # Create repository
  - do:
      snapshot.create_repository:
        repository: test_snapshot_get_repository
        body:
          type: hdfs
          settings:
            uri: "hdfs://localhost:9999"
            path: "test/snapshot_get"

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

  # Wait for green
  - do:
      cluster.health:
        wait_for_status: green

  # Create snapshot
  - do:
      snapshot.create:
        repository: test_snapshot_get_repository
        snapshot: test_snapshot_get
        wait_for_completion: true

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

  # Get snapshot info
  - do:
      snapshot.get:
        repository: test_snapshot_get_repository
        snapshot: test_snapshot_get

  - length: { snapshots: 1 }
  - match: { snapshots.0.snapshot : test_snapshot_get }

  # List snapshot info
  - do:
      snapshot.get:
        repository: test_snapshot_get_repository
        snapshot: "*"

  - length: { snapshots: 1 }
  - match: { snapshots.0.snapshot : test_snapshot_get }

  # Remove our snapshot
  - do: 
      snapshot.delete:
        repository: test_snapshot_get_repository
        snapshot: test_snapshot_get

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