mirror of https://github.com/containers/podman.git
System tests: fix three races
Three tests were running 'container rm' on 'start'ed containers that might not yet have exited. Fix. Also, tighten up the tests themselves, to make even more sure that they test what they're supposed to test. Discovered, in CI, that 'podman-remote logs --timestamps' was unimplemented. Thanks to @Luap99 for the fix to that. Fixes: #15783 Fixes: #15795 Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
parent
017d81ddd0
commit
d4a62ff932
|
@ -517,7 +517,7 @@ func (ic *ContainerEngine) ContainerLogs(_ context.Context, nameOrIDs []string,
|
||||||
stdout := opts.StdoutWriter != nil
|
stdout := opts.StdoutWriter != nil
|
||||||
stderr := opts.StderrWriter != nil
|
stderr := opts.StderrWriter != nil
|
||||||
options := new(containers.LogOptions).WithFollow(opts.Follow).WithSince(since).WithUntil(until).WithStderr(stderr)
|
options := new(containers.LogOptions).WithFollow(opts.Follow).WithSince(since).WithUntil(until).WithStderr(stderr)
|
||||||
options.WithStdout(stdout).WithTail(tail)
|
options.WithStdout(stdout).WithTail(tail).WithTimestamps(opts.Timestamps)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
stdoutCh := make(chan string)
|
stdoutCh := make(chan string)
|
||||||
|
|
|
@ -36,13 +36,28 @@ function _log_test_tail() {
|
||||||
run_podman run -d --log-driver=$driver $IMAGE sh -c "echo test1; echo test2"
|
run_podman run -d --log-driver=$driver $IMAGE sh -c "echo test1; echo test2"
|
||||||
cid="$output"
|
cid="$output"
|
||||||
|
|
||||||
run_podman logs --tail 1 $cid
|
run_podman wait $cid
|
||||||
is "$output" "test2" "logs should only show last line"
|
run_podman logs --tail 1 --timestamps $cid
|
||||||
|
log1="$output"
|
||||||
|
assert "$log1" =~ "^[0-9-]+T[0-9:.]+([\+-][0-9:]+|Z) test2" \
|
||||||
|
"logs should only show last line"
|
||||||
|
|
||||||
|
# Sigh. I hate doing this, but podman-remote --timestamp only has 1-second
|
||||||
|
# resolution (regular podman has sub-second). For the timestamps-differ
|
||||||
|
# check below, we need to force a different second.
|
||||||
|
if is_remote; then
|
||||||
|
sleep 2
|
||||||
|
fi
|
||||||
|
|
||||||
run_podman restart $cid
|
run_podman restart $cid
|
||||||
|
run_podman wait $cid
|
||||||
|
|
||||||
run_podman logs --tail 1 $cid
|
run_podman logs -t --tail 1 $cid
|
||||||
is "$output" "test2" "logs should only show last line after restart"
|
log2="$output"
|
||||||
|
assert "$log2" =~ "^[0-9-]+T[0-9:.]+([\+-][0-9:]+|Z) test2" \
|
||||||
|
"logs, after restart, shows only last line"
|
||||||
|
|
||||||
|
assert "$log2" != "$log1" "log timestamps should differ"
|
||||||
|
|
||||||
run_podman rm $cid
|
run_podman rm $cid
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ load helpers
|
||||||
@test "podman start --filter - start only containers that match the filter" {
|
@test "podman start --filter - start only containers that match the filter" {
|
||||||
run_podman run -d $IMAGE /bin/true
|
run_podman run -d $IMAGE /bin/true
|
||||||
cid="$output"
|
cid="$output"
|
||||||
|
run_podman wait $cid
|
||||||
|
|
||||||
run_podman start --filter restart-policy=always $cid
|
run_podman start --filter restart-policy=always $cid
|
||||||
is "$output" "" "CID of restart-policy=always container"
|
is "$output" "" "CID of restart-policy=always container"
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ load helpers
|
||||||
esac
|
esac
|
||||||
|
|
||||||
run_podman --cgroup-manager=$other run --name myc $IMAGE true
|
run_podman --cgroup-manager=$other run --name myc $IMAGE true
|
||||||
|
assert "$output" = "" "run true, with cgroup-manager=$other, is silent"
|
||||||
|
|
||||||
run_podman container inspect --format '{{.HostConfig.CgroupManager}}' myc
|
run_podman container inspect --format '{{.HostConfig.CgroupManager}}' myc
|
||||||
is "$output" "$other" "podman preserved .HostConfig.CgroupManager"
|
is "$output" "$other" "podman preserved .HostConfig.CgroupManager"
|
||||||
|
|
||||||
|
@ -29,7 +31,8 @@ load helpers
|
||||||
|
|
||||||
# Restart the container, without --cgroup-manager option (ie use default)
|
# Restart the container, without --cgroup-manager option (ie use default)
|
||||||
# Prior to #7970, this would fail with an OCI runtime error
|
# Prior to #7970, this would fail with an OCI runtime error
|
||||||
run_podman start myc
|
run_podman start -a myc
|
||||||
|
assert "$output" = "" "restarted container emits no output"
|
||||||
|
|
||||||
run_podman rm myc
|
run_podman rm myc
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue