diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/build_test.go | 17 | ||||
-rw-r--r-- | test/e2e/create_test.go | 13 | ||||
-rw-r--r-- | test/e2e/generate_systemd_test.go | 2 | ||||
-rw-r--r-- | test/e2e/logs_test.go | 12 | ||||
-rw-r--r-- | test/e2e/run_networking_test.go | 76 | ||||
-rw-r--r-- | test/e2e/run_userns_test.go | 7 | ||||
-rw-r--r-- | test/e2e/untag_test.go | 76 | ||||
-rw-r--r-- | test/system/020-tag.bats | 35 | ||||
-rw-r--r-- | test/system/120-load.bats | 18 |
9 files changed, 185 insertions, 71 deletions
diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index 9e41fd231..0cf5283ad 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -195,4 +195,21 @@ var _ = Describe("Podman build", func() { Expect(session.ExitCode()).To(Equal(0)) }) + It("podman build --http_proxy flag", func() { + SkipIfRemote() + os.Setenv("http_proxy", "1.2.3.4") + podmanTest.RestoreAllArtifacts() + dockerfile := `FROM docker.io/library/alpine:latest +RUN printenv http_proxy` + + dockerfilePath := filepath.Join(podmanTest.TempDir, "Dockerfile") + err := ioutil.WriteFile(dockerfilePath, []byte(dockerfile), 0755) + Expect(err).To(BeNil()) + session := podmanTest.PodmanNoCache([]string{"build", "--file", dockerfilePath, podmanTest.TempDir}) + session.Wait(120) + Expect(session.ExitCode()).To(Equal(0)) + ok, _ := session.GrepString("1.2.3.4") + Expect(ok).To(BeTrue()) + os.Unsetenv("http_proxy") + }) }) diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index 52ce0b46a..44bb5c45f 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -458,4 +458,17 @@ var _ = Describe("Podman create", func() { Expect(session.ExitCode()).To(Equal(0)) } }) + + It("podman create sets default stop signal 15", func() { + ctrName := "testCtr" + session := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "/bin/sh"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", ctrName}) + inspect.WaitWithDefaultTimeout() + data := inspect.InspectContainerToJSON() + Expect(len(data)).To(Equal(1)) + Expect(data[0].Config.StopSignal).To(Equal(uint(15))) + }) }) diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go index 497e8f71e..f43a4f865 100644 --- a/test/e2e/generate_systemd_test.go +++ b/test/e2e/generate_systemd_test.go @@ -362,7 +362,7 @@ var _ = Describe("Podman generate systemd", func() { found, _ = session.GrepString("pod create --infra-conmon-pidfile %t/pod-foo.pid --pod-id-file %t/pod-foo.pod-id --name foo") Expect(found).To(BeTrue()) - found, _ = session.GrepString("ExecStartPre=/usr/bin/rm -f %t/pod-foo.pid %t/pod-foo.pod-id") + found, _ = session.GrepString("ExecStartPre=/bin/rm -f %t/pod-foo.pid %t/pod-foo.pod-id") Expect(found).To(BeTrue()) found, _ = session.GrepString("pod stop --ignore --pod-id-file %t/pod-foo.pod-id -t 10") diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index a4a59acb2..cf69cbd3e 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -311,4 +311,16 @@ var _ = Describe("Podman logs", func() { logs.WaitWithDefaultTimeout() Expect(logs).To(Not(Exit(0))) }) + + It("follow output stopped container", func() { + containerName := "logs-f" + + logc := podmanTest.Podman([]string{"run", "--name", containerName, "-d", ALPINE, "true"}) + logc.WaitWithDefaultTimeout() + Expect(logc).To(Exit(0)) + + results := podmanTest.Podman([]string{"logs", "-f", containerName}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + }) }) diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 4fad85f00..afba12ccd 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -71,10 +71,9 @@ var _ = Describe("Podman run networking", func() { inspectOut := podmanTest.InspectContainer(name) Expect(len(inspectOut)).To(Equal(1)) Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1)) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("tcp")) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("")) + Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1)) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("80")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) }) It("podman run -p 8080:80", func() { @@ -84,10 +83,9 @@ var _ = Describe("Podman run networking", func() { inspectOut := podmanTest.InspectContainer(name) Expect(len(inspectOut)).To(Equal(1)) Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1)) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(8080))) - Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("tcp")) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("")) + Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1)) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("8080")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) }) It("podman run -p 80/udp", func() { @@ -97,10 +95,9 @@ var _ = Describe("Podman run networking", func() { inspectOut := podmanTest.InspectContainer(name) Expect(len(inspectOut)).To(Equal(1)) Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1)) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("udp")) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("")) + Expect(len(inspectOut[0].NetworkSettings.Ports["80/udp"])).To(Equal(1)) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostPort).To(Equal("80")) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostIP).To(Equal("")) }) It("podman run -p 127.0.0.1:8080:80", func() { @@ -110,10 +107,9 @@ var _ = Describe("Podman run networking", func() { inspectOut := podmanTest.InspectContainer(name) Expect(len(inspectOut)).To(Equal(1)) Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1)) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(8080))) - Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("tcp")) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("127.0.0.1")) + Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1)) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("8080")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("127.0.0.1")) }) It("podman run -p 127.0.0.1:8080:80/udp", func() { @@ -123,10 +119,9 @@ var _ = Describe("Podman run networking", func() { inspectOut := podmanTest.InspectContainer(name) Expect(len(inspectOut)).To(Equal(1)) Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1)) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(8080))) - Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("udp")) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("127.0.0.1")) + Expect(len(inspectOut[0].NetworkSettings.Ports["80/udp"])).To(Equal(1)) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostPort).To(Equal("8080")) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostIP).To(Equal("127.0.0.1")) }) It("podman run -p [::1]:8080:80/udp", func() { @@ -136,10 +131,9 @@ var _ = Describe("Podman run networking", func() { inspectOut := podmanTest.InspectContainer(name) Expect(len(inspectOut)).To(Equal(1)) Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1)) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(8080))) - Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("udp")) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("::1")) + Expect(len(inspectOut[0].NetworkSettings.Ports["80/udp"])).To(Equal(1)) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostPort).To(Equal("8080")) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostIP).To(Equal("::1")) }) It("podman run -p [::1]:8080:80/tcp", func() { @@ -149,10 +143,9 @@ var _ = Describe("Podman run networking", func() { inspectOut := podmanTest.InspectContainer(name) Expect(len(inspectOut)).To(Equal(1)) Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1)) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(8080))) - Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("tcp")) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("::1")) + Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1)) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("8080")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("::1")) }) It("podman run --expose 80 -P", func() { @@ -162,10 +155,9 @@ var _ = Describe("Podman run networking", func() { inspectOut := podmanTest.InspectContainer(name) Expect(len(inspectOut)).To(Equal(1)) Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1)) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Not(Equal(int32(0)))) - Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("tcp")) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("")) + Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1)) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Not(Equal("0"))) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) }) It("podman run --expose 80/udp -P", func() { @@ -175,10 +167,9 @@ var _ = Describe("Podman run networking", func() { inspectOut := podmanTest.InspectContainer(name) Expect(len(inspectOut)).To(Equal(1)) Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1)) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Not(Equal(int32(0)))) - Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("udp")) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("")) + Expect(len(inspectOut[0].NetworkSettings.Ports["80/udp"])).To(Equal(1)) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostPort).To(Not(Equal("0"))) + Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostIP).To(Equal("")) }) It("podman run --expose 80 -p 80", func() { @@ -188,10 +179,9 @@ var _ = Describe("Podman run networking", func() { inspectOut := podmanTest.InspectContainer(name) Expect(len(inspectOut)).To(Equal(1)) Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1)) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80))) - Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("tcp")) - Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("")) + Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1)) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("80")) + Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("")) }) It("podman run network expose host port 80 to container port 8000", func() { @@ -214,7 +204,7 @@ var _ = Describe("Podman run networking", func() { results := podmanTest.Podman([]string{"inspect", "-l"}) results.Wait(30) Expect(results.ExitCode()).To(Equal(0)) - Expect(results.OutputToString()).To(ContainSubstring(": 80,")) + Expect(results.OutputToString()).To(ContainSubstring(`"80/tcp":`)) }) It("podman run network expose duplicate host port results in error", func() { @@ -229,7 +219,9 @@ var _ = Describe("Podman run networking", func() { Expect(inspect.ExitCode()).To(Equal(0)) containerConfig := inspect.InspectContainerToJSON() - Expect(containerConfig[0].NetworkSettings.Ports[0].HostPort).ToNot(Equal(80)) + Expect(containerConfig[0].NetworkSettings.Ports).To(Not(BeNil())) + Expect(containerConfig[0].NetworkSettings.Ports["80/tcp"]).To(Not(BeNil())) + Expect(containerConfig[0].NetworkSettings.Ports["80/tcp"][0].HostPort).ToNot(Equal(80)) }) It("podman run hostname test", func() { diff --git a/test/e2e/run_userns_test.go b/test/e2e/run_userns_test.go index 5b9a99daa..be0981408 100644 --- a/test/e2e/run_userns_test.go +++ b/test/e2e/run_userns_test.go @@ -89,6 +89,13 @@ var _ = Describe("Podman UserNS support", func() { Expect(ok).To(BeTrue()) }) + It("podman --userns=keep-id root owns /usr", func() { + session := podmanTest.Podman([]string{"run", "--userns=keep-id", "alpine", "stat", "-c%u", "/usr"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal("0")) + }) + It("podman --userns=keep-id --user root:root", func() { session := podmanTest.Podman([]string{"run", "--userns=keep-id", "--user", "root:root", "alpine", "id", "-u"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/untag_test.go b/test/e2e/untag_test.go index dc1a6208e..8a1c8091d 100644 --- a/test/e2e/untag_test.go +++ b/test/e2e/untag_test.go @@ -23,13 +23,6 @@ var _ = Describe("Podman untag", func() { podmanTest = PodmanTestCreate(tempdir) podmanTest.Setup() podmanTest.RestoreAllArtifacts() - - for _, tag := range []string{"test", "foo", "bar"} { - session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, tag}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) - } - }) AfterEach(func() { @@ -40,34 +33,63 @@ var _ = Describe("Podman untag", func() { }) It("podman untag all", func() { - session := podmanTest.PodmanNoCache([]string{"untag", ALPINE}) + tags := []string{ALPINE, "registry.com/foo:bar", "localhost/foo:bar"} + + cmd := []string{"tag"} + cmd = append(cmd, tags...) + session := podmanTest.PodmanNoCache(cmd) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - results := podmanTest.PodmanNoCache([]string{"images", ALPINE}) - results.WaitWithDefaultTimeout() - Expect(results.ExitCode()).To(Equal(0)) - Expect(results.OutputToStringArray()).To(HaveLen(1)) - }) + // Make sure that all tags exists. + for _, t := range tags { + session = podmanTest.PodmanNoCache([]string{"image", "exists", t}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + } - It("podman untag single", func() { - session := podmanTest.PodmanNoCache([]string{"untag", ALPINE, "localhost/test:latest"}) + // No arguments -> remove all tags. + session = podmanTest.PodmanNoCache([]string{"untag", ALPINE}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - results := podmanTest.PodmanNoCache([]string{"images"}) - results.WaitWithDefaultTimeout() - Expect(results.ExitCode()).To(Equal(0)) - Expect(results.OutputToStringArray()).To(HaveLen(6)) - Expect(results.LineInOuputStartsWith("docker.io/library/alpine")).To(BeTrue()) - Expect(results.LineInOuputStartsWith("localhost/foo")).To(BeTrue()) - Expect(results.LineInOuputStartsWith("localhost/bar")).To(BeTrue()) - Expect(results.LineInOuputStartsWith("localhost/test")).To(BeFalse()) + // Make sure that none of tags exists anymore. + for _, t := range tags { + session = podmanTest.PodmanNoCache([]string{"image", "exists", t}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(1)) + } }) - It("podman untag not enough arguments", func() { - session := podmanTest.PodmanNoCache([]string{"untag"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).NotTo(Equal(0)) + It("podman tag/untag - tag normalization", func() { + tests := []struct { + tag, normalized string + }{ + {"registry.com/image:latest", "registry.com/image:latest"}, + {"registry.com/image", "registry.com/image:latest"}, + {"image:latest", "localhost/image:latest"}, + {"image", "localhost/image:latest"}, + } + + // Make sure that the user input is normalized correctly for + // `podman tag` and `podman untag`. + for _, tt := range tests { + session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, tt.tag}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.PodmanNoCache([]string{"image", "exists", tt.normalized}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.PodmanNoCache([]string{"untag", ALPINE, tt.tag}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.PodmanNoCache([]string{"image", "exists", tt.normalized}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(1)) + } }) + }) diff --git a/test/system/020-tag.bats b/test/system/020-tag.bats new file mode 100644 index 000000000..7593ad68f --- /dev/null +++ b/test/system/020-tag.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats + +load helpers + +# helper function for "podman tag/untag" test +function _tag_and_check() { + local tag_as="$1" + local check_as="$2" + + run_podman tag $IMAGE $tag_as + run_podman image exists $check_as + run_podman untag $IMAGE $check_as + run_podman 1 image exists $check_as +} + +@test "podman tag/untag" { + # Test a fully-qualified image reference. + _tag_and_check registry.com/image:latest registry.com/image:latest + + # Test a reference without tag and make sure ":latest" is appended. + _tag_and_check registry.com/image registry.com/image:latest + + # Test a tagged short image and make sure "localhost/" is prepended. + _tag_and_check image:latest localhost/image:latest + + # Test a short image without tag and make sure "localhost/" is + # prepended and ":latest" is appended. + _tag_and_check image localhost/image:latest + + # Test error case. + run_podman 125 untag $IMAGE registry.com/foo:bar + is "$output" "Error: \"registry.com/foo:bar\": no such tag" +} + +# vim: filetype=sh diff --git a/test/system/120-load.bats b/test/system/120-load.bats index 15df6adec..f290c1888 100644 --- a/test/system/120-load.bats +++ b/test/system/120-load.bats @@ -44,6 +44,11 @@ verify_iid_and_name() { run_podman load < $archive verify_iid_and_name "<none>:<none>" + # Same as above, using stdin but with `podman image load` + run_podman rmi $iid + run_podman image load < $archive + verify_iid_and_name "<none>:<none>" + # Cleanup: since load-by-iid doesn't preserve name, re-tag it; # otherwise our global teardown will rmi and re-pull our standard image. run_podman tag $iid $img_name @@ -57,9 +62,14 @@ verify_iid_and_name() { # Load using -i; this time the image should be tagged. run_podman load -i $archive verify_iid_and_name $img_name + run_podman rmi $iid - # Same as above, using stdin + # Also make sure that `image load` behaves the same. + run_podman image load -i $archive + verify_iid_and_name $img_name run_podman rmi $iid + + # Same as above, using stdin run_podman load < $archive verify_iid_and_name $img_name } @@ -97,4 +107,10 @@ verify_iid_and_name() { "Diagnostic from 'podman load' without redirection or -i" } +@test "podman load - at most 1 arg(s)" { + run_podman 125 load 1 2 3 + is "$output" \ + "Error: accepts at most 1 arg(s), received 3" +} + # vim: filetype=sh |