Review fixes

This commit is contained in:
Wiktor Niesiobędzki 2023-11-30 17:08:49 +00:00
parent 3557ed8a95
commit 6d68b50bc8
2 changed files with 15 additions and 7 deletions

View File

@ -1086,7 +1086,9 @@ Prepare following information:
#### How does it work #### How does it work
Each test case is provided by additional environment defined in [variables.tf](tests/examples/variables.tf). This simplifies writing the examples as this follows the same structure as for non-end-to-end tests, and allows multiple, independent and concurrent runs of tests. Each test case is provided by additional environment defined in [variables.tf](tests/examples/variables.tf). This simplifies writing the examples as this follows the same structure as for non-end-to-end tests, and allows multiple, independent and concurrent runs of tests.
The test environment can be provisioned automatically during the test run (which takes ~2 minutes) and destroyed at the end, when of the tests (option 1 below), which is targeting automated runs in CI/CD pipeline, or can be provisioned manually (option 2 below) to reduce test time, which might be typical use case for tests run locally. The test environment can be provisioned automatically during the test run (which takes ~2 minutes) and destroyed at the end, when all tests finish (option 1 below), which is targeting automated runs in CI/CD pipeline, or it can be provisioned manually (option 2 below) to reduce test time, which might be typical use case for tests run locally.
For development, to keep the feedback loop short, consider using [local sandbox](#creating-sandbox-environment-for-examples) and paste specific example in `main.tf` file.
#### Option 1 - automatically provision and de-provision testing infrastructure #### Option 1 - automatically provision and de-provision testing infrastructure
@ -1114,16 +1116,14 @@ pytest tests/examples_e2e
#### Option 2 - Provision manually test environment and use it for tests #### Option 2 - Provision manually test environment and use it for tests
##### Provision manually test environment ##### Provision manually test environment
In `tests/examples_e2e/setup_module` create `terraform.tfvars` with following values: In `tests/examples_e2e/setup_module` create `terraform.tfvars` with following values:
```hcl ```tfvars
billing_account = "123456-123456-123456" # billing account id to associate projects billing_account = "123456-123456-123456" # billing account id to associate projects
group_email = "group@example.org" # existing group within organization group_email = "group@example.org" # existing group within organization
organization_id = "1234567890" # your organization id organization_id = "1234567890" # your organization id
parent = "folders/1234567890" # folder under which test resources will be created parent = "folders/1234567890" # folder under which test resources will be created
prefix = "your-unique-prefix" # unique prefix for projects prefix = "your-unique-prefix" # unique prefix for projects
region = "europe-west4" # region to use region = "europe-west4" # region to use
suffix = "1" # suffix, keep 1 for now timestamp = "1696444185" # generate your own timestamp - will be used as a part of prefix for globally unique resources
timestamp = "1696444185" # generate your own timestamp - will be used as a part of prefix
# tftest skip
``` ```
If you use service account impersonation, set `GOOGLE_IMPERSONATE_SERVICE_ACCOUNT` If you use service account impersonation, set `GOOGLE_IMPERSONATE_SERVICE_ACCOUNT`
@ -1141,9 +1141,16 @@ This will generate also `tests/examples_e2e/setup_module/e2e_tests.tfvars` for y
##### Setup your environment ##### Setup your environment
```bash ```bash
export TFTEST_E2E_TFVARS_PATH=`pwd`/tests/examples_e2e/setup_module/e2e_tests.tfvars # generated above export TFTEST_E2E_TFVARS_PATH=`pwd`/tests/examples_e2e/setup_module/e2e_tests.tfvars # generated above
export TF_VAR_prefix="your-unique-prefix" # unique prefix for projects, no longer than 7 characters export TFTEST_E2E_prefix="your-unique-prefix" # unique prefix for projects, no longer than 7 characters
``` ```
##### De-provision the environment
Once you are done with the tests, run:
```bash
(cd tests/examples_e2e/setup_module/ && terraform apply -destroy)
```
To remove all resources created for testing and `tests/examples_e2e/setup_module/e2e_tests.tfvars` file.
#### Run tests #### Run tests
Run tests using: Run tests using:
```bash ```bash

View File

@ -31,7 +31,8 @@ variable "region" {
type = string type = string
} }
variable "suffix" { variable "suffix" {
type = string type = string
default = "0"
} }
variable "timestamp" { variable "timestamp" {
type = string type = string