Skip to content
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

Use the lowest version from a running resource, not just the lowest #623

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion ec/acc/deployment_post_node_role_upgrade_test.go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobio , I suppose this test should fail without the fix (without the fix it should output Error: Provider produced inconsistent result after apply complaining about the version), correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func TestAccDeployment_post_node_roles(t *testing.T) {
resName := "ec_deployment.post_nr_upgrade"
randomName := prefix + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
startCfg := "testdata/deployment_post_node_roles_upgrade_1.tf"
upgradeVersionCfg := "testdata/deployment_post_node_roles_upgrade_2.tf"
withoutEnterpriseSearch := "testdata/deployment_post_node_roles_upgrade_2.tf"
upgradeVersionCfg := "testdata/deployment_post_node_roles_upgrade_3.tf"

cfgF := func(cfg string) string {
return fixtureAccDeploymentResourceBasic(
Expand All @@ -55,6 +56,26 @@ func TestAccDeployment_post_node_roles(t *testing.T) {
resource.TestCheckNoResourceAttr(resName, "elastic.hot.node_type_master"),
resource.TestCheckNoResourceAttr(resName, "elastic.hot.node_type_ml"),

resource.TestCheckResourceAttrSet(resName, "enterprise_search.size"),
resource.TestCheckResourceAttrSet(resName, "kibana.size"),

resource.TestCheckNoResourceAttr(resName, "apm"),
),
},
{
Config: cfgF(withoutEnterpriseSearch),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet(resName, "elasticsearch.hot.instance_configuration_id"),
resource.TestCheckResourceAttr(resName, "elasticsearch.hot.size", "1g"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.hot.node_roles.#"),
resource.TestCheckResourceAttr(resName, "elasticsearch.hot.size_resource", "memory"),
resource.TestCheckResourceAttr(resName, "elasticsearch.hot.zone_count", "1"),

resource.TestCheckNoResourceAttr(resName, "elastic.hot.node_type_data"),
resource.TestCheckNoResourceAttr(resName, "elastic.hot.node_type_ingest"),
resource.TestCheckNoResourceAttr(resName, "elastic.hot.node_type_master"),
resource.TestCheckNoResourceAttr(resName, "elastic.hot.node_type_ml"),

resource.TestCheckNoResourceAttr(resName, "kibana"),
resource.TestCheckNoResourceAttr(resName, "apm"),
resource.TestCheckNoResourceAttr(resName, "enterprise_search"),
Expand Down
5 changes: 4 additions & 1 deletion ec/acc/testdata/deployment_post_node_roles_upgrade_1.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ resource "ec_deployment" "post_nr_upgrade" {
autoscaling = {}
}
}
}

kibana = {}
enterprise_search = {}
}
4 changes: 2 additions & 2 deletions ec/acc/testdata/deployment_post_node_roles_upgrade_2.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data "ec_stack" "post_node_roles_upgrade" {
version_regex = "7.??.?"
version_regex = "7.12.?"
region = "%s"
}

Expand All @@ -16,4 +16,4 @@ resource "ec_deployment" "post_nr_upgrade" {
autoscaling = {}
}
}
}
}
19 changes: 19 additions & 0 deletions ec/acc/testdata/deployment_post_node_roles_upgrade_3.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
data "ec_stack" "post_node_roles_upgrade" {
version_regex = "7.17.?"
region = "%s"
}

resource "ec_deployment" "post_nr_upgrade" {
name = "%s"
region = "%s"
version = data.ec_stack.post_node_roles_upgrade.version
deployment_template_id = "%s"

elasticsearch = {
hot = {
size = "1g"
zone_count = 1
autoscaling = {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,36 +258,36 @@ func getLowestVersion(res *models.DeploymentResources) (string, error) {
}

for _, r := range res.Kibana {
if !util.IsCurrentKibanaPlanEmpty(r) {
if !util.IsCurrentKibanaPlanEmpty(r) && !kibanav2.IsKibanaStopped(r) {
v := r.Info.PlanInfo.Current.Plan.Kibana.Version
if err := swapLowerVersion(&version, v); err != nil && !kibanav2.IsKibanaStopped(r) {
if err := swapLowerVersion(&version, v); err != nil {
return version.String(), fmt.Errorf("kibana version '%s' is not semver compliant: %w", v, err)
}
}
}

for _, r := range res.Apm {
if !util.IsCurrentApmPlanEmpty(r) {
if !util.IsCurrentApmPlanEmpty(r) && !apmv2.IsApmStopped(r) {
v := r.Info.PlanInfo.Current.Plan.Apm.Version
if err := swapLowerVersion(&version, v); err != nil && !apmv2.IsApmStopped(r) {
if err := swapLowerVersion(&version, v); err != nil {
return version.String(), fmt.Errorf("apm version '%s' is not semver compliant: %w", v, err)
}
}
}

for _, r := range res.IntegrationsServer {
if !util.IsCurrentIntegrationsServerPlanEmpty(r) {
if !util.IsCurrentIntegrationsServerPlanEmpty(r) && !integrationsserverv2.IsIntegrationsServerStopped(r) {
v := r.Info.PlanInfo.Current.Plan.IntegrationsServer.Version
if err := swapLowerVersion(&version, v); err != nil && !integrationsserverv2.IsIntegrationsServerStopped(r) {
if err := swapLowerVersion(&version, v); err != nil {
return version.String(), fmt.Errorf("integrations_server version '%s' is not semver compliant: %w", v, err)
}
}
}

for _, r := range res.EnterpriseSearch {
if !util.IsCurrentEssPlanEmpty(r) {
if !util.IsCurrentEssPlanEmpty(r) && !enterprisesearchv2.IsEnterpriseSearchStopped(r) {
v := r.Info.PlanInfo.Current.Plan.EnterpriseSearch.Version
if err := swapLowerVersion(&version, v); err != nil && !enterprisesearchv2.IsEnterpriseSearchStopped(r) {
if err := swapLowerVersion(&version, v); err != nil {
return version.String(), fmt.Errorf("enterprise search version '%s' is not semver compliant: %w", v, err)
}
}
Expand Down