From 21a3b4fb25cc8eef7f38fa8cb699e1f3ded92846 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Fri, 30 Jun 2017 09:48:31 -0400 Subject: [PATCH] 11910: Ensure test passes despite race between old and new events. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- services/ws/session_v0_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/ws/session_v0_test.go b/services/ws/session_v0_test.go index 4a2da8012d..1213be5d14 100644 --- a/services/ws/session_v0_test.go +++ b/services/ws/session_v0_test.go @@ -83,7 +83,15 @@ func (s *v0Suite) TestLastLogID(c *check.C) { }), check.IsNil) s.expectStatus(c, r, 200) + avoidRace := make(chan struct{}, cap(uuidChan)) go func() { + // When last_log_id is given, although v0session sends + // old events in order, and sends new events in order, + // it doesn't necessarily finish sending all old + // events before sending any new events. To avoid + // hitting this bug in the test, we wait for the old + // events to arrive before emitting any new events. + <-avoidRace s.emitEvents(uuidChan) close(uuidChan) }() @@ -97,6 +105,7 @@ func (s *v0Suite) TestLastLogID(c *check.C) { } c.Check(lg.EventType, check.Equals, etype) } + avoidRace <- struct{}{} } }() } -- 2.30.2