Skip to content

Commit

Permalink
Improve matching SyncMatch tests (cadence-workflow#6084)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaddoll authored Jun 3, 2024
1 parent 0667205 commit 4cc5736
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions service/matching/handler/engine_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestMatchingEngineSuite(t *testing.T) {
}

func (s *matchingEngineSuite) SetupSuite() {
http.Handle("/test/tasks", http.HandlerFunc(s.TasksHandler))
// http.Handle("/test/tasks", http.HandlerFunc(s.TasksHandler))
}

// Renders content of taskManager and matchingEngine when called at http://localhost:6060/test/tasks
Expand Down Expand Up @@ -545,7 +545,7 @@ func (s *matchingEngineSuite) SyncMatchTasks(taskType int, enableIsolation bool)
isolationGroups := s.matchingEngine.config.AllIsolationGroups

// Set a short long poll expiration so we don't have to wait too long for 0 throttling cases
s.matchingEngine.config.LongPollExpirationInterval = dynamicconfig.GetDurationPropertyFnFilteredByTaskListInfo(50 * time.Millisecond)
s.matchingEngine.config.LongPollExpirationInterval = dynamicconfig.GetDurationPropertyFnFilteredByTaskListInfo(200 * time.Millisecond)
s.matchingEngine.config.RangeSize = rangeSize // override to low number for the test
s.matchingEngine.config.TaskDispatchRPSTTL = time.Nanosecond
s.matchingEngine.config.MinTaskThrottlingBurstSize = dynamicconfig.GetIntPropertyFilteredByTaskListInfo(_minBurst)
Expand Down Expand Up @@ -599,6 +599,8 @@ func (s *matchingEngineSuite) SyncMatchTasks(taskType int, enableIsolation bool)
s.NotNil(result)
s.assertPollTaskResponse(taskType, testParam, scheduleID, result)
}
// expect more than half of the tasks get sync matches
s.True(s.taskManager.GetCreateTaskCount(testParam.TaskListID) < taskCount/2)

// Set the dispatch RPS to 0, to verify that poller will not get any task and task will be persisted into database
// Revert the dispatch RPS and verify that poller will get the task
Expand Down Expand Up @@ -631,19 +633,14 @@ func (s *matchingEngineSuite) SyncMatchTasks(taskType int, enableIsolation bool)
// when ratelimit is set to zero, poller is expected to return empty result
// reset ratelimit, poll again and make sure task is returned this time
s.True(isEmptyToken(result.TaskToken))
wg.Add(1)
go func() {
defer wg.Done()
result, pollErr = pollFunc(_defaultTaskDispatchRPS, group)
}()
wg.Wait()
result, pollErr = pollFunc(_defaultTaskDispatchRPS, group)
s.NoError(err)
s.NoError(pollErr)
s.NotNil(result)
s.False(isEmptyToken(result.TaskToken))
s.assertPollTaskResponse(taskType, testParam, scheduleID, result)
}
s.EqualValues(throttledTaskCount, s.taskManager.GetCreateTaskCount(testParam.TaskListID))
s.True(int(throttledTaskCount) <= s.taskManager.GetCreateTaskCount(testParam.TaskListID))
s.EqualValues(0, s.taskManager.GetTaskCount(testParam.TaskListID))
expectedRange := getExpectedRange(initialRangeID, int(taskCount+throttledTaskCount), rangeSize)
// Due to conflicts some ids are skipped and more real ranges are used.
Expand Down

0 comments on commit 4cc5736

Please sign in to comment.