Skip to content

Commit

Permalink
Update more gke tests to use bootstrapped network (#9664) (#6778)
Browse files Browse the repository at this point in the history
[upstream:7ab2f9b27100dd2c513dc8f93377648fa217b608]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Dec 19, 2023
1 parent c9f11b1 commit 4f592fc
Show file tree
Hide file tree
Showing 19 changed files with 379 additions and 140 deletions.
3 changes: 3 additions & 0 deletions .changelog/9664.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
235 changes: 141 additions & 94 deletions google-beta/services/container/resource_container_cluster_test.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func TestAccGKEBackupBackupPlanIamBindingGenerated(t *testing.T) {
"project": envvar.GetTestProjectFromEnv(),

"deletion_protection": false,
"network_name": acctest.BootstrapSharedTestNetwork(t, "gke-cluster"),
"subnetwork_name": acctest.BootstrapSubnet(t, "gke-cluster", acctest.BootstrapSharedTestNetwork(t, "gke-cluster")),
}

acctest.VcrTest(t, resource.TestCase{
Expand Down Expand Up @@ -74,6 +76,8 @@ func TestAccGKEBackupBackupPlanIamMemberGenerated(t *testing.T) {
"project": envvar.GetTestProjectFromEnv(),

"deletion_protection": false,
"network_name": acctest.BootstrapSharedTestNetwork(t, "gke-cluster"),
"subnetwork_name": acctest.BootstrapSubnet(t, "gke-cluster", acctest.BootstrapSharedTestNetwork(t, "gke-cluster")),
}

acctest.VcrTest(t, resource.TestCase{
Expand Down Expand Up @@ -103,6 +107,8 @@ func TestAccGKEBackupBackupPlanIamPolicyGenerated(t *testing.T) {
"project": envvar.GetTestProjectFromEnv(),

"deletion_protection": false,
"network_name": acctest.BootstrapSharedTestNetwork(t, "gke-cluster"),
"subnetwork_name": acctest.BootstrapSubnet(t, "gke-cluster", acctest.BootstrapSharedTestNetwork(t, "gke-cluster")),
}

acctest.VcrTest(t, resource.TestCase{
Expand Down Expand Up @@ -147,6 +153,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "basic" {
Expand Down Expand Up @@ -185,6 +193,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "basic" {
Expand Down Expand Up @@ -238,6 +248,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "basic" {
Expand Down Expand Up @@ -278,6 +290,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "basic" {
Expand Down Expand Up @@ -316,6 +330,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "basic" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func TestAccGKEBackupRestorePlanIamBindingGenerated(t *testing.T) {
"project": envvar.GetTestProjectFromEnv(),

"deletion_protection": false,
"network_name": acctest.BootstrapSharedTestNetwork(t, "gke-cluster"),
"subnetwork_name": acctest.BootstrapSubnet(t, "gke-cluster", acctest.BootstrapSharedTestNetwork(t, "gke-cluster")),
}

acctest.VcrTest(t, resource.TestCase{
Expand Down Expand Up @@ -74,6 +76,8 @@ func TestAccGKEBackupRestorePlanIamMemberGenerated(t *testing.T) {
"project": envvar.GetTestProjectFromEnv(),

"deletion_protection": false,
"network_name": acctest.BootstrapSharedTestNetwork(t, "gke-cluster"),
"subnetwork_name": acctest.BootstrapSubnet(t, "gke-cluster", acctest.BootstrapSharedTestNetwork(t, "gke-cluster")),
}

acctest.VcrTest(t, resource.TestCase{
Expand Down Expand Up @@ -103,6 +107,8 @@ func TestAccGKEBackupRestorePlanIamPolicyGenerated(t *testing.T) {
"project": envvar.GetTestProjectFromEnv(),

"deletion_protection": false,
"network_name": acctest.BootstrapSharedTestNetwork(t, "gke-cluster"),
"subnetwork_name": acctest.BootstrapSubnet(t, "gke-cluster", acctest.BootstrapSharedTestNetwork(t, "gke-cluster")),
}

acctest.VcrTest(t, resource.TestCase{
Expand Down Expand Up @@ -147,6 +153,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "basic" {
Expand Down Expand Up @@ -201,6 +209,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "basic" {
Expand Down Expand Up @@ -270,6 +280,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "basic" {
Expand Down Expand Up @@ -326,6 +338,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "basic" {
Expand Down Expand Up @@ -380,6 +394,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "basic" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func TestAccGKEBackupBackupPlan_gkebackupBackupplanBasicExample(t *testing.T) {
context := map[string]interface{}{
"project": envvar.GetTestProjectFromEnv(),
"deletion_protection": false,
"network_name": acctest.BootstrapSharedTestNetwork(t, "gke-cluster"),
"subnetwork_name": acctest.BootstrapSubnet(t, "gke-cluster", acctest.BootstrapSharedTestNetwork(t, "gke-cluster")),
"random_suffix": acctest.RandString(t, 10),
}

Expand Down Expand Up @@ -73,6 +75,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "basic" {
Expand All @@ -93,6 +97,8 @@ func TestAccGKEBackupBackupPlan_gkebackupBackupplanAutopilotExample(t *testing.T

context := map[string]interface{}{
"deletion_protection": false,
"network_name": acctest.BootstrapSharedTestNetwork(t, "gke-cluster"),
"subnetwork_name": acctest.BootstrapSubnet(t, "gke-cluster", acctest.BootstrapSharedTestNetwork(t, "gke-cluster")),
"random_suffix": acctest.RandString(t, 10),
}

Expand Down Expand Up @@ -131,6 +137,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "autopilot" {
Expand All @@ -152,6 +160,8 @@ func TestAccGKEBackupBackupPlan_gkebackupBackupplanCmekExample(t *testing.T) {
context := map[string]interface{}{
"project": envvar.GetTestProjectFromEnv(),
"deletion_protection": false,
"network_name": acctest.BootstrapSharedTestNetwork(t, "gke-cluster"),
"subnetwork_name": acctest.BootstrapSubnet(t, "gke-cluster", acctest.BootstrapSharedTestNetwork(t, "gke-cluster")),
"random_suffix": acctest.RandString(t, 10),
}

Expand Down Expand Up @@ -188,6 +198,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "cmek" {
Expand Down Expand Up @@ -224,6 +236,8 @@ func TestAccGKEBackupBackupPlan_gkebackupBackupplanFullExample(t *testing.T) {
context := map[string]interface{}{
"project": envvar.GetTestProjectFromEnv(),
"deletion_protection": false,
"network_name": acctest.BootstrapSharedTestNetwork(t, "gke-cluster"),
"subnetwork_name": acctest.BootstrapSubnet(t, "gke-cluster", acctest.BootstrapSharedTestNetwork(t, "gke-cluster")),
"random_suffix": acctest.RandString(t, 10),
}

Expand Down Expand Up @@ -260,6 +274,8 @@ resource "google_container_cluster" "primary" {
}
}
deletion_protection = "%{deletion_protection}"
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "full" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ func TestAccGKEBackupBackupPlan_update(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"project": envvar.GetTestProjectFromEnv(),
"random_suffix": acctest.RandString(t, 10),
"project": envvar.GetTestProjectFromEnv(),
"random_suffix": acctest.RandString(t, 10),
"network_name": acctest.BootstrapSharedTestNetwork(t, "gke-cluster"),
"subnetwork_name": acctest.BootstrapSubnet(t, "gke-cluster", acctest.BootstrapSharedTestNetwork(t, "gke-cluster")),
}

acctest.VcrTest(t, resource.TestCase{
Expand Down Expand Up @@ -56,21 +58,23 @@ resource "google_container_cluster" "primary" {
workload_pool = "%{project}.svc.id.goog"
}
addons_config {
gke_backup_agent_config {
enabled = true
}
gke_backup_agent_config {
enabled = true
}
}
deletion_protection = false
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "backupplan" {
name = "tf-test-testplan%{random_suffix}"
cluster = google_container_cluster.primary.id
location = "us-central1"
backup_config {
include_volume_data = false
include_secrets = false
all_namespaces = true
include_volume_data = false
include_secrets = false
all_namespaces = true
}
labels = {
"some-key-1": "some-value-1"
Expand All @@ -89,36 +93,38 @@ resource "google_container_cluster" "primary" {
workload_pool = "%{project}.svc.id.goog"
}
addons_config {
gke_backup_agent_config {
enabled = true
}
gke_backup_agent_config {
enabled = true
}
}
deletion_protection = false
network = "%{network_name}"
subnetwork = "%{subnetwork_name}"
}
resource "google_gke_backup_backup_plan" "backupplan" {
name = "tf-test-testplan%{random_suffix}"
cluster = google_container_cluster.primary.id
location = "us-central1"
retention_policy {
backup_delete_lock_days = 30
backup_retain_days = 180
backup_delete_lock_days = 30
backup_retain_days = 180
}
backup_schedule {
cron_schedule = "0 9 * * 1"
}
backup_config {
include_volume_data = true
include_secrets = true
selected_applications {
namespaced_names {
name = "app1"
namespace = "ns1"
}
namespaced_names {
name = "app2"
namespace = "ns2"
}
include_volume_data = true
include_secrets = true
selected_applications {
namespaced_names {
name = "app1"
namespace = "ns1"
}
namespaced_names {
name = "app2"
namespace = "ns2"
}
}
}
labels = {
Expand Down
Loading

0 comments on commit 4f592fc

Please sign in to comment.