From: Tom Clegg Date: Fri, 30 Jun 2017 13:48:31 +0000 (-0400) Subject: 11910: Ensure test passes despite race between old and new events. X-Git-Tag: 1.1.0~163^2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/21a3b4fb25cc8eef7f38fa8cb699e1f3ded92846 11910: Ensure test passes despite race between old and new events. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- 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{}{} } }() }