diff options
Diffstat (limited to 'test')
32 files changed, 368 insertions, 98 deletions
diff --git a/test/e2e/attach_test.go b/test/e2e/attach_test.go index 42866d5a1..9c013e459 100644 --- a/test/e2e/attach_test.go +++ b/test/e2e/attach_test.go @@ -51,6 +51,16 @@ var _ = Describe("Podman attach", func() { Expect(results.ExitCode()).To(Equal(125)) }) + It("podman container attach to non-running container", func() { + session := podmanTest.Podman([]string{"container", "create", "--name", "test1", "-d", "-i", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + results := podmanTest.Podman([]string{"container", "attach", "test1"}) + results.WaitWithDefaultTimeout() + Expect(results.ExitCode()).To(Equal(125)) + }) + It("podman attach to multiple containers", func() { session := podmanTest.RunTopContainer("test1") session.WaitWithDefaultTimeout() diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go index fda6eb085..583432df1 100644 --- a/test/e2e/checkpoint_test.go +++ b/test/e2e/checkpoint_test.go @@ -6,6 +6,7 @@ import ( "fmt" "net" "os" + "os/exec" "github.com/containers/libpod/pkg/criu" . "github.com/containers/libpod/test/utils" @@ -27,9 +28,26 @@ var _ = Describe("Podman checkpoint", func() { } podmanTest = PodmanTestCreate(tempdir) podmanTest.RestoreAllArtifacts() + // Check if the runtime implements checkpointing. Currently only + // runc's checkpoint/restore implementation is supported. + cmd := exec.Command(podmanTest.OCIRuntime, "checkpoint", "-h") + if err := cmd.Start(); err != nil { + Skip("OCI runtime does not support checkpoint/restore") + } + if err := cmd.Wait(); err != nil { + Skip("OCI runtime does not support checkpoint/restore") + } + if !criu.CheckForCriu() { Skip("CRIU is missing or too old.") } + // TODO: Remove the skip when the current CRIU SELinux problem is solved. + // See: https://github.com/containers/libpod/issues/2334 + hostInfo := podmanTest.Host + if hostInfo.Distribution == "fedora" { + Skip("Checkpointing containers on Fedora currently broken.") + } + }) AfterEach(func() { diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go index 34b218621..6b65d9b75 100644 --- a/test/e2e/commit_test.go +++ b/test/e2e/commit_test.go @@ -50,6 +50,21 @@ var _ = Describe("Podman commit", func() { Expect(StringInSlice("foobar.com/test1-image:latest", data[0].RepoTags)).To(BeTrue()) }) + It("podman container commit container", func() { + _, ec, _ := podmanTest.RunLsContainer("test1") + Expect(ec).To(Equal(0)) + Expect(podmanTest.NumberOfContainers()).To(Equal(1)) + + session := podmanTest.Podman([]string{"container", "commit", "test1", "foobar.com/test1-image:latest"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + check := podmanTest.Podman([]string{"container", "inspect", "foobar.com/test1-image:latest"}) + check.WaitWithDefaultTimeout() + data := check.InspectImageJSON() + Expect(StringInSlice("foobar.com/test1-image:latest", data[0].RepoTags)).To(BeTrue()) + }) + It("podman commit container with message", func() { _, ec, _ := podmanTest.RunLsContainer("test1") Expect(ec).To(Equal(0)) diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index 9a526b778..12e4f3508 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -56,6 +56,13 @@ var _ = Describe("Podman create", func() { Expect(podmanTest.NumberOfContainers()).To(Equal(1)) }) + It("podman container create container based on a remote image", func() { + session := podmanTest.Podman([]string{"container", "create", BB_GLIBC, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainers()).To(Equal(1)) + }) + It("podman create using short options", func() { session := podmanTest.Podman([]string{"create", ALPINE, "ls"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/diff_test.go b/test/e2e/diff_test.go index 94e150467..82ced7cfa 100644 --- a/test/e2e/diff_test.go +++ b/test/e2e/diff_test.go @@ -43,6 +43,13 @@ var _ = Describe("Podman diff", func() { Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) }) + It("podman container diff of image", func() { + session := podmanTest.Podman([]string{"container", "diff", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0)) + }) + It("podman diff bogus image", func() { session := podmanTest.Podman([]string{"diff", "1234"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index 5839b364d..667a81d07 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -57,6 +57,16 @@ var _ = Describe("Podman exec", func() { Expect(session.ExitCode()).To(Equal(0)) }) + It("podman container exec simple command", func() { + setup := podmanTest.RunTopContainer("test1") + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"container", "exec", "test1", "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + It("podman exec simple command using latest", func() { setup := podmanTest.RunTopContainer("test1") setup.WaitWithDefaultTimeout() diff --git a/test/e2e/export_test.go b/test/e2e/export_test.go index dba0a2255..114c28a3d 100644 --- a/test/e2e/export_test.go +++ b/test/e2e/export_test.go @@ -50,6 +50,22 @@ var _ = Describe("Podman export", func() { Expect(err).To(BeNil()) }) + It("podman container export output flag", func() { + SkipIfRemote() + _, ec, cid := podmanTest.RunLsContainer("") + Expect(ec).To(Equal(0)) + + outfile := filepath.Join(podmanTest.TempDir, "container.tar") + result := podmanTest.Podman([]string{"container", "export", "-o", outfile, cid}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + _, err := os.Stat(outfile) + Expect(err).To(BeNil()) + + err = os.Remove(outfile) + Expect(err).To(BeNil()) + }) + It("podman export bad filename", func() { _, ec, cid := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index 595084403..e26f4affd 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -43,6 +43,15 @@ var _ = Describe("Podman images", func() { Expect(session.LineInOuputStartsWith("docker.io/library/busybox")).To(BeTrue()) }) + It("podman image List", func() { + session := podmanTest.Podman([]string{"image", "list"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2)) + Expect(session.LineInOuputStartsWith("docker.io/library/alpine")).To(BeTrue()) + Expect(session.LineInOuputStartsWith("docker.io/library/busybox")).To(BeTrue()) + }) + It("podman images with multiple tags", func() { // tag "docker.io/library/alpine:latest" to "foo:{a,b,c}" session := podmanTest.Podman([]string{"tag", ALPINE, "foo:a", "foo:b", "foo:c"}) @@ -135,6 +144,23 @@ var _ = Describe("Podman images", func() { Expect(len(result.OutputToStringArray())).To(Equal(1)) }) + It("podman image list filter after image", func() { + if podmanTest.RemoteTest { + Skip("Does not work on remote client") + } + rmi := podmanTest.Podman([]string{"image", "rm", "busybox"}) + rmi.WaitWithDefaultTimeout() + Expect(rmi.ExitCode()).To(Equal(0)) + + dockerfile := `FROM docker.io/library/alpine:latest +` + podmanTest.BuildImage(dockerfile, "foobar.com/before:latest", "false") + result := podmanTest.Podman([]string{"image", "list", "-q", "-f", "after=docker.io/library/alpine:latest"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).To(Equal(1)) + }) + It("podman images filter dangling", func() { if podmanTest.RemoteTest { Skip("Does not work on remote client") @@ -164,6 +190,21 @@ var _ = Describe("Podman images", func() { Expect(result.ExitCode()).To(Equal(0)) }) + It("podman check for image with sha256: prefix", func() { + if podmanTest.RemoteTest { + Skip("Does not work on remote client") + } + session := podmanTest.Podman([]string{"image", "inspect", "--format=json", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.IsJSONOutputValid()).To(BeTrue()) + imageData := session.InspectImageJSON() + + result := podmanTest.Podman([]string{"image", "ls", fmt.Sprintf("sha256:%s", imageData[0].ID)}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + It("podman images sort by tag", func() { session := podmanTest.Podman([]string{"images", "--sort", "tag", "--format={{.Tag}}"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/kill_test.go b/test/e2e/kill_test.go index 5f1f5f4c1..cde8729c8 100644 --- a/test/e2e/kill_test.go +++ b/test/e2e/kill_test.go @@ -41,6 +41,19 @@ var _ = Describe("Podman kill", func() { Expect(session.ExitCode()).To(Not(Equal(0))) }) + It("podman container kill a running container by id", func() { + session := podmanTest.RunTopContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + cid := session.OutputToString() + + result := podmanTest.Podman([]string{"container", "kill", cid}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + }) + It("podman kill a running container by id", func() { session := podmanTest.RunTopContainer("") session.WaitWithDefaultTimeout() diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go index c85810454..571754347 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -59,7 +59,7 @@ var _ = Describe("Podman load", func() { Expect(save.ExitCode()).To(Equal(0)) compress := SystemExec("gzip", []string{outfile}) - compress.WaitWithDefaultTimeout() + Expect(compress.ExitCode()).To(Equal(0)) outfile = outfile + ".gz" rmi := podmanTest.Podman([]string{"rmi", ALPINE}) @@ -174,7 +174,6 @@ var _ = Describe("Podman load", func() { It("podman load localhost registry from scratch", func() { outfile := filepath.Join(podmanTest.TempDir, "load_test.tar.gz") - setup := podmanTest.Podman([]string{"tag", ALPINE, "hello:world"}) setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) @@ -255,7 +254,6 @@ var _ = Describe("Podman load", func() { save.WaitWithDefaultTimeout() Expect(save.ExitCode()).To(Equal(0)) session := SystemExec("xz", []string{outfile}) - session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) rmi := podmanTest.Podman([]string{"rmi", BB}) diff --git a/test/e2e/mount_test.go b/test/e2e/mount_test.go index 94218e6a9..bf0442de2 100644 --- a/test/e2e/mount_test.go +++ b/test/e2e/mount_test.go @@ -49,6 +49,21 @@ var _ = Describe("Podman mount", func() { Expect(umount.ExitCode()).To(Equal(0)) }) + It("podman container mount", func() { + setup := podmanTest.Podman([]string{"container", "create", ALPINE, "ls"}) + setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) + cid := setup.OutputToString() + + mount := podmanTest.Podman([]string{"container", "mount", cid}) + mount.WaitWithDefaultTimeout() + Expect(mount.ExitCode()).To(Equal(0)) + + umount := podmanTest.Podman([]string{"container", "umount", cid}) + umount.WaitWithDefaultTimeout() + Expect(umount.ExitCode()).To(Equal(0)) + }) + It("podman mount with json format", func() { setup := podmanTest.Podman([]string{"create", ALPINE, "ls"}) setup.WaitWithDefaultTimeout() diff --git a/test/e2e/pause_test.go b/test/e2e/pause_test.go index f1ea17ead..7530ca85c 100644 --- a/test/e2e/pause_test.go +++ b/test/e2e/pause_test.go @@ -80,6 +80,23 @@ var _ = Describe("Podman pause", func() { result.WaitWithDefaultTimeout() }) + It("podman container pause a running container by id", func() { + session := podmanTest.RunTopContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + cid := session.OutputToString() + + result := podmanTest.Podman([]string{"container", "pause", cid}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + Expect(podmanTest.GetContainerStatus()).To(ContainSubstring(pausedState)) + + result = podmanTest.Podman([]string{"container", "unpause", cid}) + result.WaitWithDefaultTimeout() + }) + It("podman unpause a running container by id", func() { session := podmanTest.RunTopContainer("") session.WaitWithDefaultTimeout() diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index cb2b0e7b0..4717267a1 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -95,7 +95,6 @@ var _ = Describe("Podman pod create", func() { Expect(webserver.ExitCode()).To(Equal(0)) check := SystemExec("nc", []string{"-z", "localhost", "80"}) - check.WaitWithDefaultTimeout() Expect(check.ExitCode()).To(Equal(1)) }) @@ -111,7 +110,6 @@ var _ = Describe("Podman pod create", func() { Expect(webserver.ExitCode()).To(Equal(0)) check := SystemExec("nc", []string{"-z", "localhost", "80"}) - check.WaitWithDefaultTimeout() Expect(check.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/port_test.go b/test/e2e/port_test.go index fa633c379..6ddc5d34f 100644 --- a/test/e2e/port_test.go +++ b/test/e2e/port_test.go @@ -60,6 +60,19 @@ var _ = Describe("Podman port", func() { Expect(result.LineInOuputStartsWith(fmt.Sprintf("80/tcp -> 0.0.0.0:%s", port))).To(BeTrue()) }) + It("podman container port -l nginx", func() { + podmanTest.RestoreArtifact(nginx) + session := podmanTest.Podman([]string{"container", "run", "-dt", "-P", nginx}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"container", "port", "-l"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + port := strings.Split(result.OutputToStringArray()[0], ":")[1] + Expect(result.LineInOuputStartsWith(fmt.Sprintf("80/tcp -> 0.0.0.0:%s", port))).To(BeTrue()) + }) + It("podman port -l port nginx", func() { podmanTest.RestoreArtifact(nginx) session := podmanTest.Podman([]string{"run", "-dt", "-P", nginx}) diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index 9b1c55bb4..a31fc3f09 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -65,6 +65,21 @@ var _ = Describe("Podman ps", func() { Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) }) + It("podman container list all", func() { + _, ec, _ := podmanTest.RunLsContainer("") + Expect(ec).To(Equal(0)) + + result := podmanTest.Podman([]string{"container", "list", "-a"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) + + result = podmanTest.Podman([]string{"container", "ls", "-a"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) + }) + It("podman ps size flag", func() { _, ec, _ := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index faad8202e..d9b9c7213 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -6,10 +6,12 @@ import ( "os" "fmt" + "path/filepath" + "strings" + . "github.com/containers/libpod/test/utils" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "strings" ) var _ = Describe("Podman pull", func() { @@ -92,58 +94,56 @@ var _ = Describe("Podman pull", func() { }) It("podman pull from docker-archive", func() { - session := podmanTest.Podman([]string{"save", "-o", "/tmp/alp.tar", "alpine"}) + tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") + session := podmanTest.Podman([]string{"save", "-o", tarfn, "alpine"}) session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"pull", "docker-archive:/tmp/alp.tar"}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:%s", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"/tmp/alp.tar"}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) It("podman pull from oci-archive", func() { - session := podmanTest.Podman([]string{"save", "--format", "oci-archive", "-o", "/tmp/oci-alp.tar", "alpine"}) + tarfn := filepath.Join(podmanTest.TempDir, "oci-alp.tar") + session := podmanTest.Podman([]string{"save", "--format", "oci-archive", "-o", tarfn, "alpine"}) session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"pull", "oci-archive:/tmp/oci-alp.tar"}) + session = podmanTest.Podman([]string{"pull", fmt.Sprintf("oci-archive:%s", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"/tmp/oci-alp.tar"}) - clean.WaitWithDefaultTimeout() }) It("podman pull from local directory", func() { - setup := SystemExec("mkdir", []string{"-p", "/tmp/podmantestdir"}) - setup.WaitWithDefaultTimeout() - session := podmanTest.Podman([]string{"push", "alpine", "dir:/tmp/podmantestdir"}) + dirpath := filepath.Join(podmanTest.TempDir, "alpine") + os.MkdirAll(dirpath, os.ModePerm) + imgPath := fmt.Sprintf("dir:%s", dirpath) + + session := podmanTest.Podman([]string{"push", "alpine", imgPath}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"pull", "dir:/tmp/podmantestdir"}) + session = podmanTest.Podman([]string{"pull", imgPath}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "podmantestdir"}) + session = podmanTest.Podman([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - - clean := SystemExec("rm", []string{"-fr", "/tmp/podmantestdir"}) - clean.WaitWithDefaultTimeout() }) It("podman pull check quiet", func() { diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go index 42aefd1f7..fee117783 100644 --- a/test/e2e/push_test.go +++ b/test/e2e/push_test.go @@ -51,13 +51,11 @@ var _ = Describe("Podman push", func() { }) It("podman push to dir", func() { - session := podmanTest.Podman([]string{"push", "--remove-signatures", ALPINE, "dir:/tmp/busybox"}) + bbdir := filepath.Join(podmanTest.TempDir, "busybox") + session := podmanTest.Podman([]string{"push", "--remove-signatures", ALPINE, + fmt.Sprintf("dir:%s", bbdir)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - - clean := SystemExec("rm", []string{"-fr", "/tmp/busybox"}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) It("podman push to local registry", func() { @@ -85,20 +83,21 @@ var _ = Describe("Podman push", func() { authPath := filepath.Join(podmanTest.TempDir, "auth") os.Mkdir(authPath, os.ModePerm) os.MkdirAll("/etc/containers/certs.d/localhost:5000", os.ModePerm) - debug := SystemExec("ls", []string{"-l", podmanTest.TempDir}) - debug.WaitWithDefaultTimeout() + defer os.RemoveAll("/etc/containers/certs.d/localhost:5000") cwd, _ := os.Getwd() certPath := filepath.Join(cwd, "../", "certs") if IsCommandAvailable("getenforce") { ge := SystemExec("getenforce", []string{}) - ge.WaitWithDefaultTimeout() + Expect(ge.ExitCode()).To(Equal(0)) if ge.OutputToString() == "Enforcing" { se := SystemExec("setenforce", []string{"0"}) - se.WaitWithDefaultTimeout() - - defer SystemExec("setenforce", []string{"1"}) + Expect(se.ExitCode()).To(Equal(0)) + defer func() { + se2 := SystemExec("setenforce", []string{"1"}) + Expect(se2.ExitCode()).To(Equal(0)) + }() } } podmanTest.RestoreArtifact(registry) @@ -111,8 +110,6 @@ var _ = Describe("Podman push", func() { f.WriteString(session.OutputToString()) f.Sync() - debug = SystemExec("cat", []string{filepath.Join(authPath, "htpasswd")}) - debug.WaitWithDefaultTimeout() session = podmanTest.Podman([]string{"run", "-d", "-p", "5000:5000", "--name", "registry", "-v", strings.Join([]string{authPath, "/auth"}, ":"), "-e", "REGISTRY_AUTH=htpasswd", "-e", @@ -138,8 +135,7 @@ var _ = Describe("Podman push", func() { Expect(push.ExitCode()).To(Equal(0)) setup := SystemExec("cp", []string{filepath.Join(certPath, "domain.crt"), "/etc/containers/certs.d/localhost:5000/ca.crt"}) - setup.WaitWithDefaultTimeout() - defer os.RemoveAll("/etc/containers/certs.d/localhost:5000") + Expect(setup.ExitCode()).To(Equal(0)) push = podmanTest.Podman([]string{"push", "--creds=podmantest:wrongpasswd", ALPINE, "localhost:5000/credstest"}) push.WaitWithDefaultTimeout() @@ -155,23 +151,22 @@ var _ = Describe("Podman push", func() { }) It("podman push to docker-archive", func() { - session := podmanTest.Podman([]string{"push", ALPINE, "docker-archive:/tmp/alp:latest"}) + tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") + session := podmanTest.Podman([]string{"push", ALPINE, + fmt.Sprintf("docker-archive:%s:latest", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"/tmp/alp"}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) It("podman push to docker daemon", func() { setup := SystemExec("bash", []string{"-c", "systemctl status docker 2>&1"}) - setup.WaitWithDefaultTimeout() if setup.LineInOutputContains("Active: inactive") { setup = SystemExec("systemctl", []string{"start", "docker"}) - setup.WaitWithDefaultTimeout() - - defer SystemExec("systemctl", []string{"stop", "docker"}) + defer func() { + stop := SystemExec("systemctl", []string{"stop", "docker"}) + Expect(stop.ExitCode()).To(Equal(0)) + }() } else if setup.ExitCode() != 0 { Skip("Docker is not available") } @@ -181,22 +176,19 @@ var _ = Describe("Podman push", func() { Expect(session.ExitCode()).To(Equal(0)) check := SystemExec("docker", []string{"images", "--format", "{{.Repository}}:{{.Tag}}"}) - check.WaitWithDefaultTimeout() Expect(check.ExitCode()).To(Equal(0)) Expect(check.OutputToString()).To(ContainSubstring("alpine:podmantest")) clean := SystemExec("docker", []string{"rmi", "alpine:podmantest"}) - clean.WaitWithDefaultTimeout() Expect(clean.ExitCode()).To(Equal(0)) }) It("podman push to oci-archive", func() { - session := podmanTest.Podman([]string{"push", ALPINE, "oci-archive:/tmp/alp.tar:latest"}) + tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") + session := podmanTest.Podman([]string{"push", ALPINE, + fmt.Sprintf("oci-archive:%s:latest", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"/tmp/alp.tar"}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) It("podman push to local ostree", func() { @@ -208,33 +200,29 @@ var _ = Describe("Podman push", func() { os.MkdirAll(ostreePath, os.ModePerm) setup := SystemExec("ostree", []string{strings.Join([]string{"--repo=", ostreePath}, ""), "init"}) - setup.WaitWithDefaultTimeout() + Expect(setup.ExitCode()).To(Equal(0)) session := podmanTest.Podman([]string{"push", ALPINE, strings.Join([]string{"ostree:alp@", ostreePath}, "")}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"-rf", ostreePath}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) It("podman push to docker-archive no reference", func() { - session := podmanTest.Podman([]string{"push", ALPINE, "docker-archive:/tmp/alp"}) + tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") + session := podmanTest.Podman([]string{"push", ALPINE, + fmt.Sprintf("docker-archive:%s", tarfn)}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"/tmp/alp"}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) It("podman push to oci-archive no reference", func() { - session := podmanTest.Podman([]string{"push", ALPINE, "oci-archive:/tmp/alp-oci"}) + ociarc := filepath.Join(podmanTest.TempDir, "alp-oci") + session := podmanTest.Podman([]string{"push", ALPINE, + fmt.Sprintf("oci-archive:%s", ociarc)}) + session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - clean := SystemExec("rm", []string{"/tmp/alp-oci"}) - clean.WaitWithDefaultTimeout() - Expect(clean.ExitCode()).To(Equal(0)) }) }) diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go index 5c914a367..a101219d4 100644 --- a/test/e2e/restart_test.go +++ b/test/e2e/restart_test.go @@ -90,6 +90,21 @@ var _ = Describe("Podman restart", func() { Expect(restartTime.OutputToString()).To(Not(Equal(startTime.OutputToString()))) }) + It("Podman container restart running container", func() { + _ = podmanTest.RunTopContainer("test1") + ok := WaitForContainer(podmanTest) + Expect(ok).To(BeTrue()) + startTime := podmanTest.Podman([]string{"container", "inspect", "--format='{{.State.StartedAt}}'", "test1"}) + startTime.WaitWithDefaultTimeout() + + session := podmanTest.Podman([]string{"container", "restart", "test1"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + restartTime := podmanTest.Podman([]string{"container", "inspect", "--format='{{.State.StartedAt}}'", "test1"}) + restartTime.WaitWithDefaultTimeout() + Expect(restartTime.OutputToString()).To(Not(Equal(startTime.OutputToString()))) + }) + It("Podman restart multiple containers", func() { _, exitCode, _ := podmanTest.RunLsContainer("test1") Expect(exitCode).To(Equal(0)) diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go index 71dacfa80..db08dda8b 100644 --- a/test/e2e/rm_test.go +++ b/test/e2e/rm_test.go @@ -65,6 +65,17 @@ var _ = Describe("Podman rm", func() { Expect(result.ExitCode()).To(Equal(0)) }) + It("podman container rm created container", func() { + session := podmanTest.Podman([]string{"container", "create", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + cid := session.OutputToString() + + result := podmanTest.Podman([]string{"container", "rm", cid}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + It("podman rm running container with -f", func() { session := podmanTest.RunTopContainer("") session.WaitWithDefaultTimeout() diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index dcbda2df4..26cc925ef 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -275,4 +275,13 @@ RUN find $LOCAL Expect(images.ExitCode()).To(Equal(0)) Expect(len(images.OutputToStringArray())).To(Equal(0)) }) + + // Don't rerun all tests; just assume that if we get that diagnostic, + // we're getting rmi + It("podman image rm is the same as rmi", func() { + session := podmanTest.Podman([]string{"image", "rm"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(125)) + Expect(session.LineInOutputContains("image name or ID must be specified")) + }) }) diff --git a/test/e2e/run_cleanup_test.go b/test/e2e/run_cleanup_test.go index aa823b4e6..1f2a4085d 100644 --- a/test/e2e/run_cleanup_test.go +++ b/test/e2e/run_cleanup_test.go @@ -36,14 +36,16 @@ var _ = Describe("Podman run exit", func() { It("podman run -d mount cleanup test", func() { mount := SystemExec("mount", nil) - mount.WaitWithDefaultTimeout() + Expect(mount.ExitCode()).To(Equal(0)) + out1 := mount.OutputToString() result := podmanTest.Podman([]string{"create", "-dt", ALPINE, "echo", "hello"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) mount = SystemExec("mount", nil) - mount.WaitWithDefaultTimeout() + Expect(mount.ExitCode()).To(Equal(0)) + out2 := mount.OutputToString() Expect(out1).To(Equal(out2)) }) diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index a07e4d047..c89a4f487 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -58,7 +58,6 @@ var _ = Describe("Podman run networking", func() { session.Wait(30) Expect(session.ExitCode()).To(Equal(0)) results := SystemExec("iptables", []string{"-t", "nat", "-L"}) - results.Wait(30) Expect(results.ExitCode()).To(Equal(0)) Expect(results.OutputToString()).To(ContainSubstring("222")) Expect(results.OutputToString()).To(ContainSubstring("223")) @@ -69,12 +68,10 @@ var _ = Describe("Podman run networking", func() { session.Wait(30) Expect(session.ExitCode()).To(Equal(0)) results := SystemExec("iptables", []string{"-t", "nat", "-L"}) - results.Wait(30) Expect(results.ExitCode()).To(Equal(0)) Expect(results.OutputToString()).To(ContainSubstring("8000")) ncBusy := SystemExec("nc", []string{"-l", "-p", "80"}) - ncBusy.Wait(10) Expect(ncBusy.ExitCode()).ToNot(Equal(0)) }) @@ -183,26 +180,40 @@ var _ = Describe("Podman run networking", func() { if Containerized() { Skip("Can not be run within a container.") } - SystemExec("ip", []string{"netns", "add", "xxx"}) + addXXX := SystemExec("ip", []string{"netns", "add", "xxx"}) + Expect(addXXX.ExitCode()).To(Equal(0)) + defer func() { + delXXX := SystemExec("ip", []string{"netns", "delete", "xxx"}) + Expect(delXXX.ExitCode()).To(Equal(0)) + }() + session := podmanTest.Podman([]string{"run", "-dt", "--net", "ns:/run/netns/xxx", ALPINE, "wget", "www.podman.io"}) session.Wait(90) Expect(session.ExitCode()).To(Equal(0)) - SystemExec("ip", []string{"netns", "delete", "xxx"}) }) It("podman run n user created network namespace with resolv.conf", func() { if Containerized() { Skip("Can not be run within a container.") } - SystemExec("ip", []string{"netns", "add", "xxx"}) - SystemExec("mkdir", []string{"-p", "/etc/netns/xxx"}) - SystemExec("bash", []string{"-c", "echo nameserver 11.11.11.11 > /etc/netns/xxx/resolv.conf"}) - session := podmanTest.Podman([]string{"run", "--net", "ns:/run/netns/xxx", ALPINE, "cat", "/etc/resolv.conf"}) + addXXX2 := SystemExec("ip", []string{"netns", "add", "xxx2"}) + Expect(addXXX2.ExitCode()).To(Equal(0)) + defer func() { + delXXX2 := SystemExec("ip", []string{"netns", "delete", "xxx2"}) + Expect(delXXX2.ExitCode()).To(Equal(0)) + }() + + mdXXX2 := SystemExec("mkdir", []string{"-p", "/etc/netns/xxx2"}) + Expect(mdXXX2.ExitCode()).To(Equal(0)) + defer os.RemoveAll("/etc/netns/xxx2") + + nsXXX2 := SystemExec("bash", []string{"-c", "echo nameserver 11.11.11.11 > /etc/netns/xxx2/resolv.conf"}) + Expect(nsXXX2.ExitCode()).To(Equal(0)) + + session := podmanTest.Podman([]string{"run", "--net", "ns:/run/netns/xxx2", ALPINE, "cat", "/etc/resolv.conf"}) session.Wait(90) Expect(session.ExitCode()).To(Equal(0)) Expect(session.OutputToString()).To(ContainSubstring("11.11.11.11")) - SystemExec("ip", []string{"netns", "delete", "xxx"}) - SystemExec("rm", []string{"-rf", "/etc/netns/xxx"}) }) It("podman run network in bogus user created network namespace", func() { diff --git a/test/e2e/run_ns_test.go b/test/e2e/run_ns_test.go index 9962185f2..3d95c3a0b 100644 --- a/test/e2e/run_ns_test.go +++ b/test/e2e/run_ns_test.go @@ -53,7 +53,6 @@ var _ = Describe("Podman run ns", func() { It("podman run ipcns test", func() { setup := SystemExec("ls", []string{"--inode", "-d", "/dev/shm"}) - setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) hostShm := setup.OutputToString() @@ -65,7 +64,6 @@ var _ = Describe("Podman run ns", func() { It("podman run ipcns ipcmk host test", func() { setup := SystemExec("ipcmk", []string{"-M", "1024"}) - setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) output := strings.Split(setup.OutputToString(), " ") ipc := output[len(output)-1] @@ -74,7 +72,6 @@ var _ = Describe("Podman run ns", func() { Expect(session.ExitCode()).To(Equal(0)) setup = SystemExec("ipcrm", []string{"-m", ipc}) - setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/run_privileged_test.go b/test/e2e/run_privileged_test.go index 0c0de30c5..ee6e8e950 100644 --- a/test/e2e/run_privileged_test.go +++ b/test/e2e/run_privileged_test.go @@ -46,7 +46,6 @@ var _ = Describe("Podman privileged container tests", func() { It("podman privileged CapEff", func() { cap := SystemExec("grep", []string{"CapEff", "/proc/self/status"}) - cap.WaitWithDefaultTimeout() Expect(cap.ExitCode()).To(Equal(0)) session := podmanTest.Podman([]string{"run", "--privileged", "busybox", "grep", "CapEff", "/proc/self/status"}) @@ -57,7 +56,6 @@ var _ = Describe("Podman privileged container tests", func() { It("podman cap-add CapEff", func() { cap := SystemExec("grep", []string{"CapEff", "/proc/self/status"}) - cap.WaitWithDefaultTimeout() Expect(cap.ExitCode()).To(Equal(0)) session := podmanTest.Podman([]string{"run", "--cap-add", "all", "busybox", "grep", "CapEff", "/proc/self/status"}) @@ -97,7 +95,6 @@ var _ = Describe("Podman privileged container tests", func() { } cap := SystemExec("grep", []string{"NoNewPrivs", "/proc/self/status"}) - cap.WaitWithDefaultTimeout() if cap.ExitCode() != 0 { Skip("Can't determine NoNewPrivs") } diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 6bd49de33..4ba32a94a 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -68,6 +68,20 @@ var _ = Describe("Podman run", func() { Expect(session.ExitCode()).To(Equal(0)) }) + It("podman container run a container based on on a short name with localhost", func() { + podmanTest.RestoreArtifact(nginx) + tag := podmanTest.Podman([]string{"image", "tag", nginx, "localhost/libpod/alpine_nginx:latest"}) + tag.WaitWithDefaultTimeout() + + rmi := podmanTest.Podman([]string{"image", "rm", nginx}) + rmi.WaitWithDefaultTimeout() + + session := podmanTest.Podman([]string{"container", "run", "libpod/alpine_nginx:latest", "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ErrorToString()).ToNot(ContainSubstring("Trying to pull")) + Expect(session.ExitCode()).To(Equal(0)) + }) + It("podman run a container based on local image with short options", func() { session := podmanTest.Podman([]string{"run", "-dt", ALPINE, "ls"}) session.WaitWithDefaultTimeout() @@ -387,7 +401,6 @@ var _ = Describe("Podman run", func() { err = ioutil.WriteFile(keyFile, []byte(mountString), 0755) Expect(err).To(BeNil()) execSession := SystemExec("ln", []string{"-s", targetDir, filepath.Join(secretsDir, "mysymlink")}) - execSession.WaitWithDefaultTimeout() Expect(execSession.ExitCode()).To(Equal(0)) session := podmanTest.Podman([]string{"--default-mounts-file=" + mountsFile, "run", "--rm", ALPINE, "cat", "/run/secrets/test.txt"}) diff --git a/test/e2e/start_test.go b/test/e2e/start_test.go index c4ed6f545..51fece3f1 100644 --- a/test/e2e/start_test.go +++ b/test/e2e/start_test.go @@ -50,6 +50,16 @@ var _ = Describe("Podman start", func() { Expect(session.ExitCode()).To(Equal(0)) }) + It("podman container start single container by id", func() { + session := podmanTest.Podman([]string{"container", "create", "-d", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + cid := session.OutputToString() + session = podmanTest.Podman([]string{"container", "start", cid}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + It("podman start single container by name", func() { session := podmanTest.Podman([]string{"create", "-d", "--name", "foobar99", ALPINE, "ls"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go index 8fffedbb9..eb680d2a1 100644 --- a/test/e2e/stop_test.go +++ b/test/e2e/stop_test.go @@ -59,6 +59,15 @@ var _ = Describe("Podman stop", func() { Expect(session.ExitCode()).To(Equal(0)) }) + It("podman stop container by name", func() { + session := podmanTest.RunTopContainer("test1") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + session = podmanTest.Podman([]string{"container", "stop", "test1"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + It("podman stop stopped container", func() { session := podmanTest.RunTopContainer("test1") session.WaitWithDefaultTimeout() diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go index a7e7a1500..252361288 100644 --- a/test/e2e/systemd_test.go +++ b/test/e2e/systemd_test.go @@ -53,31 +53,27 @@ WantedBy=multi-user.target sys_file := ioutil.WriteFile("/etc/systemd/system/redis.service", []byte(systemd_unit_file), 0644) Expect(sys_file).To(BeNil()) + defer func() { + stop := SystemExec("bash", []string{"-c", "systemctl stop redis"}) + os.Remove("/etc/systemd/system/redis.service") + SystemExec("bash", []string{"-c", "systemctl daemon-reload"}) + Expect(stop.ExitCode()).To(Equal(0)) + }() create := podmanTest.Podman([]string{"create", "-d", "--name", "redis", "redis"}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) - enable := SystemExec("bash", []string{"-c", "systemctl daemon-reload && systemctl enable --now redis"}) - enable.WaitWithDefaultTimeout() + enable := SystemExec("bash", []string{"-c", "systemctl daemon-reload"}) Expect(enable.ExitCode()).To(Equal(0)) start := SystemExec("bash", []string{"-c", "systemctl start redis"}) - start.WaitWithDefaultTimeout() + Expect(start.ExitCode()).To(Equal(0)) logs := SystemExec("bash", []string{"-c", "journalctl -n 20 -u redis"}) - logs.WaitWithDefaultTimeout() + Expect(logs.ExitCode()).To(Equal(0)) status := SystemExec("bash", []string{"-c", "systemctl status redis"}) - status.WaitWithDefaultTimeout() Expect(status.OutputToString()).To(ContainSubstring("active (running)")) - - cleanup := SystemExec("bash", []string{"-c", "systemctl stop redis && systemctl disable redis"}) - cleanup.WaitWithDefaultTimeout() - Expect(cleanup.ExitCode()).To(Equal(0)) - os.Remove("/etc/systemd/system/redis.service") - sys_clean := SystemExec("bash", []string{"-c", "systemctl daemon-reload"}) - sys_clean.WaitWithDefaultTimeout() - Expect(sys_clean.ExitCode()).To(Equal(0)) }) }) diff --git a/test/e2e/top_test.go b/test/e2e/top_test.go index 067358468..156c37035 100644 --- a/test/e2e/top_test.go +++ b/test/e2e/top_test.go @@ -65,6 +65,17 @@ var _ = Describe("Podman top", func() { Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) }) + It("podman container top on container", func() { + session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "top", "-d", "2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"container", "top", "-l"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) + }) + It("podman top with options", func() { session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top", "-d", "2"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/wait_test.go b/test/e2e/wait_test.go index 08da97aa0..69e64774c 100644 --- a/test/e2e/wait_test.go +++ b/test/e2e/wait_test.go @@ -66,4 +66,11 @@ var _ = Describe("Podman wait", func() { session = podmanTest.Podman([]string{"wait", "-l"}) session.Wait(20) }) + It("podman container wait on latest container", func() { + session := podmanTest.Podman([]string{"container", "run", "-d", ALPINE, "sleep", "1"}) + session.Wait(20) + Expect(session.ExitCode()).To(Equal(0)) + session = podmanTest.Podman([]string{"container", "wait", "-l"}) + session.Wait(20) + }) }) diff --git a/test/test_podman_baseline.sh b/test/test_podman_baseline.sh index 8a878b4e7..664fd2b03 100755 --- a/test/test_podman_baseline.sh +++ b/test/test_podman_baseline.sh @@ -195,7 +195,7 @@ podman rmi --all ######## # 1.004608 MB is 1,004,608 bytes. The container overhead is 4608 bytes (or 9 512 byte pages), so this allocates 1 MB of usable storage -PODMANBASE="-s overlay --storage-opt overlay.size=1.004608M --root /tmp/podman_test/crio" +PODMANBASE="--storage-driver overlay --storage-opt overlay.size=1.004608M --root /tmp/podman_test/crio" TMPDIR=/tmp/podman_test mkdir $TMPDIR dd if=/dev/zero of=$TMPDIR/virtfs bs=1024 count=30720 diff --git a/test/utils/utils.go b/test/utils/utils.go index 098779321..499466f5a 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -326,6 +326,7 @@ func SystemExec(command string, args []string) *PodmanSession { if err != nil { Fail(fmt.Sprintf("unable to run command: %s %s", command, strings.Join(args, " "))) } + session.Wait(defaultWaitTimeout) return &PodmanSession{session} } |