This guide will quickstart you on our testing environment and eases the way to contribute on our project.
Currently we do some molecule tests to check if the roles work in combination and some variables to check if anything fails.
Then there are unit tests for the parser which generates the Icinga 2 DSL.
At last we implemented a way to check if our Icingaweb roles generates valid ini files.
Make sure the following tools are available before start testing with the collection.
pip install ansible-core ansible-lint molecule pytest-testinfra
To test roles locally without docker/service issues, we created a molecule test with vagrant. Then you need to install vagrant and the molecule plugin.
pip install molecule-plugins[vagrant]
To use molecule with docker install the docker plugin.
pip install molecule-plugins[docker]
To test roles over vagrant locally, it is the easiest to run the local-default scenario. The local-default is very big and long running. For shorter tests use the role- scenarios.
molecule test -s local-default
The following tests are inplemented based on docker. Per default a ubuntu2204 image from geerlingguy's container is used. Thanks @geerlingguy Dockerhublink
To test other distros use the command with the env MOLECULE_DISTRO.
MOLECULE_DISTRO=opensuseleap15 molecule test -s role-icingadb_redis
The roles are generating configuration for Icingaweb2 and Icinga2 in various files. To ensure values are written to these files in right syntax we test those too.
For testing our Icinga 2 objects syntax we implemented python unittests and try many combinations which occur in different python versions.
For more information please have a look at the workflow Python Unittest
.
To test the INI configuration over Ansible in the Icinga Web 2 role, we implemented a molecule test to include the template from the role and test it with various values.