Run as many pytest suites that you need to run in a clean, isolated environment.
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.
cd /path/to/project
mkdir tmp
git clone https://github.com/intuitivetechnologygroup/formula-test-harness.git tmp/formula-test-harness
Merge the files if they already exist in the project.
Replace FORMULA-NAME
with the name of your formula.
cd /path/to/project
mkdir -p tests/srv/salt
cp -r tmp/formula-test-harness/tools tools
cp -r tmp/formula-test-harness/tests/pytests tests/pytests
cp tmp/formula-test-harness/.gitignore .gitignore
cp tmp/formula-test-harness/.travis.yml .travis.yml
sed -i '' 's/example/FORMULA-NAME/' .travis.yml
cp tmp/formula-test-harness/Makefile Makefile
sed -i '' 's/example/FORMULA-NAME/' Makefile
cp tmp/formula-test-harness/tests/srv/salt/top.sls tests/srv/salt/top.sls
sed -i '' 's/example/FORMULA-NAME/' tests/srv/salt/top.sls
.
├── example
│ ├── init.sls
│ └── pkg.sls
├── tests
│ ├── pytests
│ │ └── apply-all-tests
│ │ ├── __init__.py
│ │ └── test_000_apply_state.py
│ └── srv
│ ├── pillar
│ │ ├── example
│ │ │ └── init.sls
│ │ └── top.sls
│ └── salt
│ └── top.sls
├── tools
│ ├── templates
│ │ └── Dockerfile.j2
│ ├── filltmpl.py
│ └── run-tests.sh
├── .gitignore
├── .travis.yml
└── Makefile
- 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_
.
Start a virtualenv
pip install -U virtualenv
virtualenv .venv
source .venv/bin/activate
Install local requirements
make setup
Add any package installation requirements here.
Add the shell commands to run the tests here.
The tooling config/execution files should be placed under ./tests/<util-name>/*
First, follow the Development Setup instructions.
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
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
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 details are available on Travis CI.
Rendering a dockerfile:
python tools/filltmpl.py {formula-name} {image-tag}
Contributions are welcome!
Review the Contributing Guidelines for details on how to:
- Submit issues
- Submit pull requests