Git Product home page Git Product logo

terracumber's Introduction

Terracumber

When Terraform meets Cucumber.

This is exactly what Uyuni and SUSE Manager are using for part of the testing. We create an environment with terraform (sumaform) and then we run tests with Cucumber.

Until SUSE's Hackweek 18 we were using a set of bash scripts, completely ad-hoc and hard to maintain and extend, and that is how Terracumber was born.

Does this only work with sumaform?

No. It should work with any other environment as long as:

  1. It is created with terraform.
  2. The terraform has an structure similar to sumaform, with several backends, and and output 'root' that contains the 'hostname' in the same way sumaform does.
  3. The cucumber run produces one or more of the following outputs [1]:
    • Files:
      • output*.html
      • output*.json
      • spacewalk-debug.tar.bz2
    • Directories:
      • screenshots
      • cucumber_report
      • logs
      • results_junit

[1] We hope to make this configurable in the future.

How should I use it?

Software requirements

  • Python3
  • pyhcl module installed
  • paramiko module installed
  • pygit2 module installed
  • Terraform installed and configured as need to run the terraform templates you are going to use

Quickstart

See EXAMPLE.md for a quick intro about the calls to terraform-cli

Advanced usage

Create/adjust your .tf file

You will need to create at least one .tf file to use it to launch your environment, as well as configuring everything else (such as what command to run for the testsuite).

Keep in mind:

  1. There are some mandatory variables for the .tf file (see one of the examples
  2. You can add extra variables to your .tf file, so you can use it when creating the environment. Those variables will need to be exported before running terraform-cli as TF_VAR_, as explained at the terraform doc. Our example adds SCC credentials to pass them to Uyuni/SUSE Manager, and GitHub credentials to use them to clone the GitHub cucumber repository [1]

[1] To clone your terraform repository, it is allowed to use TF_VAR_GIT_USER and TF_VAR_GIT_PASSWORD instead of --gituser and --gitpassword, in case you do not want the credentials visible at the list of processes. If you use both the environment and the variables, then the parameters will be used to clone the terraform repository, and the variables to clone the cucumber repository at the controller.

Create email templates

You need to create two email templates, one to be used when the environment fails to be created, the other to be used after cucumber is able to run.

The email templates are plain text files with some variables to be replaced by terraform-cli:

  • $urlprefix - Directly from your .tf file, from variable URL_PREFIX
  • $timestamp - Either the environment variable BUILD_NUMBER provided by Jenkins, or a timestamp in format %Y-%m-%d-%H-%M-%S otherwise (corresponding to the time and date when terraform-cli started.
  • $tests - Total number of tests executed by cucumber
  • $passed - Number of tests executed by cucumber without failures or errors
  • $failures - Number of tests executed by cucumber with failures
  • $errors - Number of tests executed by cucumber with errors
  • $skipped - Number of tests skipped by cucumber
  • $failures_log - A list of failed tests, the number of failures is determined by terraform-cli --nlines parameter

Bonus: clean old results

The script clean-old-results can be used to get rid of undesired old results (use -h to get help)

How to contribute

It is easy: just create a Pull Request with your contribution, and make sure that the unit tests are passing.

To run them:

python3 -m unittest

For now the unit tests only cover the module.

terracumber's People

Contributors

juliogonzalez avatar jordimassaguerpla avatar bischoff avatar nodeg avatar mcalmer avatar srbarrios avatar cbosdo avatar rjmateus avatar maximenoel8 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.