项目作者: intuitivetechnologygroup

项目描述 :
test harness for salt formulas
高级语言: Makefile
项目地址: git://github.com/intuitivetechnologygroup/formula-test-harness.git
创建时间: 2018-02-22T19:43:29Z
项目社区:https://github.com/intuitivetechnologygroup/formula-test-harness

开源协议:MIT License

下载


Salt Formula Test Harness

Run as many pytest suites that you need to run in a clean, isolated environment.

Build Status


Assumptions:

make is on your system and available. If it is not or you are not sure what
make is, this is a good place to start.

Project Setup

Clone this repository:
  1. cd /path/to/project
  2. mkdir tmp
  3. git clone https://github.com/intuitivetechnologygroup/formula-test-harness.git tmp/formula-test-harness
Copy essentials:

Merge the files if they already exist in the project.
Replace FORMULA-NAME with the name of your formula.

  1. cd /path/to/project
  2. mkdir -p tests/srv/salt
  3. cp -r tmp/formula-test-harness/tools tools
  4. cp -r tmp/formula-test-harness/tests/pytests tests/pytests
  5. cp tmp/formula-test-harness/.gitignore .gitignore
  6. cp tmp/formula-test-harness/.travis.yml .travis.yml
  7. sed -i '' 's/example/FORMULA-NAME/' .travis.yml
  8. cp tmp/formula-test-harness/Makefile Makefile
  9. sed -i '' 's/example/FORMULA-NAME/' Makefile
  10. cp tmp/formula-test-harness/tests/srv/salt/top.sls tests/srv/salt/top.sls
  11. sed -i '' 's/example/FORMULA-NAME/' tests/srv/salt/top.sls

Project File Structure

  1. .
  2. ├── example
  3. ├── init.sls
  4. └── pkg.sls
  5. ├── tests
  6. ├── pytests
  7. └── apply-all-tests
  8. ├── __init__.py
  9. └── test_000_apply_state.py
  10. └── srv
  11. ├── pillar
  12. ├── example
  13. └── init.sls
  14. └── top.sls
  15. └── salt
  16. └── top.sls
  17. ├── tools
  18. ├── templates
  19. └── Dockerfile.j2
  20. ├── filltmpl.py
  21. └── run-tests.sh
  22. ├── .gitignore
  23. ├── .travis.yml
  24. └── Makefile

pytests

  • Create your test sequences in tests/pytests/.
  • The file structures should be setup the same way as any other python unit tests.
  • Each test suite is essentially it’s own python package so it must contain an __init__.py file.
  • All test files must be in prefixed with test_.

Development

Setup

Start a virtualenv

  1. pip install -U virtualenv
  2. virtualenv .venv
  3. source .venv/bin/activate

Install local requirements

  1. make setup

Utility Implementations

Tool Configuration

./tools/templates/Dockerfile.j2

Add any package installation requirements here.

./tools/run-tests.sh

Add the shell commands to run the tests here.

Execution Files

The tooling config/execution files should be placed under ./tests/<util-name>/*

Testing

First, follow the Development Setup instructions.

Run Tests

Tests will be run on the following base images:

  • simplyadrian/allsalt:centos_master_2017.7.2
  • simplyadrian/allsalt:debian_master_2017.7.2
  • simplyadrian/allsalt:opensuse_master_2017.7.2
  • simplyadrian/allsalt:ubuntu_master_2016.11.3
  • simplyadrian/allsalt:ubuntu_master_2017.7.2
Run the tests
  • make test-centos_master_2017.7.2
  • make test-debian_master_2017.7.2
  • make test-opensuse_master_2017.7.2
  • make test-ubuntu_master_2016.11.3
  • make test-ubuntu_master_2017.7.2

Run Interactive Containers

  • make local-centos_master_2017.7.2
  • make local-debian_master_2017.7.2
  • make local-opensuse_master_2017.7.2
  • make local-ubuntu_master_2016.11.3
  • make local-ubuntu_master_2017.7.2

Continuous Integration

Build Status

Continuous integration details are available on Travis CI.

Components

Dockerfile Template

Rendering a dockerfile:

  1. python tools/filltmpl.py {formula-name} {image-tag}

Contributing

Contributions are welcome!

Review the Contributing Guidelines for details on how to:

  • Submit issues
  • Submit pull requests