summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatej Vasek <mvasek@redhat.com>2021-02-01 23:38:50 +0100
committerMatthew Heon <matthew.heon@pm.me>2021-02-08 14:29:31 -0500
commit5397737edc4036b2aaf1704558fe3b83d9883757 (patch)
tree6ac44624e347f016960759c4d0bddc9ebf202ba1
parent9fc22932a69f39e152c672ef7b12441621a8eb5a (diff)
downloadpodman-5397737edc4036b2aaf1704558fe3b83d9883757.tar.gz
podman-5397737edc4036b2aaf1704558fe3b83d9883757.tar.bz2
podman-5397737edc4036b2aaf1704558fe3b83d9883757.zip
Add test for Docker APIv2 wait
Signed-off-by: Matej Vasek <mvasek@redhat.com>
-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