playbooks, test/system: Drop the PODMAN and SKOPEO environment variables

The toolbox(1) binary always relies on the PATH environment variable to
find the podman(1) and skopeo(1) binaries.  There's no way to override
those with the PODMAN and SKOPEO environment variables, and they only
affect any direct use of podman(1) and skopeo(1) within the test suite.

Therefore, offering the PODMAN and SKOPEO environment variables in their
current form is needlessly confusing and misleading, and can lead to
surprises arising from different podman(1) and skopeo(1) binaries being
used in different places.  Either toolbox(1) should also honour them or
the test suite shouldn't offer them.  The former is more complicated
without any obvious need for it, so the latter was chosen.

https://github.com/containers/toolbox/pull/1592
This commit is contained in:
Debarshi Ray 2024-11-11 23:17:49 +01:00
parent c11a03ce37
commit fbffd45384
10 changed files with 92 additions and 97 deletions

View File

@ -22,7 +22,6 @@
- name: Run the commands-options system tests
command: bats --filter-tags commands-options ./test/system
environment:
PODMAN: '/usr/bin/podman'
TMPDIR: '/var/tmp'
TOOLBX: '/usr/local/bin/toolbox'
TOOLBX_TEST_SYSTEM_TAGS: 'arch-fedora,commands-options,custom-image,ubuntu'

View File

@ -22,7 +22,6 @@
- name: Run the (arch-fedora,runtime-environment) system tests
command: bats --filter-tags arch-fedora,runtime-environment ./test/system
environment:
PODMAN: '/usr/bin/podman'
TMPDIR: '/var/tmp'
TOOLBX: '/usr/local/bin/toolbox'
TOOLBX_TEST_SYSTEM_TAGS: 'arch-fedora,runtime-environment'

View File

@ -22,7 +22,6 @@
- name: Run the (runtime-environment,ubuntu) system tests
command: bats --filter-tags runtime-environment,ubuntu ./test/system
environment:
PODMAN: '/usr/bin/podman'
TMPDIR: '/var/tmp'
TOOLBX: '/usr/local/bin/toolbox'
TOOLBX_TEST_SYSTEM_TAGS: 'runtime-environment,ubuntu'

View File

