Skip to content

Commit c05c48e

Browse files
authored
Fix integration test project creation (#574)
* fix tests docs updates to zonal update cb * update addon * workaround for gcloud flaky output
1 parent cf3273d commit c05c48e

File tree

31 files changed

+82
-69
lines changed

31 files changed

+82
-69
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ credentials.json
5151
# File to populate env vars used by Docker test runs
5252
.envrc
5353

54-
# ignore generated ASM yamls in /workspace/test/fixtures/simple_regional_with_asm as it is a test
54+
# ignore generated ASM yamls in /workspace/test/fixtures/simple_zonal_with_asm as it is a test
5555
# in a production scenario these files are expected to be checked in
56-
/test/fixtures/simple_regional_with_asm/asm-dir
56+
/test/fixtures/simple_zonal_with_asm/asm-dir

.kitchen.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ suites:
234234
systems:
235235
- name: safer_cluster_iap_bastion
236236
backend: local
237-
- name: "simple_regional_with_asm"
237+
- name: "simple_zonal_with_asm"
238238
driver:
239-
root_module_directory: test/fixtures/simple_regional_with_asm
239+
root_module_directory: test/fixtures/simple_zonal_with_asm
240240
verifier:
241241
systems:
242-
- name: simple_regional_with_asm
242+
- name: simple_zonal_with_asm
243243
backend: local
244244
controls:
245245
- gcloud

build/int.cloudbuild.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -404,26 +404,26 @@ steps:
404404
- verify safer-cluster-iap-bastion-local
405405
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
406406
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy safer-cluster-iap-bastion-local']
407-
- id: create simple-regional-with-asm-local
407+
- id: create simple-zonal-with-asm-local
408408
waitFor:
409409
- prepare
410410
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
411-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create simple-regional-with-asm-local']
412-
- id: converge simple-regional-with-asm-local
411+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create simple-zonal-with-asm-local']
412+
- id: converge simple-zonal-with-asm-local
413413
waitFor:
414-
- create simple-regional-with-asm-local
414+
- create simple-zonal-with-asm-local
415415
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
416-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-regional-with-asm-local']
417-
- id: verify simple-regional-with-asm-local
416+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-zonal-with-asm-local']
417+
- id: verify simple-zonal-with-asm-local
418418
waitFor:
419-
- converge simple-regional-with-asm-local
419+
- converge simple-zonal-with-asm-local
420420
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
421-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-regional-with-asm-local']
422-
- id: destroy simple-regional-with-asm-local
421+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-zonal-with-asm-local']
422+
- id: destroy simple-zonal-with-asm-local
423423
waitFor:
424-
- verify simple-regional-with-asm-local
424+
- verify simple-zonal-with-asm-local
425425
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
426-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-regional-with-asm-local']
426+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-zonal-with-asm-local']
427427
tags:
428428
- 'ci'
429429
- 'integration'

examples/simple_regional_with_asm/README.md renamed to examples/simple_zonal_with_asm/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Simple Regional Cluster with ASM
1+
# Simple Zonal Cluster with ASM
22

3-
This example illustrates how to create a simple regional cluster with ASM.
3+
This example illustrates how to create a simple zonal cluster with ASM.
44

55
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
66
## Inputs
@@ -14,6 +14,7 @@ This example illustrates how to create a simple regional cluster with ASM.
1414
| project\_id | The project ID to host the cluster in | string | n/a | yes |
1515
| region | The region to host the cluster in | string | n/a | yes |
1616
| subnetwork | The subnetwork to host the cluster in | string | n/a | yes |
17+
| zones | The zone to host the cluster in (required if is a zonal cluster) | list(string) | n/a | yes |
1718

1819
## Outputs
1920

examples/simple_regional_with_asm/main.tf renamed to examples/simple_zonal_with_asm/main.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
locals {
18-
cluster_type = "simple-regional-asm2"
18+
cluster_type = "simple-zonal-asm"
1919
}
2020

2121
provider "google-beta" {
@@ -31,9 +31,10 @@ module "gke" {
3131
source = "../../modules/beta-public-cluster/"
3232
project_id = var.project_id
3333
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
34-
regional = true
35-
release_channel = "REGULAR"
34+
regional = false
3635
region = var.region
36+
zones = var.zones
37+
release_channel = "REGULAR"
3738
network = var.network
3839
subnetwork = var.subnetwork
3940
ip_range_pods = var.ip_range_pods
@@ -42,11 +43,11 @@ module "gke" {
4243
cluster_resource_labels = { "mesh_id" : "proj-${data.google_project.project.number}" }
4344
node_pools = [
4445
{
45-
name = "asm-node-pool"
46-
autoscaling = false
46+
name = "asm-node-pool"
47+
autoscaling = false
48+
auto_upgrade = true
4749
# ASM requires minimum 4 nodes and e2-standard-4
48-
# As this is a regional cluster we have node_count * 3 = 6 nodes
49-
node_count = 2
50+
node_count = 4
5051
machine_type = "e2-standard-4"
5152
},
5253
]

examples/simple_regional_with_asm/variables.tf renamed to examples/simple_zonal_with_asm/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ variable "region" {
2727
description = "The region to host the cluster in"
2828
}
2929

30+
variable "zones" {
31+
type = list(string)
32+
description = "The zone to host the cluster in (required if is a zonal cluster)"
33+
}
34+
3035
variable "network" {
3136
description = "The VPC network to host the cluster in"
3237
}

modules/asm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Specifically, this module automates the following steps for [installing ASM](htt
99

1010
## Usage
1111

12-
There is a [full example](../../examples/simple_regional_with_asm) provided. Simple usage is as follows:
12+
There is a [full example](../../examples/simple_zonal_with_asm) provided. Simple usage is as follows:
1313

1414
```tf
1515
module "asm" {

test/fixtures/simple_regional_with_asm/example.tf renamed to test/fixtures/simple_zonal_with_asm/example.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ data "google_project" "project" {
1919
}
2020

2121
module "example" {
22-
source = "../../../examples/simple_regional_with_asm"
22+
source = "../../../examples/simple_zonal_with_asm"
2323

2424
project_id = var.project_ids[2]
2525
cluster_name_suffix = "-${random_string.suffix.result}"
2626
region = var.region
27+
zones = slice(var.zones, 0, 1)
2728
network = google_compute_network.main.name
2829
subnetwork = google_compute_subnetwork.main.name
2930
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name

test/integration/private_zonal_with_networking/controls/gcloud.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@
5757
end
5858

5959
it "has the expected addon settings" do
60-
expect(data['addonsConfig']).to eq({
60+
expect(data['addonsConfig']).to include(
6161
"horizontalPodAutoscaling" => {},
6262
"httpLoadBalancing" => {},
6363
"kubernetesDashboard" => {
6464
"disabled" => true,
6565
},
6666
"networkPolicyConfig" => {},
67-
})
67+
)
6868
end
6969
end
7070

test/integration/safer_cluster/controls/gcloud.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@
4848
end
4949

5050
it "has the expected addon settings" do
51-
expect(data['addonsConfig']).to eq({
52-
"cloudRunConfig" => {},
53-
"horizontalPodAutoscaling" => {},
54-
"httpLoadBalancing" => {},
55-
"kubernetesDashboard" => {
56-
"disabled" => true,
57-
},
58-
"networkPolicyConfig" => {},
59-
})
51+
expect(data['addonsConfig']).to include(
52+
"cloudRunConfig" => {},
53+
"horizontalPodAutoscaling" => {},
54+
"httpLoadBalancing" => {},
55+
"kubernetesDashboard" => including(
56+
"disabled" => true,
57+
),
58+
"networkPolicyConfig" => {},
59+
)
6060
end
6161
end
6262

test/integration/sandbox_enabled/controls/gcloud.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444
end
4545

4646
it "has the expected addon settings" do
47-
expect(data['addonsConfig']).to eq({
47+
expect(data['addonsConfig']).to include(
4848
"horizontalPodAutoscaling" => {},
4949
"httpLoadBalancing" => {},
5050
"kubernetesDashboard" => {
5151
"disabled" => true,
5252
},
5353
"networkPolicyConfig" => {},
54-
})
54+
)
5555
end
5656
end
5757

test/integration/simple_regional/controls/gcloud.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444
end
4545

4646
it "has the expected addon settings" do
47-
expect(data['addonsConfig']).to eq({
47+
expect(data['addonsConfig']).to include(
4848
"horizontalPodAutoscaling" => {},
4949
"httpLoadBalancing" => {},
5050
"kubernetesDashboard" => {
5151
"disabled" => true,
5252
},
5353
"networkPolicyConfig" => {},
54-
})
54+
)
5555
end
5656
end
5757

test/integration/simple_regional_private/controls/gcloud.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@
5252
end
5353

5454
it "has the expected addon settings" do
55-
expect(data['addonsConfig']).to eq({
55+
expect(data['addonsConfig']).to include(
5656
"horizontalPodAutoscaling" => {},
5757
"httpLoadBalancing" => {},
5858
"kubernetesDashboard" => {
5959
"disabled" => true,
6060
},
6161
"networkPolicyConfig" => {},
62-
})
62+
)
6363
end
6464
end
6565

test/integration/simple_regional_with_kubeconfig/controls/gcloud.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444
end
4545

4646
it "has the expected addon settings" do
47-
expect(data['addonsConfig']).to eq({
47+
expect(data['addonsConfig']).to include(
4848
"horizontalPodAutoscaling" => {},
4949
"httpLoadBalancing" => {},
5050
"kubernetesDashboard" => {
5151
"disabled" => true,
5252
},
5353
"networkPolicyConfig" => {},
54-
})
54+
)
5555
end
5656
end
5757

test/integration/simple_regional_with_networking/controls/gcloud.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444
end
4545

4646
it "has the expected addon settings" do
47-
expect(data['addonsConfig']).to eq({
47+
expect(data['addonsConfig']).to include(
4848
"horizontalPodAutoscaling" => {},
4949
"httpLoadBalancing" => {},
5050
"kubernetesDashboard" => {
5151
"disabled" => true,
5252
},
5353
"networkPolicyConfig" => {},
54-
})
54+
)
5555
end
5656
end
5757

test/integration/simple_zonal/controls/gcloud.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@
4949
end
5050

5151
it "has the expected addon settings" do
52-
expect(data['addonsConfig']).to eq({
52+
expect(data['addonsConfig']).to include(
5353
"horizontalPodAutoscaling" => {},
5454
"httpLoadBalancing" => {},
5555
"kubernetesDashboard" => {
5656
"disabled" => true,
5757
},
5858
"networkPolicyConfig" => {},
59-
})
59+
)
6060
end
6161
end
6262

test/integration/simple_zonal_private/controls/gcloud.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@
5252
end
5353

5454
it "has the expected addon settings" do
55-
expect(data['addonsConfig']).to eq({
55+
expect(data['addonsConfig']).to include(
5656
"horizontalPodAutoscaling" => {},
5757
"httpLoadBalancing" => {},
5858
"kubernetesDashboard" => {
5959
"disabled" => true,
6060
},
6161
"networkPolicyConfig" => {},
62-
})
62+
)
6363
end
6464
end
6565

test/integration/simple_regional_with_asm/inspec.yml renamed to test/integration/simple_zonal_with_asm/inspec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: simple_regional_with_asm
1+
name: simple_zonal_with_asm
22
attributes:
33
- name: cluster_name
44
required: true

test/integration/stub_domains/controls/gcloud.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
end
3737

3838
it "has the expected addon settings" do
39-
expect(data['addonsConfig']).to eq({
39+
expect(data['addonsConfig']).to include(
4040
"horizontalPodAutoscaling" => {},
4141
"httpLoadBalancing" => {},
4242
"kubernetesDashboard" => {
4343
"disabled" => true,
4444
},
4545
"networkPolicyConfig" => {},
46-
})
46+
)
4747
end
4848
end
4949
end

test/integration/stub_domains_private/controls/gcloud.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@
4343
end
4444

4545
it "has the expected addon settings" do
46-
expect(data["addonsConfig"]).to eq({
46+
expect(data["addonsConfig"]).to include(
4747
"horizontalPodAutoscaling" => {},
4848
"httpLoadBalancing" => {},
4949
"kubernetesDashboard" => {
5050
"disabled" => true,
5151
},
5252
"networkPolicyConfig" => {},
53-
})
53+
)
5454
end
5555
end
5656
end

test/integration/stub_domains_upstream_nameservers/controls/gcloud.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
end
3737

3838
it "has the expected addon settings" do
39-
expect(data['addonsConfig']).to eq({
39+
expect(data['addonsConfig']).to include(
4040
"horizontalPodAutoscaling" => {},
4141
"httpLoadBalancing" => {},
4242
"kubernetesDashboard" => {
4343
"disabled" => true,
4444
},
4545
"networkPolicyConfig" => {},
46-
})
46+
)
4747
end
4848
end
4949
end

test/integration/upstream_nameservers/controls/gcloud.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
end
3737

3838
it "has the expected addon settings" do
39-
expect(data['addonsConfig']).to eq({
39+
expect(data['addonsConfig']).to include(
4040
"horizontalPodAutoscaling" => {},
4141
"httpLoadBalancing" => {},
4242
"kubernetesDashboard" => {
4343
"disabled" => true,
4444
},
4545
"networkPolicyConfig" => {},
46-
})
46+
)
4747
end
4848
end
4949
end

0 commit comments

Comments
 (0)