|
How to add simple STI test for a package
|
|
Test as a single command
|
|
Task
|
|
There is a package *somepackage*, which contains a binary: */usr/bin/somebinary*
|
|
The most simple and obvious way to test this binary is to run it: *somebinary --help* and check the exit status of the result.
|
|
How to add this test for the package?
|
|
https://docs.fedoraproject.org/en-US/ci/standard-test-roles/[Standard Test Roles] framework provides solution for the task. It is fully supported in Fedora Rawhide.
|
|
Solution
|
|
Create file `tests/tests.yml` in the dist-git of the package:
|
|
rpms/somepackage.git:
|
|
. ├── 0001-something.patch ├── somepackage.spec ├── sources └── tests └── tests.yml
|
|
*tests.yml* is an ansible playbook, where you describe test environment and steps to run your tests.
|
|
There are many options and https://fedoraproject.org/wiki/CI/Examples[examples available], but let's focus on the task at hand: we want to run just one command.
|
|
For this case the content of the file should look as follows:
|
|
rpms/somepackage.git:tests/tests.yml
|
|
- hosts: localhost roles: - role: standard-test-basic // <1> tags: - classic tests: - simple: dir: . run: "somebinary --help" // <2>
|
|
this is a standard test role, it takes care of the test environment, logging, archiving results, etc
|
|
this is your test command, its exit code defines the outcome of the test
|
|
Submit your change as a pull request to see test results in Pagure interface, or push it directly to dist-git and get new test results every time you build package in Koji.
|
|
Test will be running in a *non-blocking* mode until you configure gating for it.
|