podman/test/system/035-logs.bats
Ed Santiago a4fcf09b7a Reenable remote system tests
podman-remote is in better shape now. Let's see what needs
to be done to reenable remote system tests.

 - logs test: skip multilog, it doesn't work remote

 - diff test: use -l only when local, not with remote

 - many other tests: skip_if_remote, with 'FIXME: pending #xxxx'
   where xxxx is a filed issue.

Unrelated: added new helper to skip_if_remote and _if_rootless,
where we check if the source message includes "remote"/"rootless"
and insert it if missing. This is a minor usability enhancement
to make it easier to understand at-a-glance why a skip triggers.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-08-03 09:36:36 -06:00

54 lines
1.5 KiB
Bash

#!/usr/bin/env bats -*- bats -*-
#
# Basic tests for podman logs
#
load helpers
@test "podman logs - basic test" {
rand_string=$(random_string 40)
run_podman create $IMAGE echo $rand_string
cid="$output"
run_podman logs $cid
is "$output" "" "logs on created container: empty"
run_podman start --attach --interactive $cid
is "$output" "$rand_string" "output from podman-start on created ctr"
is "$output" "$rand_string" "logs of started container"
run_podman logs $cid
is "$output" "$rand_string" "output from podman-logs after container is run"
run_podman rm $cid
}
@test "podman logs - multi" {
skip_if_remote "logs does not support multiple containers when run remotely"
# Simple helper to make the container starts, below, easier to read
local -a cid
doit() {
run_podman run --rm -d --name "$1" $IMAGE sh -c "$2";
cid+=($(echo "${output:0:12}"))
}
# Not really a guarantee that we'll get a-b-c-d in order, but it's
# the best we can do. The trailing 'sleep' in each container
# minimizes the chance of a race condition in which the container
# is removed before 'podman logs' has a chance to wake up and read
# the final output.
doit c1 "echo a;sleep 10;echo d;sleep 3"
doit c2 "sleep 1;echo b;sleep 2;echo c;sleep 3"
run_podman logs -f c1 c2
is "$output" \
"${cid[0]} a
${cid[1]} b
${cid[1]} c
${cid[0]} d" "Sequential output from logs"
}
# vim: filetype=sh