Skip to content

Latest commit

 

History

History
81 lines (61 loc) · 1.69 KB

tests.README.md

File metadata and controls

81 lines (61 loc) · 1.69 KB

Testing with Molecule 2

Quick start with default test scenario

sudo apt-get install python3-venv
python3 -m venv venv
source venv/bin/activate
pip3 install 'molecule[docker]'
pip3 install -r requirements.txt
MOLECULE_DISTRO=ubuntu1804 molecule test

Testing all distro variations with Tox

See https://tox.readthedocs.io/en/latest/

See tox.ini for the distro variants being tested against.

pip install tox
tox

Advanced

Setup Local Virtual Environment

  • to run a single test
sudo apt-get install python3-venv
python3 -m venv venv
source venv/bin/activate
pip3 install 'molecule[docker]'
pip3 install -r requirements.txt
MOLECULE_DISTRO=centos7 molecule test
  • note that you can substitute MOLECULE_DISTRO=version for the following:

MOLECULE_DISTRO List

centos7
centos8

debian8
debian9
debian10

ubuntu1604
ubuntu1804

Development

  • if you are creating a new molecule test suite inside an existing role then execute this ...
molecule init scenario -r ansible-role-nginx
  • you can change one line and enter a different molecule command to keep the container alive
    • from the MOLECULE_DISTRO list above, substitute your desired version for development below
# /molecule/default/molecule.yml
  image: "geerlingguy/docker-${MOLECULE_DISTRO:-debian9}-ansible:latest"
  • run this command so that the container is not dead
molecule test --destroy=never
  • ssh into the container after the test
molecule login
  • run the test suite located in molecule/test/test_default.py
molecule verify