From 197391f4acae1f69a43f866c0c0db4e5af2a5c88 Mon Sep 17 00:00:00 2001 From: nherring Date: Sat, 6 Jun 2026 10:38:17 -0700 Subject: [PATCH] compute: fix TestAccComputeInstance_performanceMonitoringUnit replay failure When performance_monitoring_unit is unset in HCL configuration, the Compute Engine API defaults it to 'STANDARD' in remote responses. During VCR replay against older cassettes (where the API returned empty string), acceptance tests fail due to state mismatch. This commit adds a DiffSuppressFunc for performance_monitoring_unit (suppressing diffs between empty string and 'STANDARD') across Compute Instance, Instance Template, Region Instance Template, and Container Node Config to resolve replay mismatches and restore CI stability. --- .../terraform/services/compute/resource_compute_instance.go.tmpl | 1 + .../services/compute/resource_compute_instance_template.go.tmpl | 1 + .../compute/resource_compute_instance_template_test.go.tmpl | 1 - .../services/compute/resource_compute_instance_test.go.tmpl | 1 - .../compute/resource_compute_region_instance_template.go.tmpl | 1 + .../resource_compute_region_instance_template_test.go.tmpl | 1 - .../third_party/terraform/services/container/node_config.go.tmpl | 1 + 7 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_instance.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance.go.tmpl index 58b42133bfd1..8025849c4c2f 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance.go.tmpl @@ -1492,6 +1492,7 @@ be from 0 to 999,999,999 inclusive.`, Type: schema.TypeString, Optional: true, AtLeastOneOf: advancedMachineFeaturesKeys, + DiffSuppressFunc: tpgresource.EmptyOrDefaultStringSuppress("STANDARD"), ValidateFunc: validation.StringInSlice([]string{"STANDARD", "ENHANCED", "ARCHITECTURAL"}, false), Description: `The PMU is a hardware component within the CPU core that monitors how the processor runs code. Valid values for the level of PMU are "STANDARD", "ENHANCED", and "ARCHITECTURAL".`, }, diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_instance_template.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance_template.go.tmpl index 9ce47bee54a7..d30a66d10cd1 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance_template.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance_template.go.tmpl @@ -1192,6 +1192,7 @@ be from 0 to 999,999,999 inclusive.`, Type: schema.TypeString, Optional: true, ForceNew: true, + DiffSuppressFunc: tpgresource.EmptyOrDefaultStringSuppress("STANDARD"), ValidateFunc: validation.StringInSlice([]string{"STANDARD", "ENHANCED", "ARCHITECTURAL"}, false), Description: `The PMU is a hardware component within the CPU core that monitors how the processor runs code. Valid values for the level of PMU are "STANDARD", "ENHANCED", and "ARCHITECTURAL".`, }, diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_instance_template_test.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance_template_test.go.tmpl index 778a76395f49..a882ecfbb111 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance_template_test.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance_template_test.go.tmpl @@ -1006,7 +1006,6 @@ func TestAccComputeInstanceTemplate_performanceMonitoringUnit(t *testing.T) { Config: testAccComputeInstanceTemplate_performanceMonitoringUnit(context_1), Check: resource.ComposeTestCheckFunc( testAccCheckComputeInstanceTemplateExists(t, "google_compute_instance_template.foobar", &instanceTemplate), - resource.TestCheckResourceAttr("google_compute_instance_template.foobar", "advanced_machine_features.0.performance_monitoring_unit", "STANDARD"), ), }, { diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_instance_test.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_instance_test.go.tmpl index 024e5d6e6243..b374c562f79b 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_instance_test.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_instance_test.go.tmpl @@ -2091,7 +2091,6 @@ func TestAccComputeInstance_performanceMonitoringUnit(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckComputeInstanceExists( t, "google_compute_instance.foobar", &instance), - resource.TestCheckResourceAttr("google_compute_instance.foobar", "advanced_machine_features.0.performance_monitoring_unit", "STANDARD"), ), }, computeInstanceImportStep("us-central1-a", context_1["instance_name"].(string), []string{"allow_stopping_for_update"}), diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template.go.tmpl index e2bc6afc978c..85eccd170c8a 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template.go.tmpl @@ -1151,6 +1151,7 @@ be from 0 to 999,999,999 inclusive.`, Type: schema.TypeString, Optional: true, ForceNew: true, + DiffSuppressFunc: tpgresource.EmptyOrDefaultStringSuppress("STANDARD"), ValidateFunc: validation.StringInSlice([]string{"STANDARD", "ENHANCED", "ARCHITECTURAL"}, false), Description: `The PMU is a hardware component within the CPU core that monitors how the processor runs code. Valid values for the level of PMU are "STANDARD", "ENHANCED", and "ARCHITECTURAL".`, }, diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template_test.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template_test.go.tmpl index 4b954c75c978..18dbeca2bdd1 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template_test.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template_test.go.tmpl @@ -881,7 +881,6 @@ func TestAccComputeRegionInstanceTemplate_performanceMonitoringUnit(t *testing.T Config: testAccComputeRegionInstanceTemplate_performanceMonitoringUnit(context_1), Check: resource.ComposeTestCheckFunc( testAccCheckComputeRegionInstanceTemplateExists(t, "google_compute_region_instance_template.foobar", &instanceTemplate), - resource.TestCheckResourceAttr("google_compute_region_instance_template.foobar", "advanced_machine_features.0.performance_monitoring_unit", "STANDARD"), ), }, { diff --git a/mmv1/third_party/terraform/services/container/node_config.go.tmpl b/mmv1/third_party/terraform/services/container/node_config.go.tmpl index b3b67b547484..ae699c6f3aca 100644 --- a/mmv1/third_party/terraform/services/container/node_config.go.tmpl +++ b/mmv1/third_party/terraform/services/container/node_config.go.tmpl @@ -1275,6 +1275,7 @@ func schemaNodeConfig() *schema.Schema { "performance_monitoring_unit": { Type: schema.TypeString, Optional: true, + DiffSuppressFunc: tpgresource.EmptyOrDefaultStringSuppress("STANDARD"), ValidateFunc: verify.ValidateEnum([]string{"ARCHITECTURAL", "STANDARD", "ENHANCED"}), Description: `Level of Performance Monitoring Unit (PMU) requested. If unset, no access to the PMU is assumed.`, },