2019-08-01 12:43:42 +00:00
|
|
|
# System tests
|
|
|
|
|
2020-07-27 13:35:17 +00:00
|
|
|
These tests are built with BATS (Bash Automated Testing System).
|
2019-08-01 12:43:42 +00:00
|
|
|
|
2020-02-18 12:17:53 +00:00
|
|
|
The tests are meant to ensure that Toolbox's functionality remains stable
|
2019-08-01 12:43:42 +00:00
|
|
|
throughout updates of both Toolbox and Podman/libpod.
|
|
|
|
|
2021-06-22 17:29:07 +00:00
|
|
|
The tests are set up in a way that does not affect the host environment.
|
|
|
|
Running them won't remove any existing containers or images.
|
2020-07-27 13:35:17 +00:00
|
|
|
|
|
|
|
## Dependencies
|
|
|
|
|
2021-07-01 10:16:44 +00:00
|
|
|
- `awk`
|
2021-01-02 19:54:11 +00:00
|
|
|
- `bats`
|
2021-07-01 10:16:44 +00:00
|
|
|
- `GNU coreutils`
|
2021-11-24 23:52:15 +00:00
|
|
|
- `httpd-tools`
|
|
|
|
- `openssl`
|
2021-01-02 19:54:11 +00:00
|
|
|
- `podman`
|
|
|
|
- `skopeo`
|
|
|
|
- `toolbox`
|
|
|
|
|
|
|
|
These tests use a few standard libraries for `bats` which help with clarity
|
2021-07-09 12:05:26 +00:00
|
|
|
and consistency. The libraries are [bats-support](https://github.com/bats-core/bats-support)
|
|
|
|
and [bats-assert](https://github.com/bats-core/bats-assert). These libraries are
|
|
|
|
provided as git submodules in the `libs` directory. Make sure both are present.
|
2019-08-01 12:43:42 +00:00
|
|
|
|
2020-07-27 13:35:17 +00:00
|
|
|
## How to run the tests
|
2019-08-01 12:43:42 +00:00
|
|
|
|
2021-01-02 19:54:11 +00:00
|
|
|
First, make sure you have all the dependencies installed.
|
2020-02-10 15:16:36 +00:00
|
|
|
|
2019-08-01 12:43:42 +00:00
|
|
|
- Enter the toolbox root folder
|
|
|
|
- Invoke command `bats ./test/system/` and the test suite should fire up
|
|
|
|
|
2021-07-01 10:16:44 +00:00
|
|
|
Mocking of images is done automatically to prevent potential networking issues
|
|
|
|
and to speed up the cases.
|
2021-01-02 19:54:11 +00:00
|
|
|
|
2021-07-01 10:16:44 +00:00
|
|
|
By default the test suite uses the system versions of `podman`, `skopeo` and
|
|
|
|
`toolbox`.
|
2021-01-02 19:54:11 +00:00
|
|
|
|
2021-07-01 10:16:44 +00:00
|
|
|
If you have a `podman`, `skopeo` or `toolbox` installed in a nonstandard
|
|
|
|
location then you can use the `PODMAN`, `SKOPEO` and `TOOLBOX` environmental
|
|
|
|
variables to set the path to the binaries. So the command to invoke the test
|
|
|
|
suite could look something like this: `PODMAN=/usr/libexec/podman TOOLBOX=./toolbox bats ./test/system/`.
|
2019-08-01 12:43:42 +00:00
|
|
|
|
2021-07-01 10:16:44 +00:00
|
|
|
When running the tests, make sure the `test suite: [job]` jobs are successful.
|
|
|
|
These jobs set up the whole environment and are a strict requirement for other
|
|
|
|
jobs to run correctly.
|
2022-03-17 20:52:35 +00:00
|
|
|
|
|
|
|
## Writing tests
|
|
|
|
|
2022-03-17 20:53:28 +00:00
|
|
|
### Environmental variables
|
|
|
|
|
|
|
|
- Inspect top part of `libs/helpers.bats` for a list of helper environmental
|
|
|
|
variables
|
|
|
|
|
2022-03-17 20:52:35 +00:00
|
|
|
### Naming convention
|
|
|
|
|
|
|
|
- All tests should follow the nomenclature: `[command]: <test description>...`
|
|
|
|
- When the test is expected to fail, start the test description with "Try
|
|
|
|
to..."
|
|
|
|
- When the test is to give a non obvious output, it should be put in parenthesis
|
|
|
|
at the end of the title
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
* `@test "create: Create the default container"`
|
|
|
|
* `@test "rm: Try to remove a non-existent container"`
|
|
|
|
|
|
|
|
### Test case environment
|
|
|
|
|
|
|
|
- All the tests start with a clean system (no images or containers) to make sure
|
|
|
|
that there are no dependencies between tests and they are really isolated. Use
|
|
|
|
the `setup()` and `teardown()` functions for that purpose.
|
2021-11-24 23:52:15 +00:00
|
|
|
|
|
|
|
### Image registry
|
|
|
|
|
|
|
|
- The system tests set up an OCI image registry for testing purposes -
|
|
|
|
`localhost:50000`. The registry requires authentication. There is one account
|
|
|
|
present: `user` (password: `user`)
|
|
|
|
|
2022-12-05 19:54:51 +00:00
|
|
|
- The registry contains by default only one image: `fedora-toolbox:34`
|
2021-11-24 23:52:15 +00:00
|
|
|
|
2022-12-05 19:54:51 +00:00
|
|
|
Example pull of the `fedora-toolbox:34` image:
|
2021-11-24 23:52:15 +00:00
|
|
|
|
|
|
|
```bash
|
|
|
|
$PODMAN login --username user --password user "$DOCKER_REG_URI"
|
2022-12-05 19:54:51 +00:00
|
|
|
$PODMAN pull "$DOCKER_REG_URI/fedora-toolbox:34"
|
2021-11-24 23:52:15 +00:00
|
|
|
```
|