github.com/containers/podman/v5@v5.1.0-rc1/test/apiv2/26-containersWait.at (about) 1 # -*- sh -*- 2 # 3 # test more container-related endpoints 4 # 5 6 podman pull "${IMAGE}" &>/dev/null 7 8 # Ensure clean slate 9 podman rm -a -f &>/dev/null 10 11 CTR="WaitTestingCtr" 12 13 t POST "containers/nonExistent/wait?condition=next-exit" 404 14 15 # Make sure to test a non-zero exit code (see #18889) 16 podman create --name "${CTR}" "${IMAGE}" sh -c "exit 3" 17 18 t POST "containers/${CTR}/wait?condition=non-existent-cond" 400 19 20 t POST "containers/${CTR}/wait?condition=not-running" 200 21 22 # Test waiting for EXIT (need to start a background trigger first) 23 (sleep 2;podman start "${CTR}") & 24 child_pid=$! 25 26 # This will block until the background job completes 27 t POST "containers/${CTR}/wait?condition=next-exit" 200 \ 28 .StatusCode=3 \ 29 .Error=null 30 wait "${child_pid}" 31 32 # Test that headers are sent before body. (We should actually never get a body) 33 APIV2_TEST_EXPECT_TIMEOUT=2 t POST "containers/${CTR}/wait?condition=next-exit" 999 34 like "$(<$WORKDIR/curl.headers.out)" ".*HTTP.* 200 OK.*" \ 35 "Received headers from /wait" 36 if [[ -s $WORKDIR/curl.result.out ]]; then 37 _show_ok 0 "UNEXPECTED: curl on /wait returned results" 38 fi 39 40 # Test waiting for REMOVE. Like above, start a background trigger. 41 (sleep 2;podman container rm "${CTR}") & 42 child_pid=$! 43 44 t POST "containers/${CTR}/wait?condition=removed" 200 \ 45 .StatusCode=3 \ 46 .Error=null 47 # Make sure the container has really been removed after waiting for 48 # "condition=removed". This check is racy but should flake in case it doesn't 49 # work correctly. 50 t POST "containers/${CTR}/wait?condition=next-exit" 404 51 wait "${child_pid}"