Skip to content

Commit

Permalink
make test stable
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Oct 30, 2024
1 parent 760bcce commit fc71a95
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2886,7 +2886,9 @@ func TestCheckCache(t *testing.T) {

// case 1: operator cannot be created due to replica-schedule-limit restriction
checker.PatrolRegions()
re.True(checker.IsPatrolRegionChanEmpty())
testutil.Eventually(re, func() bool {
return checker.IsPatrolRegionChanEmpty()
})
re.Empty(oc.GetOperators())
re.Len(checker.GetPendingProcessedRegions(), 1)

Expand All @@ -2895,22 +2897,28 @@ func TestCheckCache(t *testing.T) {
cfg.ReplicaScheduleLimit = 10
tc.SetScheduleConfig(cfg)
checker.PatrolRegions()
re.True(checker.IsPatrolRegionChanEmpty())
testutil.Eventually(re, func() bool {
return checker.IsPatrolRegionChanEmpty()
})
re.Len(oc.GetOperators(), 1)
re.Empty(checker.GetPendingProcessedRegions())

// case 2: operator cannot be created due to store limit restriction
oc.RemoveOperator(oc.GetOperator(1))
tc.SetStoreLimit(1, storelimit.AddPeer, 0)
checker.PatrolRegions()
re.True(checker.IsPatrolRegionChanEmpty())
testutil.Eventually(re, func() bool {
return checker.IsPatrolRegionChanEmpty()
})
re.Len(checker.GetPendingProcessedRegions(), 1)

// cancel the store limit restriction
tc.SetStoreLimit(1, storelimit.AddPeer, 10)
time.Sleep(time.Second)
checker.PatrolRegions()
re.True(checker.IsPatrolRegionChanEmpty())
testutil.Eventually(re, func() bool {
return checker.IsPatrolRegionChanEmpty()
})
re.Len(oc.GetOperators(), 1)
re.Empty(checker.GetPendingProcessedRegions())

Expand Down Expand Up @@ -2949,6 +2957,7 @@ func TestPatrolRegionConcurrency(t *testing.T) {
re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/schedule/checker/breakPatrol", `return`))
checker.PatrolRegions()
testutil.Eventually(re, func() bool {
fmt.Println(len(oc.GetOperators()))
return len(oc.GetOperators()) >= mergeScheduleLimit
})
checkOperatorDuplicate(re, oc.GetOperators())
Expand Down

0 comments on commit fc71a95

Please sign in to comment.