All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rest-api-spec.test.indices.simulate_template.10_basic.yml Maven / Gradle / Ivy

The newest version!
---
"Simulate template without a template in the body":
  - skip:
      version: " - 7.8.99"
      reason: "only available in 7.9+"
      features: ["default_shards"]

  - do:
      indices.put_index_template:
        name: my-template
        body:
          index_patterns: other
          template:
            settings:
              number_of_shards:   1
              number_of_replicas: 0
            mappings:
              properties:
                field:
                  type: keyword

  - do:
      indices.simulate_template:
        name: my-template

  - match: {template.settings.index.number_of_shards: "1"}
  - match: {template.settings.index.number_of_replicas: "0"}
  - match: {template.mappings.properties.field.type: "keyword"}
  - match: {overlapping: []}

---
"Simulate index template specifying a new template":
  - skip:
      version: " - 7.8.99"
      reason: "only available in 7.9+"
      features: ["default_shards"]

  - do:
      indices.put_index_template:
        name: existing_test
        body:
          index_patterns: te*
          priority: 10
          template:
            settings:
              number_of_shards:   1
              number_of_replicas: 0
            mappings:
              properties:
                field:
                  type: keyword

  - do:
      cluster.put_component_template:
        name: ct
        body:
          template:
            settings:
              index.number_of_replicas: 2
            mappings:
              properties:
                ct_field:
                  type: keyword

  - do:
      indices.simulate_template:
        body:
          index_patterns: te*
          priority: 15
          template:
            settings:
              index.blocks.write: true
            aliases:
              test_alias: {}
          composed_of: ["ct"]

  - match: {template.settings.index.blocks.write: "true"}
  - match: {template.settings.index.number_of_replicas: "2"}
  - match: {template.mappings.properties.ct_field.type: "keyword"}
  - match: {overlapping.0.name: existing_test}
  - match: {overlapping.0.index_patterns: ["te*"]}
  - length: {template.aliases: 1}
  - is_true: template.aliases.test_alias

---
"Simulate template matches overlapping legacy and composable templates":
  - skip:
      version: " - 7.8.99"
      reason: "only available in 7.9+"
      features: ["allowed_warnings", "default_shards"]

  - do:
      indices.put_template:
        name: v1_template
        body:
          index_patterns: [t*, t1*]
          settings:
            number_of_shards:   5

  - do:
      allowed_warnings:
        - "index template [v2_template] has index patterns [te*] matching patterns from existing older templates [v1_template] with patterns
        (v1_template => [t*, t1*]); this template [v2_template] will take precedence during new index creation"
      indices.put_index_template:
        name: v2_template
        body:
          index_patterns: te*
          priority: 10
          template:
            settings:
              number_of_shards:   10
              number_of_replicas: 2
            mappings:
              properties:
                field:
                  type: text

  - do:
      allowed_warnings:
        - "index template [winning_v2_template] has index patterns [te*] matching patterns from existing older templates [v1_template] with patterns
        (v1_template => [t*, t1*]); this template [winning_v2_template] will take precedence during new index creation"
      indices.put_index_template:
        name: winning_v2_template
        body:
          index_patterns: te*
          priority: 20
          template:
            settings:
              number_of_shards:   1
              number_of_replicas: 0
            mappings:
              properties:
                field:
                  type: keyword

  - do:
      indices.simulate_template:
        name: winning_v2_template

  - match: {template.settings.index.number_of_shards: "1"}
  - match: {template.settings.index.number_of_replicas: "0"}
  - match: {template.mappings.properties.field.type: "keyword"}
  - match: {overlapping.0.name: v1_template}
  - match: {overlapping.0.index_patterns: ["t*", "t1*"]}
  - match: {overlapping.1.name: v2_template}
  - match: {overlapping.1.index_patterns: ["te*"]}

---
"Simulate replacing a template with a newer version":
  - skip:
      version: " - 7.99.99"
      reason: "not yet backported"
      features: ["allowed_warnings", "default_shards"]

  - do:
      indices.put_index_template:
        name: v2_template
        body:
          index_patterns: te*
          priority: 10
          template:
            settings:
              number_of_shards:   10
              number_of_replicas: 2
            mappings:
              properties:
                field:
                  type: text

  - do:
      cluster.put_component_template:
        name: ct
        body:
          template:
            settings:
              index.number_of_replicas: 3
            mappings:
              properties:
                ct_field:
                  type: keyword

  - do:
      indices.simulate_template:
        name: v2_template
        body:
          index_patterns: te*
          priority: 10
          template:
            settings:
              index.blocks.write: true
            aliases:
              test_alias: {}
          composed_of: ["ct"]

  - match: {template.settings.index.blocks.write: "true"}
  - match: {template.settings.index.number_of_replicas: "3"}
  - match: {template.mappings.properties.ct_field.type: "keyword"}
  - length: {template.aliases: 1}
  - is_true: template.aliases.test_alias
  - length: {overlapping: 0}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy