Skip to content
Snippets Groups Projects
Commit 3ec77fd0 authored by Emanuele Aina's avatar Emanuele Aina
Browse files

immutablerootfstests: Overhaul the instructions


Give some more contetx about the Apertis approach to standalone tests
and update the instructions to be more detailed and reflect the
current status (bye bye Jenkins).

Signed-off-by: Emanuele Aina's avatarEmanuele Aina <emanuele.aina@collabora.com>
parent 9664bc16
No related branches found
No related tags found
1 merge request!154immutablerootfstests: Overhaul the instructions
Pipeline #183280 passed
...@@ -31,39 +31,124 @@ should not require dependencies to be installed on the rootfs. ...@@ -31,39 +31,124 @@ should not require dependencies to be installed on the rootfs.
## Writing self-contained tests ## Writing self-contained tests
- Each tests is shipped in a separate git repository under the The approach used by Apertis to create self contained tests is to ship all the
**[tests](https://gitlab.apertis.org/tests/)** GitLab group required test code via dedicated git repositories under the
- Check existing tests like the **[tests](https://gitlab.apertis.org/tests/)** GitLab group which get deployed
**[D-Bus reply time](https://gitlab.apertis.org/tests/dbus-dos-reply-time/)** by LAVA on the device before executing the tests.
ones or the
**[Canterbury](https://gitlab.apertis.org/tests/canterbury)** ones Those repositories can either contain interpreted code that does not need to be
- Add a subtree of the built, for instance by using the `dash` POSIX shell, or they include binaries
[`common`](https://gitlab.apertis.org/tests/common) folder. For built on OBS and synchronized with a GitLab CI/CD pipeline.
For instance, the [`apparmor-dbus`](https://qa.apertis.org/latest/apparmor-dbus.html)
testcase involves:
1. The [`apparmor-dbus.yaml`](https://gitlab.apertis.org/tests/apertis-test-cases/-/blob/apertis/v2021/test-cases/apparmor-dbus.yaml)
testcase definition
2. The [`tests/apparmor-dbus`](https://gitlab.apertis.org/tests/apparmor-dbus)
git repository
3. The [`apparmor-dbus-tester`](https://gitlab.apertis.org/pkg/apparmor-dbus-tester)
deb package
### The testcase definition
Both manual and automated testcases are defined via YAML files in the
[`apertis-test-cases`](https://gitlab.apertis.org/tests/apertis-test-cases/).
The YAML files are used to generate the [qa.apertis.org](https://qa.apertis.org/)
website and the automated ones are executed by LAVA.
Usually testcase need supporting files and scripts and these are shipped via
git repositories with the below directive:
```yaml
install:
git-repos:
- url: https://gitlab.apertis.org/tests/apparmor-dbus.git
branch: 'apertis/v2021'
```
### The git repository
The easiest way to deploy supporting files, scripts and binaries on the device
under test is by storing them in standalone git repositories that then get
unpacked on the device before the test is executed.
In the simplest case the support git repository only ships a shell script and
maybe some static test samples. Keep in mind that the Apertis reference images
do not ship `bash` on minimal/target images but use `dash`, so stick to POSIX
features and avoid [bashisms](https://mywiki.wooledge.org/Bashism).
If instead compiled binaries are needed, they need to be built on OBS and
regularly synchronized in the git repository. Apertis provides a reusable
GitLab pipeline to retrieve those external binaries and commit them in the
git repository. To set it up:
1. Create a new GitLab project under the
[`test`](https://gitlab.apertis.org/tests) group.
2. Add a subtree of the
[`common`](https://gitlab.apertis.org/tests/common) folder. For
convenience, use the convenience, use the
[`common-subtree.sh`](https://gitlab.apertis.org/tests/common/blob/master/common-subtree.sh) [`common-subtree.sh`](https://gitlab.apertis.org/tests/common/blob/apertis/v2021/common-subtree.sh)
script to add a *git-subtree* into your repository: script to add a *git-subtree* into your repository:
../common/common-subtree.sh add ```shell
../common/common-subtree.sh add
```
See the See the
[README](https://gitlab.apertis.org/tests/common/blob/master/README.md) [README](https://gitlab.apertis.org/tests/common/blob/apertis/v2021/README.md)
for further details for further details
- For tests requiring additional binaries not shipped on the base 3. Add an
image: [`external-binaries.cfg`](https://gitlab.apertis.org/tests/apparmor-dbus/blob/apertis/v2021/external-binaries.cfg)
- Add an file which describes the binaries that need to be retrieved and committed.
[`external-binaries.cfg`](https://gitlab.apertis.org/tests/dbus-dos-reply-time/blob/master/external-binaries.cfg) All the files that would otherwise need to be installed via `apt` should be
file listed here: check what the dependencies of the test are and inspect their
- Run the contents, filtering out the files which are not needed to execute the test.
[`update_test_binaries.sh`](https://gitlab.apertis.org/tests/helper-tools/blob/master/update_test_binaries.sh) The format is a simple list of `$PACKAGE $FILEPATH` on each line.
script: The retrieved binaries will be committed under the appropriate `$ARCH/bin`
./helper-tools/update_test_binaries.sh --repository <name-of-repo-under-gitlab-tests> --release 18.06 --dry-run subdirectory in the repository. An optional `prefix=` attribute is supported
` This should add a commit with the binaries required by your test repository` to control where the retrieved file should be installed, for instance
- Tests should use compiled executables included with from the
`update_test_binaries.sh` and/or POSIX shell scripts (avoid [`canterbury`](https://gitlab.apertis.org/tests/canterbury/-/blob/apertis/v2021/external-binaries.cfg)
[bashisms](https://mywiki.wooledge.org/Bashism) and assume that test repository:
`/bin/sh` points to `dash`)
- Test the scripts in a `minimal` or `ostree` image ```
- Add your repository to the canterbury-tests-additions usr/lib/installed-tests/canterbury-0/store-app-bundle-apparmor prefix=lib/installed-tests/canterbury-0
[`test-repositories.txt` list](https://gitlab.apertis.org/tests/helper-tools/blob/master/test-repositories.txt) canterbury-core-tests /etc/apparmor.d/canterbury-tests prefix=etc/apparmor.d
and Jenkins will keep the binaries automatically updated ```
4. Add a [`.gitlab-ci.yml`](https://gitlab.apertis.org/tests/apparmor-dbus/-/blob/apertis/v2021/.gitlab-ci.yml)
which defines the GitLab CI/CD pipeline that is responsible of keeping the
binaries updated by pulling them from the built packages and committing them
to the repository:
```yaml
variables:
osname: apertis
release: v2021
include:
- project: tests/helper-tools
ref: apertis/v2021
file: /gitlab-ci/update-test-binaries.yaml
update-test-binaries:
stage: build
extends:
- .update-test-binaries
```
5. Configure a [CI/CD schedule](https://gitlab.apertis.org/tests/apparmor-dbus/-/pipeline_schedules)
to run the pipeline daily.
### The deb package
In some cases the needed binaries can be extracted from existing packages.
For instance the [`glib-gio-fs`](https://gitlab.apertis.org/tests/glib-gio-fs/-/blob/apertis/v2021/external-binaries.cfg)
testcases sources them from the upstream `libglib2.0-tests` package.
In other cases a new, dedicated package needs to be created to host the test
utilities. No specific requirements are needed on this package, but
conventionally they are named `${TESTCASE}-tester`, like
[`apparmor-dbus-tester`](https://gitlab.apertis.org/tests/glib-gio-fs/-/blob/apertis/v2022dev1/external-binaries.cfg).
## References ## References
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment