Skip to content

Commit

Permalink
Fix TestAccGKEHubFeatureMembership_gkehubFeatureAcmUpdate (GoogleClou…
Browse files Browse the repository at this point in the history
  • Loading branch information
zli82016 authored Oct 10, 2024
1 parent 6fa720f commit c72b949
Showing 1 changed file with 60 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func TestAccGKEHubFeatureMembership_gkehubFeatureAcmUpdate(t *testing.T) {
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
CheckDestroy: testAccCheckGKEHubFeatureDestroyProducer(t),
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -97,7 +100,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "bar"
}
depends_on = [google_project_service.mci, google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_feature_membership" "feature_member_1" {
Expand Down Expand Up @@ -148,7 +151,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "changed"
}
depends_on = [google_project_service.mci, google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_feature_membership" "feature_member_1" {
Expand Down Expand Up @@ -206,7 +209,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "changed"
}
depends_on = [google_project_service.mci, google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_feature_membership" "feature_member_2" {
Expand All @@ -228,7 +231,7 @@ resource "google_gke_hub_feature_membership" "feature_member_2" {
enabled = true
audit_interval_seconds = "9"
exemptable_namespaces = ["different", "1234"]
template_library_installed = false
template_library_installed = true
}
hierarchy_controller {
enable_hierarchical_resource_quota = true
Expand Down Expand Up @@ -285,9 +288,6 @@ resource "google_gke_hub_feature_membership" "feature_member_4" {
}
}
}



`, context)
}

Expand All @@ -301,7 +301,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "changed"
}
depends_on = [google_project_service.mci, google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_feature_membership" "feature_member_3" {
Expand Down Expand Up @@ -336,6 +336,9 @@ func TestAccGKEHubFeatureMembership_gkehubFeatureAcmAllFields(t *testing.T) {
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
CheckDestroy: testAccCheckGKEHubFeatureDestroyProducer(t),
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -394,7 +397,7 @@ resource "google_container_cluster" "primary" {
location = "us-central1-a"
initial_node_count = 1
deletion_protection = false
depends_on = [google_project_service.mci, google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_membership" "membership" {
Expand All @@ -418,7 +421,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "bar"
}
depends_on = [google_project_service.mci, google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_feature_membership" "feature_member" {
Expand Down Expand Up @@ -461,7 +464,7 @@ resource "google_container_cluster" "primary" {
location = "us-central1-a"
initial_node_count = 1
deletion_protection = false
depends_on = [google_project_service.mci, google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_membership" "membership" {
Expand All @@ -485,7 +488,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "bar"
}
depends_on = [google_project_service.mci, google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_feature_membership" "feature_member" {
Expand Down Expand Up @@ -529,7 +532,7 @@ resource "google_container_cluster" "primary" {
location = "us-central1-a"
initial_node_count = 1
deletion_protection = false
depends_on = [google_project_service.mci, google_project_service.container, google_project_service.container, google_project_service.gkehub, google_project_service.acm]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_membership" "membership" {
Expand All @@ -553,7 +556,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "bar"
}
depends_on = [google_project_service.mci, google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_service_account" "feature_sa" {
Expand Down Expand Up @@ -594,6 +597,9 @@ func TestAccGKEHubFeatureMembership_gkehubFeatureAcmOci(t *testing.T) {
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
CheckDestroy: testAccCheckGKEHubFeatureDestroyProducer(t),
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -643,7 +649,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "bar"
}
depends_on = [google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_service_account" "feature_sa" {
Expand Down Expand Up @@ -693,7 +699,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "bar"
}
depends_on = [google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_service_account" "feature_sa" {
Expand Down Expand Up @@ -743,7 +749,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "bar"
}
depends_on = [google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_service_account" "feature_sa" {
Expand Down Expand Up @@ -785,6 +791,9 @@ func TestAccGKEHubFeatureMembership_gkehubFeatureMesh(t *testing.T) {
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
CheckDestroy: testAccCheckGKEHubFeatureDestroyProducer(t),
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -832,7 +841,7 @@ resource "google_container_cluster" "primary" {
location = "us-central1-a"
initial_node_count = 1
deletion_protection = false
depends_on = [google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_membership" "membership" {
Expand All @@ -856,7 +865,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "bar"
}
depends_on = [google_project_service.container, google_project_service.gkehub, google_project_service.mesh]
depends_on = [time_sleep.wait_120s]
}

resource "google_service_account" "feature_sa" {
Expand Down Expand Up @@ -885,7 +894,7 @@ resource "google_container_cluster" "primary" {
location = "us-central1-a"
initial_node_count = 1
deletion_protection = false
depends_on = [google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_membership" "membership" {
Expand All @@ -909,7 +918,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "bar"
}
depends_on = [google_project_service.container, google_project_service.gkehub, google_project_service.mesh]
depends_on = [time_sleep.wait_120s]
}

resource "google_service_account" "feature_sa" {
Expand Down Expand Up @@ -937,7 +946,7 @@ resource "google_container_cluster" "primary" {
location = "us-central1-a"
initial_node_count = 1
deletion_protection = false
depends_on = [google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_membership" "membership" {
Expand All @@ -961,7 +970,7 @@ resource "google_gke_hub_feature" "feature" {
labels = {
foo = "bar"
}
depends_on = [google_project_service.container, google_project_service.gkehub, google_project_service.mesh]
depends_on = [time_sleep.wait_120s]
}

resource "google_service_account" "feature_sa" {
Expand Down Expand Up @@ -995,6 +1004,9 @@ func TestAccGKEHubFeatureMembership_gkehubFeaturePolicyController(t *testing.T)
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
CheckDestroy: testAccCheckGKEHubFeatureDestroyProducer(t),
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -1040,7 +1052,7 @@ resource "google_gke_hub_feature" "feature" {
project = google_project.project.project_id
name = "policycontroller"
location = "global"
depends_on = [google_project_service.container, google_project_service.gkehub, google_project_service.poco]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_feature_membership" "feature_member" {
Expand All @@ -1066,7 +1078,7 @@ resource "google_gke_hub_feature" "feature" {
project = google_project.project.project_id
name = "policycontroller"
location = "global"
depends_on = [google_project_service.container, google_project_service.gkehub, google_project_service.poco]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_feature_membership" "feature_member" {
Expand Down Expand Up @@ -1137,7 +1149,7 @@ resource "google_gke_hub_feature" "feature" {
project = google_project.project.project_id
name = "policycontroller"
location = "global"
depends_on = [google_project_service.container, google_project_service.gkehub, google_project_service.poco]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_feature_membership" "feature_member" {
Expand Down Expand Up @@ -1189,7 +1201,7 @@ resource "google_container_cluster" "primary" {
initial_node_count = 1
project = google_project.project.project_id
deletion_protection = false
depends_on = [google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_container_cluster" "secondary" {
Expand All @@ -1198,7 +1210,7 @@ resource "google_container_cluster" "secondary" {
initial_node_count = 1
project = google_project.project.project_id
deletion_protection = false
depends_on = [google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_container_cluster" "tertiary" {
Expand All @@ -1207,7 +1219,7 @@ resource "google_container_cluster" "tertiary" {
initial_node_count = 1
project = google_project.project.project_id
deletion_protection = false
depends_on = [google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}


Expand All @@ -1217,7 +1229,7 @@ resource "google_container_cluster" "quarternary" {
initial_node_count = 1
project = google_project.project.project_id
deletion_protection = false
depends_on = [google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_membership" "membership" {
Expand Down Expand Up @@ -1281,7 +1293,7 @@ resource "google_compute_network" "testnetwork" {
project = google_project.project.project_id
name = "testnetwork"
auto_create_subnetworks = true
depends_on = [google_project_service.compute]
depends_on = [time_sleep.wait_120s]
}

resource "google_container_cluster" "container_acmoci" {
Expand All @@ -1291,7 +1303,7 @@ resource "google_container_cluster" "container_acmoci" {
network = google_compute_network.testnetwork.self_link
project = google_project.project.project_id
deletion_protection = false
depends_on = [google_project_service.container, google_project_service.container, google_project_service.gkehub]
depends_on = [time_sleep.wait_120s]
}

resource "google_gke_hub_membership" "membership_acmoci" {
Expand Down Expand Up @@ -1407,6 +1419,22 @@ resource "google_project_service" "gkehub" {
service = "gkehub.googleapis.com"
disable_on_destroy = false
}

// It needs waiting until the API services are really activated.
resource "time_sleep" "wait_120s" {
create_duration = "120s"
depends_on = [
google_project_service.anthos,
google_project_service.mesh,
google_project_service.mci,
google_project_service.acm,
google_project_service.poco,
google_project_service.mcsd,
google_project_service.compute,
google_project_service.container,
google_project_service.gkehub,
]
}
`, context)
}

Expand Down

0 comments on commit c72b949

Please sign in to comment.