From 12153da8373a766f0b9ca19dd600496489cb328b Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Mon, 20 Feb 2023 09:36:16 -0700 Subject: [PATCH] Logs follow-until tests: loosen checks ...in hopes of fixing a flake with podman-remote. It's still possible that there's a real problem with logs under remote, and this will just sweep that under the rug. Also, fix a nasty-red test warning (add cleanup), refactor uses of $(pause_image), and improve a few test assertions. Closes: #17286 Signed-off-by: Ed Santiago --- test/system/010-images.bats | 3 +-- test/system/035-logs.bats | 10 ++++++---- test/system/170-run-userns.bats | 4 ++-- test/system/500-networking.bats | 17 ++++++++++++----- test/system/700-play.bats | 3 +-- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/test/system/010-images.bats b/test/system/010-images.bats index 7f9abcfdbf..d556ec5579 100644 --- a/test/system/010-images.bats +++ b/test/system/010-images.bats @@ -272,8 +272,7 @@ Deleted: $pauseID" "infra images gets removed as well" pname=$(random_string) run_podman create --pod new:$pname $IMAGE - run_podman version --format "{{.Server.Version}}-{{.Server.Built}}" - pauseImage=localhost/podman-pause:$output + pauseImage=$(pause_image) run_podman inspect --format '{{.ID}}' $pauseImage pauseID=$output diff --git a/test/system/035-logs.bats b/test/system/035-logs.bats index da0d01a802..bb67a3e9ff 100644 --- a/test/system/035-logs.bats +++ b/test/system/035-logs.bats @@ -114,7 +114,7 @@ function _log_test_multi() { doit c2 "sleep 1;echo b;sleep 2;echo c;sleep 3" run_podman ${events_backend} logs -f c1 c2 - is "$output" \ + assert "$output" =~ \ "${cid[0]} a$etc ${cid[1]} b$etc ${cid[1]} c$etc @@ -355,20 +355,22 @@ function _log_test_follow_until() { fi run_podman ${events_backend} run --log-driver=$driver --name $cname -d $IMAGE \ - sh -c "while :; do echo $content && sleep 2; done" + sh -c "n=1;while :; do echo $content--\$n; n=\$((n+1));sleep 1; done" t0=$SECONDS # The logs command should exit after the until time even when follow is set PODMAN_TIMEOUT=10 run_podman ${events_backend} logs --until 3s -f $cname t1=$SECONDS + logs_seen="$output" # The delta should be 3 but because it could be a bit longer on a slow system such as CI we also accept 4. delta_t=$(( $t1 - $t0 )) assert $delta_t -gt 2 "podman logs --until: exited too early!" assert $delta_t -lt 5 "podman logs --until: exited too late!" - assert "$output" == "$content -$content" "logs --until -f on running container works" + # Impossible to know how many lines we'll see, but require at least two + assert "$logs_seen" =~ "$content--1 +$content--2.*" "logs --until -f on running container works" run_podman ${events_backend} rm -t 0 -f $cname } diff --git a/test/system/170-run-userns.bats b/test/system/170-run-userns.bats index dd4897b820..8971553842 100644 --- a/test/system/170-run-userns.bats +++ b/test/system/170-run-userns.bats @@ -49,8 +49,7 @@ function _require_crun() { # Remove the pod and the pause image run_podman pod rm $random_pod_name - run_podman version --format "{{.Server.Version}}-{{.Server.Built}}" - run_podman rmi -f localhost/podman-pause:$output + run_podman rmi -f $(pause_image) } @test "podman --remote --group-add keep-groups " { @@ -142,4 +141,5 @@ EOF pid=$output run_podman run --rm --pod $pid $IMAGE id -u is "${output}" "$user" "Container should run as the current user" + run_podman rmi -f $(pause_image) } diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index 95f49e0f28..01a30973c2 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -665,21 +665,28 @@ EOF if is_netavark; then assert "$store" == "search example.com${nl}nameserver $subnet.1" "only integrated dns nameserver is set" else - is "$store" ".*nameserver 1.1.1.1${nl}nameserver $searchIP${nl}nameserver 1.0.0.1${nl}nameserver 8.8.8.8" "nameserver order is correct" + assert "$store" == "search example.com +nameserver 1.1.1.1 +nameserver $searchIP +nameserver 1.0.0.1 +nameserver 8.8.8.8" "nameserver order is correct" fi # we should use the integrated dns server run_podman run --network $netname --rm $IMAGE cat /etc/resolv.conf - is "$output" "search dns.podman.*" "correct search domain" - is "$output" ".*nameserver $subnet.1.*" "integrated dns nameserver is set" + assert "$output" =~ "search dns.podman.*" "correct search domain" + assert "$output" =~ ".*nameserver $subnet.1.*" \ + "integrated dns nameserver is set" # host network should keep localhost nameservers if grep 127.0.0. /etc/resolv.conf >/dev/null; then run_podman run --network host --rm $IMAGE cat /etc/resolv.conf - is "$output" ".*nameserver 127\.0\.0.*" "resolv.conf contains localhost nameserver" + assert "$output" =~ ".*nameserver 127\.0\.0.*" \ + "resolv.conf contains localhost nameserver" fi # host net + dns still works run_podman run --network host --dns 1.1.1.1 --rm $IMAGE cat /etc/resolv.conf - is "$output" ".*nameserver 1\.1\.1\.1.*" "resolv.conf contains 1.1.1.1 nameserver" + assert "$output" =~ ".*nameserver 1\.1\.1\.1.*" \ + "resolv.conf contains 1.1.1.1 nameserver" } @test "podman run port forward range" { diff --git a/test/system/700-play.bats b/test/system/700-play.bats index 01c6ef59c8..27a85aa57b 100644 --- a/test/system/700-play.bats +++ b/test/system/700-play.bats @@ -80,8 +80,7 @@ RELABEL="system_u:object_r:container_file_t:s0" # Make sure that the K8s pause image isn't pulled but the local podman-pause is built. run_podman images run_podman 1 image exists k8s.gcr.io/pause - run_podman version --format "{{.Server.Version}}-{{.Server.Built}}" - run_podman image exists localhost/podman-pause:$output + run_podman image exists $(pause_image) run_podman stop -a -t 0 run_podman pod rm -t 0 -f test_pod