From 6cb1c31d3f9e575688ace95206898c7fff0c88f9 Mon Sep 17 00:00:00 2001 From: baude Date: Mon, 26 Feb 2018 09:08:19 -0600 Subject: Restrict top output to container's pids only Due to the way ps arguments work, it was possible to display pids that dont below to the container in top output. We now filter pids that dont belong to the container out of the output. This also means the pid column must be present in the output or we throw an error. This resolves issue #391 Signed-off-by: baude Closes: #400 Approved by: rhatdan --- test/e2e/top_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'test/e2e') diff --git a/test/e2e/top_test.go b/test/e2e/top_test.go index d4438293b..410803353 100644 --- a/test/e2e/top_test.go +++ b/test/e2e/top_test.go @@ -59,14 +59,26 @@ var _ = Describe("Podman top", func() { Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) }) - It("podman top on non-running container", func() { + It("podman top with 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(), "-o", "fuser,f,comm,label"}) + result := podmanTest.Podman([]string{"top", session.OutputToString(), "-o", "pid,fuser,f,comm,label"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) }) + + It("podman top on container invalid options", func() { + sleep := podmanTest.RunSleepContainer("") + sleep.WaitWithDefaultTimeout() + Expect(sleep.ExitCode()).To(Equal(0)) + cid := sleep.OutputToString() + + result := podmanTest.Podman([]string{"top", cid, "-o time"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(125)) + }) + }) -- cgit v1.2.3-54-g00ecf