Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

feat!: introduce basic Terratest based tests, unified Makefile and ChatOPS like workflows #304

Merged
merged 33 commits into from
Sep 7, 2023

Conversation

FoSix
Copy link
Contributor

@FoSix FoSix commented Aug 28, 2023

Description

This PR will introduce:

  • a single Makefile, repository-wide, flexible enough to handle any new Terratest based test.
  • Terratest based action (in place of the old plan/apply, Terraform based one)
  • ChatOPS workflows.

Motivation and Context

Makefile

With a single Makefile there will be no copy pasting between modules. The current one is capable of running any test in any module (modules/examples).

TL;DR
To run a test (from the repository's root folder):

make [module path] ACTION=[test to run]

Example:

make examples/common_vmseries ACTION=Apply

Run make help for more details.

Terratest based action

This action is simply a GH Actions wrapper around the new Makefile. It will be fully usable by the reusable workflows introduced in this PR.

ChatOPS introduction

The ChatOPS-like workflows provide a way of running on demand, Terratest based tests. They can become handy in situations where a particular test is not run in PR CI workflow (Apply/Idempotence), or the CI workflow is not triggered (PRs created by other workflows, like pre-commit dependencies update).

Currently there are 4 supported commands:

  • sca - runs pre-commit with all tests
  • plan - runs plan action
  • apply - runs apply action
  • idempotence - runs idempotence test (apply following a plan)

The 1st one takes no parameters. The remaining can take two:

  • paths - space separated list of module paths to test
  • tf_version - (optional) space separated list of Terraform versions to use to run the test, when skipped, the latest Terraform version will be used.

Example:

/validate paths="examples/common_vmseries modules/vnet"

load_balancer module

There is a small change in this module to add flexibility to how we specify the NSG. Next to the old approach one can also use key values from the VNET definition to reference an NSG that will be created by the Terraform code.

How Has This Been Tested?

Some of the tests can be seen in the PR CI triggered by this workflow.
The ChatOPS tests can be run/tested on the Azure test repo.

Screenshots (if appropriate)

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes if appropriate.
  • All new and existing tests passed.

@FoSix FoSix requested a review from a team as a code owner August 28, 2023 12:54
@FoSix FoSix force-pushed the 263-terratest-for-azure branch from 429b6c2 to 7db309e Compare August 28, 2023 14:20
Copy link
Contributor

@sebastianczech sebastianczech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

.github/workflows/chatops.yml Show resolved Hide resolved
.github/workflows/release_ci.yml Show resolved Hide resolved
.github/workflows/pr_ci.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@sebastianczech sebastianczech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work 👍

@FoSix FoSix merged commit 20e456b into main Sep 7, 2023
@FoSix FoSix deleted the 263-terratest-for-azure branch September 7, 2023 10:19
sebastianczech pushed a commit that referenced this pull request Oct 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants