Skip to content

Commit

Permalink
test/system: Consolidate teardown() to remove both containers & images
Browse files Browse the repository at this point in the history
It's far more consistent and understandable if all tests start with a
clean state without any containers or images present.  Otherwise, the
subtle side-effects of having some image left behind from a previous
test can lead to surprises, and there's no need to spend time wondering
whether some tests should only clean up the containers or both
containers and images.

This additional work of cleaning up the images for all tests makes it
necessary to increase the timeout for all Fedora nodes to prevent the CI
from timing out.

#1526
  • Loading branch information
debarshiray committed Aug 29, 2024
1 parent 3f359f3 commit 67d4002
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 31 deletions.
6 changes: 3 additions & 3 deletions .zuul.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
- job:
name: system-test-fedora-rawhide
description: Run Toolbx's system tests in Fedora Rawhide
timeout: 4800
timeout: 7800
nodeset:
nodes:
- name: fedora-rawhide
Expand All @@ -62,7 +62,7 @@
- job:
name: system-test-fedora-40
description: Run Toolbx's system tests in Fedora 40
timeout: 3600
timeout: 6600
nodeset:
nodes:
- name: fedora-40
Expand All @@ -73,7 +73,7 @@
- job:
name: system-test-fedora-39
description: Run Toolbx's system tests in Fedora 39
timeout: 3600
timeout: 6600
nodeset:
nodes:
- name: fedora-39
Expand Down
2 changes: 1 addition & 1 deletion test/system/101-create.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ load 'libs/helpers'
setup() {
bats_require_minimum_version 1.7.0
_setup_environment
cleanup_containers
cleanup_all
}

teardown() {
Expand Down
4 changes: 2 additions & 2 deletions test/system/103-container.bats
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ load 'libs/helpers'

setup() {
_setup_environment
cleanup_containers
cleanup_all
}

teardown() {
cleanup_containers
cleanup_all
}


Expand Down
4 changes: 2 additions & 2 deletions test/system/104-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ load 'libs/helpers'
setup() {
bats_require_minimum_version 1.7.0
_setup_environment
cleanup_containers
cleanup_all
pushd "$HOME" || return 1
}

teardown() {
popd || return 1
cleanup_containers
cleanup_all
}

@test "run: Smoke test with true(1)" {
Expand Down
4 changes: 2 additions & 2 deletions test/system/105-enter.bats
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ load 'libs/helpers'

setup() {
_setup_environment
cleanup_containers
cleanup_all
}

teardown() {
cleanup_containers
cleanup_all
}

@test "enter: Try to enter the default container with no containers created" {
Expand Down
4 changes: 2 additions & 2 deletions test/system/106-rm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ load 'libs/helpers'

setup() {
_setup_environment
cleanup_containers
cleanup_all
}

teardown() {
cleanup_containers
cleanup_all
}


Expand Down
4 changes: 2 additions & 2 deletions test/system/201-ipc.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ load 'libs/helpers'
setup() {
bats_require_minimum_version 1.7.0
_setup_environment
cleanup_containers
cleanup_all
pushd "$HOME" || return 1
}

teardown() {
popd || return 1
cleanup_containers
cleanup_all
}

@test "ipc: No namespace" {
Expand Down
4 changes: 2 additions & 2 deletions test/system/203-network.bats
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ readonly RESOLVER_SH='resolvectl --legend false --no-pager --type "$0" query "$1
setup() {
bats_require_minimum_version 1.7.0
_setup_environment
cleanup_containers
cleanup_all
pushd "$HOME" || return 1
}

teardown() {
popd || return 1
cleanup_containers
cleanup_all
}

@test "network: No namespace" {
Expand Down
4 changes: 2 additions & 2 deletions test/system/206-user.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ load 'libs/helpers'
setup() {
bats_require_minimum_version 1.7.0
_setup_environment
cleanup_containers
cleanup_all
pushd "$HOME" || return 1
}

teardown() {
popd || return 1
cleanup_containers
cleanup_all
}

@test "user: Separate namespace" {
Expand Down
4 changes: 2 additions & 2 deletions test/system/210-ulimit.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ load 'libs/helpers'
setup() {
bats_require_minimum_version 1.7.0
_setup_environment
cleanup_containers
cleanup_all
pushd "$HOME" || return 1
}

teardown() {
popd || return 1
cleanup_containers
cleanup_all
}

@test "ulimit: real-time non-blocking time (hard)" {
Expand Down
4 changes: 2 additions & 2 deletions test/system/211-dbus.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ load 'libs/helpers'
setup() {
bats_require_minimum_version 1.7.0
_setup_environment
cleanup_containers
cleanup_all
pushd "$HOME" || return 1
}

teardown() {
popd || return 1
cleanup_containers
cleanup_all
}

@test "dbus: session bus inside the default container" {
Expand Down
4 changes: 2 additions & 2 deletions test/system/220-environment-variables.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ load 'libs/helpers'
setup() {
bats_require_minimum_version 1.7.0
_setup_environment
cleanup_containers
cleanup_all
pushd "$HOME" || return 1
}

teardown() {
popd || return 1
cleanup_containers
cleanup_all
}

@test "environment variables: HISTFILESIZE inside the default container" {
Expand Down
4 changes: 2 additions & 2 deletions test/system/230-cdi.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ load 'libs/helpers'
setup() {
bats_require_minimum_version 1.7.0
_setup_environment
cleanup_containers
cleanup_all
pushd "$HOME" || return 1
rm --force "$XDG_RUNTIME_DIR/toolbox/cdi-nvidia.json" || return 1
}

teardown() {
rm --force "$XDG_RUNTIME_DIR/toolbox/cdi-nvidia.json" || return 1
popd || return 1
cleanup_containers
cleanup_all
}

@test "cdi: Smoke test" {
Expand Down
5 changes: 0 additions & 5 deletions test/system/libs/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ function cleanup_all() {
}


function cleanup_containers() {
"$PODMAN" rm --all --force >/dev/null
}


function _setup_environment() {
_setup_containers_storage
check_xdg_runtime_dir
Expand Down

0 comments on commit 67d4002

Please sign in to comment.