Skip to content

Commit

Permalink
tests/label: use eventually to make sure label equal (#7949)
Browse files Browse the repository at this point in the history
ref #7930

Signed-off-by: husharp <jinhao.hu@pingcap.com>
  • Loading branch information
HuSharp authored Mar 20, 2024
1 parent b0c49fa commit b5c56b6
Showing 1 changed file with 5 additions and 2 deletions.
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

0 comments on commit b5c56b6

Please sign in to comment.