toolbox/test/system
Debarshi Ray 836c0557f4 test/system: Optimize the environment variable tests
The system tests can be very I/O intensive, because many of them copy
OCI images from the test suite's image cache directory to its local
container/storage store, create containers, and then delete everything
to run the next test with a clean slate.  This makes them slow.

The runtime environment tests, which includes the environment variable
tests, are particularly slow because they don't skip the I/O even when
testing error handling.  This makes them a good target for
optimizations.

The environment variable tests query the values of different environment
variables from different containers without changing their state.
Therefore, a lot of disk I/O can be avoided by creating these containers
only once for all the tests.

This can reduce the time needed to run the environment variable tests
from almost 26 minutes to almost 9 minutes.

https://github.com/containers/toolbox/pull/1646
2025-05-12 23:26:00 +02:00
..
data cmd/initContainer, test/system: Handle NVIDIA's create-symlinks CDI hook 2024-09-20 17:17:17 +02:00
libs test/system: Remove redundant clean-up 2025-05-12 17:58:15 +02:00
001-version.bats .zuul, playbooks, test/system: Optimize the CI on Fedora nodes 2024-09-28 01:28:58 +02:00
002-help.bats test/system: Optimize the help tests 2025-05-01 18:05:28 +02:00
101-create.bats test/system: Enable 101-create.bats on Arch Linux 2024-11-17 11:26:29 +01:00
102-list.bats test/system: Enable 102-list.bats on Arch Linux 2024-11-17 11:26:29 +01:00
103-container.bats test/system: Skip the test before doing any needless work 2024-11-12 01:35:36 +01:00
104-run.bats playbooks, test/system: Drop the PODMAN and SKOPEO environment variables 2024-11-14 02:06:33 +01:00
105-enter.bats .zuul, playbooks, test/system: Optimize the CI on Fedora nodes 2024-09-28 01:28:58 +02:00
106-rm.bats .zuul, playbooks, test/system: Optimize the CI on Fedora nodes 2024-09-28 01:28:58 +02:00
107-rmi.bats .zuul, playbooks, test/system: Optimize the CI on Fedora nodes 2024-09-28 01:28:58 +02:00
108-completion.bats .zuul, playbooks, test/system: Optimize the CI on Fedora nodes 2024-09-28 01:28:58 +02:00
201-ipc.bats .zuul, playbooks, test/system: Optimize the CI on Fedora nodes 2024-09-28 01:28:58 +02:00
203-network.bats test/system: Optimize the networking tests 2025-05-01 23:28:17 +02:00
206-user.bats test/system: Optimize the group and user tests 2025-05-01 20:24:07 +02:00
210-ulimit.bats test/system: Optimize the resource limits tests 2024-09-28 01:32:12 +02:00
211-dbus.bats test/system: Optimize the D-Bus tests 2025-05-06 23:16:27 +02:00
220-environment-variables.bats test/system: Optimize the environment variable tests 2025-05-12 23:26:00 +02:00
230-cdi.bats playbooks, test/system: Drop the PODMAN and SKOPEO environment variables 2024-11-14 02:06:33 +01:00
250-kerberos.bats Link to the website instead of the code repository (part 2) 2025-05-01 14:11:42 +02:00
270-rpm.bats Link to the website instead of the code repository (part 2) 2025-05-01 14:11:42 +02:00
501-create.bats test/system: Unbreak the downstream Fedora CI 2024-10-02 22:52:01 +02:00
504-run.bats test/system: Unbreak the downstream Fedora CI 2024-10-02 22:52:01 +02:00
505-enter.bats test/system: Unbreak the downstream Fedora CI 2024-10-02 22:52:01 +02:00
README.md playbooks, test/system: Drop the PODMAN and SKOPEO environment variables 2024-11-14 02:06:33 +01:00
meson.build .github/workflows, test/system: Test the Kerberos configuration 2025-04-30 16:12:22 +02:00
setup_suite.bash test/system: Remove redundant clean-up 2025-05-12 17:58:15 +02:00

README.md

System tests

These tests are built with BATS (Bash Automated Testing System).

The tests are meant to ensure that Toolbx's functionality remains stable throughout updates of both Toolbx and Podman/libpod.

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.

Dependencies

  • awk
  • bats
  • GNU coreutils
  • httpd-tools
  • openssl
  • podman
  • skopeo
  • toolbox

These tests use a few standard libraries for bats which help with clarity and consistency. The libraries are bats-support and bats-assert. These libraries are provided as git submodules in the libs directory. Make sure both are present by running git submodule init and git submodule update.

How to run the tests

First, make sure you have all the dependencies installed.

  • Enter the toolbox root folder
  • Invoke command bats ./test/system/ and the test suite should fire up

Mocking of images is done automatically to prevent potential networking issues and to speed up the cases.

By default the test suite uses the system versions of podman, skopeo and toolbox.

If you have toolbox installed in a nonstandard location then you can use the TOOLBX environmental variable to set the path to the binary. So the command to invoke the test suite could look something like this: TOOLBX=./toolbox bats ./test/system/.

It's recommended to set the TMPDIR environment variable to /var/tmp when running the tests. Otherwise, the images downloaded during the tests will be cached in /tmp, which is typically on tmpfs backed by RAM or swap and should be used for smaller size-bounded files only.

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.

Writing tests

Environmental variables

  • Inspect top part of libs/helpers.bats for a list of helper environmental variables

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.

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)

  • The registry contains by default only one image: fedora-toolbox:34

Example pull of the fedora-toolbox:34 image:

podman login --username user --password user "$DOCKER_REG_URI"
podman pull "$DOCKER_REG_URI/fedora-toolbox:34"