1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #35844 from thaJeztah/remove-test-events-limit

Remove TestEventsLimit(), and minor cleanups
This commit is contained in:
Vincent Demeester 2017-12-22 09:23:19 +01:00 committed by GitHub
commit c753095bf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 54 deletions

View file

@ -28,7 +28,7 @@ func New() *Events {
}
}
// Subscribe adds new listener to events, returns slice of 64 stored
// Subscribe adds new listener to events, returns slice of 256 stored
// last events, a channel in which you can expect new events (in form
// of interface{}, so you need type assertion), and a function to call
// to stop the stream of events.
@ -46,7 +46,7 @@ func (e *Events) Subscribe() ([]eventtypes.Message, chan interface{}, func()) {
return current, l, cancel
}
// SubscribeTopic adds new listener to events, returns slice of 64 stored
// SubscribeTopic adds new listener to events, returns slice of 256 stored
// last events, a channel in which you can expect new events (in form
// of interface{}, so you need type assertion).
func (e *Events) SubscribeTopic(since, until time.Time, ef *Filter) ([]eventtypes.Message, chan interface{}) {

View file

@ -135,21 +135,28 @@ func TestLogEvents(t *testing.T) {
t.Fatalf("Must be %d events, got %d", eventsLimit, len(current))
}
first := current[0]
if first.Status != "action_16" {
t.Fatalf("First action is %s, must be action_16", first.Status)
// TODO remove this once we removed the deprecated `ID`, `Status`, and `From` fields
if first.Action != first.Status {
// Verify that the (deprecated) Status is set to the expected value
t.Fatalf("Action (%s) does not match Status (%s)", first.Action, first.Status)
}
if first.Action != "action_16" {
t.Fatalf("First action is %s, must be action_16", first.Action)
}
last := current[len(current)-1]
if last.Status != "action_271" {
t.Fatalf("Last action is %s, must be action_271", last.Status)
if last.Action != "action_271" {
t.Fatalf("Last action is %s, must be action_271", last.Action)
}
firstC := msgs[0]
if firstC.Status != "action_272" {
t.Fatalf("First action is %s, must be action_272", firstC.Status)
if firstC.Action != "action_272" {
t.Fatalf("First action is %s, must be action_272", firstC.Action)
}
lastC := msgs[len(msgs)-1]
if lastC.Status != "action_281" {
t.Fatalf("Last action is %s, must be action_281", lastC.Status)
if lastC.Action != "action_281" {
t.Fatalf("Last action is %s, must be action_281", lastC.Action)
}
}

View file

@ -81,50 +81,6 @@ func (s *DockerSuite) TestEventsUntag(c *check.C) {
}
}
func (s *DockerSuite) TestEventsLimit(c *check.C) {
// Windows: Limit to 4 goroutines creating containers in order to prevent
// timeouts creating so many containers simultaneously. This is a due to
// a bug in the Windows platform. It will be fixed in a Windows Update.
numContainers := 17
eventPerContainer := 7 // create, attach, network connect, start, die, network disconnect, destroy
numConcurrentContainers := numContainers
if testEnv.DaemonPlatform() == "windows" {
numConcurrentContainers = 4
}
sem := make(chan bool, numConcurrentContainers)
errChan := make(chan error, numContainers)
startTime := daemonUnixTime(c)
args := []string{"run", "--rm", "busybox", "true"}
for i := 0; i < numContainers; i++ {
sem <- true
go func(i int) {
defer func() { <-sem }()
out, err := exec.Command(dockerBinary, args...).CombinedOutput()
if err != nil {
err = fmt.Errorf("%v: %s", err, string(out))
}
errChan <- err
}(i)
}
// Wait for all goroutines to finish
for i := 0; i < cap(sem); i++ {
sem <- true
}
close(errChan)
for err := range errChan {
c.Assert(err, checker.IsNil, check.Commentf("%q failed with error", strings.Join(args, " ")))
}
out, _ := dockerCmd(c, "events", "--since="+startTime, "--until", daemonUnixTime(c))
events := strings.Split(out, "\n")
nEvents := len(events) - 1
c.Assert(nEvents, checker.Equals, numContainers*eventPerContainer, check.Commentf("events should be limited to 256, but received %d", nEvents))
}
func (s *DockerSuite) TestEventsContainerEvents(c *check.C) {
dockerCmd(c, "run", "--rm", "--name", "container-events-test", "busybox", "true")