From 3d14504e6222a80fd802fba2e0286244918aa307 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 19 Sep 2023 16:57:04 +0200 Subject: [PATCH 1/3] test/system: Simplify checking if the container started or not Bats' 'run' helper is not necessary to merely check if a command succeeded or not [1]. It also complicates using pipes to feed the output of 'podman logs' into grep(1) [1]. In this case, it's idiomatic to pipe the 'output' directly to grep(1) and use it as the condition for an 'if' branch. [1] https://bats-core.readthedocs.io/en/stable/writing-tests.html https://github.com/containers/toolbox/pull/1367 --- test/system/libs/helpers.bash | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index 0d78fbeb4..64856c823 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -439,10 +439,9 @@ function container_started() { for TRIES in 1 2 3 4 5 do run "$PODMAN" logs "$container_name" - container_output="$output" + # Look for last line of the container startup log - run grep 'Listening to file system and ticker events' <<< "$container_output" - if [[ "$status" -eq 0 ]]; then + if echo "$output" | grep "Listening to file system and ticker events"; then container_initialized=0 break fi From 5c6b566371ed2b77a82b6d339e865555be9ba3ed Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 19 Sep 2023 18:51:10 +0200 Subject: [PATCH 2/3] test/system: Use existing wrapper for 'podman start' https://github.com/containers/toolbox/pull/1367 --- test/system/libs/helpers.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index 64856c823..0e2fdc709 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -431,7 +431,7 @@ function container_started() { local container_name container_name="$1" - run "$PODMAN" start "$container_name" + start_container "$container_name" # Used as a return value container_initialized=1 From 363c3f83ca1cb7ea2d81f6836884d76a918983aa Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 19 Sep 2023 19:07:29 +0200 Subject: [PATCH 3/3] test/system: Style fix https://github.com/containers/toolbox/pull/1367 --- test/system/libs/helpers.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index 0e2fdc709..668dff38f 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -436,8 +436,7 @@ function container_started() { # Used as a return value container_initialized=1 - for TRIES in 1 2 3 4 5 - do + for TRIES in 1 2 3 4 5; do run "$PODMAN" logs "$container_name" # Look for last line of the container startup log