Skip to content

Commit

Permalink
Fix integration test project creation (#574)
Browse files Browse the repository at this point in the history
* fix tests

docs updates to zonal

update cb

* update addon

* workaround for gcloud flaky output
  • Loading branch information
bharathkkb authored Jun 24, 2020
1 parent cf3273d commit c05c48e
Show file tree
Hide file tree
Showing 31 changed files with 82 additions and 69 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ credentials.json
# File to populate env vars used by Docker test runs
.envrc

# ignore generated ASM yamls in /workspace/test/fixtures/simple_regional_with_asm as it is a test
# ignore generated ASM yamls in /workspace/test/fixtures/simple_zonal_with_asm as it is a test
# in a production scenario these files are expected to be checked in
/test/fixtures/simple_regional_with_asm/asm-dir
/test/fixtures/simple_zonal_with_asm/asm-dir
6 changes: 3 additions & 3 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ suites:
systems:
- name: safer_cluster_iap_bastion
backend: local
- name: "simple_regional_with_asm"
- name: "simple_zonal_with_asm"
driver:
root_module_directory: test/fixtures/simple_regional_with_asm
root_module_directory: test/fixtures/simple_zonal_with_asm
verifier:
systems:
- name: simple_regional_with_asm
- name: simple_zonal_with_asm
backend: local
controls:
- gcloud
Expand Down
22 changes: 11 additions & 11 deletions build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -404,26 +404,26 @@ steps:
- verify safer-cluster-iap-bastion-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy safer-cluster-iap-bastion-local']
- id: create simple-regional-with-asm-local
- id: create simple-zonal-with-asm-local
waitFor:
- prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create simple-regional-with-asm-local']
- id: converge simple-regional-with-asm-local
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create simple-zonal-with-asm-local']
- id: converge simple-zonal-with-asm-local
waitFor:
- create simple-regional-with-asm-local
- create simple-zonal-with-asm-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-regional-with-asm-local']
- id: verify simple-regional-with-asm-local
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-zonal-with-asm-local']
- id: verify simple-zonal-with-asm-local
waitFor:
- converge simple-regional-with-asm-local
- converge simple-zonal-with-asm-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-regional-with-asm-local']
- id: destroy simple-regional-with-asm-local
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-zonal-with-asm-local']
- id: destroy simple-zonal-with-asm-local
waitFor:
- verify simple-regional-with-asm-local
- verify simple-zonal-with-asm-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-regional-with-asm-local']
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-zonal-with-asm-local']
tags:
- 'ci'
- 'integration'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Simple Regional Cluster with ASM
# Simple Zonal Cluster with ASM

This example illustrates how to create a simple regional cluster with ASM.
This example illustrates how to create a simple zonal cluster with ASM.

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

## Outputs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

locals {
cluster_type = "simple-regional-asm2"
cluster_type = "simple-zonal-asm"
}

provider "google-beta" {
Expand All @@ -31,9 +31,10 @@ module "gke" {
source = "../../modules/beta-public-cluster/"
project_id = var.project_id
name = "${local.cluster_type}-cluster${var.cluster_name_suffix}"
regional = true
release_channel = "REGULAR"
regional = false
region = var.region
zones = var.zones
release_channel = "REGULAR"
network = var.network
subnetwork = var.subnetwork
ip_range_pods = var.ip_range_pods
Expand All @@ -42,11 +43,11 @@ module "gke" {
cluster_resource_labels = { "mesh_id" : "proj-${data.google_project.project.number}" }
node_pools = [
{
name = "asm-node-pool"
autoscaling = false
name = "asm-node-pool"
autoscaling = false
auto_upgrade = true
# ASM requires minimum 4 nodes and e2-standard-4
# As this is a regional cluster we have node_count * 3 = 6 nodes
node_count = 2
node_count = 4
machine_type = "e2-standard-4"
},
]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ variable "region" {
description = "The region to host the cluster in"
}

variable "zones" {
type = list(string)
description = "The zone to host the cluster in (required if is a zonal cluster)"
}

variable "network" {
description = "The VPC network to host the cluster in"
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion modules/asm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Specifically, this module automates the following steps for [installing ASM](htt

## Usage

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

```tf
module "asm" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ data "google_project" "project" {
}

module "example" {
source = "../../../examples/simple_regional_with_asm"
source = "../../../examples/simple_zonal_with_asm"

project_id = var.project_ids[2]
cluster_name_suffix = "-${random_string.suffix.result}"
region = var.region
zones = slice(var.zones, 0, 1)
network = google_compute_network.main.name
subnetwork = google_compute_subnetwork.main.name
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@
end

it "has the expected addon settings" do
expect(data['addonsConfig']).to eq({
expect(data['addonsConfig']).to include(
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
)
end
end

Expand Down
18 changes: 9 additions & 9 deletions test/integration/safer_cluster/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
end

it "has the expected addon settings" do
expect(data['addonsConfig']).to eq({
"cloudRunConfig" => {},
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
expect(data['addonsConfig']).to include(
"cloudRunConfig" => {},
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => including(
"disabled" => true,
),
"networkPolicyConfig" => {},
)
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/integration/sandbox_enabled/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
end

it "has the expected addon settings" do
expect(data['addonsConfig']).to eq({
expect(data['addonsConfig']).to include(
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
)
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/integration/simple_regional/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
end

it "has the expected addon settings" do
expect(data['addonsConfig']).to eq({
expect(data['addonsConfig']).to include(
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
)
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/integration/simple_regional_private/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
end

it "has the expected addon settings" do
expect(data['addonsConfig']).to eq({
expect(data['addonsConfig']).to include(
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
end

it "has the expected addon settings" do
expect(data['addonsConfig']).to eq({
expect(data['addonsConfig']).to include(
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
end

it "has the expected addon settings" do
expect(data['addonsConfig']).to eq({
expect(data['addonsConfig']).to include(
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
)
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/integration/simple_zonal/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
end

it "has the expected addon settings" do
expect(data['addonsConfig']).to eq({
expect(data['addonsConfig']).to include(
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
)
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/integration/simple_zonal_private/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
end

it "has the expected addon settings" do
expect(data['addonsConfig']).to eq({
expect(data['addonsConfig']).to include(
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
)
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: simple_regional_with_asm
name: simple_zonal_with_asm
attributes:
- name: cluster_name
required: true
Expand Down
4 changes: 2 additions & 2 deletions test/integration/stub_domains/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
end

it "has the expected addon settings" do
expect(data['addonsConfig']).to eq({
expect(data['addonsConfig']).to include(
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/integration/stub_domains_private/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
end

it "has the expected addon settings" do
expect(data["addonsConfig"]).to eq({
expect(data["addonsConfig"]).to include(
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
end

it "has the expected addon settings" do
expect(data['addonsConfig']).to eq({
expect(data['addonsConfig']).to include(
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/integration/upstream_nameservers/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
end

it "has the expected addon settings" do
expect(data['addonsConfig']).to eq({
expect(data['addonsConfig']).to include(
"horizontalPodAutoscaling" => {},
"httpLoadBalancing" => {},
"kubernetesDashboard" => {
"disabled" => true,
},
"networkPolicyConfig" => {},
})
)
end
end
end
Expand Down
Loading

0 comments on commit c05c48e

Please sign in to comment.