Browse code

Fix events test flakiness.

Since channel is getting a send instead of a close now, this can cause
random issues ranging through the list of channels if the channel is
unbuffered since the send may be blocked.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>

Brian Goff authored on 2016/02/19 06:10:29
Showing 3 changed files
... ...
@@ -265,8 +265,8 @@ func (s *DockerAuthzSuite) TestAuthZPluginAllowEventStream(c *check.C) {
265 265
 	c.Assert(s.d.waitRun(containerID), checker.IsNil)
266 266
 
267 267
 	events := map[string]chan bool{
268
-		"create": make(chan bool),
269
-		"start":  make(chan bool),
268
+		"create": make(chan bool, 1),
269
+		"start":  make(chan bool, 1),
270 270
 	}
271 271
 
272 272
 	matcher := matchEventLine(containerID, "container", events)
... ...
@@ -277,7 +277,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginAllowEventStream(c *check.C) {
277 277
 	for event, eventChannel := range events {
278 278
 
279 279
 		select {
280
-		case <-time.After(5 * time.Second):
280
+		case <-time.After(30 * time.Second):
281 281
 			// Fail the test
282 282
 			observer.CheckEventError(c, containerID, event, matcher)
283 283
 			c.FailNow()
... ...
@@ -171,8 +171,8 @@ func (s *DockerSuite) TestBuildCancellationKillsSleep(c *check.C) {
171 171
 	}
172 172
 
173 173
 	testActions := map[string]chan bool{
174
-		"start": make(chan bool),
175
-		"die":   make(chan bool),
174
+		"start": make(chan bool, 1),
175
+		"die":   make(chan bool, 1),
176 176
 	}
177 177
 
178 178
 	matcher := matchEventLine(buildID, "container", testActions)
... ...
@@ -232,10 +232,10 @@ func (s *DockerSuite) TestEventsStreaming(c *check.C) {
232 232
 	containerID := strings.TrimSpace(out)
233 233
 
234 234
 	testActions := map[string]chan bool{
235
-		"create":  make(chan bool),
236
-		"start":   make(chan bool),
237
-		"die":     make(chan bool),
238
-		"destroy": make(chan bool),
235
+		"create":  make(chan bool, 1),
236
+		"start":   make(chan bool, 1),
237
+		"die":     make(chan bool, 1),
238
+		"destroy": make(chan bool, 1),
239 239
 	}
240 240
 
241 241
 	matcher := matchEventLine(containerID, "container", testActions)
... ...
@@ -291,8 +291,8 @@ func (s *DockerSuite) TestEventsImageUntagDelete(c *check.C) {
291 291
 	c.Assert(deleteImages(name), checker.IsNil)
292 292
 
293 293
 	testActions := map[string]chan bool{
294
-		"untag":  make(chan bool),
295
-		"delete": make(chan bool),
294
+		"untag":  make(chan bool, 1),
295
+		"delete": make(chan bool, 1),
296 296
 	}
297 297
 
298 298
 	matcher := matchEventLine(imageID, "image", testActions)