aboutsummaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/common_test.go27
-rw-r--r--test/e2e/port_test.go30
-rw-r--r--test/e2e/run_test.go15
-rw-r--r--test/e2e/run_volume_test.go18
4 files changed, 72 insertions, 18 deletions
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index 9529346b4..8b6eab892 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -10,6 +10,7 @@ import (
"sort"
"strings"
"testing"
+ "time"
"github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/libpod"
@@ -22,6 +23,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
+ "github.com/pkg/errors"
)
var (
@@ -367,6 +369,18 @@ func (p *PodmanTestIntegration) RunLsContainer(name string) (*PodmanSessionInteg
return session, session.ExitCode(), session.OutputToString()
}
+// RunNginxWithHealthCheck runs the alpine nginx container with an optional name and adds a healthcheck into it
+func (p *PodmanTestIntegration) RunNginxWithHealthCheck(name string) (*PodmanSessionIntegration, string) {
+ var podmanArgs = []string{"run"}
+ if name != "" {
+ podmanArgs = append(podmanArgs, "--name", name)
+ }
+ podmanArgs = append(podmanArgs, "-dt", "-P", "--healthcheck-command", "CMD-SHELL curl http://localhost/", nginx)
+ session := p.Podman(podmanArgs)
+ session.WaitWithDefaultTimeout()
+ return session, session.OutputToString()
+}
+
func (p *PodmanTestIntegration) RunLsContainerInPod(name, pod string) (*PodmanSessionIntegration, int, string) {
var podmanArgs = []string{"run", "--pod", pod}
if name != "" {
@@ -508,3 +522,16 @@ func (p *PodmanTestIntegration) ImageExistsInMainStore(idOrName string) bool {
results.WaitWithDefaultTimeout()
return Expect(results.ExitCode()).To(Equal(0))
}
+
+func (p *PodmanTestIntegration) RunHealthCheck(cid string) error {
+ for i := 0; i < 10; i++ {
+ hc := p.Podman([]string{"healthcheck", "run", cid})
+ hc.WaitWithDefaultTimeout()
+ if hc.ExitCode() == 0 {
+ return nil
+ }
+ fmt.Printf("Waiting for %s to pass healthcheck\n", cid)
+ time.Sleep(1 * time.Second)
+ }
+ return errors.Errorf("unable to detect %s as running", cid)
+}
diff --git a/test/e2e/port_test.go b/test/e2e/port_test.go
index e45118361..26c5fd7d0 100644
--- a/test/e2e/port_test.go
+++ b/test/e2e/port_test.go
@@ -48,11 +48,14 @@ var _ = Describe("Podman port", func() {
Expect(result.ExitCode()).ToNot(Equal(0))
})
- It("podman port -l nginx", func() {
- session := podmanTest.Podman([]string{"run", "-dt", "-P", nginx})
- session.WaitWithDefaultTimeout()
+ It("podman port -l nginx", func() {
+ session, cid := podmanTest.RunNginxWithHealthCheck("")
Expect(session.ExitCode()).To(Equal(0))
+ if err := podmanTest.RunHealthCheck(cid); err != nil {
+ Fail(err.Error())
+ }
+
result := podmanTest.Podman([]string{"port", "-l"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
@@ -61,10 +64,13 @@ var _ = Describe("Podman port", func() {
})
It("podman container port -l nginx", func() {
- session := podmanTest.Podman([]string{"container", "run", "-dt", "-P", nginx})
- session.WaitWithDefaultTimeout()
+ session, cid := podmanTest.RunNginxWithHealthCheck("")
Expect(session.ExitCode()).To(Equal(0))
+ if err := podmanTest.RunHealthCheck(cid); err != nil {
+ Fail(err.Error())
+ }
+
result := podmanTest.Podman([]string{"container", "port", "-l"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
@@ -73,10 +79,13 @@ var _ = Describe("Podman port", func() {
})
It("podman port -l port nginx", func() {
- session := podmanTest.Podman([]string{"run", "-dt", "-P", nginx})
- session.WaitWithDefaultTimeout()
+ session, cid := podmanTest.RunNginxWithHealthCheck("")
Expect(session.ExitCode()).To(Equal(0))
+ if err := podmanTest.RunHealthCheck(cid); err != nil {
+ Fail(err.Error())
+ }
+
result := podmanTest.Podman([]string{"port", "-l", "80"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
@@ -85,10 +94,13 @@ var _ = Describe("Podman port", func() {
})
It("podman port -a nginx", func() {
- session := podmanTest.Podman([]string{"run", "-dt", "-P", nginx})
- session.WaitWithDefaultTimeout()
+ session, cid := podmanTest.RunNginxWithHealthCheck("")
Expect(session.ExitCode()).To(Equal(0))
+ if err := podmanTest.RunHealthCheck(cid); err != nil {
+ Fail(err.Error())
+ }
+
result := podmanTest.Podman([]string{"port", "-a"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index 3ba3c2bb3..3fc628589 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -712,28 +712,25 @@ USER mail`
Expect(session.OutputToString()).To(Not(ContainSubstring("/dev/shm type tmpfs (ro,")))
})
- It("podman run with bad healthcheck interval", func() {
- session := podmanTest.Podman([]string{"run", "-dt", "--healthcheck-cmd", "foo", "--healthcheck-interval", "0.5s", ALPINE, "top"})
- session.Wait()
- Expect(session.ExitCode()).ToNot(Equal(0))
- })
-
It("podman run with bad healthcheck retries", func() {
- session := podmanTest.Podman([]string{"run", "-dt", "--healthcheck-cmd", "foo", "--healthcheck-retries", "0", ALPINE, "top"})
+ session := podmanTest.Podman([]string{"run", "-dt", "--healthcheck-command", "foo", "--healthcheck-retries", "0", ALPINE, "top"})
session.Wait()
Expect(session.ExitCode()).ToNot(Equal(0))
+ Expect(session.ErrorToString()).To(ContainSubstring("healthcheck-retries must be greater than 0"))
})
It("podman run with bad healthcheck timeout", func() {
- session := podmanTest.Podman([]string{"run", "-dt", "--healthcheck-cmd", "foo", "--healthcheck-timeout", "0s", ALPINE, "top"})
+ session := podmanTest.Podman([]string{"run", "-dt", "--healthcheck-command", "foo", "--healthcheck-timeout", "0s", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).ToNot(Equal(0))
+ Expect(session.ErrorToString()).To(ContainSubstring("healthcheck-timeout must be at least 1 second"))
})
It("podman run with bad healthcheck start-period", func() {
- session := podmanTest.Podman([]string{"run", "-dt", "--healthcheck-cmd", "foo", "--healthcheck-start-period", "-1s", ALPINE, "top"})
+ session := podmanTest.Podman([]string{"run", "-dt", "--healthcheck-command", "foo", "--healthcheck-start-period", "-1s", ALPINE, "top"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).ToNot(Equal(0))
+ Expect(session.ErrorToString()).To(ContainSubstring("healthcheck-start-period must be 0 seconds or greater"))
})
It("podman run with --add-host and --no-hosts fails", func() {
diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go
index d89c80909..9e160e73c 100644
--- a/test/e2e/run_volume_test.go
+++ b/test/e2e/run_volume_test.go
@@ -63,6 +63,24 @@ var _ = Describe("Podman run with volumes", func() {
Expect(found).Should(BeTrue())
Expect(matches[0]).To(ContainSubstring("rw"))
Expect(matches[0]).To(ContainSubstring("shared"))
+
+ // Cached is ignored
+ session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:cached", mountPath), ALPINE, "grep", "/run/test", "/proc/self/mountinfo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ found, matches = session.GrepString("/run/test")
+ Expect(found).Should(BeTrue())
+ Expect(matches[0]).To(ContainSubstring("rw"))
+ Expect(matches[0]).To(Not(ContainSubstring("cached")))
+
+ // Delegated is ignored
+ session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:delegated", mountPath), ALPINE, "grep", "/run/test", "/proc/self/mountinfo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ found, matches = session.GrepString("/run/test")
+ Expect(found).Should(BeTrue())
+ Expect(matches[0]).To(ContainSubstring("rw"))
+ Expect(matches[0]).To(Not(ContainSubstring("delegated")))
})
It("podman run with --mount flag", func() {