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

tests/label: use eventually to make sure label equal #7949

Merged
merged 1 commit into from
Mar 20, 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
7 changes: 5 additions & 2 deletions pkg/schedule/labeler/labeler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/tikv/pd/pkg/storage/endpoint"
"github.com/tikv/pd/pkg/storage/kv"
"github.com/tikv/pd/pkg/utils/etcdutil"
"github.com/tikv/pd/pkg/utils/testutil"
)

func TestAdjustRule(t *testing.T) {
Expand Down Expand Up @@ -382,8 +383,10 @@ func TestLabelerRuleTTL(t *testing.T) {
re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/schedule/labeler/regionLabelExpireSub1Minute", "return(true)"))

// rule2 should expire and only 2 labels left.
labels := labeler.GetRegionLabels(region)
re.Len(labels, 2)
testutil.Eventually(re, func() bool {
labels := labeler.GetRegionLabels(region)
return len(labels) == 2
})

re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/schedule/labeler/regionLabelExpireSub1Minute"))
// rule2 should be existed since `GetRegionLabels` won't clear it physically.
Expand Down
Loading