From 676486a856336ef61692966ee25681f1588eb8ab Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 11 Apr 2023 10:22:42 +0200 Subject: [PATCH] test/system/252-quadlet.bats: fix flake Wait for the expected logs to appear in the journal before using `journalctl`. #18132 is likely flaking because `journalctl` does not yet see the container's logs. Also force the test to use the `passthrough` log driver to make sure `podman logs` continues being tests. Fixes: #18132 Signed-off-by: Valentin Rothberg --- test/system/252-quadlet.bats | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/system/252-quadlet.bats b/test/system/252-quadlet.bats index eaa22d0ed3..cc429d5f8c 100644 --- a/test/system/252-quadlet.bats +++ b/test/system/252-quadlet.bats @@ -145,19 +145,25 @@ function remove_secret() { Image=$IMAGE Exec=sh -c "echo STARTED CONTAINER; echo "READY=1" | socat -u STDIN unix-sendto:\$NOTIFY_SOCKET; sleep inf" Notify=yes +LogDriver=passthrough EOF run_quadlet "$quadlet_file" service_setup $QUADLET_SERVICE_NAME - # Ensure we have output. Output is synced via sd-notify (socat in Exec) + # Check that we can read the logs from the container with podman logs even + # with the `passthrough` driver. The log may need a short period of time + # to bubble up into the journal logs, so wait for it. + wait_for_output "STARTED CONTAINER" $QUADLET_CONTAINER_NAME + # Make sure it's an *exact* match, not just a substring (i.e. no spurious + # warnings or other cruft). + run_podman logs $QUADLET_CONTAINER_NAME + assert "$output" == "STARTED CONTAINER" "exact/full match when using the 'passthrough' driver" + + # Also look for the logs via `journalctl`. run journalctl "--since=$STARTED_TIME" --unit="$QUADLET_SERVICE_NAME" is "$output" '.*STARTED CONTAINER.*' - # check that we can read the logs from the container with podman logs - run_podman logs $QUADLET_CONTAINER_NAME - assert "$output" == "STARTED CONTAINER" "podman logs works on quadlet container" - run_podman container inspect --format "{{.State.Status}}" $QUADLET_CONTAINER_NAME is "$output" "running" "container should be started by systemd and hence be running"