This project uses Test Kitchen with Docker to validate our infrastructure. It includes a Makefile for easy command handling and a Dockerfile to create a standardized testing environment.
- Environment Variables
- Running Tests with Docker
- Running Tests Manually
- Test Kitchen 101
- GitHub Actions - Manual Workflow Trigger
These environment variables are used for running the tests:
OBSERVE_CUSTOMER
: The Observe customerOBSERVE_TOKEN
: The Observe tokenOBSERVE_DOMAIN
: The Observe environment domain (default: observe-eng.com)AWS_ACCESS_KEY_ID
: Your AWS access key IDAWS_SECRET_ACCESS_KEY
: Your AWS secret access keyAWS_SESSION_TOKEN
: Your AWS session token (if required)AWS_REGION
: Your preferred AWS region (default: us-east-1)PROVIDER
:terraform
orcloudformation
(default: cloudformation)
If you want to persist your environment configuration a env.template
file is available
cp env.template .env
vi .env # edit the values
source .env
We're ignoring .env*
so feel free make as many as required ie .env-cloudformation
or .env-accountnumber
etc
- AWS Access (
aws sts get-caller-identity
is your friend ) - A valid observe customer / token / domain
- Docker installed
- Run the tests within a docker container by running
make docker/test
. - To clean up the resources created during the test, run
make docker/test/clean
- To clean up the resources including the docker image / container run
make docker/clean
- AWS Access (
aws sts get-caller-identity
is your friend ) - A valid observe customer / token / domain
- Ensure the dependencies within the
./validate_deps.sh
script are installed by running./validate_deps.sh
. - Install the gems listed within the Gemfile via
bundler install
.
- Run
make test
to validate dependencies, create the kitchen environment and run the verifier. - To clean up the resources created during the test, run
make test/clean
.
Refer to the test kitchen (documentation)[https://kitchen.ci/docs/getting-started/introduction/] but bellow is a brief explanation of some common commands.
Provision the infrastructure
# make test/create
kitchen create
Test the infrastructure agains the spec
# make test/verify
kitchen verify
# the rspec equivalent
rspec -c -f documentation --default-path '/workdir' -P 'test/integration/base/verify/collection_spec.rb'
Teardown the infrastructure
# make test/clean
kitchen destroy
In addition to the automated tests that run on pull requests and pushes to the main
branch, you can also manually trigger the testing workflow using GitHub's workflow_dispatch
event.
- Navigate to the "Actions" tab in the GitHub repository.
- Select the desired workflow from the left sidebar.
- Click on the "Run workflow" button on the right side.
- Select the branch on which you want to run the workflow.
- Provide the required inputs:
test_type
: Choose between 'terraform' or 'cloudformation'.code_sha
: Provide the SHA of the terraform or cloudformation code to checkout.
- Click the "Run workflow" button.
This allows for more flexibility in testing, especially in scenarios where you might want to test specific changes or configurations without making a pull request or a push.
For more details on GitHub's workflow dispatch event, refer to the official documentation.