---
"Basic test for upgrade indices":

  - do:
      indices.create:
        index: test_index
        body:
          settings:
            index:
              number_of_replicas: 0

  - do:
      indices.upgrade:
        index: test_index

  - match: {upgraded_indices.test_index.oldest_lucene_segment_version: '/(\d\.)+\d/'}
  - is_true: upgraded_indices.test_index.upgrade_version

---
"Upgrade indices ignore unavailable":
  - skip:
      version: " - 5.0.0"
      reason: ignore_unavailable was added as a bugfix in 5.0.1 see #21281

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

  - do:
      indices.upgrade:
        index: ["does_not_exist", "test_index"]
        ignore_unavailable: true

  - match: {_shards.total: 1}
  - is_true: upgraded_indices.test_index.upgrade_version
  - is_false: upgraded_indices.does_not_exist

---
"Upgrade indices allow no indices":

  - skip:
      version: " - 5.0.0"
      reason: ignore_unavailable was added as a bugfix in 5.0.1 see #21281

  - do:
      indices.upgrade:
        index: test_index
        ignore_unavailable: true
        allow_no_indices: true

  - match: {_shards.total: 0}

---
"Upgrade indices disallow no indices":

  - skip:
      version: " - 5.0.0"
      reason: ignore_unavailable was added as a bugfix in 5.0.1 see #21281

  - do:
      catch: missing
      indices.upgrade:
        index: test_index
        ignore_unavailable: true
        allow_no_indices: false

---
"Upgrade indices disallow unavailable":

  - skip:
      version: " - 5.0.0"
      reason: ignore_unavailable was added as a bugfix in 5.0.1 see #21281

  - do:
      indices.create:
        index: test_index

  - do:
      catch: missing
      indices.upgrade:
        index: ["test_index", "does_not_exist"]
        ignore_unavailable: false

