New partial-line test is flaking

...possibly because we somehow ended up with a two-line
log file for a simple 'echo hi'? Make our timestamp-getting
code safer by adding 'head -1'.

Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
Ed Santiago
2023-08-09 17:42:36 -06:00
parent a60bafea48
commit 5908999e6d

View File

@ -398,16 +398,21 @@ $content--2.*" "logs --until -f on running container works"
# Hand-craft a log file with partial lines and carriage returns # Hand-craft a log file with partial lines and carriage returns
run_podman inspect --format '{{.HostConfig.LogConfig.Path}}' $cname run_podman inspect --format '{{.HostConfig.LogConfig.Path}}' $cname
logpath="$output" logpath="$output"
timestamp=$(awk '{print $1}' <"$logpath") timestamp=$(head -n1 "$logpath" | awk '{print $1}')
cr=$'\r' cr=$'\r'
nl=$'\n' nl=$'\n'
cat >| $logpath <<EOF # Delete, don't overwrite, in case conmon still has the fd open
rm -f $logpath
cat > $logpath <<EOF
$timestamp stdout F podman1$cr $timestamp stdout F podman1$cr
$timestamp stdout P podman2 $timestamp stdout P podman2
$timestamp stdout F $cr $timestamp stdout F $cr
$timestamp stdout F podman3$cr $timestamp stdout F podman3$cr
EOF EOF
# FIXME: remove after 2024-01-01 if no more flakes seen.
cat -vET $logpath
expect1="podman3${cr}" expect1="podman3${cr}"
expect2="podman2${cr}${nl}podman3${cr}" expect2="podman2${cr}${nl}podman3${cr}"
expect3="podman1${cr}${nl}podman2${cr}${nl}podman3${cr}" expect3="podman1${cr}${nl}podman2${cr}${nl}podman3${cr}"