Skip to content

Commit

Permalink
*: make TestBatchEvict stable (#8590)
Browse files Browse the repository at this point in the history
close #8560

Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Sep 3, 2024
1 parent 8571ca4 commit cdc86a8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/schedule/schedulers/evict_leader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/tikv/pd/pkg/schedule/types"
"github.com/tikv/pd/pkg/storage"
"github.com/tikv/pd/pkg/utils/operatorutil"
"github.com/tikv/pd/pkg/utils/testutil"
)

func TestEvictLeader(t *testing.T) {
Expand Down Expand Up @@ -115,7 +116,7 @@ func TestBatchEvict(t *testing.T) {
tc.AddLeaderStore(2, 0)
tc.AddLeaderStore(3, 0)
// the random might be the same, so we add 1000 regions to make sure the batch is full
for i := 1; i <= 1000; i++ {
for i := 1; i <= 10000; i++ {
tc.AddLeaderRegion(uint64(i), 1, 2, 3)
}
tc.AddLeaderRegion(6, 2, 1, 3)
Expand All @@ -124,9 +125,13 @@ func TestBatchEvict(t *testing.T) {
sl, err := CreateScheduler(types.EvictLeaderScheduler, oc, storage.NewStorageWithMemoryBackend(), ConfigSliceDecoder(types.EvictLeaderScheduler, []string{"1"}), func(string) error { return nil })
re.NoError(err)
re.True(sl.IsScheduleAllowed(tc))
ops, _ := sl.Schedule(tc, false)
re.Len(ops, 3)
testutil.Eventually(re, func() bool {
ops, _ := sl.Schedule(tc, false)
return len(ops) == 3
})
sl.(*evictLeaderScheduler).conf.Batch = 5
ops, _ = sl.Schedule(tc, false)
re.Len(ops, 5)
testutil.Eventually(re, func() bool {
ops, _ := sl.Schedule(tc, false)
return len(ops) == 5
})
}

0 comments on commit cdc86a8

Please sign in to comment.