Skip to content

Commit

Permalink
test/system/252-quadlet.bats: fix flake
Browse files Browse the repository at this point in the history
Wait for the expected logs to appear in the journal before using
`journalctl`.  containers#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: containers#18132
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Apr 11, 2023
1 parent 4857c65 commit 676486a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions test/system/252-quadlet.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 676486a

Please sign in to comment.