From 3e6470e783b694e1ff7ee8aa5cf919e8f62a526c Mon Sep 17 00:00:00 2001 From: Fengtu Wang Date: Thu, 6 Apr 2017 16:33:49 +0800 Subject: [PATCH] fix TestExecWithUserAfterLiveRestore When container's status is running, shell command may have not executed end. So if we use 'docker exec -u test' to execute command, it may fail since user 'test' have not be added yet. Signed-off-by: Fengtu Wang Upstream-commit: c7c6167bcad5133dc94f7173cb40f3d974ef8a36 Component: engine --- components/engine/integration-cli/docker_cli_daemon_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/engine/integration-cli/docker_cli_daemon_test.go b/components/engine/integration-cli/docker_cli_daemon_test.go index 53bc45e8f2..fcd36ca481 100644 --- a/components/engine/integration-cli/docker_cli_daemon_test.go +++ b/components/engine/integration-cli/docker_cli_daemon_test.go @@ -2788,11 +2788,15 @@ func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *check.C) { testRequires(c, DaemonIsLinux) s.d.StartWithBusybox(c, "--live-restore") - out, err := s.d.Cmd("run", "-d", "--name=top", "busybox", "sh", "-c", "addgroup -S test && adduser -S -G test test -D -s /bin/sh && top") + out, err := s.d.Cmd("run", "-d", "--name=top", "busybox", "sh", "-c", "addgroup -S test && adduser -S -G test test -D -s /bin/sh && touch /adduser_end && top") c.Assert(err, check.IsNil, check.Commentf("Output: %s", out)) s.d.WaitRun("top") + // Wait for shell command to be completed + _, err = s.d.Cmd("exec", "top", "sh", "-c", `for i in $(seq 1 5); do if [ -e /adduser_end ]; then rm -f /adduser_end && break; else sleep 1 && false; fi; done`) + c.Assert(err, check.IsNil, check.Commentf("Timeout waiting for shell command to be completed")) + out1, err := s.d.Cmd("exec", "-u", "test", "top", "id") // uid=100(test) gid=101(test) groups=101(test) c.Assert(err, check.IsNil, check.Commentf("Output: %s", out1))