English
Standard Test Roles
Package `standard-test-roles` provides shared Ansible roles and inventory scripts implementing the xref:standard-test-interface.adoc[Standard Test Interface] version `1.1.0`. It has support for multiple testing frameworks (such as BeakerLib or Avocado) and in this way allows to easily enable existing tests in Fedora CI.
Setup
Packages
STR is available for Centos/RHEL from https://fedoraproject.org/wiki/EPEL[EPEL repository]. As the first step install all necessary packages:
sudo dnf install fedpkg libselinux-python standard-test-roles
You can also install the latest version from the copr repo:
sudo dnf copr -y enable @osci/standard-test-roles
sudo dnf update standard-test-roles
Artifacts
Output of the test (such as the stdout/stderr output, log files or screenshots) is by default saved in the `artifacts` directory. Use `TEST_ARTIFACTS` environment variable to choose a different location if desired:
export TEST_ARTIFACTS=/tmp/artifacts
*Artifacts cleanup* +
Before running tests make sure that all logs `/tmp/artifacts/test.*` are deleted.
Inventory
A _test subject_ is what we call the thing to be tested. To turn a test subject into a launched, installed system to be tested, we use http://docs.ansible.com/ansible/intro_dynamic_inventory.html[Ansible dynamic inventory]. Use the following command to enable it:
export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
As you can see from the way how the inventory is set, tests may contain their own inventory, which defines their own instructions for turning a _test subject_ into one or more testable systems.
Testing
Classic
You can always invoke the tests locally. Many tests modify or change the system they are run against, so take that into account when looking at how to invoke tests. The following examples invoke tests against the same system that the package git repository is checked out on. Below there are further options for invoking tests against another fully formed and integrated systems, such as an Atomic Host or container image _test subject_.
There may be more than one test present in a package git repository. Testing system will run each playbook matching the glob `tests/tests*.yml` separately in a clean environment. Most often a single `tests.yml` file is used as the main entry point. To run it use the following command: