mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Log events stream when TestEventStreaming fails.
Let the tag event some more time to be emitted. Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
parent
5525593a68
commit
a3056f9f72
2 changed files with 17 additions and 13 deletions
|
@ -6449,7 +6449,7 @@ func (s *DockerSuite) TestBuildTagEvent(c *check.C) {
|
||||||
case ev := <-ch:
|
case ev := <-ch:
|
||||||
c.Assert(ev.Status, check.Equals, "tag")
|
c.Assert(ev.Status, check.Equals, "tag")
|
||||||
c.Assert(ev.ID, check.Equals, "test:latest")
|
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")
|
c.Fatal("The 'tag' event not heard from the server")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"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'"))
|
c.Assert(eventsCmd.Start(), checker.IsNil, check.Commentf("failed to start 'docker events'"))
|
||||||
defer eventsCmd.Process.Kill()
|
defer eventsCmd.Process.Kill()
|
||||||
|
|
||||||
|
buffer := new(bytes.Buffer)
|
||||||
go func() {
|
go func() {
|
||||||
containerID := <-id
|
containerID := <-id
|
||||||
|
|
||||||
matchCreate := regexp.MustCompile(containerID + `: \(from busybox:latest\) create$`)
|
matchCreate := regexp.MustCompile(containerID + `: \(from busybox:latest\) create\z`)
|
||||||
matchStart := regexp.MustCompile(containerID + `: \(from busybox:latest\) start$`)
|
matchStart := regexp.MustCompile(containerID + `: \(from busybox:latest\) start\z`)
|
||||||
matchDie := regexp.MustCompile(containerID + `: \(from busybox:latest\) die$`)
|
matchDie := regexp.MustCompile(containerID + `: \(from busybox:latest\) die\z`)
|
||||||
matchDestroy := regexp.MustCompile(containerID + `: \(from busybox:latest\) destroy$`)
|
matchDestroy := regexp.MustCompile(containerID + `: \(from busybox:latest\) destroy\z`)
|
||||||
|
|
||||||
scanner := bufio.NewScanner(stdout)
|
scanner := bufio.NewScanner(stdout)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
|
text := scanner.Text()
|
||||||
|
buffer.WriteString(text + "\n")
|
||||||
switch {
|
switch {
|
||||||
case matchCreate.MatchString(scanner.Text()):
|
case matchCreate.MatchString(text):
|
||||||
close(eventCreate)
|
close(eventCreate)
|
||||||
case matchStart.MatchString(scanner.Text()):
|
case matchStart.MatchString(text):
|
||||||
close(eventStart)
|
close(eventStart)
|
||||||
case matchDie.MatchString(scanner.Text()):
|
case matchDie.MatchString(text):
|
||||||
close(eventDie)
|
close(eventDie)
|
||||||
case matchDestroy.MatchString(scanner.Text()):
|
case matchDestroy.MatchString(text):
|
||||||
close(eventDestroy)
|
close(eventDestroy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,21 +467,21 @@ func (s *DockerSuite) TestEventsStreaming(c *check.C) {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(5 * time.Second):
|
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:
|
case <-eventCreate:
|
||||||
// ignore, done
|
// ignore, done
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(5 * time.Second):
|
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:
|
case <-eventStart:
|
||||||
// ignore, done
|
// ignore, done
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(5 * time.Second):
|
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:
|
case <-eventDie:
|
||||||
// ignore, done
|
// ignore, done
|
||||||
}
|
}
|
||||||
|
@ -486,7 +490,7 @@ func (s *DockerSuite) TestEventsStreaming(c *check.C) {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(5 * time.Second):
|
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:
|
case <-eventDestroy:
|
||||||
// ignore, done
|
// ignore, done
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue