From a3056f9f72baf71655a47ac5b891c892d0174ac4 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Fri, 11 Dec 2015 16:06:24 -0500 Subject: [PATCH] Log events stream when TestEventStreaming fails. Let the tag event some more time to be emitted. Signed-off-by: David Calavera --- integration-cli/docker_cli_build_test.go | 2 +- integration-cli/docker_cli_events_test.go | 28 +++++++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index c9ed8ebe50..8db301376d 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -6449,7 +6449,7 @@ func (s *DockerSuite) TestBuildTagEvent(c *check.C) { case ev := <-ch: c.Assert(ev.Status, check.Equals, "tag") c.Assert(ev.ID, check.Equals, "test:latest") - case <-time.After(time.Second): + case <-time.After(5 * time.Second): c.Fatal("The 'tag' event not heard from the server") } } diff --git a/integration-cli/docker_cli_events_test.go b/integration-cli/docker_cli_events_test.go index cd4ad54382..23028a5b2d 100644 --- a/integration-cli/docker_cli_events_test.go +++ b/integration-cli/docker_cli_events_test.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "bytes" "fmt" "io/ioutil" "net/http" @@ -434,24 +435,27 @@ func (s *DockerSuite) TestEventsStreaming(c *check.C) { c.Assert(eventsCmd.Start(), checker.IsNil, check.Commentf("failed to start 'docker events'")) defer eventsCmd.Process.Kill() + buffer := new(bytes.Buffer) go func() { containerID := <-id - matchCreate := regexp.MustCompile(containerID + `: \(from busybox:latest\) create$`) - matchStart := regexp.MustCompile(containerID + `: \(from busybox:latest\) start$`) - matchDie := regexp.MustCompile(containerID + `: \(from busybox:latest\) die$`) - matchDestroy := regexp.MustCompile(containerID + `: \(from busybox:latest\) destroy$`) + matchCreate := regexp.MustCompile(containerID + `: \(from busybox:latest\) create\z`) + matchStart := regexp.MustCompile(containerID + `: \(from busybox:latest\) start\z`) + matchDie := regexp.MustCompile(containerID + `: \(from busybox:latest\) die\z`) + matchDestroy := regexp.MustCompile(containerID + `: \(from busybox:latest\) destroy\z`) scanner := bufio.NewScanner(stdout) for scanner.Scan() { + text := scanner.Text() + buffer.WriteString(text + "\n") switch { - case matchCreate.MatchString(scanner.Text()): + case matchCreate.MatchString(text): close(eventCreate) - case matchStart.MatchString(scanner.Text()): + case matchStart.MatchString(text): close(eventStart) - case matchDie.MatchString(scanner.Text()): + case matchDie.MatchString(text): close(eventDie) - case matchDestroy.MatchString(scanner.Text()): + case matchDestroy.MatchString(text): close(eventDestroy) } } @@ -463,21 +467,21 @@ func (s *DockerSuite) TestEventsStreaming(c *check.C) { select { case <-time.After(5 * time.Second): - c.Fatal("failed to observe container create in timely fashion") + c.Fatal("failed to observe container create in timely fashion", "\n", buffer.String()) case <-eventCreate: // ignore, done } select { case <-time.After(5 * time.Second): - c.Fatal("failed to observe container start in timely fashion") + c.Fatal("failed to observe container start in timely fashion", "\n", buffer.String()) case <-eventStart: // ignore, done } select { case <-time.After(5 * time.Second): - c.Fatal("failed to observe container die in timely fashion") + c.Fatal("failed to observe container die in timely fashion", "\n", buffer.String()) case <-eventDie: // ignore, done } @@ -486,7 +490,7 @@ func (s *DockerSuite) TestEventsStreaming(c *check.C) { select { case <-time.After(5 * time.Second): - c.Fatal("failed to observe container destroy in timely fashion") + c.Fatal("failed to observe container destroy in timely fashion", "\n", buffer.String()) case <-eventDestroy: // ignore, done }