diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/common_test.go | 27 | ||||
-rw-r--r-- | test/e2e/cp_test.go | 4 | ||||
-rw-r--r-- | test/e2e/diff_test.go | 14 | ||||
-rw-r--r-- | test/e2e/inspect_test.go | 27 | ||||
-rw-r--r-- | test/e2e/logs_test.go | 17 | ||||
-rw-r--r-- | test/e2e/port_test.go | 30 | ||||
-rw-r--r-- | test/e2e/ps_test.go | 12 | ||||
-rw-r--r-- | test/e2e/run_networking_test.go | 6 | ||||
-rw-r--r-- | test/e2e/run_test.go | 15 | ||||
-rw-r--r-- | test/e2e/run_volume_test.go | 18 | ||||
-rw-r--r-- | test/install/Dockerfile.Fedora | 2 | ||||
-rw-r--r-- | test/system/030-run.bats | 4 | ||||
-rw-r--r-- | test/test_podman_build.sh | 14 | ||||
-rw-r--r-- | test/utils/utils.go | 2 |
14 files changed, 169 insertions, 23 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/cp_test.go b/test/e2e/cp_test.go index f7596d77d..5e98e73eb 100644 --- a/test/e2e/cp_test.go +++ b/test/e2e/cp_test.go @@ -58,6 +58,10 @@ var _ = Describe("Podman cp", func() { session = podmanTest.Podman([]string{"cp", name + ":foo", dstPath}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"start", name}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) }) It("podman cp file to dir", func() { diff --git a/test/e2e/diff_test.go b/test/e2e/diff_test.go index 0f53d9bc8..d273f9463 100644 --- a/test/e2e/diff_test.go +++ b/test/e2e/diff_test.go @@ -80,4 +80,18 @@ var _ = Describe("Podman diff", func() { sort.Strings(imageDiff) Expect(imageDiff).To(Equal(containerDiff)) }) + + It("podman diff latest container", func() { + SkipIfRemote() + session := podmanTest.Podman([]string{"run", "--name=diff-test", ALPINE, "touch", "/tmp/diff-test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + session = podmanTest.Podman([]string{"diff", "-l"}) + session.WaitWithDefaultTimeout() + containerDiff := session.OutputToStringArray() + sort.Strings(containerDiff) + Expect(session.LineInOutputContains("C /tmp")).To(BeTrue()) + Expect(session.LineInOutputContains("A /tmp/diff-test")).To(BeTrue()) + Expect(session.ExitCode()).To(Equal(0)) + }) }) diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go index ccd8602c4..790115133 100644 --- a/test/e2e/inspect_test.go +++ b/test/e2e/inspect_test.go @@ -107,4 +107,31 @@ var _ = Describe("Podman inspect", func() { Expect(result.ExitCode()).To(Equal(125)) }) + It("podman inspect with mount filters", func() { + SkipIfRemote() + + ctrSession := podmanTest.Podman([]string{"create", "-v", "/tmp:/test1", ALPINE, "top"}) + ctrSession.WaitWithDefaultTimeout() + Expect(ctrSession.ExitCode()).To(Equal(0)) + + inspectSource := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Source}}"}) + inspectSource.WaitWithDefaultTimeout() + Expect(inspectSource.ExitCode()).To(Equal(0)) + Expect(inspectSource.OutputToString()).To(Equal("/tmp")) + + inspectSrc := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Src}}"}) + inspectSrc.WaitWithDefaultTimeout() + Expect(inspectSrc.ExitCode()).To(Equal(0)) + Expect(inspectSrc.OutputToString()).To(Equal("/tmp")) + + inspectDestination := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Destination}}"}) + inspectDestination.WaitWithDefaultTimeout() + Expect(inspectDestination.ExitCode()).To(Equal(0)) + Expect(inspectDestination.OutputToString()).To(Equal("/test1")) + + inspectDst := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Dst}}"}) + inspectDst.WaitWithDefaultTimeout() + Expect(inspectDst.ExitCode()).To(Equal(0)) + Expect(inspectDst.OutputToString()).To(Equal("/test1")) + }) }) diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index cc50c4d95..d17f60a5d 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -218,4 +218,21 @@ var _ = Describe("Podman logs", func() { Expect(results.ExitCode()).To(Equal(0)) Expect(len(results.OutputToStringArray())).To(Equal(3)) }) + + It("podman logs -f two lines", func() { + containerName := "logs-f-rm" + + logc := podmanTest.Podman([]string{"run", "--rm", "--name", containerName, "-dt", ALPINE, "sh", "-c", "echo podman; sleep 1; echo podman"}) + logc.WaitWithDefaultTimeout() + Expect(logc.ExitCode()).To(Equal(0)) + + results := podmanTest.Podman([]string{"logs", "-f", containerName}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(0)) + + // Verify that the cleanup process worked correctly and we can recreate a container with the same name + logc = podmanTest.Podman([]string{"run", "--rm", "--name", containerName, "-dt", ALPINE, "true"}) + logc.WaitWithDefaultTimeout() + Expect(logc.ExitCode()).To(Equal(0)) + }) }) 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/ps_test.go b/test/e2e/ps_test.go index b0a28501a..2b86f663f 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -320,4 +320,16 @@ var _ = Describe("Podman ps", func() { session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(ContainSubstring("0.0.0.0:1000-1006")) }) + + It("podman ps sync flag", func() { + session := podmanTest.RunTopContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + fullCid := session.OutputToString() + + result := podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "--sync"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToStringArray()[0]).To(Equal(fullCid)) + }) }) diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 1497a651b..31291d373 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -178,6 +178,12 @@ var _ = Describe("Podman run networking", func() { Expect(exec4.OutputToString()).To(ContainSubstring("192.0.2.2 test1")) }) + It("podman run /etc/hosts contains --hostname", func() { + session := podmanTest.Podman([]string{"run", "--rm", "--hostname", "foohostname", ALPINE, "grep", "foohostname", "/etc/hosts"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + It("podman run network in user created network namespace", func() { SkipIfRootless() if Containerized() { 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() { diff --git a/test/install/Dockerfile.Fedora b/test/install/Dockerfile.Fedora index 74cee771d..3e7b6e238 100644 --- a/test/install/Dockerfile.Fedora +++ b/test/install/Dockerfile.Fedora @@ -1,3 +1,3 @@ -FROM registry.fedoraproject.org/fedora:29 +FROM registry.fedoraproject.org/fedora:30 RUN dnf install -y rpms/x86_64/* diff --git a/test/system/030-run.bats b/test/system/030-run.bats index a29b1adc3..cefff0e2c 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -9,8 +9,8 @@ true | 0 | false | 1 | sh -c 'exit 32' | 32 | echo $rand | 0 | $rand -/no/such/command | 127 | Error: container create failed:.*exec:.* no such file or dir -/etc | 126 | Error: container create failed:.*exec:.* permission denied +/no/such/command | 127 | Error: .*: starting container process caused .*exec:.*stat /no/such/command: no such file or directory +/etc | 126 | Error: .*: starting container process caused .*exec:.* permission denied " while read cmd expected_rc expected_output; do diff --git a/test/test_podman_build.sh b/test/test_podman_build.sh index 39f1e784d..e3e53cae6 100644 --- a/test/test_podman_build.sh +++ b/test/test_podman_build.sh @@ -196,10 +196,22 @@ echo ######################################################## echo test "build with preprocessor" echo ######################################################## - target=alpine-image + TARGET=alpine-image podman build -q -t ${TARGET} -f Decomposed.in $HOME/test/build/preprocess buildah --debug=false images CID=$(buildah from $TARGET) buildah rm $CID podman rmi $(buildah --debug=false images -q) buildah --debug=false images -q + +echo ######################################################## +echo test "build with priv'd RUN" +echo ######################################################## + + TARGET=alpinepriv + podman build -q -t ${TARGET} -f $HOME/test/build/run-privd $HOME/test/build/run-privd + buildah --debug=false images + CID=$(buildah from $TARGET) + buildah rm $CID + podman rmi $(buildah --debug=false images -q) + buildah --debug=false images -q diff --git a/test/utils/utils.go b/test/utils/utils.go index 98031385d..43819350c 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -63,7 +63,7 @@ func (p *PodmanTest) MakeOptions(args []string) []string { return p.PodmanMakeOptions(args) } -// PodmanAsUserBase exec podman as user. uid and gid is set for credentials useage. env is used +// PodmanAsUserBase exec podman as user. uid and gid is set for credentials usage. env is used // to record the env for debugging func (p *PodmanTest) PodmanAsUserBase(args []string, uid, gid uint32, cwd string, env []string, nocache bool) *PodmanSession { var command *exec.Cmd |