diff options
-rw-r--r-- | Dockerfile | 3 | ||||
-rw-r--r-- | Dockerfile.CentOSDev | 1 | ||||
-rw-r--r-- | Dockerfile.Fedora | 3 | ||||
-rw-r--r-- | cmd/podman/create.go | 14 | ||||
-rw-r--r-- | libpod/runtime_img.go | 2 | ||||
-rw-r--r-- | test/e2e/libpod_suite_test.go | 18 | ||||
-rw-r--r-- | test/e2e/ps_test.go | 202 | ||||
-rw-r--r-- | test/e2e/pull_test.go | 141 | ||||
-rw-r--r-- | test/e2e/push_test.go | 70 | ||||
-rw-r--r-- | test/e2e/rm_test.go | 110 | ||||
-rw-r--r-- | test/e2e/rmi_test.go | 10 | ||||
-rw-r--r-- | test/podman_ps.bats | 190 | ||||
-rw-r--r-- | test/podman_pull.bats | 136 | ||||
-rw-r--r-- | test/podman_push.bats | 102 | ||||
-rw-r--r-- | test/podman_rm.bats | 71 |
15 files changed, 565 insertions, 508 deletions
diff --git a/Dockerfile b/Dockerfile index affcf8b39..42eb00d5a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -120,7 +120,8 @@ RUN mkdir -p /etc/cni/net.d/ COPY cni/87-podman-bridge.conflist /etc/cni/net.d/87-podman-bridge.conflist # Make sure we have some policy for pulling images -RUN mkdir -p /etc/containers +RUN mkdir -p /etc/containers && curl https://raw.githubusercontent.com/projectatomic/registries/master/registries.fedora -o /etc/containers/registries.conf + COPY test/policy.json /etc/containers/policy.json COPY test/redhat_sigstore.yaml /etc/containers/registries.d/registry.access.redhat.com.yaml diff --git a/Dockerfile.CentOSDev b/Dockerfile.CentOSDev index 3bb834c10..4296ef97e 100644 --- a/Dockerfile.CentOSDev +++ b/Dockerfile.CentOSDev @@ -1,6 +1,7 @@ FROM registry.centos.org/centos/centos:7 RUN yum -y install btrfs-progs-devel \ + atomic-registries \ bzip2 \ device-mapper-devel \ findutils \ diff --git a/Dockerfile.Fedora b/Dockerfile.Fedora index 1dbc1a02e..055d2b9e3 100644 --- a/Dockerfile.Fedora +++ b/Dockerfile.Fedora @@ -19,8 +19,9 @@ RUN dnf -y install btrfs-progs-devel \ python \ which\ golang-github-cpuguy83-go-md2man \ - crio \ + conmon \ procps-ng \ + atomic-registries \ iptables && dnf clean all # install bats diff --git a/cmd/podman/create.go b/cmd/podman/create.go index e0825566a..045703074 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -298,6 +298,18 @@ func isPortInPortBindings(pb map[nat.Port][]nat.PortBinding, port nat.Port) bool return libpod.StringInSlice(port.Port(), hostPorts) } +// isPortInImagePorts determines if an exposed host port was given to us by metadata +// in the image itself +func isPortInImagePorts(exposedPorts map[string]struct{}, port string) bool { + for i := range exposedPorts { + fields := strings.Split(i, "/") + if port == fields[0] { + return true + } + } + return false +} + func exposedPorts(c *cli.Context, imageExposedPorts map[string]struct{}) (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error) { var exposedPorts []string var ports map[nat.Port]struct{} @@ -337,7 +349,7 @@ func exposedPorts(c *cli.Context, imageExposedPorts map[string]struct{}) (map[na return nil, nil, err } // check if the port in question is already being used - if isPortInPortBindings(portBindings, p) { + if isPortInPortBindings(portBindings, p) && !isPortInImagePorts(imageExposedPorts, p.Port()) { return nil, nil, errors.Errorf("host port %s already used in --publish option", p.Port()) } diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index 882174856..a572afcbb 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -312,7 +312,7 @@ func (k *Image) Decompose() error { return nil } // We need to check if the registry name is legit - _, err = net.LookupAddr(k.Registry) + _, err = net.LookupHost(k.Registry) if err == nil { return nil } diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index c83105325..95b9def77 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -205,6 +205,13 @@ func (s *PodmanSession) OutputToString() string { return strings.Join(fields, " ") } +// OutputToStringArray returns the output as a []string +// where each array item is a line split by newline +func (s *PodmanSession) OutputToStringArray() []string { + output := fmt.Sprintf("%s", s.Out.Contents()) + return strings.Split(output, "\n") +} + // IsJSONOutputValid attempts to unmarshall the session buffer // and if successful, returns true, else false func (s *PodmanSession) IsJSONOutputValid() bool { @@ -335,3 +342,14 @@ func (p *PodmanTest) RunSleepContainer(name string) *PodmanSession { podmanArgs = append(podmanArgs, "-d", ALPINE, "sleep", "90") return p.Podman(podmanArgs) } + +//RunLsContainer runs a simple container in the background that +// simply runs ls. If the name passed != "", it will have a name +func (p *PodmanTest) RunLsContainer(name string) *PodmanSession { + var podmanArgs = []string{"run"} + if name != "" { + podmanArgs = append(podmanArgs, "--name", name) + } + podmanArgs = append(podmanArgs, "-d", ALPINE, "ls") + return p.Podman(podmanArgs) +} diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go new file mode 100644 index 000000000..690015552 --- /dev/null +++ b/test/e2e/ps_test.go @@ -0,0 +1,202 @@ +package integration + +import ( + "os" + + "fmt" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman ps", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman ps no containers", func() { + session := podmanTest.Podman([]string{"ps"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + + It("podman ps default", func() { + session := podmanTest.RunSleepContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"ps"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) + }) + + It("podman ps all", func() { + session := podmanTest.RunLsContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"ps", "-a"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) + }) + + It("podman ps size flag", func() { + session := podmanTest.RunLsContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"ps", "-a", "--size"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) + }) + + It("podman ps quiet flag", func() { + session := podmanTest.RunLsContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + fullCid := session.OutputToString() + + result := podmanTest.Podman([]string{"ps", "-a", "-q"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) + Expect(fullCid).To(ContainSubstring(result.OutputToStringArray()[0])) + }) + + It("podman ps latest flag", func() { + session := podmanTest.RunLsContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"ps", "--latest"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) + }) + + It("podman ps last flag", func() { + session := podmanTest.RunLsContainer("test1") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.RunLsContainer("test2") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.RunLsContainer("test3") + session.WaitWithDefaultTimeout() + + Expect(session.ExitCode()).To(Equal(0)) + result := podmanTest.Podman([]string{"ps", "--last", "2"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).Should(Equal(4)) + }) + + It("podman ps no-trunc", func() { + session := podmanTest.RunLsContainer("test1") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + fullCid := session.OutputToString() + + result := podmanTest.Podman([]string{"ps", "-aq", "--no-trunc"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) + Expect(fullCid).To(Equal(result.OutputToStringArray()[0])) + }) + + It("podman ps namespace flag", func() { + session := podmanTest.RunLsContainer("test1") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"ps", "-a", "--namespace"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0)) + }) + + It("podman ps namespace flag with json format", func() { + session := podmanTest.RunLsContainer("test1") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"ps", "-a", "--ns", "--format", "json"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.IsJSONOutputValid()).To(BeTrue()) + }) + + It("podman ps namespace flag with go template format", func() { + session := podmanTest.RunLsContainer("test1") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"ps", "-a", "--format", "\"table {{.ID}} {{.Image}} {{.Labels}}\""}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.IsJSONOutputValid()).To(BeTrue()) + }) + + It("podman ps ancestor filter flag", func() { + session := podmanTest.RunLsContainer("test1") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"ps", "-a", "--filter", "ancestor=docker.io/library/alpine:latest"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + + It("podman ps id filter flag", func() { + session := podmanTest.RunLsContainer("test1") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + fullCid := session.OutputToString() + + result := podmanTest.Podman([]string{"ps", "-a", "--filter", fmt.Sprintf("id=%s", fullCid)}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + + It("podman ps id filter flag", func() { + session := podmanTest.RunSleepContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + fullCid := session.OutputToString() + + result := podmanTest.Podman([]string{"ps", "-aq", "--no-trunc", "--filter", "status=running"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(result.OutputToStringArray()[0]).To(Equal(fullCid)) + }) + + It("podman ps mutually exclusive flags", func() { + session := podmanTest.Podman([]string{"ps", "-aqs"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + + session = podmanTest.Podman([]string{"ps", "-a", "--ns", "-s"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + }) +}) diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go new file mode 100644 index 000000000..e24d8a5a7 --- /dev/null +++ b/test/e2e/pull_test.go @@ -0,0 +1,141 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman pull", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman pull from docker with tag", func() { + session := podmanTest.Podman([]string{"pull", "busybox:glibc"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"rmi", "busybox:glibc"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + + It("podman pull from docker without tag", func() { + session := podmanTest.Podman([]string{"pull", "busybox"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"rmi", "busybox"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + + It("podman pull from alternate registry with tag", func() { + session := podmanTest.Podman([]string{"pull", "registry.fedoraproject.org/fedora-minimal:latest"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"rmi", "registry.fedoraproject.org/fedora-minimal:latest"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + + It("podman pull from alternate registry without tag", func() { + session := podmanTest.Podman([]string{"pull", "registry.fedoraproject.org/fedora-minimal"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"rmi", "registry.fedoraproject.org/fedora-minimal"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + + It("podman pull by digest", func() { + session := podmanTest.Podman([]string{"pull", "alpine@sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"rmi", "alpine:latest"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + + It("podman pull bogus image", func() { + session := podmanTest.Podman([]string{"pull", "umohnani/get-started"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + }) + + It("podman pull from docker-archive", func() { + session := podmanTest.Podman([]string{"save", "-o", "/tmp/alp.tar", "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.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + session = podmanTest.Podman([]string{"rmi", "alpine"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + clean := podmanTest.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"}) + 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.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + session = podmanTest.Podman([]string{"rmi", "alpine"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + clean := podmanTest.SystemExec("rm", []string{"/tmp/oci-alp.tar"}) + clean.WaitWithDefaultTimeout() + }) + + It("podman pull from local directory", func() { + setup := podmanTest.SystemExec("mkdir", []string{"-p", "/tmp/podmantestdir"}) + setup.WaitWithDefaultTimeout() + session := podmanTest.Podman([]string{"push", "alpine", "dir:/tmp/podmantestdir"}) + 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.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + session = podmanTest.Podman([]string{"rmi", "podmantestdir"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + clean := podmanTest.SystemExec("rm", []string{"-fr", "/tmp/podmantestdir"}) + clean.WaitWithDefaultTimeout() + }) +}) diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go new file mode 100644 index 000000000..028f96424 --- /dev/null +++ b/test/e2e/push_test.go @@ -0,0 +1,70 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman push", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman push to containers/storage", func() { + session := podmanTest.Podman([]string{"push", ALPINE, "containers-storage:busybox:test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"rmi", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + + session = podmanTest.Podman([]string{"rmi", "busybox:test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + + session = podmanTest.Podman([]string{"rmi", "-f", "busybox:test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + }) + + // push to oci-archive, docker-archive, and dir are tested in pull_test.go + + It("podman push to containers/storage", func() { + session := podmanTest.Podman([]string{"push", "--remove-signatures", ALPINE, "dir:/tmp/busybox"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + clean := podmanTest.SystemExec("rm", []string{"-fr", "/tmp/busybox"}) + clean.WaitWithDefaultTimeout() + Expect(clean.ExitCode()).To(Equal(0)) + }) + + It("podman push to local registry", func() { + session := podmanTest.Podman([]string{"run", "-d", "-p", "5000:5000", "docker.io/library/registry:2", "/entrypoint.sh", "/etc/docker/registry/config.yml"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"}) + push.WaitWithDefaultTimeout() + Expect(push.ExitCode()).To(Equal(0)) + }) +}) diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go new file mode 100644 index 000000000..1ef8ee5e6 --- /dev/null +++ b/test/e2e/rm_test.go @@ -0,0 +1,110 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman rm", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + It("podman rm stopped container", func() { + session := podmanTest.RunLsContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + cid := session.OutputToString() + + result := podmanTest.Podman([]string{"rm", cid}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + + It("podman rm refuse to remove a running container", func() { + session := podmanTest.RunSleepContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + cid := session.OutputToString() + + result := podmanTest.Podman([]string{"rm", cid}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Not(Equal(0))) + }) + + It("podman rm created container", func() { + session := podmanTest.Podman([]string{"create", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + cid := session.OutputToString() + + result := podmanTest.Podman([]string{"rm", cid}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + + It("podman rm created container", func() { + session := podmanTest.RunSleepContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + cid := session.OutputToString() + + result := podmanTest.Podman([]string{"rm", "-f", cid}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + + It("podman rm all containers", func() { + session := podmanTest.Podman([]string{"create", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"create", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"create", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"rm", "-a"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) + + It("podman rm all containers with one running and short options", func() { + session := podmanTest.Podman([]string{"create", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"create", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.RunSleepContainer("") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"rm", "-af"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) +}) diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index 895c812c6..04346f5ac 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -32,21 +32,21 @@ var _ = Describe("Podman rmi", func() { It("podman rmi bogus image", func() { session := podmanTest.Podman([]string{"rmi", "debian:6.0.10"}) - session.Wait() + session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(125)) }) It("podman rmi with fq name", func() { session := podmanTest.Podman([]string{"rmi", image1}) - session.Wait() + session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) It("podman rmi with short name", func() { session := podmanTest.Podman([]string{"rmi", "alpine"}) - session.Wait() + session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) @@ -54,7 +54,7 @@ var _ = Describe("Podman rmi", func() { It("podman rmi all images", func() { podmanTest.PullImages([]string{image3}) session := podmanTest.Podman([]string{"rmi", "-a"}) - session.Wait() + session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) @@ -62,7 +62,7 @@ var _ = Describe("Podman rmi", func() { It("podman rmi all images forceably with short options", func() { podmanTest.PullImages([]string{image3}) session := podmanTest.Podman([]string{"rmi", "-fa"}) - session.Wait() + session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) diff --git a/test/podman_ps.bats b/test/podman_ps.bats deleted file mode 100644 index 8f2232cbf..000000000 --- a/test/podman_ps.bats +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -IMAGE="redis:alpine" -function setup() { - copy_images -} - -function teardown() { - cleanup_test -} - -@test "podman ps with no containers" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps default" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps all flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps size flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --size - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps quiet flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - ctr_id="$output" - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --quiet - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps latest flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps --latest - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps last flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${BB} ls - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls -s - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps --last 2 - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps no-trunc flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --no-trunc - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps namespace flag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps --all --namespace - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps namespace flag and format flag = json" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --ns --format json | python -m json.tool | grep namespace" - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps without namespace flag and format flag = json" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --format json | python -m json.tool | grep namespace" - echo "$output" - [ "$status" -eq 1 ] -} - -@test "podman ps format flag = go template" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --format 'table {{.ID}} {{.Image}} {{.Labels}}' - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps filter flag - ancestor" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --filter ancestor=${ALPINE} - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps filter flag - id" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --filter id=$ctr_id - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps filter flag - status" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} sleep 99 - ctr_id="$output" - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --filter status=running - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} stop $ctr_id - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps short options" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} sleep 99 - ctr_id="$output" - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -aq - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} stop $ctr_id - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman ps with mutually exclusive flags" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} sleep 99 - ctr_id="$output" - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -aqs - echo "$output" - [ "$status" -ne 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --ns -s - echo "$output" - [ "$status" -ne 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --ns format {{.ID}} - echo "$output" - [ "$status" -ne 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} ps -a --ns --format json - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} stop $ctr_id - echo "$output" - [ "$status" -eq 0 ] -} diff --git a/test/podman_pull.bats b/test/podman_pull.bats deleted file mode 100644 index 4052d56d5..000000000 --- a/test/podman_pull.bats +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -@test "podman pull from docker with tag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pull debian:6.0.10 - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi debian:6.0.10 - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman pull from docker without tag" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS pull debian - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi debian - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman pull from a non-docker registry with tag" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS pull registry.fedoraproject.org/fedora:rawhide - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi registry.fedoraproject.org/fedora:rawhide - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman pull from a non-docker registry without tag" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS pull registry.fedoraproject.org/fedora - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi registry.fedoraproject.org/fedora - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman pull using digest" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS pull alpine@sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi alpine:latest - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman pull from a non existent image" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS pull umohnani/get-started - echo "$output" - [ "$status" -ne 0 ] -} - -@test "podman pull from docker with shortname" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pull debian - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi docker.io/debian:latest - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman pull from docker with shortname and tag" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pull debian:6.0.10 - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi docker.io/debian:6.0.10 - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman pull from docker-archive" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pull alpine - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save -o alp.tar alpine - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi alpine - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pull docker-archive:alp.tar - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi alpine - echo "$output" - [ "$status" -eq 0 ] - rm -f alp.tar -} - -@test "podman pull from oci-archive" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pull alpine - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} save --format oci-archive -o oci-alp.tar alpine - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi alpine - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pull oci-archive:oci-alp.tar - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi alpine - echo "$output" - [ "$status" -eq 0 ] - rm -f oci-alp.tar -} - -@test "podman pull from local directory" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pull alpine - echo "$output" - [ "$status" -eq 0 ] - run mkdir test_pull_dir - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} push alpine dir:test_pull_dir - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi alpine - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} pull dir:test_pull_dir - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} rmi test_pull_dir - echo "$output" - [ "$status" -eq 0 ] - rm -rf test_pull_dir -} diff --git a/test/podman_push.bats b/test/podman_push.bats deleted file mode 100644 index 8308f4e83..000000000 --- a/test/podman_push.bats +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function teardown() { - cleanup_test -} - -function setup() { - copy_images -} - -@test "podman push to containers/storage" { - skip "Issues with bash, skipping" - echo # Push the image right back into storage: it now has two names. - run bash -c ${PODMAN_BINARY} $PODMAN_OPTIONS --log-level=debug push $ALPINE containers-storage:busybox:test - echo "$output" - [ "$status" -eq 0 ] - echo # Try to remove it using the first name. Should be refused. - run bash -c ${PODMAN_BINARY} $PODMAN_OPTIONS --log-level=debug rmi $ALPINE - echo "$output" - [ "$status" -ne 0 ] - echo # Try to remove it using the second name. Should also be refused. - run bash -c ${PODMAN_BINARY} $PODMAN_OPTIONS --log-level=debug rmi busybox:test - echo "$output" - [ "$status" -ne 0 ] - echo # Force removal despite having multiple names. Should succeed. - run ${PODMAN_BINARY} $PODMAN_OPTIONS --log-level=debug rmi -f busybox:test - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman push to directory" { - mkdir /tmp/busybox - run ${PODMAN_BINARY} $PODMAN_OPTIONS push $ALPINE dir:/tmp/busybox - echo "$output" - [ "$status" -eq 0 ] - rm -rf /tmp/busybox - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi $ALPINE - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman push to docker archive" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS push $ALPINE docker-archive:/tmp/busybox-archive:1.26 - echo "$output" - echo "--->" - [ "$status" -eq 0 ] - rm /tmp/busybox-archive - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi $ALPINE - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman push to oci-archive without compression" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS push $ALPINE oci-archive:/tmp/oci-busybox.tar:alpine - echo "$output" - [ "$status" -eq 0 ] - rm -f /tmp/oci-busybox.tar - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi $ALPINE - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman push without signatures" { - mkdir /tmp/busybox - run ${PODMAN_BINARY} $PODMAN_OPTIONS push --remove-signatures $ALPINE dir:/tmp/busybox - echo "$output" - [ "$status" -eq 0 ] - rm -rf /tmp/busybox - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi $ALPINE - echo "$output" - [ "$status" -eq 0 ] -} - -@test "podman push without transport" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS pull "$ALPINE" - echo "$output" - [ "$status" -eq 0 ] - # TODO: The following should fail until a registry is running in Travis CI. - run ${PODMAN_BINARY} $PODMAN_OPTIONS push "$ALPINE" localhost:5000/my-alpine - echo "$output" - [ "$status" -ne 0 ] - run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi "$ALPINE" - echo "$output" -} - -@test "push with manifest type conversion" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS push --format oci "${BB}" dir:my-dir - echo "$output" - [ "$status" -eq 0 ] - run grep "application/vnd.oci.image.config.v1+json" my-dir/manifest.json - echo "$output" - [ "$status" -eq 0 ] - run ${PODMAN_BINARY} $PODMAN_OPTIONS push --compress --format v2s2 "${BB}" dir:my-dir - echo "$output" - [ "$status" -eq 0 ] - run bash -c "grep "application/vnd.docker.distribution.manifest.v2+json" my-dir/manifest.json" - echo "$output" - [ "$status" -eq 0 ] - rm -rf my-dir -} diff --git a/test/podman_rm.bats b/test/podman_rm.bats deleted file mode 100644 index 8382bb3fe..000000000 --- a/test/podman_rm.bats +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env bats - -load helpers - -function setup() { - copy_images -} - -function teardown() { - cleanup_test -} - -@test "remove a stopped container" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS run -d ${ALPINE} ls - echo "$output" - [ "$status" -eq 0 ] - ctr_id="$output" - run ${PODMAN_BINARY} $PODMAN_OPTIONS rm "$ctr_id" - echo "$output" - [ "$status" -eq 0 ] -} - -@test "refuse to remove a running container" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS run -d ${ALPINE} sleep 15 - echo "$output" - [ "$status" -eq 0 ] - ctr_id="$output" - run bash ${PODMAN_BINARY} $PODMAN_OPTIONS rm "$ctr_id" - echo "$output" - [ "$status" -ne 0 ] -} - -@test "remove a created container" { - run ${PODMAN_BINARY} ${PODMAN_OPTIONS} create $BB ls - echo "$output" - [ "$status" -eq 0 ] - ctr_id="$output" - run ${PODMAN_BINARY} $PODMAN_OPTIONS rm -f "$ctr_id" - echo "$output" - [ "$status" -eq 0 ] -} - -@test "remove a running container" { - run ${PODMAN_BINARY} $PODMAN_OPTIONS run -d ${ALPINE} sleep 15 - echo "$output" - [ "$status" -eq 0 ] - ctr_id="$output" - run ${PODMAN_BINARY} $PODMAN_OPTIONS rm -f "$ctr_id" - echo "$output" - [ "$status" -eq 0 ] -} - -@test "remove all containers" { - ${PODMAN_BINARY} ${PODMAN_OPTIONS} create $BB ls - ${PODMAN_BINARY} ${PODMAN_OPTIONS} create $BB ls -l - ${PODMAN_BINARY} ${PODMAN_OPTIONS} create $BB true - ${PODMAN_BINARY} ${PODMAN_OPTIONS} create $BB whoami - run ${PODMAN_BINARY} $PODMAN_OPTIONS rm -a - echo "$output" - [ "$status" -eq 0 ] -} - -@test "remove all containers with one running with short options" { - ${PODMAN_BINARY} ${PODMAN_OPTIONS} create $BB ls - ${PODMAN_BINARY} ${PODMAN_OPTIONS} create $BB ls -l - ${PODMAN_BINARY} ${PODMAN_OPTIONS} create $BB whoami - ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -d ${ALPINE} sleep 30 - run ${PODMAN_BINARY} $PODMAN_OPTIONS rm -af - echo "$output" - [ "$status" -eq 0 ] -} |