/tdd-infrastructure

Some examples of Test-Driven Development for Infrastructure

Primary LanguageRubyMIT LicenseMIT

tdd-infrastructure

Examples for Test-Driven Development (TDD) of infrastructure.

Each directory has its own README and Makefile documenting how to run the tests and build the infrastructure associated with the example.

Refer to the Makefile in each directory for how to build the tests.

Useful References

Test-Driven Development

Generally, you can write your own testing framework with any language, focusing on testing the state or definition of infrastructure. For unit or contract (state) testing, tests will involve checking JSON or YAML configuration. Most infrastructure as code frameworks will already have acceptance tests to ensure the infrastructure resources are created properly.

Server Testing Tools

Terraform Specific

Unit / Contract Testing

Below are frameworks that check for configuration that might lead to upstream problems (not caught by Terraform plan). For example, database username must be 16 characters.

The tools below are mostly presented as policy as code frameworks but can be used for unit or contract (state) testing infrastructure.

BDD Frameworks

Thanks to @petems for discovering these!

End-to-End Frameworks

These are frameworks that create the infrastructure, execute a set of tests, and (optionally) destroys the infrastructure.

Policy as Code (with Security Scanning)

Some of these frameworks include built-in policies for various providers, others must be extended.

Built-In Policies
Write Your Own

Infrastructure Mocking

Use with caution. Mocks aren't always updated with latest API or configuration.

Kubernetes