A collection of docker-compose scripts to run ansible tests. There are 6 compose commands to run:
- sanity tests on python 2.7
- sanity tests on python 3.5
- integration tests in any number of docker containers
- unit tests in fedora28 container
- manual (interactive) shell with python 2.7 environment
- manual (interactive) shell with python 3.5 environment
- Docker installed and running with /var/run/docker.sock used to communicate with daemon
- docker-compose installed locally
-
Clone this repo:
git clone [email protected]:astorath/ansible-test.git cd ansible-test/
-
Replace submodule reference with your own fork:
git submodule deinit --force ansible/ git rm --force ansible/ git submodule add -b <your_feature_branch> --force <your_ansible_fork> ansible/
-
Add
.env
file to the root of repository and set some vars.- MODULES: space separated list of modules to checked on sanity
- INTEGRATION_MODULE: an integration module name to run in
ansible-test integration
command - CONTAINERS: space separated list of containers to run integration tests
- FILTER_TAGS: tags to filter for in integration tests
- LOG_LEVEL: log level to use during integration and unit tests (
vv
by default)
Sample
.env
file: sample.env -
Build containers (you may skip this step, containers should be built on first launch):
docker-compose build
After your changes are made:
# run ansible-test sanity on python 3.5 for ${MODULES}
docker-compose run --rm sanity35
# run ansible-test sanity on python 2.7 for ${MODULES}
docker-compose run --rm sanity27
# run ansible-test integration for ${INTEGRATION_MODULE} in ${CONTAINERS}
docker-compose run --rm integration
# TODO: run ansible-test unit
docker-compose run --rm unit
You can have multiple env files for different modules / test suites when this PR is live:
# run ansible-test sanity on python 3.5 with modules from suite01.env
docker-compose --env-file suite01.env run --rm sanity35
-
Run an appropriate container:
docker-compose run --rm manual35
-
Exec your tests
# quick-test module ansible/hacking/test-module -m ./ansible/lib/ansible/modules/database/postgresql/postgresql_user.py # add custom deps pip install psycopg2-binary # exec module against some test playbook ansible-playbook sample.testmod.yml
Sample playbook file: sample.testmod.yml