mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
TestContainerAPITop: fix flakyness
The following failure is seen in CI from time to time: > FAIL: docker_api_containers_test.go:435: DockerSuite.TestContainerAPITop > > docker_api_containers_test.go:453: > c.Assert(top.Processes[0][10], checker.Equals, "/bin/sh -c top") > ... obtained string = "top" > ... expected string = "/bin/sh -c top" The test case expects two processes in the output: 1. /bin/sh -c top 2. top in the given order. Now, "ps aux" output is sorted by PID*, and so since the "top" is a child of "/bin/sh -c top" it has a higher PID and will come second as expected by the test... unless the PIDs on the system are exhausted and PID rollover happens, in which case PID of "top" will be lower than that of "/bin/sh". Fix: sort output by process name. * - in fact it is not sorted, but is being printed in the same order as the kernel list PID entries in /proc directory, which appears to be sorted by PID (see ls -1 -U /proc). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
bcaf891369
commit
0823ab7099
1 changed files with 2 additions and 1 deletions
|
@ -442,7 +442,8 @@ func (s *DockerSuite) TestContainerAPITop(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
top, err := cli.ContainerTop(context.Background(), id, []string{"aux"})
|
||||
// sort by comm[andline] to make sure order stays the same in case of PID rollover
|
||||
top, err := cli.ContainerTop(context.Background(), id, []string{"aux", "--sort=comm"})
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(top.Titles, checker.HasLen, 11, check.Commentf("expected 11 titles, found %d: %v", len(top.Titles), top.Titles))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue