summaryrefslogtreecommitdiff
path: root/test/e2e/ps_test.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-01-30 13:19:01 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-31 20:23:31 +0000
commit3c044f9267f62b8f7f88c7395ad325df3bf420f5 (patch)
treed868f625ff78b5403fa82b9e7f51ffdaa953356a /test/e2e/ps_test.go
parentecb74aa40641cd322112401a593eaf26458e9d24 (diff)
downloadpodman-3c044f9267f62b8f7f88c7395ad325df3bf420f5.tar.gz
podman-3c044f9267f62b8f7f88c7395ad325df3bf420f5.tar.bz2
podman-3c044f9267f62b8f7f88c7395ad325df3bf420f5.zip
Ginkgo Tests: ps, pull, push and rm
Migrate ps, pull, push, and rm from bats to ginkgo. Also, fixed a conditional issue with adding ports when an image defines the port and the user wants to override it. Signed-off-by: baude <bbaude@redhat.com> Closes: #277 Approved by: baude
Diffstat (limited to 'test/e2e/ps_test.go')
-rw-r--r--test/e2e/ps_test.go202
1 files changed, 202 insertions, 0 deletions
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)))
+ })
+})