summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorhaircommander <pehunt@redhat.com>2018-06-14 15:29:46 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-06-19 14:45:29 +0000
commit4ab054073dadf5257bdd0ff21e154b859e139f1e (patch)
tree73cc17e44047506e8d548b8625346400899af0f1 /test
parentdfd34b1b03d3ec0447fb04e15b2d0861a4a9778d (diff)
downloadpodman-4ab054073dadf5257bdd0ff21e154b859e139f1e.tar.gz
podman-4ab054073dadf5257bdd0ff21e154b859e139f1e.tar.bz2
podman-4ab054073dadf5257bdd0ff21e154b859e139f1e.zip
Added --sort to ps
Also podman ps now allows user to only output size of root FS, changed language of images and ps --sort to be by "created" as opposed to "time", and refactored the way templates are created (converted from psJSONParams type). Signed-off-by: haircommander <pehunt@redhat.com> Closes: #948 Approved by: rhatdan
Diffstat (limited to 'test')
-rw-r--r--test/e2e/ps_test.go62
1 files changed, 60 insertions, 2 deletions
diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go
index feb0628b3..38b59e1d1 100644
--- a/test/e2e/ps_test.go
+++ b/test/e2e/ps_test.go
@@ -1,10 +1,12 @@
package integration
import (
- "os"
-
"fmt"
+ "os"
+ "regexp"
+ "sort"
+ "github.com/docker/go-units"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -186,4 +188,60 @@ var _ = Describe("Podman ps", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Not(Equal(0)))
})
+
+ It("podman --sort by size", func() {
+ // these images chosen because their size would be sorted differently alphabetically vs
+ // by the size of their virtual fs
+ session := podmanTest.Podman([]string{"run", "docker.io/mattdm/fedora-small", "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ podmanTest.RestoreArtifact(nginx)
+ session = podmanTest.Podman([]string{"run", "-dt", "-P", "docker.io/library/nginx:latest"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"ps", "-a", "--sort=size", "--format", "{{.Size}}"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ sortedArr := session.OutputToStringArray()
+
+ Expect(sort.SliceIsSorted(sortedArr, func(i, j int) bool {
+ r := regexp.MustCompile(`^\S+\s+\(virtual (\S+)\)`)
+ matches1 := r.FindStringSubmatch(sortedArr[i])
+ matches2 := r.FindStringSubmatch(sortedArr[j])
+
+ // sanity check in case an oddly formatted size appears
+ if len(matches1) < 2 || len(matches2) < 2 {
+ return sortedArr[i] < sortedArr[j]
+ } else {
+ size1, _ := units.FromHumanSize(matches1[1])
+ size2, _ := units.FromHumanSize(matches2[1])
+ return size1 < size2
+ }
+ })).To(BeTrue())
+
+ })
+
+ It("podman --sort by command", func() {
+ session := podmanTest.RunTopContainer("")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ podmanTest.RestoreArtifact(nginx)
+ session = podmanTest.Podman([]string{"run", "-d", fedoraMinimal, "pwd"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"ps", "-a", "--sort=command", "--format", "{{.Command}}"})
+
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ sortedArr := session.OutputToStringArray()
+
+ Expect(sort.SliceIsSorted(sortedArr, func(i, j int) bool { return sortedArr[i] < sortedArr[j] })).To(BeTrue())
+
+ })
})