summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/apiv2/01-basic.at4
-rw-r--r--test/apiv2/26-containersWait.at47
-rw-r--r--test/e2e/common_test.go2
-rw-r--r--test/e2e/generate_kube_test.go60
-rw-r--r--test/e2e/network_connect_disconnect_test.go20
-rw-r--r--test/e2e/wait_test.go4
6 files changed, 132 insertions, 5 deletions
diff --git a/test/apiv2/01-basic.at b/test/apiv2/01-basic.at
index f550d5fc3..1ddf49c6f 100644
--- a/test/apiv2/01-basic.at
+++ b/test/apiv2/01-basic.at
@@ -18,8 +18,8 @@ t HEAD libpod/_ping 200
for i in /version version; do
t GET $i 200 \
.Components[0].Name="Podman Engine" \
- .Components[0].Details.APIVersion=2.0.0 \
- .Components[0].Details.MinAPIVersion=2.0.0 \
+ .Components[0].Details.APIVersion=3.0.0 \
+ .Components[0].Details.MinAPIVersion=3.0.0 \
.Components[0].Details.Os=linux \
.ApiVersion=1.40 \
.MinAPIVersion=1.24 \
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
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index 61c0cb4fe..54d801e12 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -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()))
}
diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go
index dba366a1e..bcfab0f68 100644
--- a/test/e2e/generate_kube_test.go
+++ b/test/e2e/generate_kube_test.go
@@ -1,6 +1,7 @@
package integration
import (
+ "io/ioutil"
"os"
"path/filepath"
"strconv"
@@ -639,4 +640,63 @@ var _ = Describe("Podman generate kube", func() {
Expect(pod.Spec.DNSConfig.Options[0].Name).To(Equal("color"))
Expect(*pod.Spec.DNSConfig.Options[0].Value).To(Equal("blue"))
})
+
+ It("podman generate kube - set entrypoint as command", func() {
+ session := podmanTest.Podman([]string{"create", "--pod", "new:testpod", "--entrypoint", "/bin/sleep", ALPINE, "10s"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", "testpod"})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ // Now make sure that the container's command is set to the
+ // entrypoint and it's arguments to "10s".
+ pod := new(v1.Pod)
+ err := yaml.Unmarshal(kube.Out.Contents(), pod)
+ Expect(err).To(BeNil())
+
+ containers := pod.Spec.Containers
+ Expect(len(containers)).To(Equal(1))
+
+ Expect(containers[0].Command).To(Equal([]string{"/bin/sleep"}))
+ Expect(containers[0].Args).To(Equal([]string{"10s"}))
+ })
+
+ It("podman generate kube - use entrypoint from image", func() {
+ // Build an image with an entrypoint.
+ containerfile := `FROM quay.io/libpod/alpine:latest
+ENTRYPOINT /bin/sleep`
+
+ targetPath, err := CreateTempDirInTempDir()
+ Expect(err).To(BeNil())
+ containerfilePath := filepath.Join(targetPath, "Containerfile")
+ err = ioutil.WriteFile(containerfilePath, []byte(containerfile), 0644)
+ Expect(err).To(BeNil())
+
+ image := "generatekube:test"
+ session := podmanTest.Podman([]string{"build", "-f", containerfilePath, "-t", image})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"create", "--pod", "new:testpod", image, "10s"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", "testpod"})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ // Now make sure that the container's command is set to the
+ // entrypoint and it's arguments to "10s".
+ pod := new(v1.Pod)
+ err = yaml.Unmarshal(kube.Out.Contents(), pod)
+ Expect(err).To(BeNil())
+
+ containers := pod.Spec.Containers
+ Expect(len(containers)).To(Equal(1))
+
+ Expect(containers[0].Command).To(Equal([]string{"/bin/sh", "-c", "/bin/sleep"}))
+ Expect(containers[0].Args).To(Equal([]string{"10s"}))
+ })
})
diff --git a/test/e2e/network_connect_disconnect_test.go b/test/e2e/network_connect_disconnect_test.go
index dd94bd7ca..cc23b10c1 100644
--- a/test/e2e/network_connect_disconnect_test.go
+++ b/test/e2e/network_connect_disconnect_test.go
@@ -74,6 +74,11 @@ var _ = Describe("Podman network connect and disconnect", func() {
dis.WaitWithDefaultTimeout()
Expect(dis.ExitCode()).To(BeZero())
+ inspect := podmanTest.Podman([]string{"container", "inspect", "test", "--format", "{{len .NetworkSettings.Networks}}"})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(BeZero())
+ Expect(inspect.OutputToString()).To(Equal("0"))
+
exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"})
exec.WaitWithDefaultTimeout()
Expect(exec.ExitCode()).ToNot(BeZero())
@@ -146,6 +151,11 @@ var _ = Describe("Podman network connect and disconnect", func() {
connect.WaitWithDefaultTimeout()
Expect(connect.ExitCode()).To(BeZero())
+ inspect := podmanTest.Podman([]string{"container", "inspect", "test", "--format", "{{len .NetworkSettings.Networks}}"})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(BeZero())
+ Expect(inspect.OutputToString()).To(Equal("2"))
+
exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth1"})
exec.WaitWithDefaultTimeout()
Expect(exec.ExitCode()).To(BeZero())
@@ -167,6 +177,11 @@ var _ = Describe("Podman network connect and disconnect", func() {
dis.WaitWithDefaultTimeout()
Expect(dis.ExitCode()).To(BeZero())
+ inspect := podmanTest.Podman([]string{"container", "inspect", "test", "--format", "{{len .NetworkSettings.Networks}}"})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(BeZero())
+ Expect(inspect.OutputToString()).To(Equal("2"))
+
start := podmanTest.Podman([]string{"start", "test"})
start.WaitWithDefaultTimeout()
Expect(start.ExitCode()).To(BeZero())
@@ -202,6 +217,11 @@ var _ = Describe("Podman network connect and disconnect", func() {
dis.WaitWithDefaultTimeout()
Expect(dis.ExitCode()).To(BeZero())
+ inspect := podmanTest.Podman([]string{"container", "inspect", "test", "--format", "{{len .NetworkSettings.Networks}}"})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(BeZero())
+ Expect(inspect.OutputToString()).To(Equal("1"))
+
start := podmanTest.Podman([]string{"start", "test"})
start.WaitWithDefaultTimeout()
Expect(start.ExitCode()).To(BeZero())
diff --git a/test/e2e/wait_test.go b/test/e2e/wait_test.go
index aa8a1f245..4f1e74977 100644
--- a/test/e2e/wait_test.go
+++ b/test/e2e/wait_test.go
@@ -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))
})