Add hint of progress to the output of docker build

This fix tries to address the issue raised in 24912 where docker
build only consists of the current step without overall total steps.

This fix adds the overall total steps so that end user could follow
the progress of the docker build.

An additonal test has been added to cover the changes.

This fix fixes 24912.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 35418c145518c3f816ae5837beda7d853ce96dfc
Component: engine
This commit is contained in:
Yong Tang
2016-07-24 08:13:58 -07:00
parent 7319473b2d
commit 48c6a8f86f
5 changed files with 24 additions and 8 deletions
@@ -5402,7 +5402,7 @@ func (s *DockerSuite) TestBuildNoDupOutput(c *check.C) {
c.Fatalf("Build should have worked: %q", err)
}
exp := "\nStep 2 : RUN env\n"
exp := "\nStep 2/2 : RUN env\n"
if !strings.Contains(out, exp) {
c.Fatalf("Bad output\nGot:%s\n\nExpected to contain:%s\n", out, exp)
}
@@ -5419,7 +5419,7 @@ func (s *DockerSuite) TestBuildStartsFromOne(c *check.C) {
c.Fatalf("Build should have worked: %q", err)
}
exp := "\nStep 1 : FROM busybox\n"
exp := "\nStep 1/1 : FROM busybox\n"
if !strings.Contains(out, exp) {
c.Fatalf("Bad output\nGot:%s\n\nExpected to contain:%s\n", out, exp)
}
@@ -6967,3 +6967,16 @@ func (s *DockerSuite) TestBuildCmdShellArgsEscaped(c *check.C) {
c.Fatalf("CMD was not escaped Config.Cmd: got %v", res)
}
}
// Test case for #24912.
func (s *DockerSuite) TestBuildStepsWithProgress(c *check.C) {
name := "testbuildstepswithprogress"
totalRun := 5
_, out, err := buildImageWithOut(name, "FROM busybox\n"+strings.Repeat("RUN echo foo\n", totalRun), true)
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, fmt.Sprintf("Step 1/%d : FROM busybox", 1+totalRun))
for i := 2; i <= 1+totalRun; i++ {
c.Assert(out, checker.Contains, fmt.Sprintf("Step %d/%d : RUN echo foo", i, 1+totalRun))
}
}