From ba1871dac033783ab0329c9b3c9113a34a90992f Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Thu, 19 Jul 2018 14:41:58 +0200 Subject: podman-top: use containers/psgo Use github.com/containers/psgo instead of execing `ps (1)`. The psgo library enables a much more flexible interface with respect to which data to be printed (e.g., capabilities, seccomp mode, PID, PCPU, etc.) while the output can be parsed reliably. The library does not use ps (1) but parses /proc and /dev instead. To list the processes of a given container, psgo will join the mount namespace of the given container and extract all data from there. Notice that this commit breaks compatibility with docker-top. Signed-off-by: Valentin Rothberg Closes: #1113 Approved by: rhatdan --- test/e2e/top_test.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'test/e2e') diff --git a/test/e2e/top_test.go b/test/e2e/top_test.go index e7ac90219..d26a19ba4 100644 --- a/test/e2e/top_test.go +++ b/test/e2e/top_test.go @@ -59,32 +59,24 @@ var _ = Describe("Podman top", func() { Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) }) - // XXX(ps-issue): for the time being, podman-top and the libpod API - // GetContainerPidInformation(...) will ignore any arguments passed to ps, - // so we have to disable the tests below. Please refer to - // https://github.com/projectatomic/libpod/pull/939 for more background - // information. - It("podman top with options", func() { - Skip("podman-top with options: options are temporarily ignored") 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", "pid,fuser,f,comm,label"}) + result := podmanTest.Podman([]string{"top", session.OutputToString(), "pid", "%C", "args"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) Expect(len(result.OutputToStringArray())).To(BeNumerically(">", 1)) }) It("podman top on container invalid options", func() { - Skip("podman-top with invalid options: options are temporarily ignored") top := podmanTest.RunTopContainer("") top.WaitWithDefaultTimeout() Expect(top.ExitCode()).To(Equal(0)) cid := top.OutputToString() - result := podmanTest.Podman([]string{"top", cid, "-o time"}) + result := podmanTest.Podman([]string{"top", cid, "invalid"}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(125)) }) -- cgit v1.2.3-54-g00ecf