Skip to content

Commit 0f536b7

Browse files
authored
chore(CI): migrate node_pool test to CFT (using CAI) (#2172)
1 parent bbdc63c commit 0f536b7

File tree

15 files changed

+991
-726
lines changed

15 files changed

+991
-726
lines changed

.kitchen.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,3 @@ suites:
8585
systems:
8686
- name: workload_metadata_config
8787
backend: local
88-
- name: "node_pool"
89-
transport:
90-
root_module_directory: test/fixtures/node_pool
91-
verifier:
92-
systems:
93-
- name: node_pool
94-
backend: local
95-
controls:
96-
- gcloud
97-
- kubectl

build/int.cloudbuild.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,21 +305,21 @@ steps:
305305
- verify deploy-service-local
306306
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
307307
args: ['/bin/bash', '-c', 'cft test run TestDeployService --stage destroy --verbose']
308-
- id: converge node-pool-local
308+
- id: apply node-pool-local
309309
waitFor:
310310
- create-all
311311
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
312-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge node-pool-local']
312+
args: ['/bin/bash', '-c', 'cft test run TestNodePool --stage apply --verbose']
313313
- id: verify node-pool-local
314314
waitFor:
315-
- converge node-pool-local
315+
- apply node-pool-local
316316
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
317-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify node-pool-local']
317+
args: ['/bin/bash', '-c', 'cft test run TestNodePool --stage verify --verbose']
318318
- id: destroy node-pool-local
319319
waitFor:
320320
- verify node-pool-local
321321
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
322-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy node-pool-local']
322+
args: ['/bin/bash', '-c', 'cft test run TestNodePool --stage destroy --verbose']
323323
- id: apply sandbox-enabled-local
324324
waitFor:
325325
- create-all

examples/node_pool/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module "gke" {
4343
disable_legacy_metadata_endpoints = false
4444
cluster_autoscaling = var.cluster_autoscaling
4545
deletion_protection = false
46+
service_account = "default"
4647

4748
node_pools = [
4849
{

test/fixtures/node_pool/example.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17+
locals {
18+
compute_engine_service_account = var.compute_engine_service_accounts[0]
19+
}
20+
1721
module "example" {
1822
source = "../../../examples/node_pool"
1923

@@ -25,7 +29,7 @@ module "example" {
2529
subnetwork = google_compute_subnetwork.main.name
2630
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
2731
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
28-
compute_engine_service_account = var.compute_engine_service_accounts[0]
32+
compute_engine_service_account = local.compute_engine_service_account
2933

3034
cluster_autoscaling = {
3135
enabled = true

test/fixtures/node_pool/outputs.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,11 @@ output "service_account" {
8383
output "registry_project_ids" {
8484
value = var.registry_project_ids
8585
}
86+
87+
output "random_string" {
88+
value = random_string.suffix.result
89+
}
90+
91+
output "compute_engine_service_account" {
92+
value = local.compute_engine_service_account
93+
}

test/integration/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ require (
99
github.com/gruntwork-io/terratest v0.48.1
1010
github.com/hashicorp/terraform-json v0.24.0
1111
github.com/stretchr/testify v1.10.0
12+
github.com/tidwall/gjson v1.18.0
13+
golang.org/x/sync v0.10.0
1214
)
1315

1416
require (
@@ -103,7 +105,6 @@ require (
103105
github.com/pquerna/otp v1.4.0 // indirect
104106
github.com/russross/blackfriday/v2 v2.1.0 // indirect
105107
github.com/spf13/pflag v1.0.5 // indirect
106-
github.com/tidwall/gjson v1.18.0 // indirect
107108
github.com/tidwall/match v1.1.1 // indirect
108109
github.com/tidwall/pretty v1.2.1 // indirect
109110
github.com/tidwall/sjson v1.2.5 // indirect
@@ -116,7 +117,6 @@ require (
116117
golang.org/x/mod v0.22.0 // indirect
117118
golang.org/x/net v0.31.0 // indirect
118119
golang.org/x/oauth2 v0.24.0 // indirect
119-
golang.org/x/sync v0.10.0 // indirect
120120
golang.org/x/sys v0.28.0 // indirect
121121
golang.org/x/term v0.27.0 // indirect
122122
golang.org/x/text v0.21.0 // indirect

0 commit comments

Comments
 (0)