mirror of
https://github.com/containers/podman.git
synced 2026-03-30 04:22:04 -04:00
For the past two months we've been splitting system tests
into two categories: those that CAN be run in parallel,
and those that CANNOT. Much work has been done to replace
hardcoded names (mycontainer, mypod) with safename().
Hundreds of test runs, in CI and on Ed's laptop, have
proven this approach viable.
make {local,remote}system now runs in two steps: first
the serial ones, then the parallel ones. hack/bats will
now recognize the 'ci:parallel' tag and add --jobs (nprocs).
This requires some tweaking of leak_check, because there
can be umpteen tests running (affecting image/container/pod/etc
state) when any given test completes.
Rules for enabling parallelization in tests:
* use unique container/pod/volume/network names (safename)
* do not run 'podman rm -a' or 'rmi -a'
* never use the -l (--latest) option
* do not run 'podman ps/images' and expect precise output
Signed-off-by: Ed Santiago <santiago@redhat.com>
56 lines
1.7 KiB
Bash
56 lines
1.7 KiB
Bash
# -*- bash -*-
|
|
#
|
|
# global setup/teardown for the entire system test suite
|
|
#
|
|
bats_require_minimum_version 1.8.0
|
|
|
|
load helpers
|
|
load helpers.network
|
|
load helpers.registry
|
|
|
|
# Create common environment just in case we end up needing a registry.
|
|
# These environment variables will be available to all tests.
|
|
function setup_suite() {
|
|
# FIXME: 2023-12-13: https://github.com/bats-core/bats-core/issues/812
|
|
# Running 'bats --filter-tags' sets IFS=',' which ... ugh. Not fun to debug.
|
|
# The line below is newline, space, tab.
|
|
IFS="
|
|
"
|
|
|
|
export PODMAN_LOGIN_WORKDIR="$BATS_SUITE_TMPDIR/podman-bats-registry"
|
|
mkdir "$PODMAN_LOGIN_WORKDIR"
|
|
|
|
export PODMAN_LOGIN_USER="user$(random_string 4)"
|
|
export PODMAN_LOGIN_PASS="pw$(random_string 15)"
|
|
|
|
# FIXME: racy! It could be many minutes between now and when we start it.
|
|
# To mitigate, we use a range not used anywhere else in system tests.
|
|
export PODMAN_LOGIN_REGISTRY_PORT=$(random_free_port 42000-42999)
|
|
|
|
# The above does not handle errors. Do a final confirmation.
|
|
assert "$PODMAN_LOGIN_REGISTRY_PORT" != "" \
|
|
"Unable to set PODMAN_LOGIN_REGISTRY_PORT"
|
|
|
|
clean_setup
|
|
|
|
# Canary file. Will be removed if any individual test fails.
|
|
touch "$BATS_SUITE_TMPDIR/all-tests-passed"
|
|
}
|
|
|
|
# Run at the very end of all tests. Useful for cleanup of non-BATS tmpdirs.
|
|
function teardown_suite() {
|
|
stop_registry
|
|
local exit_code=$?
|
|
|
|
# At end, if all tests have passed, check for leaks.
|
|
# Don't do this if there were errors: failing tests may not clean up.
|
|
if [[ -e "$BATS_SUITE_TMPDIR/all-tests-passed" ]]; then
|
|
leak_check
|
|
if [ $? -gt 0 ]; then
|
|
exit_code=$((exit_code + 1))
|
|
fi
|
|
fi
|
|
|
|
return $exit_code
|
|
}
|