From 97baba8cefe9af1a41b39000b264a472f580e443 Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Thu, 15 Sep 2022 10:00:21 -0700 Subject: [PATCH 1/3] Fix Monitoring Test --- .../resource_container_cluster_test.go.erb | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb b/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb index d25fff55a7be..7d131791f0a3 100755 --- a/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb @@ -990,7 +990,7 @@ func TestAccContainerCluster_withNodePoolDefaults(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("google_container_cluster.with_node_pool_defaults", "node_pool_defaults.0.node_config_defaults.0.gcfs_config.#", "1"), - resource.TestCheckResourceAttr("google_container_cluster.with_node_pool_defaults", + resource.TestCheckResourceAttr("google_container_cluster.with_node_pool_defaults", "node_pool_defaults.0.node_config_defaults.0.gcfs_config.0.enabled", "true"), ), }, @@ -2287,7 +2287,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) { CheckDestroy: testAccCheckContainerClusterDestroyProducer(t), Steps: []resource.TestStep{ { - Config: testAccContainerCluster_basic(clusterName), + Config: testAccContainerCluster_basic_1_23_8(clusterName), }, { ResourceName: "google_container_cluster.primary", @@ -2321,7 +2321,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) { }, // Back to basic settings to test setting Prometheus on its own { - Config: testAccContainerCluster_basic(clusterName), + Config: testAccContainerCluster_basic_1_23_8(clusterName), }, { ResourceName: "google_container_cluster.primary", @@ -2338,7 +2338,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) { }, <% end -%> { - Config: testAccContainerCluster_basic(clusterName), + Config: testAccContainerCluster_basic_1_23_8(clusterName), }, { ResourceName: "google_container_cluster.primary", @@ -6079,12 +6079,24 @@ resource "google_container_cluster" "primary" { `, name) } +func testAccContainerCluster_basic_1_23_8(name string) string { + return fmt.Sprintf(` +resource "google_container_cluster" "primary" { + name = "%s" + location = "us-central1-a" + initial_node_count = 1 + min_master_version = "1.23.8-gke.1900" +} +`, name) +} + func testAccContainerCluster_withMonitoringConfigEnabled(name string) string { return fmt.Sprintf(` resource "google_container_cluster" "primary" { name = "%s" location = "us-central1-a" initial_node_count = 1 + min_master_version = "1.23.8-gke.1900" monitoring_config { enable_components = [ "SYSTEM_COMPONENTS", "APISERVER", "CONTROLLER_MANAGER", "SCHEDULER" ] } @@ -6099,6 +6111,7 @@ resource "google_container_cluster" "primary" { name = "%s" location = "us-central1-a" initial_node_count = 1 + min_master_version = "1.23.8-gke.1900" monitoring_config { enable_components = [ "SYSTEM_COMPONENTS", "APISERVER", "CONTROLLER_MANAGER", "SCHEDULER", "WORKLOADS" ] } @@ -6112,6 +6125,7 @@ resource "google_container_cluster" "primary" { name = "%s" location = "us-central1-a" initial_node_count = 1 + min_master_version = "1.23.8-gke.1900" monitoring_config { enable_components = [ "SYSTEM_COMPONENTS", "APISERVER", "CONTROLLER_MANAGER", "SCHEDULER", "WORKLOADS" ] managed_prometheus { @@ -6128,6 +6142,7 @@ resource "google_container_cluster" "primary" { name = "%s" location = "us-central1-a" initial_node_count = 1 + min_master_version = "1.23.8-gke.1900" monitoring_config { managed_prometheus { enabled = true From de47be8bddde387bf9752881caa1a9cc8edd3b26 Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Thu, 15 Sep 2022 11:24:22 -0700 Subject: [PATCH 2/3] ignore changes on min_master_version, value not read from api --- .../terraform/tests/resource_container_cluster_test.go.erb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb b/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb index 7d131791f0a3..4a0182020c5f 100755 --- a/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb @@ -2293,6 +2293,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) { ResourceName: "google_container_cluster.primary", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"min_master_version"}, }, { Config: testAccContainerCluster_withMonitoringConfigEnabled(clusterName), @@ -2302,6 +2303,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) { ResourceName: "google_container_cluster.primary", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"min_master_version"}, }, { Config: testAccContainerCluster_withMonitoringConfigUpdated(clusterName), @@ -2310,6 +2312,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) { ResourceName: "google_container_cluster.primary", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"min_master_version"}, }, { Config: testAccContainerCluster_withMonitoringConfigPrometheusUpdated(clusterName), @@ -2318,6 +2321,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) { ResourceName: "google_container_cluster.primary", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"min_master_version"}, }, // Back to basic settings to test setting Prometheus on its own { @@ -2327,6 +2331,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) { ResourceName: "google_container_cluster.primary", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"min_master_version"}, }, { Config: testAccContainerCluster_withMonitoringConfigPrometheusOnly(clusterName), @@ -2335,6 +2340,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) { ResourceName: "google_container_cluster.primary", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"min_master_version"}, }, <% end -%> { @@ -2344,6 +2350,7 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) { ResourceName: "google_container_cluster.primary", ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"min_master_version"}, }, }, }) From 9e1a5d6f501328f58cb8fe824ade597c6457cac2 Mon Sep 17 00:00:00 2001 From: Scott Suarez Date: Fri, 16 Sep 2022 14:48:13 -0700 Subject: [PATCH 3/3] Apply suggestions from code review --- .../terraform/tests/resource_container_cluster_test.go.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb b/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb index 4a0182020c5f..2952896162fe 100755 --- a/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb @@ -6103,7 +6103,7 @@ resource "google_container_cluster" "primary" { name = "%s" location = "us-central1-a" initial_node_count = 1 - min_master_version = "1.23.8-gke.1900" + min_master_version = "1.23.8-gke.1900" monitoring_config { enable_components = [ "SYSTEM_COMPONENTS", "APISERVER", "CONTROLLER_MANAGER", "SCHEDULER" ] }