Skip to content

Commit 81eb717

Browse files
authored
Merge pull request #262 from paulpalamarchuk/move_tests_to_cloudbuild
Update integration tests to use new approach
2 parents f99ddf4 + f7d2a6c commit 81eb717

File tree

72 files changed

+670
-2438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+670
-2438
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ test/fixtures/*/.terraform
77
test/fixtures/*/terraform.tfstate.d
88
examples/.kitchen
99
examples/*/.terraform
10-
examples/*/terraform.tfstate.d
10+
examples/*/terraform.tfstate.d
11+

.kitchen.yml

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,31 @@ platforms:
2929
- name: local
3030

3131
suites:
32-
- name: "deploy_service"
33-
driver:
34-
root_module_directory: test/fixtures/deploy_service
35-
verifier:
36-
systems:
37-
- name: deploy_service
38-
backend: local
32+
# Disabled due to issue #274
33+
# (https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/issues/274)
34+
# - name: "deploy_service"
35+
# driver:
36+
# root_module_directory: test/fixtures/deploy_service
37+
# verifier:
38+
# systems:
39+
# - name: deploy_service
40+
# backend: local
3941
- name: "disable_client_cert"
4042
driver:
4143
root_module_directory: test/fixtures/disable_client_cert
4244
verifier:
4345
systems:
4446
- name: disable_client_cert
4547
backend: local
46-
- name: "node_pool"
47-
driver:
48-
root_module_directory: test/fixtures/node_pool
49-
verifier:
50-
systems:
51-
- name: node_pool
52-
backend: local
48+
# Disabled due to issue #274
49+
# (https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/issues/274)
50+
# - name: "node_pool"
51+
# driver:
52+
# root_module_directory: test/fixtures/node_pool
53+
# verifier:
54+
# systems:
55+
# - name: node_pool
56+
# backend: local
5357
- name: "shared_vpc"
5458
driver:
5559
root_module_directory: test/fixtures/shared_vpc
@@ -98,12 +102,14 @@ suites:
98102
systems:
99103
- name: stub_domains
100104
backend: local
101-
- name: stub_domains_private
102-
driver:
103-
root_module_directory: test/fixtures/stub_domains_private
104-
systems:
105-
- name: stub_domains_private
106-
backend: local
105+
# Disabled due to issue #264
106+
# (https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/issues/264)
107+
# - name: stub_domains_private
108+
# driver:
109+
# root_module_directory: test/fixtures/stub_domains_private
110+
# systems:
111+
# - name: stub_domains_private
112+
# backend: local
107113
- name: "upstream_nameservers"
108114
driver:
109115
root_module_directory: test/fixtures/upstream_nameservers

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

CONTRIBUTING.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Contributing
2+
3+
This document provides guidelines for contributing to the module.
4+
5+
## Dependencies
6+
7+
The following dependencies must be installed on the development system:
8+
9+
- [Docker Engine][docker-engine]
10+
- [Google Cloud SDK][google-cloud-sdk]
11+
- [make]
12+
13+
## Generating Documentation for Inputs and Outputs
14+
15+
The Inputs and Outputs tables in the READMEs of the root module,
16+
submodules, and example modules are automatically generated based on
17+
the `variables` and `outputs` of the respective modules. These tables
18+
must be refreshed if the module interfaces are changed.
19+
20+
## Templating
21+
22+
To more cleanly handle cases where desired functionality would require complex duplication of Terraform resources (i.e. [PR 51](https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/51)), this repository is largely generated from the [`autogen`](/autogen) directory.
23+
24+
The root module is generated by running `make generate`. Changes to this repository should be made in the [`autogen`](/autogen) directory where appropriate.
25+
26+
Note: The correct sequence to update the repo using autogen functionality is to run
27+
`make docker_generate && make docker_generate_docs`. This will create the various Terraform files, and then
28+
generate the Terraform documentation using `terraform-docs`.
29+
30+
### Autogeneration of documentation from .tf files
31+
To generate new Inputs and Outputs tables run
32+
```
33+
make docker_generate_docs
34+
```
35+
36+
## Integration Testing
37+
38+
Integration tests are used to verify the behaviour of the root module,
39+
submodules, and example modules. Additions, changes, and fixes should
40+
be accompanied with tests.
41+
42+
The integration tests are run using [Kitchen][kitchen],
43+
[Kitchen-Terraform][kitchen-terraform], and [InSpec][inspec]. These
44+
tools are packaged within a Docker image for convenience.
45+
46+
The general strategy for these tests is to verify the behaviour of the
47+
[example modules](./examples/), thus ensuring that the root module,
48+
submodules, and example modules are all functionally correct.
49+
50+
Six test-kitchen instances are defined:
51+
52+
- `deploy-service`
53+
- `node-pool`
54+
- `shared-vpc`
55+
- `simple-regional`
56+
- `simple-zonal`
57+
- `stub-domains`
58+
59+
The test-kitchen instances in `test/fixtures/` wrap identically-named examples in the `examples/` directory.`
60+
61+
### Test Environment
62+
The easiest way to test the module is in an isolated test project. The setup for such a project is defined in [test/setup](./test/setup/) directory.
63+
64+
To use this setup, you need a service account with Project Creator access on a folder. Export the Service Account credentials to your environment like so:
65+
66+
```
67+
export SERVICE_ACCOUNT_JSON=$(< credentials.json)
68+
```
69+
70+
You will also need to set a few environment variables:
71+
```
72+
export TF_VAR_org_id="your_org_id"
73+
export TF_VAR_folder_id="your_folder_id"
74+
export TF_VAR_billing_account="your_billing_account_id"
75+
```
76+
77+
With these settings in place, you can prepare a test project using Docker:
78+
```
79+
make docker_test_prepare
80+
```
81+
82+
### Noninteractive Execution
83+
84+
Run `make docker_test_integration` to test all of the example modules
85+
noninteractively, using the prepared test project.
86+
87+
### Interactive Execution
88+
89+
1. Run `make docker_run` to start the testing Docker container in
90+
interactive mode.
91+
92+
1. Run `kitchen_do create <EXAMPLE_NAME>` to initialize the working
93+
directory for an example module.
94+
95+
1. Run `kitchen_do converge <EXAMPLE_NAME>` to apply the example module.
96+
97+
1. Run `kitchen_do verify <EXAMPLE_NAME>` to test the example module.
98+
99+
1. Run `kitchen_do destroy <EXAMPLE_NAME>` to destroy the example module
100+
state.
101+
102+
## Linting and Formatting
103+
104+
Many of the files in the repository can be linted or formatted to
105+
maintain a standard of quality.
106+
107+
### Execution
108+
109+
Run `make docker_test_lint`.
110+
111+
[docker-engine]: https://www.docker.com/products/docker-engine
112+
[flake8]: http://flake8.pycqa.org/en/latest/
113+
[gofmt]: https://golang.org/cmd/gofmt/
114+
[google-cloud-sdk]: https://cloud.google.com/sdk/install
115+
[hadolint]: https://github.com/hadolint/hadolint
116+
[inspec]: https://inspec.io/
117+
[kitchen-terraform]: https://github.com/newcontext-oss/kitchen-terraform
118+
[kitchen]: https://kitchen.ci/
119+
[make]: https://en.wikipedia.org/wiki/Make_(software)
120+
[shellcheck]: https://www.shellcheck.net/
121+
[terraform-docs]: https://github.com/segmentio/terraform-docs
122+
[terraform]: https://terraform.io/

0 commit comments

Comments
 (0)