---
"Get backing indices for data stream":
  - requires:
      cluster_features: ["gte_v7.9.0"]
      reason: "data streams only supported in 7.9+"
      test_runner_features: allowed_warnings

  - do:
      allowed_warnings:
        - "index template [my-template] has index patterns [data-*] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template] will take precedence during new index creation"
      indices.put_index_template:
        name: my-template
        body:
          index_patterns: [data-*]
          data_stream: {}

  - do:
      indices.create_data_stream:
        name: data-stream1
  - is_true: acknowledged

  # save the backing index names for later use
  - do:
      indices.get_data_stream:
        name: data-stream1
  - set: { data_streams.0.indices.0.index_name: idx0name }

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

  - do:
      indices.get:
        index: ['.ds-data-stream1-*000001', 'test_index']

  - is_true: .$idx0name.settings
  - is_true: .$idx0name.data_stream
  - match: { .$idx0name.data_stream: data-stream1 }
  - is_true: test_index.settings
  - is_false: test_index.data_stream

  - do:
      indices.delete_data_stream:
        name: data-stream1
  - is_true: acknowledged
