mirror of
https://github.com/containers/podman.git
synced 2025-10-25 18:25:59 +08:00
Merge pull request #9048 from matejvasek/apiv2_wait
Fix Docker APIv2 container wait endpoint
This commit is contained in:
47
test/apiv2/26-containersWait.at
Normal file
47
test/apiv2/26-containersWait.at
Normal file
@ -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
|
||||
@ -441,7 +441,7 @@ func (p *PodmanTestIntegration) BuildImage(dockerfile, imageName string, layers
|
||||
err := ioutil.WriteFile(dockerfilePath, []byte(dockerfile), 0755)
|
||||
Expect(err).To(BeNil())
|
||||
session := p.Podman([]string{"build", "--layers=" + layers, "-t", imageName, "--file", dockerfilePath, p.TempDir})
|
||||
session.Wait(120)
|
||||
session.Wait(240)
|
||||
Expect(session).Should(Exit(0), fmt.Sprintf("BuildImage session output: %q", session.OutputToString()))
|
||||
}
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ var _ = Describe("Podman wait", func() {
|
||||
|
||||
It("podman wait on bogus container", func() {
|
||||
session := podmanTest.Podman([]string{"wait", "1234"})
|
||||
session.Wait()
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(125))
|
||||
|
||||
})
|
||||
@ -45,7 +45,7 @@ var _ = Describe("Podman wait", func() {
|
||||
cid := session.OutputToString()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
session = podmanTest.Podman([]string{"wait", cid})
|
||||
session.Wait()
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user