CI Tests for the Base Runtime docker image
How to run a test using the avocado testing framework:
$ avocado run $TEST.py [ --mux-inject 'run:$TESTPARAM:$VALUE' ... ]
Install prerequisite RPMs if necessary:
-
mock - Builds packages inside chroots
-
python2-configparser - Configuration file parser
$ sudo dnf install mock python2-configparser
-
modularity-testing-framework - Modularity test framework
$ sudo dnf copr enable phracek/Modularity-testing-framework $ sudo dnf install modularity-testing-framework
Add your user to the mock group:
$ sudo usermod -aG mock $USER
Configure docker to run as your (non-root!) userid:
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
Configure docker to start automatically (and start it):
$ sudo systemctl enable docker
$ sudo systemctl start docker
Log out and log back in so that your group membership is re-evaluated.
Add the following lines to /etc/sudoers or put them into a new file such as /etc/sudoers.d/mock-tar-chroot:
%mock ALL=(root) NOPASSWD: /usr/bin/tar -C /var/lib/mock/*/root -c .,\
!/usr/bin/tar -C /var/lib/mock/* */root -c .
The above configuration allows members of the 'mock' group to generate a complete docker image. An image can still be created without performing this step, but it will be incomplete and the test setup phase will finish with a warning.
Avocado starts a fresh process per test method and runs setup/teardown methods each time. We can't afford to have that cause our docker image be repeatedly created/removed. Thus, these CI tests have been split up into three phases:
- setup: creates the docker image
- smoke: runs the tests
- teardown: removes the docker image
Run each of the phases in sequence. e.g.,
$ avocado run ./setup.py
$ avocado run ./smoke.py
$ avocado run ./teardown.py
In the future, additional test scripts can be run between the setup and teardown.
Optional test script configuration overrides can provided on the command line using avocado's parameter passing mechanism in the following manner:
$ avocado run $TEST.py [ --mux-inject 'run:$TESTPARAM:$VALUE' ... ]
The setup.py and teardown.py scripts need to read a base-runtime mock configuration file. The default path is 'resources/base-runtime-mock.cfg' relative to the directory where the test script resides. This path can be overridden with the 'mockcfg' parameter.
The smoke.py script needs to access a base-runtime compiler test resource directory. The default path is 'resources/hello-world' relative to the directory where the test script resides. This path can be overridden with the 'compiler-test-dir' parameter.
All of the scripts need to know the name to use for the base-runtime docker image. The default name is 'base-runtime-smoke'. This name can be overridden with the 'docker-image-name' parameter.