Skip to content

Commit 29c0a54

Browse files
committed
chore(CI): migrate tests to cft
1 parent 1044071 commit 29c0a54

File tree

7 files changed

+943
-33
lines changed

7 files changed

+943
-33
lines changed

.kitchen.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,6 @@ suites:
6464
# systems:
6565
# - name: stub_domains_private
6666
# backend: local
67-
- name: "upstream_nameservers"
68-
transport:
69-
root_module_directory: test/fixtures/upstream_nameservers
70-
verifier:
71-
systems:
72-
- name: upstream_nameservers
73-
backend: local
7467
- name: "stub_domains_upstream_nameservers"
7568
transport:
7669
root_module_directory: test/fixtures/stub_domains_upstream_nameservers

CONTRIBUTING.md

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,14 @@ Integration tests are used to verify the behaviour of the root module,
4141
submodules, and example modules. Additions, changes, and fixes should
4242
be accompanied with tests.
4343

44-
The integration tests are run using [Kitchen][kitchen],
45-
[Kitchen-Terraform][kitchen-terraform], and [InSpec][inspec]. These
46-
tools are packaged within a Docker image for convenience.
44+
The integration tests are run using[Cloud Foundation Toolkit CLI (CFT CLI)][https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/tree/main/cli],
45+
and [Blueprint Test][https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/tree/main/infra/blueprint-test]. The CFT CLI
46+
is packaged within a Docker image for convenience.
4747

4848
The general strategy for these tests is to verify the behaviour of the
4949
[example modules](./examples/), thus ensuring that the root module,
5050
submodules, and example modules are all functionally correct.
5151

52-
Six test-kitchen instances are defined:
53-
54-
- `deploy-service`
55-
- `node-pool`
56-
- `shared-vpc`
57-
- `simple-regional`
58-
- `simple-zonal`
59-
- `stub-domains`
60-
61-
The test-kitchen instances in `test/fixtures/` wrap identically-named examples in the `examples/` directory.`
62-
6352
### Test Environment
6453
The easiest way to test the module is in an isolated test project. The
6554
setup for such a project is defined in [test/setup](./test/setup/)
@@ -101,14 +90,14 @@ noninteractively, using the prepared test project.
10190
1. Run `make docker_run` to start the testing Docker container in
10291
interactive mode.
10392

104-
1. Run `kitchen_do create <EXAMPLE_NAME>` to initialize the working
93+
1. Run `cft test run <EXAMPLE_NAME> --stage init` to initialize the working
10594
directory for an example module.
10695

107-
1. Run `kitchen_do converge <EXAMPLE_NAME>` to apply the example module.
96+
1. Run `cft test run <EXAMPLE_NAME> --stage apply` to apply the example module.
10897

109-
1. Run `kitchen_do verify <EXAMPLE_NAME>` to test the example module.
98+
1. Run `cft test run <EXAMPLE_NAME> --stage verify` to test the example module.
11099

111-
1. Run `kitchen_do destroy <EXAMPLE_NAME>` to destroy the example module
100+
1. Run `cft test run <EXAMPLE_NAME> --stage destroy` to destroy the example module
112101
state.
113102

114103
## Linting and Formatting

build/int.cloudbuild.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,21 @@ steps:
215215
- verify stub-domains-local
216216
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
217217
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy stub-domains-local']
218-
- id: converge upstream-nameservers-local
218+
- id: apply upstream-nameservers-local
219219
waitFor:
220220
- create-all
221221
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
222-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge upstream-nameservers-local']
222+
args: ['/bin/bash', '-c', 'cft test run TestUpstreamNameservers --stage apply --verbose --test-dir test/integration']
223223
- id: verify upstream-nameservers-local
224224
waitFor:
225-
- converge upstream-nameservers-local
225+
- apply upstream-nameservers-local
226226
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
227-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify upstream-nameservers-local']
227+
args: ['/bin/bash', '-c', 'cft test run TestUpstreamNameservers --stage verify --verbose --test-dir test/integration']
228228
- id: destroy upstream-nameservers-local
229229
waitFor:
230230
- verify upstream-nameservers-local
231231
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
232-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy upstream-nameservers-local']
232+
args: ['/bin/bash', '-c', 'cft test run TestUpstreamNameservers --stage destroy --verbose --test-dir test/integration']
233233
- id: converge stub-domains-upstream-nameservers-local
234234
waitFor:
235235
- create-all

test/fixtures/upstream_nameservers/example.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2018-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,6 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

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

@@ -24,6 +28,6 @@ module "example" {
2428
subnetwork = google_compute_subnetwork.main.name
2529
ip_range_pods = google_compute_subnetwork.main.secondary_ip_range[0].range_name
2630
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
27-
compute_engine_service_account = var.compute_engine_service_accounts[1]
31+
compute_engine_service_account = local.compute_engine_service_account
2832
}
2933

test/fixtures/upstream_nameservers/outputs.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2018-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,3 +56,11 @@ output "service_account" {
5656
description = "The service account to default running nodes as if not overridden in `node_pools`."
5757
value = module.example.service_account
5858
}
59+
60+
output "random_string" {
61+
value = random_string.suffix.result
62+
}
63+
64+
output "compute_engine_service_account" {
65+
value = local.compute_engine_service_account
66+
}

0 commit comments

Comments
 (0)