Skip to content

Commit

Permalink
tests: make schedulerTestSuite stable (#8670)
Browse files Browse the repository at this point in the history
ref #4399

Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 authored Sep 25, 2024
1 parent f3e9d9a commit 8e9443a
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions tools/pd-ctl/tests/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ func (suite *schedulerTestSuite) TearDownTest() {
suite.env.Cleanup()
}

func (suite *schedulerTestSuite) checkDefaultSchedulers(re *require.Assertions, cmd *cobra.Command, pdAddr string) {
expected := make(map[string]bool)
for _, scheduler := range suite.defaultSchedulers {
expected[scheduler] = true
}
checkSchedulerCommand(re, cmd, pdAddr, nil, expected)
}

func (suite *schedulerTestSuite) TestScheduler() {
suite.env.RunTestBasedOnMode(suite.checkScheduler)
}
Expand Down Expand Up @@ -152,18 +160,11 @@ func (suite *schedulerTestSuite) checkScheduler(cluster *pdTests.TestCluster) {
// note: because pdqsort is a unstable sort algorithm, set ApproximateSize for this region.
pdTests.MustPutRegion(re, cluster, 1, 1, []byte("a"), []byte("b"), core.SetApproximateSize(10))

// scheduler show command
expected := map[string]bool{
"balance-region-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
"evict-slow-store-scheduler": true,
}
checkSchedulerCommand(re, cmd, pdAddr, nil, expected)
suite.checkDefaultSchedulers(re, cmd, pdAddr)

// scheduler delete command
args := []string{"-u", pdAddr, "scheduler", "remove", "balance-region-scheduler"}
expected = map[string]bool{
expected := map[string]bool{
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
"evict-slow-store-scheduler": true,
Expand Down Expand Up @@ -435,6 +436,8 @@ func (suite *schedulerTestSuite) checkSchedulerConfig(cluster *pdTests.TestClust
// note: because pdqsort is an unstable sort algorithm, set ApproximateSize for this region.
pdTests.MustPutRegion(re, cluster, 1, 1, []byte("a"), []byte("b"), core.SetApproximateSize(10))

suite.checkDefaultSchedulers(re, cmd, pdAddr)

// test evict-slow-store && evict-slow-trend schedulers config
evictSlownessSchedulers := []string{"evict-slow-store-scheduler", "evict-slow-trend-scheduler"}
for _, schedulerName := range evictSlownessSchedulers {
Expand Down Expand Up @@ -620,6 +623,9 @@ func (suite *schedulerTestSuite) checkHotRegionSchedulerConfig(cluster *pdTests.
}
// note: because pdqsort is an unstable sort algorithm, set ApproximateSize for this region.
pdTests.MustPutRegion(re, cluster, 1, 1, []byte("a"), []byte("b"), core.SetApproximateSize(10))

suite.checkDefaultSchedulers(re, cmd, pdAddr)

leaderServer := cluster.GetLeaderServer()
// test hot region config
expected1 := map[string]any{
Expand Down Expand Up @@ -799,6 +805,8 @@ func (suite *schedulerTestSuite) checkSchedulerDiagnostic(cluster *pdTests.TestC
// note: because pdqsort is an unstable sort algorithm, set ApproximateSize for this region.
pdTests.MustPutRegion(re, cluster, 1, 1, []byte("a"), []byte("b"), core.SetApproximateSize(10))

suite.checkDefaultSchedulers(re, cmd, pdAddr)

echo := mustExec(re, cmd, []string{"-u", pdAddr, "config", "set", "enable-diagnostic", "true"}, nil)
re.Contains(echo, "Success!")
checkSchedulerDescribeCommand("balance-region-scheduler", "pending", "1 store(s) RegionNotMatchRule; ")
Expand Down

0 comments on commit 8e9443a

Please sign in to comment.