Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve matching SyncMatch tests #6084

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove if not needed?

}

// 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
Loading