Skip to content

Commit 0ad6a78

Browse files
illianovsaschjmilCarus11Phani kumar ThodupunooriPhanikumarThodupunoori
authored
test: table test framework (PSKD-1363) (#439)
* feat: (PSKD-1145) Add initial plan tests Signed-off-by: chjmil <[email protected]> * feat: (PSKD-1145) WIP defaults unit tests Created by Griffin Signed-off-by: chjmil <[email protected]> * more work on default tests Signed-off-by: chjmil <[email protected]> * Finished general variables for defaults Signed-off-by: chjmil <[email protected]> * Restoring go:build tag Signed-off-by: chjmil <[email protected]> * chore(deps): update default vm generations off v3 (#417) * chore(deps): update default vm generations off v3 Signed-off-by: Carus Kyle <[email protected]> * docs: update examples default vm generations from _v3 to _v5 Signed-off-by: Carus Kyle <[email protected]> * fix: flex server v5 to v3 Reverting the flex server from v5 to v3 to make it more generally available. Signed-off-by: chjmil <[email protected]> --------- Signed-off-by: Carus Kyle <[email protected]> Signed-off-by: chjmil <[email protected]> Co-authored-by: chjmil <[email protected]> * Adding additional node pool tests Signed-off-by: chjmil <[email protected]> * Finished NodePools tests * Finished NodePools tests * Rework node pool checking Signed-off-by: chjmil <[email protected]> * Finished Additional Node Pool testing Signed-off-by: chjmil <[email protected]> * fix: explicitly install terraform in linter Signed-off-by: chjmil <[email protected]> * Finished testing for Networking Variables * Updated tfvars file path * Add two more tests using RawPlan Signed-off-by: chjmil <[email protected]> * Add two networking tests Signed-off-by: chjmil <[email protected]> * Add cluster_egress_type test Signed-off-by: chjmil <[email protected]> * test: (PSKD-1271) create test for fips_enabled * Finished testing Networking Variables * Finished testing Networking Variables * Make temp file OS-independent Signed-off-by: chjmil <[email protected]> * Combine network tests and gitignore .vscode Signed-off-by: chjmil <[email protected]> * ci: (PSKD-1310) add git leaks pre commit hook Signed-off-by: Ian Dominno <[email protected]> * feat: add storage_type and nfs tests test storage_type test create_nfs_public_ip test enable_nfs_public_static_ip Signed-off-by: Griffin Tomaszewski <[email protected]> * feat: Add terratest workflow Signed-off-by: chjmil <[email protected]> * fix: secret -> env Signed-off-by: chjmil <[email protected]> * fix: update workflow env Signed-off-by: chjmil <[email protected]> * intentional failure Signed-off-by: chjmil <[email protected]> * Update nodepool_test.go * Add parse_results.go Signed-off-by: chjmil <[email protected]> * fix parse_results Signed-off-by: chjmil <[email protected]> * remove failure printing Signed-off-by: chjmil <[email protected]> * Remove dummy failure Signed-off-by: chjmil <[email protected]> * Fix exit code Signed-off-by: chjmil <[email protected]> * feat: Add prefix test (PSKD-1263) (#430) Co-authored-by: [email protected] <[email protected]> * move acr_test.go and tidy up Signed-off-by: chjmil <[email protected]> * fix go setup cache warning Signed-off-by: chjmil <[email protected]> * test: (PSKD-1264) add location terratest Signed-off-by: Ian Dominno <[email protected]> * test: (PSKD-1275) and (PSKD-1265) Tests the default values for both the rbac_add_enabled and nfs_vm_admin variables. Signed-off-by: joboon <[email protected]> * fix: update plan test workflow name Signed-off-by: chjmil <[email protected]> * fix: temp failure to test workflow Signed-off-by: chjmil <[email protected]> * fix: remove expected failure Signed-off-by: chjmil <[email protected]> * test: add test for nfs_vm_machine_type default (PSKD-1276) (#431) * test: add test for nfs_vm_machine_type default (PSKD-1276) * test: sign-off previous commit (PSKD-1276) DCO Remediation Commit for Ed Overton <[email protected]> I, Ed Overton <[email protected]>, hereby add my Signed-off-by to this commit: 4f1e72c Signed-off-by: Ed Overton <[email protected]> --------- Signed-off-by: Ed Overton <[email protected]> * test: add tests for nfs_raid_disk_type, nfs_raid_disk_size (PSKD-1278)(PSKD-1279) - add test for nfs_raid_disk_type - add test for nfs_raid_disk_size Signed-off-by: David.Houck <[email protected]> * test: (PSKD-1277) terratest test for nfs_vm_zone Signed-off-by: Ian Dominno <[email protected]> * feat: Add ACR tests (PSKD-1353) (#433) * feat: Add ACR tests (PSKD-1353) * feat: Add ACR tests (PSKD-1353) * feat: Add ACR tests (PSKD-1353) --------- Co-authored-by: [email protected] <[email protected]> * Completed 9 variables * Tested all the variables * Tested all the Variables * tested * test: (PSKD-1352) add azure netapp tests (#435) Signed-off-by: Ian Dominno <[email protected]> * test: rbac tests using jsonpath (PSKD-1378) (#436) * test: rbac tests using jsonpath (PSKD-1378) * test: sshkey test refactor (PSKD-1378) * test: refactor acr_test * test: nuke the build tags * test: run all tests * test: testy stuff * test: testy stuff * Tested all the Variables * ci: update helpers and fix some errors Signed-off-by: chjmil <[email protected]> * fix: update go.mod and go.sum Signed-off-by: chjmil <[email protected]> * fix: fix remaining tests Signed-off-by: chjmil <[email protected]> * test: nodetest and postgres tests with jsonpath * test: table test framework (PSKD-1363) * test: add helper for plan vars (PSKD-1363) * test: move some tests to table (PSKD-1363) * Added * test: move rbac_add_enabled to test table (PSKD-1391) Signed-off-by: joboon <[email protected]> * added nodepool to test table * test: acr tests refactor prototype (PSKD-1363) * test: enable dynamic name (PSKD-1363) * changes to nodepool test table * test: message support added for assert failures (PSKD-1363) * test: (PSKD-1397) and (PSKD-1393) Refactors additional nodepool attribute tests for the default plan to use test tables. Included in these attributes are the tests for fips_enabled in PSKD-1393. Signed-off-by: joboon <[email protected]> * docs: (PSKD-1390) convert default required value location to table tests Signed-off-by: Ian Dominno <[email protected]> * test: refactor azure netapp into test table (PSKD-1399) Also refactors non-default RBAC tests into a test table. * test: Convert Default Storage and NFS Server var group to table tests (PSKD-1398) Signed-off-by: David.Houck <[email protected]> * Merge testing into pr-pskd-1145 (#443) * added networking variables table test * changed function to TestPlanNetwork --------- Co-authored-by: Chris Miller <[email protected]> * test: refactor postgres tests into test table (PSKD-1401) * test: add general and output tests (#444) Signed-off-by: chjmil <[email protected]> * test: move admin access tests to table (PSKD-1392) * test: add subnet tests Signed-off-by: chjmil <[email protected]> * test: consolidate testing files (#445) * test: consolidate testing files Signed-off-by: Ian Dominno <[email protected]> * fix: remove parent temp folder Signed-off-by: chjmil <[email protected]> * fix: make file deletion os-agnostic Signed-off-by: chjmil <[email protected]> --------- Signed-off-by: Ian Dominno <[email protected]> Signed-off-by: chjmil <[email protected]> Co-authored-by: chjmil <[email protected]> * test: update admin tests (PSKD-1392) * ci: add testing dockerfile and documentation (#441) * add dockerfile/compose.yml * feat: add dockerfile and docker compose Signed-off-by: chjmil <[email protected]> * feat: change terratest dockerfile implementation Signed-off-by: chjmil <[email protected]> * fix: update workflow Signed-off-by: chjmil <[email protected]> * fix: remove mount Signed-off-by: chjmil <[email protected]> * feat: update docker env params Signed-off-by: chjmil <[email protected]> * fix: (PSKD-1361) install terratest_log_parser) Signed-off-by: Ian Dominno <[email protected]> * fix: (PSKD-1361) remove cp step from terratest_log_parser Signed-off-by: Ian Dominno <[email protected]> * fix: (PSKD-1361) add test results output Signed-off-by: Ian Dominno <[email protected]> * feat: add terratest dockerfile input handling Signed-off-by: chjmil <[email protected]> * test: add failing test for workflow Signed-off-by: chjmil <[email protected]> * fix: remove expected failure Signed-off-by: chjmil <[email protected]> * docs: first pass at terratest log Signed-off-by: chjmil <[email protected]> * test: update workflow results Signed-off-by: chjmil <[email protected]> * ci: update results Signed-off-by: chjmil <[email protected]> * ci: verbose Signed-off-by: chjmil <[email protected]> * ci: fix logging location Signed-off-by: chjmil <[email protected]> * ci: fix part 2 Signed-off-by: chjmil <[email protected]> * revert: remove junit testing Signed-off-by: chjmil <[email protected]> * docs: update terratest dockerfile documentation Signed-off-by: chjmil <[email protected]> * docs: (PSKD-1388) update CONTRIBUTING.md Signed-off-by: Ian Dominno <[email protected]> * ci: update workflow to use verbose Signed-off-by: chjmil <[email protected]> * docs: add testing philosophy Signed-off-by: chjmil <[email protected]> * update go.sum and go.mod Signed-off-by: chjmil <[email protected]> * remove docker compose file Signed-off-by: chjmil <[email protected]> * fix: update default values in entrypoint script * docs: move testing philosophy to docs folder Signed-off-by: chjmil <[email protected]> * docs: terratest_log_parser info to TerratestDockerusage.md Signed-off-by: Ian Dominno <[email protected]> * docs: fix typo Signed-off-by: chjmil <[email protected]> * docs: fix formatting; remove unused parameter Signed-off-by: chjmil <[email protected]> * docs: add section about adding unit tests Signed-off-by: chjmil <[email protected]> * Experimental dockerfile change Signed-off-by: chjmil <[email protected]> * Update workflow Signed-off-by: chjmil <[email protected]> * fix working directory Signed-off-by: chjmil <[email protected]> * Fix workflow file Signed-off-by: chjmil <[email protected]> * test: add Makefile for tests Signed-off-by: Griffin Tomaszewski <[email protected]> * docs: add quotes around $(pwd) Signed-off-by: chjmil <[email protected]> * docs: various fixes Signed-off-by: chjmil <[email protected]> * docs: fix spacing on volume mounts Signed-off-by: chjmil <[email protected]> --------- Signed-off-by: chjmil <[email protected]> Signed-off-by: Ian Dominno <[email protected]> Signed-off-by: Griffin Tomaszewski <[email protected]> Co-authored-by: Griffin Tomaszewski <[email protected]> Co-authored-by: Ian Dominno <[email protected]> * docs: add copyright Signed-off-by: chjmil <[email protected]> --------- Signed-off-by: chjmil <[email protected]> Signed-off-by: Carus Kyle <[email protected]> Signed-off-by: Ian Dominno <[email protected]> Signed-off-by: Griffin Tomaszewski <[email protected]> Signed-off-by: joboon <[email protected]> Signed-off-by: Ed Overton <[email protected]> Signed-off-by: David.Houck <[email protected]> Co-authored-by: chjmil <[email protected]> Co-authored-by: Carus Kyle <[email protected]> Co-authored-by: Phani kumar Thodupunoori <[email protected]> Co-authored-by: Phkuma <[email protected]> Co-authored-by: Vincent Illiano <[email protected]> Co-authored-by: Ian Dominno <[email protected]> Co-authored-by: Griffin Tomaszewski <[email protected]> Co-authored-by: Phkuma <[email protected]> Co-authored-by: Nathaniel Dickens <[email protected]> Co-authored-by: [email protected] <[email protected]> Co-authored-by: John Boone <[email protected]> Co-authored-by: Ed Overton <[email protected]> Co-authored-by: David.Houck <[email protected]> Co-authored-by: Ian Dominno <[email protected]> Co-authored-by: Kyle Hia <[email protected]> Co-authored-by: kylhia <[email protected]> Co-authored-by: Chris Miller <[email protected]>
1 parent 98d95c7 commit 0ad6a78

20 files changed

+2326
-20
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ docs/
22
*.md
33
*.txt
44
terraform.tfstate*
5-
examples/
65
.terraform/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Default Plan Unit Tests
5+
on:
6+
push:
7+
branches: ['**'] # '*' will cause the workflow to run on all commits to all branches.
8+
9+
jobs:
10+
go-tests:
11+
name: Default Plan Unit Tests
12+
runs-on: ubuntu-latest
13+
environment: terraformSecrets
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v4
17+
- name: Build Docker Image
18+
run: docker build -t viya4-iac-azure:terratest -f Dockerfile.terratest .
19+
- name: Run Tests
20+
run: |
21+
docker run \
22+
-e TF_VAR_subscription_id=$TF_VAR_subscription_id \
23+
-e TF_VAR_tenant_id=$TF_VAR_tenant_id \
24+
-e TF_VAR_client_id=$TF_VAR_client_id \
25+
-e TF_VAR_client_secret=$TF_VAR_client_secret \
26+
-v $(pwd):/viya4-iac-azure \
27+
viya4-iac-azure:terratest -v
28+
env:
29+
# TF ENVIRONMENT
30+
TF_VAR_subscription_id: "${{ secrets.TF_VAR_SUBSCRIPTION_ID }}"
31+
TF_VAR_tenant_id: "${{ secrets.TF_VAR_TENANT_ID }}"
32+
TF_VAR_client_id: "${{ secrets.TF_VAR_CLIENT_ID }}"
33+
TF_VAR_client_secret: "${{ secrets.TF_VAR_CLIENT_SECRET }}"

.github/workflows/linter-analysis.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ jobs:
4646
path: ~/.tflint.d/plugins
4747
key: ubuntu-latest-tflint-${{ hashFiles('.tflint.hcl') }}
4848

49+
- name: Setup Terraform
50+
uses: hashicorp/setup-terraform@v3
51+
with:
52+
terraform_version: "^1.9.8"
53+
terraform_wrapper: false
54+
4955
- name: Setup TFLint
5056
uses: terraform-linters/[email protected]
5157
with:

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ terraform.tfvars
99
.terraform.lock.hcl
1010
.DS_Store
1111
sas_iac_buildinfo.yaml
12+
.idea
13+
.vscode
14+
test/bin
15+
test/pkg
16+
test/test_output

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
default_stages: [pre-commit]
3+
repos:
4+
- repo: https://github.com/gitleaks/gitleaks
5+
rev: v8.23.3
6+
hooks:
7+
- id: gitleaks
8+
9+
ci:
10+
autofix_prs: false
11+
autoupdate_commit_msg: "chore: auto-update of pre-commit hooks"

CONTRIBUTING.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
# How to Contribute
2-
We'd love to accept your patches and contributions to this project.
3-
We just ask that you follow our contribution guidelines when you do.
2+
This project is community-driven, and we'd love to accept your patches and contributions.
3+
We just ask that you follow our contribution guidelines when you do. Refer
4+
to the [Contributor Handbook](https://sassoftware.github.io/contributor-handbook.html)
5+
for guidance.
46

57
## Contributor License Agreement
68
Contributions to this project must be accompanied by a signed [Contributor Agreement](ContributorAgreement.txt).
7-
You (or your employer) retain the copyright to your contribution; this simply grants us permission to use and redistribute your contributions as part of the project.
9+
You (or your employer) retain the copyright to your contribution; this agreement simply grants
10+
us permission to use and redistribute your contributions as part of the project.
811

9-
## Code reviews
10-
All submissions to this project—including submissions from project members—require review.
11-
Our review process typically involves performing unit tests, development tests, integration tests, and security scans using internal SAS infrastructure.
12-
For this reason, we don’t often merge pull requests directly from GitHub.
12+
## Code Reviews
13+
All submissions to this project—including submissions from project members—require
14+
review. Our review process typically involves performing unit tests, development
15+
tests, integration tests, and security scans.
1316

14-
Instead, we work with submissions internally first, vetting them to ensure they meet our security and quality standards.
15-
We’ll do our best to work with contributors in public issues and pull requests; however, to ensure our code meets our internal compliance standards, we may need to incorporate your submission into a solution we push ourselves.
17+
## Pull Request Requirement
18+
All contributions (PRs) must be accompanied by passing unit and/or integration
19+
tests, following our [testing philosophy](./docs/user/TestingPhilosophy.md). If you are unfamiliar with this process,
20+
we are happy to help you navigate it by providing continuous collaboration within the pull request.
21+
All pull requests must also pass our linter analysis checks. Contributions might
22+
be subjected to security scans before they can be accepted.
1623

17-
This does not mean we don’t value or appreciate your contribution.
18-
We simply need to review your code internally before merging it.
19-
We work to ensure all contributors receive appropriate recognition for their contributions, at least by acknowledging them in our release notes.
24+
## Security Scans
25+
To ensure that all submissions meet our security and quality standards, we perform security
26+
scans using internal SAS infrastructure. Reporting of any Common Vulnerabilities and Exposures
27+
(CVEs) that are detected is not available in this project at this time.

Dockerfile.terratest

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM golang:1.23
2+
3+
# Install terraform from apt repository and terratest_log_parser
4+
RUN \
5+
apt-get update \
6+
&& apt-get install -y jq lsb-release \
7+
&& wget -O - https://apt.releases.hashicorp.com/gpg \
8+
| gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg \
9+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" \
10+
| tee /etc/apt/sources.list.d/hashicorp.list \
11+
&& apt update \
12+
&& apt install terraform \
13+
&& ssh-keygen -f ~/.ssh/id_rsa -P "" \
14+
&& go install github.com/gruntwork-io/terratest/cmd/terratest_log_parser@latest
15+
16+
WORKDIR /viya4-iac-azure/test
17+
18+
# Copy the test directory so it can install the go modules
19+
# during the docker build rather than the docker run
20+
COPY ./test ./
21+
RUN go mod tidy
22+
23+
ENTRYPOINT ["/viya4-iac-azure/test/terratest_docker_entrypoint.sh"]

Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# from .github/workflows/default_plan_unit_tests.yml
5+
6+
IMAGE := viya4-iac-azure:terratest
7+
8+
buildTests:
9+
ifeq ($(shell docker images -q $(IMAGE) 2> /dev/null),)
10+
docker build -t $(IMAGE) -f Dockerfile.terratest .
11+
endif
12+
13+
checkEnv:
14+
ifndef TF_VAR_subscription_id
15+
$(error TF_VAR_subscription_id is undefined)
16+
endif
17+
ifndef TF_VAR_tenant_id
18+
$(error TF_VAR_tenant_id is undefined)
19+
endif
20+
ifndef TF_VAR_client_id
21+
$(error TF_VAR_client_id is undefined)
22+
endif
23+
ifndef TF_VAR_client_secret
24+
$(error TF_VAR_client_secret is undefined)
25+
endif
26+
27+
28+
runTests: checkEnv buildTests
29+
docker run -it --rm \
30+
-e TF_VAR_subscription_id=$(TF_VAR_subscription_id) \
31+
-e TF_VAR_tenant_id=$(TF_VAR_tenant_id) \
32+
-e TF_VAR_client_id=$(TF_VAR_client_id) \
33+
-e TF_VAR_client_secret=$(TF_VAR_client_secret) \
34+
$(IMAGE) -v
35+
36+
clean:
37+
docker image rm $(IMAGE)

docs/CONFIG-VARS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,22 @@ The default values for the `subnets` variable are as follows:
127127
aks = {
128128
"prefixes": ["192.168.0.0/23"],
129129
"service_endpoints": ["Microsoft.Sql"],
130-
"private_endpoint_network_policies": "Disabled",
130+
"private_endpoint_network_policies": "Enabled",
131131
"private_link_service_network_policies_enabled": false,
132132
"service_delegations": {},
133133
}
134134
misc = {
135135
"prefixes": ["192.168.2.0/24"],
136136
"service_endpoints": ["Microsoft.Sql"],
137-
"private_endpoint_network_policies": "Disabled",
137+
"private_endpoint_network_policies": "Enabled",
138138
"private_link_service_network_policies_enabled": false,
139139
"service_delegations": {},
140140
}
141141
## If using ha storage then the following is also added
142142
netapp = {
143143
"prefixes": ["192.168.3.0/24"],
144144
"service_endpoints": [],
145-
"private_endpoint_network_policies": "Disabled",
145+
"private_endpoint_network_policies": "Enabled",
146146
"private_link_service_network_policies_enabled": false,
147147
"service_delegations": {
148148
netapp = {

docs/user/TerratestDockerUsage.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Using the Terratest Docker Container
2+
3+
Use the Terratest Docker container to run the suite of Terratest Go tests. For more information on Terratest, follow the [Documentation](https://terratest.gruntwork.io/docs/) page. The Terratest Docker image is used by the [Github Workflow](../../.github/workflows/default_plan_unit_tests.yml) as a required check before merging changes.
4+
5+
## Prereqs
6+
7+
- Docker [installed on your workstation](../../README.md#docker).
8+
9+
## Preparation
10+
11+
### Docker image
12+
13+
Run the following command to create the `viya4-iac-azure-terratest` Docker image using the provided [Dockerfile.terratest](../../Dockerfile.terratest)
14+
15+
```bash
16+
docker build -t viya4-iac-azure-terratest -f Dockerfile.terratest .
17+
```
18+
19+
The Docker image `viya4-iac-azure-terratest` will contain Terraform and Go executables, as well as the required Go modules. The Docker entrypoint for the image is `go test`, and it accepts several optional command-line arguments. For more information about command-line arguments, see [Command-Line Arguments](#command-line-arguments).
20+
21+
### Docker Environment File for Azure Authentication
22+
23+
Follow either one of the authentication methods that are described in [Authenticating Terraform to access Azure](./TerraformAzureAuthentication.md), and create a file with the authentication variable values to use with container invocation. Store these values outside of this repository in a secure file, such as
24+
`$HOME/.azure_docker_creds.env`. Protect that file with Azure credentials so that only you have Read access to it. **NOTE**: Do not use quotation marks around the values in the file, and be sure to avoid any trailing blank spaces.
25+
26+
Now each time you invoke the container, specify the file with the [`--env-file`](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file) option to pass Azure credentials to the container.
27+
28+
### Docker Volume Mounts
29+
30+
Run the following command:
31+
`--volume="$(pwd)":/viya4-iac-azure`
32+
Note that the project must be mounted to the `/viya4-iac-azure` directory.
33+
34+
## Command-Line Arguments
35+
36+
The `terratest_docker_entrypoint.sh` script supports several command-line arguments to customize the test execution. Here are the available options:
37+
38+
* `-p, --package=PACKAGE`: The package to test. Default is './...'
39+
* `-r, --run=TEST`: The name of the test to run. Default is '.\*Plan.\*'.
40+
* `-v, --verbose`: Run the tests in verbose mode.
41+
* `-h, --help`: Display the help message.
42+
43+
## Running Terratest Commands
44+
45+
### Running the Default Tests
46+
47+
To run the default suite of unit tests (only `terraform plan`), run the following Docker command:
48+
49+
```bash
50+
# Run from the ./viya4-iac-azure directory
51+
docker run --rm \
52+
--env-file=$HOME/.azure_docker_creds.env \
53+
--volume "$(pwd)":/viya4-iac-azure \
54+
viya4-iac-azure-terratest
55+
```
56+
57+
### Running a Specific Go Test
58+
59+
To run a specific test, run the following Docker command with the `-r` option:
60+
61+
```bash
62+
# Run from the ./viya4-iac-azure directory
63+
docker run --rm \
64+
--env-file=$HOME/.azure_docker_creds.env \
65+
--volume "$(pwd)":/viya4-iac-azure \
66+
viya4-iac-azure-terratest \
67+
  -r="YourTest"
68+
```
69+
To run multiple tests, pass in a regex to the `-r` option - "TestName1|TestName2|TestName3"
70+
71+
### Running a Specific Go Package and Test
72+
73+
If you want to specify the Go package and test name, run the following Docker command with the following options:
74+
75+
```bash
76+
# Run from the ./viya4-iac-azure directory
77+
docker run --rm \
78+
--env-file=$HOME/.azure_docker_creds.env \
79+
--volume "$(pwd)":/viya4-iac-azure \
80+
viya4-iac-azure-terratest \
81+
  -r="YourTest" \
82+
  -p="YourPackage"
83+
```
84+
85+
### Running the Go Tests with verbose mode
86+
87+
If you want to run the tests in verbose mode, run the Docker command with the `-v` option:
88+
89+
```bash
90+
# Run from the ./viya4-iac-azure directory
91+
docker run --rm \
92+
--env-file=$HOME/.azure_docker_creds.env \
93+
--volume "$(pwd)":/viya4-iac-azure \
94+
viya4-iac-azure-terratest -v
95+
```
96+
97+
### Accessing test run logs
98+
99+
After you have started the Docker container, log files are created in the `./viya4-iac-azure/test/test_output` directory. These files enable you to view the test results in XML format, as well as test logs that are generated by the terrratest_log_parser.

0 commit comments

Comments
 (0)