Skip to content

Commit

Permalink
tests/misc: Poll journal for error message
Browse files Browse the repository at this point in the history
We could race in having the client error out and try querying the journal
before the daemon had written the error message.

Closes: #3075
  • Loading branch information
cgwalters committed Aug 19, 2021
1 parent baf28a9 commit 3ff0a1a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 15 additions & 0 deletions tests/common/libtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,21 @@ rpmostree_assert_status() {
rm -f status.json
}

# Wait for a non-empty result from journalctl.
# It's recommended to use arguments like this to search
# for a message from a specific service `--after-cursor <cursor> --grep=message -u rpm-ostreed`.
journal_poll() {
timeout=60
for x in $(seq $timeout); do
if journalctl -q -n 1 "$@"; then
return
fi
sleep 1
done
echo "timed out waiting $timeout seconds for journalctl $@" 1>&2
exit 1
}

# This function below was taken and adapted from coreos-assembler. We
# should look into sharing this code more easily.

Expand Down
3 changes: 1 addition & 2 deletions tests/kolainst/nondestructive/misc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ if env FAILPOINTS='client::connect=return(synthetic-error)' rpm-ostree initramfs
fatal "should have errored"
fi
assert_file_has_content_literal err.txt "error: synthetic-error"
journalctl -u rpm-ostreed --after-cursor "${cursor}" > out.txt
assert_file_has_content_literal out.txt 'client disconnected before calling Start'
journal_poll -u rpm-ostreed --after-cursor "${cursor}" --grep="client disconnected before calling Start"
rpm-ostree status > out.txt
assert_file_has_content_literal out.txt 'State: idle'
echo "ok auto-cancel not-started transaction"
Expand Down

0 comments on commit 3ff0a1a

Please sign in to comment.