From 93e9fb3a3432a54dfd816927bc0a375929b01057 Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Thu, 27 Aug 2020 15:22:42 +0800 Subject: [PATCH] system test: Add --log-driver test for podman run Add a test for testing options for podman run --log-driver. Signed-off-by: Yiqiao Pu --- test/system/030-run.bats | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 34afd5bae7..1da6f0ed96 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -305,4 +305,28 @@ echo $rand | 0 | $rand run_podman wait $cid } +@test "podman run --log-driver" { + randomlog=$(random_string 30) + + run_podman run --log-driver k8s-file --log-opt path=$PODMAN_TMPDIR/podmantest.log --rm $IMAGE echo $randomlog + run grep $randomlog $PODMAN_TMPDIR/podmantest.log + is "$output" ".*stdout.*$randomlog" "log should exist in log file" + + run_podman run --log-driver journald --name test-journald $IMAGE echo $randomlog + run grep $randomlog <(journalctl) + is "$output" ".*$randomlog" "log should exist in journalctl output" + run_podman logs test-journald + is "$output" ".*$randomlog" "logs can be read from journald" + + run_podman run --log-driver none --name test-none $IMAGE sleep 1 + run_podman 125 logs test-none + is "$output" ".*this container is not logging output" "can not read log when set --log-driver to none" + + run_podman run --log-driver json-file --log-opt path=$PODMAN_TMPDIR/json-file.log --name test-jsonfile $IMAGE echo $randomlog + run grep $randomlog $PODMAN_TMPDIR/json-file.log + is "$output" ".*stdout.*$randomlog" "json-file aliased to k8s-file for scripting compatibility." + run_podman logs test-jsonfile + is "$output" ".*stdout.*$randomlog" "logs can be read from log file" +} + # vim: filetype=sh