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

resource_manager: fix unstable test TestSkipConsumptionForBackgroundJobs #7130

Merged
merged 5 commits into from
Sep 25, 2023
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
14 changes: 10 additions & 4 deletions tests/integrations/mcs/resourcemanager/resource_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ func (suite *resourceManagerClientTestSuite) TestRemoveStaleResourceGroup() {
controller.Stop()
}

func (suite *resourceManagerClientTestSuite) TestSkipConsumptionForBackgroundJobs() {
func (suite *resourceManagerClientTestSuite) TestCheckBackgroundJobs() {
re := suite.Require()
cli := suite.client

Expand All @@ -1226,7 +1226,7 @@ func (suite *resourceManagerClientTestSuite) TestSkipConsumptionForBackgroundJob
c, _ := controller.NewResourceGroupController(suite.ctx, 1, cli, cfg)
c.Start(suite.ctx)

resourceGroupName := suite.initGroups[1].Name
resourceGroupName := suite.initGroups[0].Name
re.False(c.IsBackgroundRequest(suite.ctx, resourceGroupName, "internal_default"))
// test fallback for nil.
re.False(c.IsBackgroundRequest(suite.ctx, resourceGroupName, "internal_lightning"))
Expand Down Expand Up @@ -1257,9 +1257,15 @@ func (suite *resourceManagerClientTestSuite) TestSkipConsumptionForBackgroundJob
re.NoError(err)
re.Contains(resp, "Success!")
// wait for watch event modify.
time.Sleep(time.Millisecond * 100)
testutil.Eventually(re, func() bool {
meta := c.GetActiveResourceGroup("default")
if meta != nil && meta.BackgroundSettings != nil {
return len(meta.BackgroundSettings.JobTypes) == 2
}
return false
}, testutil.WithTickInterval(50*time.Millisecond))

resourceGroupName = suite.initGroups[1].Name
resourceGroupName = suite.initGroups[0].Name
re.False(c.IsBackgroundRequest(suite.ctx, resourceGroupName, "internal_default"))
// test fallback for `"lightning", "ddl"`.
re.True(c.IsBackgroundRequest(suite.ctx, resourceGroupName, "internal_lightning"))
Expand Down