Files
podman/test/apiv2/26-containersWait.at
Ed Santiago e634470fae APIv2 test cleanup, part 2 of 2
This finishes the removal of curls and exits.

Please please please, everyone, if you see a 'curl' or 'exit'
in any new PR, reject the PR and tell me immediately so I can
help the developer do it the proper way.

Also, removed some very-very-wrong USER/UID code. Both are
reserved variables in bash. You cannot override them.

Also, added a cleanup to a system-connection test. I wasted
a lot of time because my podman-remote stopped working, all
because I had run this test as part of something unrelated.

Also, found and fixed dangerously-broken timeout code.
Implemented a new mechanism for requiring a timeout.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-08-25 11:07:11 -06:00

47 lines
1.3 KiB
Bash

# -*- sh -*-
#
# test more container-related endpoints
#
podman pull "${IMAGE}" &>/dev/null
# Ensure clean slate
podman rm -a -f &>/dev/null
CTR="WaitTestingCtr"
t POST "containers/nonExistent/wait?condition=next-exit" 404
podman create --name "${CTR}" --entrypoint '["true"]' "${IMAGE}"
t POST "containers/${CTR}/wait?condition=non-existent-cond" 400
t POST "containers/${CTR}/wait?condition=not-running" 200
# Test waiting for EXIT (need to start a background trigger first)
(sleep 2;podman start "${CTR}") &
child_pid=$!
# This will block until the background job completes
t POST "containers/${CTR}/wait?condition=next-exit" 200 \
.StatusCode=0 \
.Error=null
wait "${child_pid}"
# Test that headers are sent before body. (We should actually never get a body)
APIV2_TEST_EXPECT_TIMEOUT=2 t POST "containers/${CTR}/wait?condition=next-exit" 999
like "$(<$WORKDIR/curl.headers.out)" ".*HTTP.* 200 OK.*" \
"Received headers from /wait"
if [[ -e $WORKDIR/curl.result.out ]]; then
_show_ok 0 "UNEXPECTED: curl on /wait returned results"
fi
# Test waiting for REMOVE. Like above, start a background trigger.
(sleep 2;podman container rm "${CTR}") &
child_pid=$!
t POST "containers/${CTR}/wait?condition=removed" 200 \
.StatusCode=0 \
.Error=null
wait "${child_pid}"