File: 26-containersWait.at

package info (click to toggle)
podman 5.7.0%2Bds2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,824 kB
  • sloc: sh: 4,700; python: 2,798; perl: 1,885; ansic: 1,484; makefile: 977; ruby: 42; csh: 8
file content (66 lines) | stat: -rw-r--r-- 2,128 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- 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

# Make sure to test a non-zero exit code (see #18889)
podman create --name "${CTR}" "${IMAGE}" sh -c "exit 3"

t GET libpod/containers/${CTR}/json 200 \
  .Id~[0-9a-f]\\{64\\}

# We need the cid for the wait test at the end
cid=$(jq -r '.Id' <<<"$output")

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=3 \
  .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 [[ -s $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=3 \
  .Error=null
# Make sure the container has really been removed after waiting for
# "condition=removed". This check is racy but should flake in case it doesn't
# work correctly.
t POST "containers/${CTR}/wait?condition=next-exit" 404
wait "${child_pid}"

t POST "libpod/containers/${CTR}/wait?condition=running" 404
t POST "libpod/containers/${cid}/wait?condition=running" 404
# The container no longer exists but we want to ensure the remote client
# can still fetch the exit code correctly until the exit code is pruned
# (after 5 mins) but only by the container id and not the name.
t POST "libpod/containers/${CTR}/wait" 404
t POST "libpod/containers/${cid}/wait" 200 \
 "3"