|
@@ -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$`)
|
|
|
|
- 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)
|
|
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
|
|
}
|
|
}
|