diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2019-04-29 11:21:55 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2019-05-03 11:20:16 +0200 |
commit | 0d2d52339058a19e66ecc75f78c52596054c7dad (patch) | |
tree | 73636772d105d249a996ee145b0afd48fddf16ab /test/e2e/top_test.go | |
parent | d9d9c82184ad6d7e3fad07dfe2e99b158560d3a8 (diff) | |
download | podman-0d2d52339058a19e66ecc75f78c52596054c7dad.tar.gz podman-0d2d52339058a19e66ecc75f78c52596054c7dad.tar.bz2 podman-0d2d52339058a19e66ecc75f78c52596054c7dad.zip |
top: fallback to execing ps(1)
Fallback to executing ps(1) in case we hit an unknown psgo descriptor.
This ensures backwards compatibility with docker-top, which was purely
ps(1) driven.
Also support comma-separated descriptors as input.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'test/e2e/top_test.go')
-rw-r--r-- | test/e2e/top_test.go | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/test/e2e/top_test.go b/test/e2e/top_test.go index 2d3a5629c..4c2cdb7b5 100644 --- a/test/e2e/top_test.go +++ b/test/e2e/top_test.go @@ -87,13 +87,39 @@ var _ = Describe("Podman top", func() { Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) }) + It("podman top with ps(1) options", func() { + session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top", "-d", "2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"top", session.OutputToString(), "aux"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) + }) + + It("podman top with comma-separated options", func() { + session := podmanTest.Podman([]string{"run", "-d", ALPINE, "top", "-d", "2"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"top", session.OutputToString(), "user,pid,comm"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) + }) + It("podman top on container invalid options", func() { top := podmanTest.RunTopContainer("") top.WaitWithDefaultTimeout() Expect(top.ExitCode()).To(Equal(0)) cid := top.OutputToString() - result := podmanTest.Podman([]string{"top", cid, "invalid"}) + // We need to pass -eo to force executing ps in the Alpine container. + // Alpines stripped down ps(1) is accepting any kind of weird input in + // contrast to others, such that a `ps invalid` will silently ignore + // the wrong input and still print the -ef output instead. + result := podmanTest.Podman([]string{"top", cid, "-eo", "invalid"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(125)) }) |