Skip to content

Commit

Permalink
docs(blueprint-test): update notes in README (#2626)
Browse files Browse the repository at this point in the history
  • Loading branch information
wyardley authored Sep 26, 2024
1 parent 5f3baf4 commit f9b4d6f
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions infra/blueprint-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Apart from the necessity of including a testing framework as part of our GCP blu

Considering the above, our test framework has been developed (details in the following sections) with backward compatibility to allow for current tests to keep functioning.

*Note: If you have a question about the test framework, feel free to ask it on our user group.
> [!NOTE]
> If you have a question about the test framework, feel free to ask it on our user group.
Feature requests can also be submitted as Issues.*

# 2. Framework Concepts

```
Note: The best reference documentation for the framework is the [autogenerated documentation](https://pkg.go.dev/github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test).
```
> [!NOTE]
> The best reference documentation for the framework is the [autogenerated documentation](https://pkg.go.dev/github.com/GoogleCloudPlatform/cloud-foundation-toolkit/infra/blueprint-test).
The test framework uses Golang with the testing package at its core to allow for creation and setup of GCP blueprints integration tests.

Expand Down Expand Up @@ -125,16 +125,12 @@ module "mysql-db" {
}
```

```
Note:
Variables defined in the example module’s variables (normally variables.tf) configuration can be set 1) from
wrapping modules calling the example module (e.g. fixtures) or 2) using environment variables by prefixing
the environment variable with “TF_VAR”.
E.g. to set the project_id variable (above), setting the value in a “TF_VAR_project_id” environment variable
would automatically populate its value upon execution. This is illustrated the file
> [!NOTE]
> Variables defined in the example module’s variables (normally variables.tf) configuration can be set 1) from wrapping modules calling the example module (e.g. fixtures) or 2) using environment variables by prefixing the environment variable with `TF_VAR`.
>
> E.g. to set the project_id variable (above), setting the value in a `TF_VAR_project_id` environment variable
> would automatically populate its value upon execution. This is illustrated the file
`test/setup/outputs.tf` where the `project_id` is being exported as an env variable.
```

#### 3.1.1.2 Output variables for the test
Upon successful execution of your example module, you will most likely need outputs for resources being provisioned to validate and assert in your test. This is done using outputs in Terraform.
Expand Down Expand Up @@ -255,7 +251,8 @@ By default, tests go through 4 stages above. You can also explicitly run individ
## 4.1 Test prerequisites
In order for the test to execute, certain prerequisite resources and components need to be in place. These can be set up using the TF modules under `test/setup`. Running `terraform apply` in this directory will set up all resources required for the test.

> Note: Output values from `test/setup` are automatically loaded as Terraform environment variables and are available to both auto discovered and custom/explicit tests as inputs. This is also illustrated in the [Create the example configuration - Step 4](https://github.com/g-awmalik/cloud-foundation-toolkit/tree/feat/add-bp-test-doc/infra/blueprint-test#3111-create-the-example-configuration) above where the `project_id` variable output by the `test/setup` is consumed as a variable for the example.
> [!NOTE]
> Output values from `test/setup` are automatically loaded as Terraform environment variables and are available to both auto discovered and custom/explicit tests as inputs. This is also illustrated in the [Create the example configuration - Step 4](https://github.com/g-awmalik/cloud-foundation-toolkit/tree/feat/add-bp-test-doc/infra/blueprint-test#3111-create-the-example-configuration) above where the `project_id` variable output by the `test/setup` is consumed as a variable for the example.


## 4.2 Default and stage specific execution
Expand Down Expand Up @@ -323,9 +320,9 @@ This section shows the execution for auto-discovered tests and the output illust

4. Beginning of `verify` stage

```
Note: this illustration is from the 2nd test case (mssql-public) that made it through the apply stage successfully.
```
> [!NOTE]
> this illustration is from the 2nd test case (mssql-public) that made it through the apply stage successfully.

![4](https://user-images.githubusercontent.com/21246369/131234120-6a3bdb62-0437-4d93-a1b7-2ef7b0191d40.jpg)
This illustrates the execution of the verify stage where TF plan is executed to refresh the TF state and confirm no permadiffs occur and all resources were successfully provisioned.

Expand Down

0 comments on commit f9b4d6f

Please sign in to comment.