summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@redhat.com>2021-11-12 11:15:18 -0500
committerMatthew Heon <mheon@redhat.com>2021-12-06 14:34:25 -0500
commit08bcd60c8f4147e4817d3e4e488e3394dbb29c64 (patch)
treee524206f1fd04c5b534373440cefb0dda1c42cb4 /test
parent76ada2c0119430d10f5aad423120b4b082d3570d (diff)
downloadpodman-08bcd60c8f4147e4817d3e4e488e3394dbb29c64.tar.gz
podman-08bcd60c8f4147e4817d3e4e488e3394dbb29c64.tar.bz2
podman-08bcd60c8f4147e4817d3e4e488e3394dbb29c64.zip
journald logs: keep reading until the journal's end
When reading logs from the journal, keep going after the container exits, in case it gets restarted. Events logged to the journal via the normal paths don't include CONTAINER_ID_FULL, so don't bother adding it to the "history" event we use to force at least one entry for the container to show up in the log. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/system/035-logs.bats21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/system/035-logs.bats b/test/system/035-logs.bats
index 76ce12b81..d8bc0f27d 100644
--- a/test/system/035-logs.bats
+++ b/test/system/035-logs.bats
@@ -76,6 +76,27 @@ ${cid[0]} d" "Sequential output from logs"
_log_test_multi journald
}
+function _log_test_restarted() {
+ run_podman run --log-driver=$1 --name logtest $IMAGE sh -c 'start=0; if test -s log; then start=`tail -n 1 log`; fi; seq `expr $start + 1` `expr $start + 10` | tee -a log'
+ run_podman start -a logtest
+ logfile=$(mktemp -p ${PODMAN_TMPDIR} logfileXXXXXXXX)
+ $PODMAN $_PODMAN_TEST_OPTS logs -f logtest > $logfile
+ expected=$(mktemp -p ${PODMAN_TMPDIR} expectedXXXXXXXX)
+ seq 1 20 > $expected
+ diff -u ${expected} ${logfile}
+}
+
+@test "podman logs restarted - k8s-file" {
+ _log_test_restarted k8s-file
+}
+
+@test "podman logs restarted journald" {
+ # We can't use journald on RHEL as rootless: rhbz#1895105
+ skip_if_journald_unavailable
+
+ _log_test_restarted journald
+}
+
@test "podman logs - journald log driver requires journald events backend" {
skip_if_remote "remote does not support --events-backend"
# We can't use journald on RHEL as rootless: rhbz#1895105