Skip to content

Commit

Permalink
Fix concurrent activities test
Browse files Browse the repository at this point in the history
  • Loading branch information
madhuravi committed Dec 21, 2017
1 parent c77b1c1 commit 2dff6f6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions service/matching/matchingEngine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,17 +591,17 @@ func (s *matchingEngineSuite) TestConcurrentPublishConsumeActivitiesWithZeroDisp
// Set a short long poll expiration so we don't have to wait too long for 0 throttling cases
s.matchingEngine.config.LongPollExpirationInterval = 20 * time.Millisecond
dispatchLimitFn := func(wc int, tc int64) float64 {
if tc == 0 && wc%5 == 0 { // Gets triggered atleast 4 times
if tc%50 == 0 && wc%5 == 0 { // Gets triggered atleast 20 times
return 0
}
return _defaultTaskDispatchRPS
}
const workerCount = 20
const taskCount = 100
errCt := s.concurrentPublishConsumeActivities(workerCount, taskCount, dispatchLimitFn)
// atleast 4 times from 0 dispatch poll, but quite a bit more until TTL is hit and throttle limit
// is reset
s.True(errCt >= 4 && errCt < (workerCount*int(taskCount)))
// atleast once from 0 dispatch poll, and until TTL is hit at which time throttle limit is reset
// hard to predict exactly how many times, since the atomic.Value load might not have updated.
s.True(errCt >= 1 && errCt < (workerCount*int(taskCount)))
}

func (s *matchingEngineSuite) concurrentPublishConsumeActivities(
Expand Down

0 comments on commit 2dff6f6

Please sign in to comment.