|
| 1 | +## Collection Testing Guide |
| 2 | + |
| 3 | +This guide will quickstart you on our testing environment and eases the way to |
| 4 | +contribute on our project. |
| 5 | + |
| 6 | +### Tests |
| 7 | + |
| 8 | +Currently we do some molecule tests to check if the roles work in combination |
| 9 | +and some variables to check if anything fails. |
| 10 | + |
| 11 | +Then there are unit tests for the parser which generates the Icinga 2 DSL. |
| 12 | + |
| 13 | +At last we implemented a way to check if our Icingaweb roles generates valid |
| 14 | +ini files. |
| 15 | + |
| 16 | +### Tools |
| 17 | + |
| 18 | +Make sure the following tools are available before start testing with the collection. |
| 19 | + |
| 20 | +``` |
| 21 | +pip install ansible-core ansible-lint molecule pytest-testinfra |
| 22 | +``` |
| 23 | + |
| 24 | +To test roles locally without docker/service issues, we created a molecule test |
| 25 | +with vagrant. Then you need to install [vagrant](link/to/vagrant) and the molecule plugin. |
| 26 | + |
| 27 | +`pip install molecule-plugins[vagrant]` |
| 28 | + |
| 29 | +To use molecule with docker install the docker plugin. |
| 30 | + |
| 31 | +`pip install molecule-plugins[docker]` |
| 32 | + |
| 33 | +### Roles Testing |
| 34 | + |
| 35 | +To test roles over vagrant locally, it is the easiest to run the **local-default** |
| 36 | +scenario. The local-default is very big and long running. For shorter tests use |
| 37 | +the role-<rolename> scenarios. |
| 38 | + |
| 39 | +`molecule test -s local-default` |
| 40 | + |
| 41 | +The following tests are inplemented based on docker. Per default a **ubuntu2204** |
| 42 | +image from geerlingguy's container is used. Thanks [@geerlingguy Dockerhublink](https://hub.docker.com/u/geerlingguy) |
| 43 | + |
| 44 | +To test other distros use the command with the env **MOLECULE_DISTRO**. |
| 45 | + |
| 46 | +`MOLECULE_DISTRO=opensuseleap15 molecule test -s role-icingadb_redis` |
| 47 | + |
| 48 | +### Templating Tests |
| 49 | + |
| 50 | +The roles are generating configuration for Icingaweb2 and Icinga2 in various files. |
| 51 | +To ensure values are written to these files in right syntax we test those too. |
| 52 | + |
| 53 | +#### Python Unittest |
| 54 | + |
| 55 | +For testing our Icinga 2 objects syntax we implemented python unittests and try |
| 56 | +many combinations which occur in different python versions. |
| 57 | + |
| 58 | +For more information please have a look at the workflow `Python Unittest`. |
| 59 | + |
| 60 | +#### Icingaweb2 INI |
| 61 | + |
| 62 | +To test the INI configuration over Ansible in the Icinga Web 2 role, we implemented |
| 63 | +a molecule test to include the template from the role and test it with various values. |
0 commit comments