From acdafef59e4e7715a038f59393ec7c4fd6a86bf3 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Wed, 2 Oct 2024 22:43:37 +0200 Subject: [PATCH 1/8] test/system: Unbreak the downstream Fedora CI The working directory from which bats(1) is invoked might not be part of the Toolbx container. eg., the downstream Fedora CI invokes the tests as: $ cd /path/to/toolbox/test/system $ bats . ... and it led to: not ok 8 help: Try unknown command (forwarded to host) # tags: commands-options # (from function `assert_line' in file ./libs/bats-assert/src/assert.bash, line 488, # in test file ./002-help.bats, line 135) # `assert_line --index 0 "Error: unknown command \"foo\" for \"toolbox\""' failed # # -- line differs -- # index : 0 # expected : Error: unknown command "foo" for "toolbox" # actual : Error: crun: chdir to `/usr/share/toolbox/test/system`: No such file or directory: OCI runtime attempted to invoke a command that was not found # -- # https://github.com/containers/toolbox/pull/1560 https://github.com/containers/toolbox/pull/1745 (backported from commit 1e90c721858b3119702b93445f535f9c23af88e6) --- test/system/002-help.bats | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/system/002-help.bats b/test/system/002-help.bats index 695c51f92..38ff39743 100644 --- a/test/system/002-help.bats +++ b/test/system/002-help.bats @@ -21,6 +21,11 @@ load 'libs/helpers.bash' setup() { _setup_environment + pushd "$HOME" || return 1 +} + +teardown() { + popd || return 1 } @test "help: Smoke test" { From 470410ad6ef9170168cae8439db3e9e3e78f1934 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 27 Jan 2026 12:48:05 +0100 Subject: [PATCH 2/8] test/system: Optimize the 'create' 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. In the case of these two particular tests, toolbox(1) is supposed to validate the command line options before trying to find the image. So, there's no need to copy the image from the test suite's image cache directory to its local container/storage store. Fallout from 32b147b9ffc5511d61759a01c4f42cee0596d3f8 https://github.com/containers/toolbox/pull/1595 https://github.com/containers/toolbox/pull/1745 (backported from commit adc8650660b454f3ce1e2fa40efc33b77ccd8e3f) --- test/system/101-create.bats | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/system/101-create.bats b/test/system/101-create.bats index 02791673e..097929666 100644 --- a/test/system/101-create.bats +++ b/test/system/101-create.bats @@ -639,8 +639,6 @@ teardown() { } @test "create: Try using both --distro and --image" { - pull_distro_image fedora 34 - run "$TOOLBOX" --assumeyes create --distro fedora --image fedora-toolbox:34 assert_failure @@ -650,8 +648,6 @@ teardown() { } @test "create: Try using both --image and --release" { - pull_distro_image fedora 34 - run "$TOOLBOX" --assumeyes create --image fedora-toolbox:34 --release 34 assert_failure From 23a9850822a2f57dccdaf9ba1bd0e2877c2ee63a Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Mon, 9 Dec 2024 18:45:20 +0100 Subject: [PATCH 3/8] .zuul: Drop testing on Fedora 39 Fedora 39 reached End of Life on 26th November 2024: https://docs.fedoraproject.org/en-US/releases/eol/ https://github.com/containers/toolbox/pull/1602 https://github.com/containers/toolbox/pull/1745 (backported from commit 0bb4ff8b803c43982d680151e8e3493909805ea5) --- .zuul.yaml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index c8c734a9a..886b7e82b 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -81,24 +81,12 @@ pre-run: playbooks/setup-env.yaml run: playbooks/system-test.yaml -- job: - name: system-test-fedora-39 - description: Run Toolbx's system tests in Fedora 39 - timeout: 9000 - nodeset: - nodes: - - name: fedora-39 - label: cloud-fedora-39 - pre-run: playbooks/setup-env.yaml - run: playbooks/system-test.yaml - - project: periodic: jobs: - system-test-fedora-rawhide - system-test-fedora-41 - system-test-fedora-40 - - system-test-fedora-39 check: jobs: - unit-test @@ -107,7 +95,6 @@ - system-test-fedora-rawhide - system-test-fedora-41 - system-test-fedora-40 - - system-test-fedora-39 gate: jobs: - unit-test @@ -116,4 +103,3 @@ - system-test-fedora-rawhide - system-test-fedora-41 - system-test-fedora-40 - - system-test-fedora-39 From 54d123f450b95efb1941352c0e3c2de6a758dd8d Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Mon, 26 Jan 2026 22:30:57 +0100 Subject: [PATCH 4/8] .zuul: Enable testing on Fedora 42 https://github.com/containers/toolbox/pull/1619 https://github.com/containers/toolbox/pull/1745 (backported from commit c2520f2016e3e20346435b2005e84dd812cd06e1) --- .zuul.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.zuul.yaml b/.zuul.yaml index 886b7e82b..03352da6d 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -59,6 +59,17 @@ pre-run: playbooks/setup-env.yaml run: playbooks/system-test.yaml +- job: + name: system-test-fedora-42 + description: Run Toolbx's system tests in Fedora 42 + timeout: 9000 + nodeset: + nodes: + - name: fedora-42 + label: cloud-fedora-42 + pre-run: playbooks/setup-env.yaml + run: playbooks/system-test.yaml + - job: name: system-test-fedora-41 description: Run Toolbx's system tests in Fedora 41 @@ -85,6 +96,7 @@ periodic: jobs: - system-test-fedora-rawhide + - system-test-fedora-42 - system-test-fedora-41 - system-test-fedora-40 check: @@ -93,6 +105,7 @@ - unit-test-migration-path-for-coreos-toolbox - unit-test-restricted - system-test-fedora-rawhide + - system-test-fedora-42 - system-test-fedora-41 - system-test-fedora-40 gate: @@ -101,5 +114,6 @@ - unit-test-migration-path-for-coreos-toolbox - unit-test-restricted - system-test-fedora-rawhide + - system-test-fedora-42 - system-test-fedora-41 - system-test-fedora-40 From cf78a72f15f6862c209f31eff626e22427bb9bb9 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 27 Jan 2026 13:41:20 +0100 Subject: [PATCH 5/8] test/system: Optimize the group and user 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 group and user 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 group and user tests check the group and user configuration in 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 group and user tests from almost 22 minutes to almost 5 minutes. https://github.com/containers/toolbox/pull/1635 https://github.com/containers/toolbox/pull/1746 (backported from commit 3017a46c03c963efd4207a3e6f6b77920f46f16b) --- test/system/206-user.bats | 55 +++++++-------------------------------- 1 file changed, 9 insertions(+), 46 deletions(-) diff --git a/test/system/206-user.bats b/test/system/206-user.bats index b51434ac2..5d31ae032 100644 --- a/test/system/206-user.bats +++ b/test/system/206-user.bats @@ -19,14 +19,21 @@ load 'libs/bats-support/load' load 'libs/bats-assert/load' load 'libs/helpers' -setup() { +setup_file() { bats_require_minimum_version 1.7.0 _setup_environment cleanup_all pushd "$HOME" || return 1 + create_default_container + create_distro_container arch latest arch-toolbox-latest + create_distro_container fedora 34 fedora-toolbox-34 + create_distro_container rhel 8.7 rhel-toolbox-8.7 + create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 + create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 + create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 } -teardown() { +teardown_file() { popd || return 1 cleanup_all } @@ -35,8 +42,6 @@ teardown() { local ns_host ns_host=$(readlink /proc/$$/ns/user) - create_default_container - run --keep-empty-lines --separate-stderr "$TOOLBOX" run sh -c 'readlink /proc/$$/ns/user' assert_success @@ -57,7 +62,6 @@ teardown() { local default_container default_container="$(get_system_id)-toolbox-$(get_system_version)" - create_default_container container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount "$default_container")" "$TOOLBOX" run true @@ -74,7 +78,6 @@ teardown() { } @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)" "$TOOLBOX" run --distro arch true @@ -91,7 +94,6 @@ teardown() { } @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)" "$TOOLBOX" run --distro fedora --release 34 true @@ -108,7 +110,6 @@ teardown() { } @test "user: root in shadow(5) inside RHEL 8.7" { - create_distro_container rhel 8.7 rhel-toolbox-8.7 container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount rhel-toolbox-8.7)" "$TOOLBOX" run --distro rhel --release 8.7 true @@ -125,7 +126,6 @@ teardown() { } @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)" "$TOOLBOX" run --distro ubuntu --release 16.04 true @@ -142,7 +142,6 @@ teardown() { } @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)" "$TOOLBOX" run --distro ubuntu --release 18.04 true @@ -159,7 +158,6 @@ teardown() { } @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)" "$TOOLBOX" run --distro ubuntu --release 20.04 true @@ -182,8 +180,6 @@ teardown() { local user_id_real user_id_real="$(id --real --user)" - create_default_container - run --keep-empty-lines --separate-stderr "$TOOLBOX" run cat /etc/passwd assert_success @@ -201,8 +197,6 @@ teardown() { local user_id_real user_id_real="$(id --real --user)" - create_distro_container arch latest arch-toolbox-latest - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro arch cat /etc/passwd assert_success @@ -220,8 +214,6 @@ teardown() { local user_id_real user_id_real="$(id --real --user)" - create_distro_container fedora 34 fedora-toolbox-34 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro fedora --release 34 cat /etc/passwd assert_success @@ -239,8 +231,6 @@ teardown() { local user_id_real user_id_real="$(id --real --user)" - create_distro_container rhel 8.7 rhel-toolbox-8.7 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro rhel --release 8.7 cat /etc/passwd assert_success @@ -258,8 +248,6 @@ teardown() { local user_id_real user_id_real="$(id --real --user)" - create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro ubuntu --release 16.04 cat /etc/passwd assert_success @@ -277,8 +265,6 @@ teardown() { local user_id_real user_id_real="$(id --real --user)" - create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro ubuntu --release 18.04 cat /etc/passwd assert_success @@ -296,8 +282,6 @@ teardown() { local user_id_real user_id_real="$(id --real --user)" - create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro ubuntu --release 20.04 cat /etc/passwd assert_success @@ -312,7 +296,6 @@ teardown() { local default_container default_container="$(get_system_id)-toolbox-$(get_system_version)" - create_default_container container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount "$default_container")" "$TOOLBOX" run true @@ -329,7 +312,6 @@ teardown() { } @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)" "$TOOLBOX" run --distro arch true @@ -346,7 +328,6 @@ teardown() { } @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)" "$TOOLBOX" run --distro fedora --release 34 true @@ -363,7 +344,6 @@ teardown() { } @test "user: $USER in shadow(5) inside RHEL 8.7" { - create_distro_container rhel 8.7 rhel-toolbox-8.7 container_root_file_system="$("$PODMAN" unshare "$PODMAN" mount rhel-toolbox-8.7)" "$TOOLBOX" run --distro rhel --release 8.7 true @@ -380,7 +360,6 @@ teardown() { } @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)" "$TOOLBOX" run --distro ubuntu --release 16.04 true @@ -397,7 +376,6 @@ teardown() { } @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)" "$TOOLBOX" run --distro ubuntu --release 18.04 true @@ -414,7 +392,6 @@ teardown() { } @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)" "$TOOLBOX" run --distro ubuntu --release 20.04 true @@ -431,8 +408,6 @@ teardown() { } @test "user: $USER in group(5) inside the default container" { - create_default_container - run --keep-empty-lines --separate-stderr "$TOOLBOX" run cat /etc/group assert_success @@ -444,8 +419,6 @@ teardown() { } @test "user: $USER in group(5) inside Arch Linux" { - create_distro_container arch latest arch-toolbox-latest - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro arch cat /etc/group assert_success @@ -457,8 +430,6 @@ teardown() { } @test "user: $USER in group(5) inside Fedora 34" { - create_distro_container fedora 34 fedora-toolbox-34 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro fedora --release 34 cat /etc/group assert_success @@ -470,8 +441,6 @@ teardown() { } @test "user: $USER in group(5) inside RHEL 8.7" { - create_distro_container rhel 8.7 rhel-toolbox-8.7 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro rhel --release 8.7 cat /etc/group assert_success @@ -483,8 +452,6 @@ teardown() { } @test "user: $USER in group(5) inside Ubuntu 16.04" { - create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro ubuntu --release 16.04 cat /etc/group assert_success @@ -496,8 +463,6 @@ teardown() { } @test "user: $USER in group(5) inside Ubuntu 18.04" { - create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro ubuntu --release 18.04 cat /etc/group assert_success @@ -509,8 +474,6 @@ teardown() { } @test "user: $USER in group(5) inside Ubuntu 20.04" { - create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro ubuntu --release 20.04 cat /etc/group assert_success From ebf51d6bda45ef0eaa397677ee485c810bae756d Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Thu, 1 May 2025 23:07:01 +0200 Subject: [PATCH 6/8] test/system: Optimize the networking 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 networking 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 networking tests check the behaviour and configuration of the network in 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 networking tests from almost 15 minutes to almost 6 minutes. https://github.com/containers/toolbox/pull/1637 https://github.com/containers/toolbox/pull/1746 (cherry picked from commit 1b9dd007ea1d077896379d2355acb4a1934fc405) --- test/system/203-network.bats | 55 ++++++------------------------------ 1 file changed, 9 insertions(+), 46 deletions(-) diff --git a/test/system/203-network.bats b/test/system/203-network.bats index 4d88dc4e6..73fc5f88b 100644 --- a/test/system/203-network.bats +++ b/test/system/203-network.bats @@ -31,14 +31,21 @@ print(addr)' readonly RESOLVER_SH='resolvectl --legend false --no-pager --type "$0" query "$1" \ | cut --delimiter " " --fields 4' -setup() { +setup_file() { bats_require_minimum_version 1.7.0 _setup_environment cleanup_all pushd "$HOME" || return 1 + create_default_container + create_distro_container arch latest arch-toolbox-latest + create_distro_container fedora 34 fedora-toolbox-34 + create_distro_container rhel 8.7 rhel-toolbox-8.7 + create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 + create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 + create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 } -teardown() { +teardown_file() { popd || return 1 cleanup_all } @@ -47,8 +54,6 @@ teardown() { local ns_host ns_host=$(readlink /proc/$$/ns/net) - create_default_container - run --keep-empty-lines --separate-stderr "$TOOLBOX" run sh -c 'readlink /proc/$$/ns/net' assert_success @@ -65,8 +70,6 @@ teardown() { } @test "network: /etc/resolv.conf inside the default container" { - create_default_container - run --keep-empty-lines --separate-stderr "$TOOLBOX" run readlink /etc/resolv.conf assert_success @@ -83,8 +86,6 @@ teardown() { } @test "network: /etc/resolv.conf inside Arch Linux" { - create_distro_container arch latest arch-toolbox-latest - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro arch readlink /etc/resolv.conf assert_success @@ -101,8 +102,6 @@ teardown() { } @test "network: /etc/resolv.conf inside Fedora 34" { - create_distro_container fedora 34 fedora-toolbox-34 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro fedora --release 34 readlink /etc/resolv.conf assert_success @@ -119,8 +118,6 @@ teardown() { } @test "network: /etc/resolv.conf inside RHEL 8.7" { - create_distro_container rhel 8.7 rhel-toolbox-8.7 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro rhel --release 8.7 readlink /etc/resolv.conf assert_success @@ -137,8 +134,6 @@ teardown() { } @test "network: /etc/resolv.conf inside Ubuntu 16.04" { - create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro ubuntu --release 16.04 readlink /etc/resolv.conf assert_success @@ -155,8 +150,6 @@ teardown() { } @test "network: /etc/resolv.conf inside Ubuntu 18.04" { - create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro ubuntu --release 18.04 readlink /etc/resolv.conf assert_success @@ -173,8 +166,6 @@ teardown() { } @test "network: /etc/resolv.conf inside Ubuntu 20.04" { - create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro ubuntu --release 20.04 readlink /etc/resolv.conf assert_success @@ -207,8 +198,6 @@ teardown() { skip "DNS not working on host" fi - create_default_container - if ! $ipv4_skip; then run --keep-empty-lines --separate-stderr "$TOOLBOX" run python3 -c "$RESOLVER_PYTHON3" A k.root-servers.net @@ -257,8 +246,6 @@ teardown() { skip "DNS not working on host" fi - create_distro_container arch latest arch-toolbox-latest - if ! $ipv4_skip; then run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro arch \ @@ -311,8 +298,6 @@ teardown() { skip "DNS not working on host" fi - create_distro_container fedora 34 fedora-toolbox-34 - if ! $ipv4_skip; then run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro fedora \ @@ -367,8 +352,6 @@ teardown() { skip "DNS not working on host" fi - create_distro_container rhel 8.7 rhel-toolbox-8.7 - if ! $ipv4_skip; then run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro rhel \ @@ -423,8 +406,6 @@ teardown() { skip "DNS not working on host" fi - create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 - if ! $ipv4_skip; then run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro ubuntu \ @@ -479,8 +460,6 @@ teardown() { skip "DNS not working on host" fi - create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 - if ! $ipv4_skip; then run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro ubuntu \ @@ -535,8 +514,6 @@ teardown() { skip "DNS not working on host" fi - create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 - if ! $ipv4_skip; then run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro ubuntu \ @@ -575,8 +552,6 @@ teardown() { } @test "network: ping(8) inside the default container" { - create_default_container - run --keep-empty-lines --separate-stderr "$TOOLBOX" run ping -c 2 f.root-servers.net if [ "$status" -eq 1 ]; then @@ -591,8 +566,6 @@ teardown() { } @test "network: ping(8) inside Arch Linux" { - create_distro_container arch latest arch-toolbox-latest - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro arch ping -c 2 f.root-servers.net if [ "$status" -eq 1 ]; then @@ -607,8 +580,6 @@ teardown() { } @test "network: ping(8) inside Fedora 34" { - create_distro_container fedora 34 fedora-toolbox-34 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro fedora --release 34 ping -c 2 f.root-servers.net if [ "$status" -eq 1 ]; then @@ -623,8 +594,6 @@ teardown() { } @test "network: ping(8) inside RHEL 8.7" { - create_distro_container rhel 8.7 rhel-toolbox-8.7 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro rhel --release 8.7 ping -c 2 f.root-servers.net if [ "$status" -eq 1 ]; then @@ -639,8 +608,6 @@ teardown() { } @test "network: ping(8) inside Ubuntu 16.04" { - create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 - run -2 --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro ubuntu --release 16.04 ping -c 2 f.root-servers.net assert_failure @@ -653,8 +620,6 @@ teardown() { } @test "network: ping(8) inside Ubuntu 18.04" { - create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro ubuntu --release 18.04 ping -c 2 f.root-servers.net if [ "$status" -eq 1 ]; then @@ -669,8 +634,6 @@ teardown() { } @test "network: ping(8) inside Ubuntu 20.04" { - create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run --distro ubuntu --release 20.04 ping -c 2 f.root-servers.net if [ "$status" -eq 1 ]; then From aeca509c633f5d5c6d04f343bee36b4824ead918 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 6 May 2025 22:13:29 +0200 Subject: [PATCH 7/8] test/system: Optimize the D-Bus 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 D-Bus 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 D-Bus tests check if methods can be called across the user or session and system D-Bus instances from different containers without changing their state. Therefore, a lot of disk I/O can be avoided by reating these containers only once for all the tests. This can reduce the time needed to run the D-Bus tests from almost 10 minutes to almost 5 minutes. https://github.com/containers/toolbox/pull/1641 https://github.com/containers/toolbox/pull/1746 (cherry picked from commit 5881bc43f34815b1403c3e9c9ff439f21f447877) --- test/system/211-dbus.bats | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/test/system/211-dbus.bats b/test/system/211-dbus.bats index ca34101ac..2eb3de198 100644 --- a/test/system/211-dbus.bats +++ b/test/system/211-dbus.bats @@ -19,14 +19,21 @@ load 'libs/bats-support/load' load 'libs/bats-assert/load' load 'libs/helpers' -setup() { +setup_file() { bats_require_minimum_version 1.7.0 _setup_environment cleanup_all pushd "$HOME" || return 1 + create_default_container + create_distro_container arch latest arch-toolbox-latest + create_distro_container fedora 34 fedora-toolbox-34 + create_distro_container rhel 8.7 rhel-toolbox-8.7 + create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 + create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 + create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 } -teardown() { +teardown_file() { popd || return 1 cleanup_all } @@ -39,8 +46,6 @@ teardown() { --object-path /org/freedesktop/DBus \ --method org.freedesktop.DBus.Peer.Ping)" - create_default_container - run --keep-empty-lines --separate-stderr "$TOOLBOX" run gdbus call \ --session \ --dest org.freedesktop.DBus \ @@ -68,8 +73,6 @@ teardown() { --object-path /org/freedesktop/DBus \ --method org.freedesktop.DBus.Peer.Ping)" - create_distro_container arch latest arch-toolbox-latest - run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro arch \ gdbus call \ @@ -99,8 +102,6 @@ teardown() { --object-path /org/freedesktop/DBus \ --method org.freedesktop.DBus.Peer.Ping)" - create_distro_container fedora 34 fedora-toolbox-34 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro fedora \ --release 34 \ @@ -131,8 +132,6 @@ teardown() { --object-path /org/freedesktop/DBus \ --method org.freedesktop.DBus.Peer.Ping)" - create_distro_container rhel 8.7 rhel-toolbox-8.7 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro rhel \ --release 8.7 \ @@ -158,8 +157,6 @@ teardown() { @test "dbus: session bus inside Ubuntu 16.04" { busctl --user call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Peer Ping - create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro ubuntu \ --release 16.04 \ @@ -177,8 +174,6 @@ teardown() { @test "dbus: session bus inside Ubuntu 18.04" { busctl --user call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Peer Ping - create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro ubuntu \ --release 18.04 \ @@ -196,8 +191,6 @@ teardown() { @test "dbus: session bus inside Ubuntu 20.04" { busctl --user call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Peer Ping - create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro ubuntu \ --release 20.04 \ @@ -222,8 +215,6 @@ teardown() { org.freedesktop.systemd1.Manager \ Version)" - create_default_container - run --keep-empty-lines --separate-stderr "$TOOLBOX" run gdbus call \ --system \ --dest org.freedesktop.systemd1 \ @@ -255,8 +246,6 @@ teardown() { org.freedesktop.systemd1.Manager \ Version)" - create_distro_container arch latest arch-toolbox-latest - run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro arch \ gdbus call \ @@ -290,8 +279,6 @@ teardown() { org.freedesktop.systemd1.Manager \ Version)" - create_distro_container fedora 34 fedora-toolbox-34 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro fedora \ --release 34 \ @@ -326,8 +313,6 @@ teardown() { org.freedesktop.systemd1.Manager \ Version)" - create_distro_container rhel 8.7 rhel-toolbox-8.7 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro rhel \ --release 8.7 \ @@ -360,8 +345,6 @@ teardown() { org.freedesktop.systemd1.Manager \ Version)" - create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro ubuntu \ --release 16.04 \ @@ -392,8 +375,6 @@ teardown() { org.freedesktop.systemd1.Manager \ Version)" - create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro ubuntu \ --release 18.04 \ @@ -424,8 +405,6 @@ teardown() { org.freedesktop.systemd1.Manager \ Version)" - create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 - run --keep-empty-lines --separate-stderr "$TOOLBOX" run \ --distro ubuntu \ --release 20.04 \ From ad2a72934c8bdb15f42306324a91c22490ec5401 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Mon, 12 May 2025 18:18:32 +0200 Subject: [PATCH 8/8] 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 https://github.com/containers/toolbox/pull/1746 (cherry picked from commit 836c0557f4dc100b9e6b6d56b2b3ee57a60b53ed) --- test/system/220-environment-variables.bats | 39 +++++----------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/test/system/220-environment-variables.bats b/test/system/220-environment-variables.bats index bc818b29c..21062efcf 100644 --- a/test/system/220-environment-variables.bats +++ b/test/system/220-environment-variables.bats @@ -19,21 +19,26 @@ load 'libs/bats-support/load' load 'libs/bats-assert/load' load 'libs/helpers' -setup() { +setup_file() { bats_require_minimum_version 1.7.0 _setup_environment cleanup_all pushd "$HOME" || return 1 + create_default_container + create_distro_container arch latest arch-toolbox-latest + create_distro_container fedora 34 fedora-toolbox-34 + create_distro_container rhel 8.7 rhel-toolbox-8.7 + create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 + create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 + create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 } -teardown() { +teardown_file() { popd || return 1 cleanup_all } @test "environment variables: HISTFILESIZE inside the default container" { - create_default_container - if [ "$HISTFILESIZE" = "" ]; then # shellcheck disable=SC2030 HISTFILESIZE=1001 @@ -62,8 +67,6 @@ teardown() { @test "environment variables: HISTSIZE inside the default container" { skip "https://pagure.io/setup/pull-request/48" - create_default_container - if [ "$HISTSIZE" = "" ]; then # shellcheck disable=SC2030 HISTSIZE=1001 @@ -90,8 +93,6 @@ teardown() { } @test "environment variables: HISTFILESIZE inside Arch Linux" { - create_distro_container arch latest arch-toolbox-latest - # shellcheck disable=SC2031 if [ "$HISTFILESIZE" = "" ]; then # shellcheck disable=SC2030 @@ -119,8 +120,6 @@ teardown() { } @test "environment variables: HISTSIZE inside Arch Linux" { - create_distro_container arch latest arch-toolbox-latest - # shellcheck disable=SC2031 if [ "$HISTSIZE" = "" ]; then # shellcheck disable=SC2030 @@ -148,8 +147,6 @@ teardown() { } @test "environment variables: HISTFILESIZE inside Fedora 34" { - create_distro_container fedora 34 fedora-toolbox-34 - # shellcheck disable=SC2031 if [ "$HISTFILESIZE" = "" ]; then # shellcheck disable=SC2030 @@ -179,8 +176,6 @@ teardown() { @test "environment variables: HISTSIZE inside Fedora 34" { skip "https://pagure.io/setup/pull-request/48" - create_distro_container fedora 34 fedora-toolbox-34 - # shellcheck disable=SC2031 if [ "$HISTSIZE" = "" ]; then # shellcheck disable=SC2030 @@ -208,8 +203,6 @@ teardown() { } @test "environment variables: HISTFILESIZE inside RHEL 8.7" { - create_distro_container rhel 8.7 rhel-toolbox-8.7 - # shellcheck disable=SC2031 if [ "$HISTFILESIZE" = "" ]; then # shellcheck disable=SC2030 @@ -239,8 +232,6 @@ teardown() { @test "environment variables: HISTSIZE inside RHEL 8.7" { skip "https://pagure.io/setup/pull-request/48" - create_distro_container rhel 8.7 rhel-toolbox-8.7 - # shellcheck disable=SC2031 if [ "$HISTSIZE" = "" ]; then # shellcheck disable=SC2030 @@ -268,8 +259,6 @@ teardown() { } @test "environment variables: HISTFILESIZE inside Ubuntu 16.04" { - create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 - # shellcheck disable=SC2031 if [ "$HISTFILESIZE" = "" ]; then # shellcheck disable=SC2030 @@ -298,8 +287,6 @@ teardown() { } @test "environment variables: HISTSIZE inside Ubuntu 16.04" { - create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04 - # shellcheck disable=SC2031 if [ "$HISTSIZE" = "" ]; then # shellcheck disable=SC2030 @@ -327,8 +314,6 @@ teardown() { } @test "environment variables: HISTFILESIZE inside Ubuntu 18.04" { - create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 - # shellcheck disable=SC2031 if [ "$HISTFILESIZE" = "" ]; then # shellcheck disable=SC2030 @@ -357,8 +342,6 @@ teardown() { } @test "environment variables: HISTSIZE inside Ubuntu 18.04" { - create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04 - # shellcheck disable=SC2031 if [ "$HISTSIZE" = "" ]; then # shellcheck disable=SC2030 @@ -386,8 +369,6 @@ teardown() { } @test "environment variables: HISTFILESIZE inside Ubuntu 20.04" { - create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 - # shellcheck disable=SC2031 if [ "$HISTFILESIZE" = "" ]; then HISTFILESIZE=1001 @@ -415,8 +396,6 @@ teardown() { } @test "environment variables: HISTSIZE inside Ubuntu 20.04" { - create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04 - # shellcheck disable=SC2031 if [ "$HISTSIZE" = "" ]; then HISTSIZE=1001