mirror of
https://github.com/containers/podman.git
synced 2025-06-18 15:39:08 +08:00

The podman-login tests have accumulated much cruft over the years, because that's the only place where we run a local registry, and the process was crufty: we actually start/stopped the registry as the first & last tests of the file. Meaning, you couldn't do 'hack/bats 150:just-one-test' because that would skip the registry start. And just now, a completely unrelated test has had to be shoved into the login file. This PR revamps the whole thing, by adding a new registry helper module that can be used anywhere. And, once the registry is started, it just stays running until the end of tests. (This requires BATS 1.7 or greater). Signed-off-by: Ed Santiago <santiago@redhat.com>
30 lines
1023 B
Bash
30 lines
1023 B
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() {
|
|
# Can't use $BATS_SUITE_TMPDIR because podman barfs:
|
|
# Error: the specified runroot is longer than 50 characters
|
|
export PODMAN_LOGIN_WORKDIR=$(mktemp -d --tmpdir=${BATS_TMPDIR:-${TMPDIR:-/tmp}} podman-bats-registry.XXXXXX)
|
|
|
|
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)
|
|
}
|
|
|
|
# Run at the very end of all tests. Useful for cleanup of non-BATS tmpdirs.
|
|
function teardown_suite() {
|
|
stop_registry
|
|
}
|