From edf6f1814e2c01e23d0c13fb50b8df85200a7a4f Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 28 May 2024 11:16:58 +0200 Subject: [PATCH] test/system: speed up podman logs - multi ... The test used sleep to synchronize log output between both containers which is slow. There is actually no way to guarantee the ordering on the reading side so just remove the sleep's and check the the lines within the same container are in the right order. Trying to preserve the orignal ordering is just not possible if we speed up the test as it would flake to often. Signed-off-by: Paul Holzinger --- test/system/035-logs.bats | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/test/system/035-logs.bats b/test/system/035-logs.bats index e0d80db689..6325b88e06 100644 --- a/test/system/035-logs.bats +++ b/test/system/035-logs.bats @@ -89,36 +89,30 @@ function _log_test_multi() { skip_if_remote "logs does not support multiple containers when run remotely" - # Under k8s file, 'podman logs' returns just the facts, Ma'am. - # Under journald, there may be other cruft (e.g. container removals) - local etc= - if [[ $driver =~ journal ]]; then - etc='.*' - fi - local events_backend=$(_additional_events_backend $driver) # Simple helper to make the container starts, below, easier to read local -a cid doit() { - run_podman ${events_backend} run --log-driver=$driver --rm -d --name "$1" $IMAGE sh -c "$2"; + run_podman ${events_backend} run --log-driver=$driver -d \ + --name "$1" $IMAGE sh -c "$2"; cid+=($(echo "${output:0:12}")) } - # Not really a guarantee that we'll get a-b-c-d in order, but it's - # the best we can do. The trailing 'sleep' in each container - # minimizes the chance of a race condition in which the container - # is removed before 'podman logs' has a chance to wake up and read - # the final output. - doit c1 "echo a;sleep 10;echo d;sleep 3" - doit c2 "sleep 1;echo b;sleep 2;echo c;sleep 3" + doit c1 "echo a1; echo a2" + doit c2 "echo b1; echo b2" + # Reading logs only guarantees the order for a single container, + # when using multiple containers the line order between them can vary. run_podman ${events_backend} logs -f c1 c2 assert "$output" =~ \ - "${cid[0]} a$etc -${cid[1]} b$etc -${cid[1]} c$etc -${cid[0]} d" "Sequential output from logs" + ".*^${cid[0]} a1\$.* +${cid[0]} a2" "Sequential output from c1" + assert "$output" =~ \ + ".*^${cid[1]} b1\$.* +${cid[1]} b2" "Sequential output from c2" + + run_podman rm -f -t0 ${cid[0]} ${cid[1]} } @test "podman logs - multi k8s-file" {