summaryrefslogtreecommitdiff
path: root/test/apiv2
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-02-05 04:41:41 -0500
committerGitHub <noreply@github.com>2021-02-05 04:41:41 -0500
commit42d4652fed759904bb51a5d3420724dc25009494 (patch)
treee75db0e16733dfbf688168293042e972f2b1c1c0 /test/apiv2
parent4a0ae01261f2aa90c37d95b7cc4415682e96dead (diff)
parent05444cb2ccf29515e6cb8f2711c64213b7cb3325 (diff)
downloadpodman-42d4652fed759904bb51a5d3420724dc25009494.tar.gz
podman-42d4652fed759904bb51a5d3420724dc25009494.tar.bz2
podman-42d4652fed759904bb51a5d3420724dc25009494.zip
Merge pull request #9048 from matejvasek/apiv2_wait
Fix Docker APIv2 container wait endpoint
Diffstat (limited to 'test/apiv2')
-rw-r--r--test/apiv2/26-containersWait.at47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/apiv2/26-containersWait.at b/test/apiv2/26-containersWait.at
new file mode 100644
index 000000000..3f530c3f0
--- /dev/null
+++ b/test/apiv2/26-containersWait.at
@@ -0,0 +1,47 @@
+# -*- sh -*-
+#
+# test more container-related endpoints
+#
+
+red='\e[31m'
+nc='\e[0m'
+
+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 '["sleep", "0.5"]' "${IMAGE}"
+
+t POST "containers/${CTR}/wait?condition=non-existent-cond" '' 400
+
+t POST "containers/${CTR}/wait?condition=not-running" '' 200
+
+t POST "containers/${CTR}/wait?condition=next-exit" '' 200 &
+child_pid=$!
+podman start "${CTR}"
+wait "${child_pid}"
+
+
+# check if headers are sent in advance before body
+WAIT_TEST_ERROR=""
+curl -I -X POST "http://$HOST:$PORT/containers/${CTR}/wait?condition=next-exit" &> "/dev/null" &
+child_pid=$!
+sleep 0.5
+if kill -2 "${child_pid}" 2> "/dev/null"; then
+ echo -e "${red}NOK: Failed to get response headers immediately.${nc}" 1>&2;
+ WAIT_TEST_ERROR="1"
+fi
+
+t POST "containers/${CTR}/wait?condition=removed" '' 200 &
+child_pid=$!
+podman container rm "${CTR}"
+wait "${child_pid}"
+
+if [[ "${WAIT_TEST_ERROR}" ]] ; then
+ exit 1;
+fi