Giter VIP home page Giter VIP logo

coverup's Introduction

Coverup

An interpretation of "test coverage" for Terraform.

Measurements

This tool currently checks data sources and resources defined in Terraform code bases, against what is actually deployed - which it gets by reading a deployment's state.

It currently operates on block level, not line level - so for example it does not check dynamic blocks nor field level conditionals.

Rationale

Despite questionable usefulness, "test coverage" remains a - perhaps the most - popular metrics to measure code "quality". Terraform code, as an implementation of "Infrastructure as Code" (IaC), can be argued to require the same metrics. However, it is perhaps not as clear as "functionality code" in terms of how to gauge it, or even what should we be testing.

Usually, "tests" are performed against the results of execution of the "code". Our argument follows that, the coverage of Terraform code should be from terraform apply execution results - which is recorded in the state file. This is why merely using terraform validate is not enough, as it does not actually execute the code (providers, actually) and unfortunately the syntax alone is not enough to cover all edge cases, and actual target systems can enforce additional constraints when creating or updating resources.

Note we're not testing, for example "provisioning this AWS resource should call this AWS API with this set of parameters". These lower level details are covered by the comprehensive set of tests Terraform itself and the providers provide.

Nowadays, most if not all services will be deployed to various internal development or testing environments before being release to external customers. IaC is a powerful tool in this respect, not only to capture the shared basis between all deployments on various environments, but also those little (or big) differences between environments and expose them directly in code.

And this angle leads us to the interpretation that, the "test" is - at least in non-production environments - somewhat an integration (or e2e) test in the form of running terraform apply successfully. And the "coverage" is how much of the code is actually deployed. The environmental differences, and how much of the Terraform code are not "tested" before applying them in production environments, can thus be quantified by this tool.

coverup's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.