@ -204,7 +204,7 @@ teardown() {
assert_output --partial "Created container: ubuntu-toolbox-16.04"
assert_output --partial "Enter with: toolbox enter ubuntu-toolbox-16.04"
run $PODMAN ps --all
run podman ps --all
assert_success
assert_output --regexp "Created[[:blank:]]+ubuntu-toolbox-16.04"
@ -219,7 +219,7 @@ teardown() {
assert_output --partial "Created container: ubuntu-toolbox-18.04"
assert_output --partial "Enter with: toolbox enter ubuntu-toolbox-18.04"
run $PODMAN ps --all
run podman ps --all
assert_success
assert_output --regexp "Created[[:blank:]]+ubuntu-toolbox-18.04"
@ -234,7 +234,7 @@ teardown() {
assert_output --partial "Created container: ubuntu-toolbox-20.04"
assert_output --partial "Enter with: toolbox enter ubuntu-toolbox-20.04"
run $PODMAN ps --all
run podman ps --all
assert_success
assert_output --regexp "Created[[:blank:]]+ubuntu-toolbox-20.04"
@ -251,7 +251,7 @@ teardown() {
assert [ ${#lines[@]} -eq 2 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
run $PODMAN ps --all
run podman ps --all
assert_success
assert_output --regexp "Created[[:blank:]]+$image"
@ -268,7 +268,7 @@ teardown() {
assert [ ${#lines[@]} -eq 2 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
run $PODMAN ps --all
run podman ps --all
assert_success
assert_output --regexp "Created[[:blank:]]+non-default"
@ -285,7 +285,7 @@ teardown() {
assert [ ${#lines[@]} -eq 2 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
run $PODMAN ps --all
run podman ps --all
assert_success
assert_output --regexp "Created[[:blank:]]+non-default"
@ -842,7 +842,7 @@ teardown() {
local authfile="$BATS_TEST_TMPDIR/authfile"
local image="fedora-toolbox:34"
run $PODMAN login --authfile "$authfile" --username user --password user "$DOCKER_REG_URI"
run podman login --authfile "$authfile" --username user --password user "$DOCKER_REG_URI"
assert_success
run "$TOOLBX" --assumeyes create --image "$DOCKER_REG_URI/$image"

View File

@ -535,7 +535,7 @@ teardown() {
num_of_images="$(list_images)"
assert_equal "$num_of_images" 1
$PODMAN create --name busybox-container "$busybox_image"
podman create --name busybox-container "$busybox_image"
local num_of_containers
num_of_containers="$(list_containers)"
@ -558,7 +558,7 @@ teardown() {
num_of_images="$(list_images)"
assert_equal "$num_of_images" 1
$PODMAN create --name busybox-container "$busybox_image"
podman create --name busybox-container "$busybox_image"
local num_of_containers
num_of_containers="$(list_containers)"
@ -581,7 +581,7 @@ teardown() {
num_of_images="$(list_images)"
assert_equal "$num_of_images" 1
$PODMAN create --name busybox-container "$busybox_image"
podman create --name busybox-container "$busybox_image"
local num_of_containers
num_of_containers="$(list_containers)"

View File

@ -842,11 +842,11 @@ teardown() {
local container="ancient"
run "$PODMAN" create --name "$container" "$default_image" true
run podman create --name "$container" "$default_image" true
assert_success
run $PODMAN ps --all
run podman ps --all
assert_success
assert_output --regexp "Created[[:blank:]]+$container"

View File

@ -57,12 +57,12 @@ teardown() {
default_container="$(get_system_id)-toolbox-$(get_system_version)"
create_default_container
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount "$default_container")"
container_root_file_system="$(podman unshare podman mount "$default_container")"
"$TOOLBX" run true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount "$default_container"
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount "$default_container"
assert_success
assert_line --regexp '^root::.+$'
@ -75,12 +75,12 @@ teardown() {
# bats test_tags=arch-fedora
@test "user: root in shadow(5) inside Arch Linux" {
create_distro_container arch latest arch-toolbox-latest
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount arch-toolbox-latest)"
container_root_file_system="$(podman unshare podman mount arch-toolbox-latest)"
"$TOOLBX" run --distro arch true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount arch-toolbox-latest
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount arch-toolbox-latest
assert_success
assert_line --regexp '^root::.+$'
@ -93,12 +93,12 @@ teardown() {
# bats test_tags=arch-fedora
@test "user: root in shadow(5) inside Fedora 34" {
create_distro_container fedora 34 fedora-toolbox-34
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount fedora-toolbox-34)"
container_root_file_system="$(podman unshare podman mount fedora-toolbox-34)"
"$TOOLBX" run --distro fedora --release 34 true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount fedora-toolbox-34
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount fedora-toolbox-34
assert_success
assert_line --regexp '^root::.+$'
@ -111,12 +111,12 @@ teardown() {
# bats test_tags=arch-fedora
@test "user: root in shadow(5) inside RHEL 8.10" {
create_distro_container rhel 8.10 rhel-toolbox-8.10
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount rhel-toolbox-8.10)"
container_root_file_system="$(podman unshare podman mount rhel-toolbox-8.10)"
"$TOOLBX" run --distro rhel --release 8.10 true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount rhel-toolbox-8.10
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount rhel-toolbox-8.10
assert_success
assert_line --regexp '^root::.+$'
@ -129,12 +129,12 @@ teardown() {
# bats test_tags=ubuntu
@test "user: root in shadow(5) inside Ubuntu 16.04" {
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount ubuntu-toolbox-16.04)"
container_root_file_system="$(podman unshare podman mount ubuntu-toolbox-16.04)"
"$TOOLBX" run --distro ubuntu --release 16.04 true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount ubuntu-toolbox-16.04
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount ubuntu-toolbox-16.04
assert_success
assert_line --regexp '^root::.+$'
@ -147,12 +147,12 @@ teardown() {
# bats test_tags=ubuntu
@test "user: root in shadow(5) inside Ubuntu 18.04" {
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount ubuntu-toolbox-18.04)"
container_root_file_system="$(podman unshare podman mount ubuntu-toolbox-18.04)"
"$TOOLBX" run --distro ubuntu --release 18.04 true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount ubuntu-toolbox-18.04
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount ubuntu-toolbox-18.04
assert_success
assert_line --regexp '^root::.+$'
@ -165,12 +165,12 @@ teardown() {
# bats test_tags=ubuntu
@test "user: root in shadow(5) inside Ubuntu 20.04" {
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount ubuntu-toolbox-20.04)"
container_root_file_system="$(podman unshare podman mount ubuntu-toolbox-20.04)"
"$TOOLBX" run --distro ubuntu --release 20.04 true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount ubuntu-toolbox-20.04
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount ubuntu-toolbox-20.04
assert_success
assert_line --regexp '^root::.+$'
@ -326,12 +326,12 @@ teardown() {
default_container="$(get_system_id)-toolbox-$(get_system_version)"
create_default_container
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount "$default_container")"
container_root_file_system="$(podman unshare podman mount "$default_container")"
"$TOOLBX" run true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount "$default_container"
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount "$default_container"
assert_success
refute_line --regexp "^$USER:.*$"
@ -344,12 +344,12 @@ teardown() {
# bats test_tags=arch-fedora
@test "user: $USER in shadow(5) inside Arch Linux" {
create_distro_container arch latest arch-toolbox-latest
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount arch-toolbox-latest)"
container_root_file_system="$(podman unshare podman mount arch-toolbox-latest)"
"$TOOLBX" run --distro arch true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount arch-toolbox-latest
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount arch-toolbox-latest
assert_success
refute_line --regexp "^$USER:.*$"
@ -362,12 +362,12 @@ teardown() {
# bats test_tags=arch-fedora
@test "user: $USER in shadow(5) inside Fedora 34" {
create_distro_container fedora 34 fedora-toolbox-34
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount fedora-toolbox-34)"
container_root_file_system="$(podman unshare podman mount fedora-toolbox-34)"
"$TOOLBX" run --distro fedora --release 34 true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount fedora-toolbox-34
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount fedora-toolbox-34
assert_success
refute_line --regexp "^$USER:.*$"
@ -380,12 +380,12 @@ teardown() {
# bats test_tags=arch-fedora
@test "user: $USER in shadow(5) inside RHEL 8.10" {
create_distro_container rhel 8.10 rhel-toolbox-8.10
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount rhel-toolbox-8.10)"
container_root_file_system="$(podman unshare podman mount rhel-toolbox-8.10)"
"$TOOLBX" run --distro rhel --release 8.10 true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount rhel-toolbox-8.10
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount rhel-toolbox-8.10
assert_success
refute_line --regexp "^$USER:.*$"
@ -398,12 +398,12 @@ teardown() {
# bats test_tags=ubuntu
@test "user: $USER in shadow(5) inside Ubuntu 16.04" {
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount ubuntu-toolbox-16.04)"
container_root_file_system="$(podman unshare podman mount ubuntu-toolbox-16.04)"
"$TOOLBX" run --distro ubuntu --release 16.04 true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount ubuntu-toolbox-16.04
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount ubuntu-toolbox-16.04
assert_success
refute_line --regexp "^$USER:.*$"
@ -416,12 +416,12 @@ teardown() {
# bats test_tags=ubuntu
@test "user: $USER in shadow(5) inside Ubuntu 18.04" {
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount ubuntu-toolbox-18.04)"
container_root_file_system="$(podman unshare podman mount ubuntu-toolbox-18.04)"
"$TOOLBX" run --distro ubuntu --release 18.04 true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount ubuntu-toolbox-18.04
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount ubuntu-toolbox-18.04
assert_success
refute_line --regexp "^$USER:.*$"
@ -434,12 +434,12 @@ teardown() {
# bats test_tags=ubuntu
@test "user: $USER in shadow(5) inside Ubuntu 20.04" {
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04
container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount ubuntu-toolbox-20.04)"
container_root_file_system="$(podman unshare podman mount ubuntu-toolbox-20.04)"
"$TOOLBX" run --distro ubuntu --release 20.04 true
run --keep-empty-lines --separate-stderr "$PODMAN" unshare cat "$container_root_file_system/etc/shadow"
"$PODMAN" unshare "$PODMAN" unmount ubuntu-toolbox-20.04
run --keep-empty-lines --separate-stderr podman unshare cat "$container_root_file_system/etc/shadow"
podman unshare podman unmount ubuntu-toolbox-20.04
assert_success
refute_line --regexp "^$USER:.*$"

View File

@ -161,7 +161,7 @@ teardown() {
assert [ ${#lines[@]} -eq 1 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
"$PODMAN" stop "$default_container"
podman stop "$default_container"
run --keep-empty-lines --separate-stderr "$TOOLBX" run test -e /run/toolbox.1
@ -241,7 +241,7 @@ teardown() {
assert [ ${#lines[@]} -eq 1 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
"$PODMAN" stop "$default_container"
podman stop "$default_container"
run --keep-empty-lines --separate-stderr "$TOOLBX" run test -e /opt/bin/toolbox
@ -321,7 +321,7 @@ teardown() {
assert [ ${#lines[@]} -eq 1 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
"$PODMAN" stop "$default_container"
podman stop "$default_container"
run --keep-empty-lines --separate-stderr "$TOOLBX" run test -e /usr/bin/toolbox.1
@ -453,7 +453,7 @@ teardown() {
assert [ ${#lines[@]} -eq 1 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
"$PODMAN" stop "$default_container"
podman stop "$default_container"
run --keep-empty-lines --separate-stderr "$TOOLBX" run test -e /run/toolbox.1
@ -559,7 +559,7 @@ teardown() {
assert [ ${#lines[@]} -eq 1 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
"$PODMAN" stop "$default_container"
podman stop "$default_container"
run --keep-empty-lines --separate-stderr "$TOOLBX" run test -e /run/toolbox.1
@ -639,7 +639,7 @@ teardown() {
assert [ ${#lines[@]} -eq 1 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
"$PODMAN" stop "$default_container"
podman stop "$default_container"
run --keep-empty-lines --separate-stderr "$TOOLBX" run test -e /opt/bin/toolbox
@ -719,7 +719,7 @@ teardown() {
assert [ ${#lines[@]} -eq 1 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
"$PODMAN" stop "$default_container"
podman stop "$default_container"
run --keep-empty-lines --separate-stderr "$TOOLBX" run test -e /usr/bin/toolbox.1
@ -851,7 +851,7 @@ teardown() {
assert [ ${#lines[@]} -eq 1 ]
assert [ ${#stderr_lines[@]} -eq 0 ]
"$PODMAN" stop "$default_container"
podman stop "$default_container"
run --keep-empty-lines --separate-stderr "$TOOLBX" run test -e /run/toolbox.1

View File

@ -38,10 +38,10 @@ and to speed up the cases.
By default the test suite uses the system versions of `podman`, `skopeo` and
`toolbox`.
If you have a `podman`, `skopeo` or `toolbox` installed in a nonstandard
location then you can use the `PODMAN`, `SKOPEO` and `TOOLBX` 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 TOOLBX=./toolbox bats ./test/system/`.
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](https://systemd.io/TEMPORARY_DIRECTORIES/)
environment variable to `/var/tmp` when running the tests. Otherwise, the
@ -90,6 +90,6 @@ Examples:
Example pull of the `fedora-toolbox:34` image:
```bash
$PODMAN login --username user --password user "$DOCKER_REG_URI"
$PODMAN pull "$DOCKER_REG_URI/fedora-toolbox:34"
podman login --username user --password user "$DOCKER_REG_URI"
podman pull "$DOCKER_REG_URI/fedora-toolbox:34"
```

View File

@ -18,11 +18,9 @@ readonly DOCKER_REG_URI="localhost:50000"
readonly DOCKER_REG_NAME="docker-registry"
# Podman and Toolbx commands to run
readonly PODMAN="${PODMAN:-$(command -v podman)}"
readonly TOOLBX="${TOOLBX:-$(command -v toolbox)}"
readonly TOOLBX_TEST_SYSTEM_TAGS_ALL="arch-fedora,commands-options,custom-image,runtime-environment,ubuntu"
readonly TOOLBX_TEST_SYSTEM_TAGS="${TOOLBX_TEST_SYSTEM_TAGS:-$TOOLBX_TEST_SYSTEM_TAGS_ALL}"
readonly SKOPEO="${SKOPEO:-$(command -v skopeo)}"
# Images
declare -Ag IMAGES=([arch]="quay.io/toolbx/arch-toolbox" \
@ -34,8 +32,8 @@ declare -Ag IMAGES=([arch]="quay.io/toolbx/arch-toolbox" \
function cleanup_all() {
"$PODMAN" rm --all --force >/dev/null
"$PODMAN" rmi --all --force >/dev/null
podman rm --all --force >/dev/null
podman rmi --all --force >/dev/null
}
@ -53,7 +51,7 @@ function _setup_containers_storage() {
function _clean_temporary_storage() {
"$PODMAN" system reset --force >/dev/null
podman system reset --force >/dev/null
rm --force --recursive "${ROOTLESS_PODMAN_STORE_DIR}"
rm --force --recursive "${ROOTLESS_PODMAN_RUNROOT_DIR}"
@ -110,7 +108,7 @@ function _pull_and_cache_distro_image() {
local -i ret_val
for ((j = 0; j < num_of_retries; j++)); do
error_message="$( ("$SKOPEO" copy --dest-compress \
error_message="$( (skopeo copy --dest-compress \
"docker://${image}" \
"dir:${IMAGE_CACHE_DIR}/${image_archive}" >/dev/null) 2>&1)"
ret_val="$?"
@ -183,11 +181,11 @@ function _setup_docker_registry() {
assert_success
# Pull Docker registry image
run "$PODMAN" --root "${DOCKER_REG_ROOT}" pull "${IMAGES[docker-reg]}"
run podman --root "${DOCKER_REG_ROOT}" pull "${IMAGES[docker-reg]}"
assert_success
# Create a Docker registry
run "$PODMAN" --root "${DOCKER_REG_ROOT}" run \
run podman --root "${DOCKER_REG_ROOT}" run \
--detach \
--env REGISTRY_AUTH=htpasswd \
--env REGISTRY_AUTH_HTPASSWD_PATH="/auth/htpasswd" \
@ -203,7 +201,7 @@ function _setup_docker_registry() {
"${IMAGES[docker-reg]}"
assert_success
run "$PODMAN" login \
run podman login \
--authfile "${TEMP_BASE_DIR}/authfile.json" \
--username user \
--password user \
@ -211,7 +209,7 @@ function _setup_docker_registry() {
assert_success
# Add fedora-toolbox:34 image to the registry
run "$SKOPEO" copy --dest-authfile "${TEMP_BASE_DIR}/authfile.json" \
run skopeo copy --dest-authfile "${TEMP_BASE_DIR}/authfile.json" \
dir:"${IMAGE_CACHE_DIR}"/fedora-toolbox-34 \
docker://"${DOCKER_REG_URI}"/fedora-toolbox:34
assert_success
@ -224,13 +222,13 @@ function _setup_docker_registry() {
# Stop, removes and cleans after a locally hosted Docker registry
function _clean_docker_registry() {
# Stop Docker registry container
if "$PODMAN" --root "$DOCKER_REG_ROOT" container exists "$DOCKER_REG_NAME"; then
"$PODMAN" --root "${DOCKER_REG_ROOT}" stop --time 0 "${DOCKER_REG_NAME}"
if podman --root "$DOCKER_REG_ROOT" container exists "$DOCKER_REG_NAME"; then
podman --root "${DOCKER_REG_ROOT}" stop --time 0 "${DOCKER_REG_NAME}"
fi
# Clean up Podman's registry root state
"$PODMAN" --root "${DOCKER_REG_ROOT}" rm --all --force
"$PODMAN" --root "${DOCKER_REG_ROOT}" rmi --all --force
podman --root "${DOCKER_REG_ROOT}" rm --all --force
podman --root "${DOCKER_REG_ROOT}" rmi --all --force
# Remove Docker registry dir
rm --force --recursive "${DOCKER_REG_ROOT}"
# Remove dir with created registry certificates
@ -241,7 +239,7 @@ function _clean_docker_registry() {
function build_image_without_name() {
echo -e "FROM scratch\n\nLABEL com.github.containers.toolbox=\"true\"" > "$BATS_TEST_TMPDIR"/Containerfile
run "$PODMAN" build "$BATS_TEST_TMPDIR"
run podman build "$BATS_TEST_TMPDIR"
assert_success
assert_line --index 0 --partial "FROM scratch"
@ -331,12 +329,12 @@ function pull_distro_image() {
fi
# No need to copy if the image is already available in Podman
if "$PODMAN" image exists "${image}"; then
if podman image exists "${image}"; then
return 0
fi
# https://github.com/containers/skopeo/issues/547 for the options for containers-storage
run "$SKOPEO" copy "dir:${IMAGE_CACHE_DIR}/${image_archive}" "containers-storage:[overlay@$ROOTLESS_PODMAN_STORE_DIR+$ROOTLESS_PODMAN_STORE_DIR]${image}"
run skopeo copy "dir:${IMAGE_CACHE_DIR}/${image_archive}" "containers-storage:[overlay@$ROOTLESS_PODMAN_STORE_DIR+$ROOTLESS_PODMAN_STORE_DIR]${image}"
# shellcheck disable=SC2154
if [ "$status" -ne 0 ]; then
@ -368,7 +366,7 @@ function pull_default_image_and_copy() {
image="${IMAGES[$distro]}:$version"
# https://github.com/containers/skopeo/issues/547 for the options for containers-storage
run "$SKOPEO" copy \
run skopeo copy \
"containers-storage:[overlay@$ROOTLESS_PODMAN_STORE_DIR+$ROOTLESS_PODMAN_STORE_DIR]$image" \
"containers-storage:[overlay@$ROOTLESS_PODMAN_STORE_DIR+$ROOTLESS_PODMAN_STORE_DIR]$image-copy"
@ -431,7 +429,7 @@ function start_container() {
local container_name
container_name="$1"
"$PODMAN" start "$container_name" >/dev/null \
podman start "$container_name" >/dev/null \
|| fail "Podman couldn't start the container '$container_name'"
}
@ -458,11 +456,11 @@ function container_started() {
local num_of_retries=5
for ((j = 0; j < num_of_retries; j++)); do
run --separate-stderr "$PODMAN" logs "$container_name"
run --separate-stderr podman logs "$container_name"
# shellcheck disable=SC2154
if [ "$status" -ne 0 ]; then
fail "Failed to invoke '$PODMAN logs'"
fail "Failed to invoke 'podman logs'"
ret_val="$status"
break
fi
@ -495,26 +493,26 @@ function stop_container() {
container_name="$1"
# Make sure the container is running before trying to stop it
"$PODMAN" start "$container_name" >/dev/null \
podman start "$container_name" >/dev/null \
|| fail "Podman couldn't start the container '$container_name'"
"$PODMAN" stop "$container_name" >/dev/null \
podman stop "$container_name" >/dev/null \
|| fail "Podman couldn't stop the container '$container_name'"
}
# Returns the name of the latest created container
function get_latest_container_name() {
"$PODMAN" ps --latest --format "{{ .Names }}"
podman ps --latest --format "{{ .Names }}"
}
function list_images() {
"$PODMAN" images --all --format "{{.ID}}" | wc --lines
podman images --all --format "{{.ID}}" | wc --lines
}
function list_containers() {
"$PODMAN" ps --all --quiet | wc --lines
podman ps --all --quiet | wc --lines
}