Skip to content

Commit

Permalink
chore(CI): migrate node_pool test to CFT (using CAI) (#2172)
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody authored Dec 20, 2024
1 parent bbdc63c commit 0f536b7
Show file tree
Hide file tree
Showing 15 changed files with 991 additions and 726 deletions.
10 changes: 0 additions & 10 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,3 @@ suites:
systems:
- name: workload_metadata_config
backend: local
- name: "node_pool"
transport:
root_module_directory: test/fixtures/node_pool
verifier:
systems:
- name: node_pool
backend: local
controls:
- gcloud
- kubectl
10 changes: 5 additions & 5 deletions build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,21 +305,21 @@ steps:
- verify deploy-service-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestDeployService --stage destroy --verbose']
- id: converge node-pool-local
- id: apply node-pool-local
waitFor:
- create-all
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 node-pool-local']
args: ['/bin/bash', '-c', 'cft test run TestNodePool --stage apply --verbose']
- id: verify node-pool-local
waitFor:
- converge node-pool-local
- apply node-pool-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 node-pool-local']
args: ['/bin/bash', '-c', 'cft test run TestNodePool --stage verify --verbose']
- id: destroy node-pool-local
waitFor:
- verify node-pool-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 node-pool-local']
args: ['/bin/bash', '-c', 'cft test run TestNodePool --stage destroy --verbose']
- id: apply sandbox-enabled-local
waitFor:
- create-all
Expand Down
1 change: 1 addition & 0 deletions examples/node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module "gke" {
disable_legacy_metadata_endpoints = false
cluster_autoscaling = var.cluster_autoscaling
deletion_protection = false
service_account = "default"

node_pools = [
{
Expand Down
6 changes: 5 additions & 1 deletion test/fixtures/node_pool/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* limitations under the License.
*/

locals {
compute_engine_service_account = var.compute_engine_service_accounts[0]
}

module "example" {
source = "../../../examples/node_pool"

Expand All @@ -25,7 +29,7 @@ module "example" {
subnetwork = google_compute_subnetwork.main.name
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
compute_engine_service_account = var.compute_engine_service_accounts[0]
compute_engine_service_account = local.compute_engine_service_account

cluster_autoscaling = {
enabled = true
Expand Down
8 changes: 8 additions & 0 deletions test/fixtures/node_pool/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,11 @@ output "service_account" {
output "registry_project_ids" {
value = var.registry_project_ids
}

output "random_string" {
value = random_string.suffix.result
}

output "compute_engine_service_account" {
value = local.compute_engine_service_account
}
4 changes: 2 additions & 2 deletions test/integration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ require (
github.com/gruntwork-io/terratest v0.48.1
github.com/hashicorp/terraform-json v0.24.0
github.com/stretchr/testify v1.10.0
github.com/tidwall/gjson v1.18.0
golang.org/x/sync v0.10.0
)

require (
Expand Down Expand Up @@ -103,7 +105,6 @@ require (
github.com/pquerna/otp v1.4.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
Expand All @@ -116,7 +117,6 @@ require (
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
Expand Down
Loading

0 comments on commit 0f536b7

Please sign in to comment.