Browse Source

Merge pull request #32463 from FengtuWang/fix_TestExecWithUserAfterLiveRestore2

fix TestExecWithUserAfterLiveRestore
Victor Vieux 8 years ago
parent
commit
bc4560e512
1 changed files with 5 additions and 1 deletions
  1. 5 1
      integration-cli/docker_cli_daemon_test.go

+ 5 - 1
integration-cli/docker_cli_daemon_test.go

@@ -2804,11 +2804,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))