-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utilise the migrate template API when applying changes to the deployment template id #547
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:feature | ||
resource/deployment: Utilise the template migration API to build the base update request when changing `deployment_template_id`. This results in more reliable changes between deployment templates. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package acc | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccDeployment_template_migration(t *testing.T) { | ||
resName := "ec_deployment.compute_optimized" | ||
randomName := prefix + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) | ||
basicCfg := "testdata/deployment_compute_optimized_1.tf" | ||
region := getRegion() | ||
cfg := fixtureAccDeploymentResourceBasicDefaults(t, basicCfg, randomName, region, computeOpTemplate) | ||
secondConfigCfg := fixtureAccDeploymentResourceBasicDefaults(t, basicCfg, randomName, region, memoryOpTemplate) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: testAccProviderFactory, | ||
CheckDestroy: testAccDeploymentDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
// Create a Compute Optimized deployment with the default settings. | ||
Config: cfg, | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr(resName, "deployment_template_id", setDefaultTemplate(region, computeOpTemplate)), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.#", "1"), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.#", "1"), | ||
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.topology.0.instance_configuration_id"), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.size", "8g"), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.size_resource", "memory"), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_data", ""), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_ingest", ""), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_master", ""), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_ml", ""), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.id", "hot_content"), | ||
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.topology.0.node_roles.#"), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.zone_count", "2"), | ||
resource.TestCheckResourceAttr(resName, "kibana.#", "1"), | ||
resource.TestCheckResourceAttr(resName, "kibana.0.topology.0.zone_count", "1"), | ||
resource.TestCheckResourceAttr(resName, "kibana.0.topology.#", "1"), | ||
resource.TestCheckResourceAttrSet(resName, "kibana.0.topology.0.instance_configuration_id"), | ||
resource.TestCheckResourceAttr(resName, "kibana.0.topology.0.size", "1g"), | ||
resource.TestCheckResourceAttr(resName, "kibana.0.topology.0.size_resource", "memory"), | ||
resource.TestCheckResourceAttr(resName, "apm.#", "0"), | ||
resource.TestCheckResourceAttr(resName, "enterprise_search.#", "0"), | ||
), | ||
}, | ||
{ | ||
// Change the deployment to memory optimized | ||
Config: secondConfigCfg, | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr(resName, "deployment_template_id", setDefaultTemplate(region, memoryOpTemplate)), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.#", "1"), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.#", "1"), | ||
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.topology.0.instance_configuration_id"), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.size", "8g"), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.size_resource", "memory"), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_data", ""), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_ingest", ""), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_master", ""), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.node_type_ml", ""), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.id", "hot_content"), | ||
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.topology.0.node_roles.#"), | ||
resource.TestCheckResourceAttr(resName, "elasticsearch.0.topology.0.zone_count", "2"), | ||
resource.TestCheckResourceAttr(resName, "kibana.#", "1"), | ||
resource.TestCheckResourceAttr(resName, "kibana.0.topology.0.zone_count", "1"), | ||
resource.TestCheckResourceAttr(resName, "kibana.0.topology.#", "1"), | ||
resource.TestCheckResourceAttrSet(resName, "kibana.0.topology.0.instance_configuration_id"), | ||
resource.TestCheckResourceAttr(resName, "kibana.0.topology.0.size", "1g"), | ||
resource.TestCheckResourceAttr(resName, "kibana.0.topology.0.size_resource", "memory"), | ||
resource.TestCheckResourceAttr(resName, "apm.#", "0"), | ||
resource.TestCheckResourceAttr(resName, "enterprise_search.#", "0"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to modify test checks instead? It looks like the acceptance test (
TestAccDeployment_basic_defaults_hw
) checks updating configuration once the template is changed.Also shall the acceptance test work as expected without these explicit changes to the sizes? The new template (
aws-hot-warm-v2
) has size 4g for bothhot_content
andwarm
tiers so I guess once the template attribute is set toaws-hot-warm-v2
, the tier sizes should change accordingly even without these explicit settings in the configuration.