Skip to content

Commit

Permalink
This is an automated cherry-pick of tikv#7765
Browse files Browse the repository at this point in the history
close tikv#4399

Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
rleungx authored and ti-chi-bot committed Dec 11, 2024
1 parent de32e69 commit 2c0d131
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/schedule/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,12 @@ type SchedulerConfig struct {
var DefaultSchedulers = SchedulerConfigs{
{Type: "balance-region"},
{Type: "balance-leader"},
{Type: "balance-witness"},
{Type: "hot-region"},
<<<<<<< HEAD
{Type: "transfer-witness-leader"},
=======
{Type: "evict-slow-store"},
>>>>>>> 5b939c6fc (config: disable witness related schedulers by default (#7765))
}

// IsDefaultScheduler checks whether the scheduler is enable by default.
Expand Down
14 changes: 14 additions & 0 deletions server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3041,8 +3041,12 @@ func TestAddScheduler(t *testing.T) {
re.NoError(controller.RemoveScheduler(schedulers.BalanceLeaderName))
re.NoError(controller.RemoveScheduler(schedulers.BalanceRegionName))
re.NoError(controller.RemoveScheduler(schedulers.HotRegionName))
<<<<<<< HEAD
re.NoError(controller.RemoveScheduler(schedulers.BalanceWitnessName))
re.NoError(controller.RemoveScheduler(schedulers.TransferWitnessLeaderName))
=======
re.NoError(controller.RemoveScheduler(schedulers.EvictSlowStoreName))
>>>>>>> 5b939c6fc (config: disable witness related schedulers by default (#7765))
re.Empty(controller.GetSchedulerNames())

stream := mockhbstream.NewHeartbeatStream()
Expand Down Expand Up @@ -3137,9 +3141,15 @@ func TestPersistScheduler(t *testing.T) {
re.NoError(controller.RemoveScheduler(schedulers.BalanceLeaderName))
re.NoError(controller.RemoveScheduler(schedulers.BalanceRegionName))
re.NoError(controller.RemoveScheduler(schedulers.HotRegionName))
<<<<<<< HEAD
re.NoError(controller.RemoveScheduler(schedulers.BalanceWitnessName))
re.NoError(controller.RemoveScheduler(schedulers.TransferWitnessLeaderName))
re.Len(controller.GetSchedulerNames(), defaultCount-3)
=======
re.NoError(controller.RemoveScheduler(schedulers.EvictSlowStoreName))
// only remains 2 items with independent config.
re.Len(controller.GetSchedulerNames(), 2)
>>>>>>> 5b939c6fc (config: disable witness related schedulers by default (#7765))
re.NoError(co.GetCluster().GetSchedulerConfig().Persist(storage))
co.Stop()
co.GetSchedulersController().Wait()
Expand Down Expand Up @@ -3249,8 +3259,12 @@ func TestRemoveScheduler(t *testing.T) {
re.NoError(controller.RemoveScheduler(schedulers.BalanceRegionName))
re.NoError(controller.RemoveScheduler(schedulers.HotRegionName))
re.NoError(controller.RemoveScheduler(schedulers.GrantLeaderName))
<<<<<<< HEAD
re.NoError(controller.RemoveScheduler(schedulers.BalanceWitnessName))
re.NoError(controller.RemoveScheduler(schedulers.TransferWitnessLeaderName))
=======
re.NoError(controller.RemoveScheduler(schedulers.EvictSlowStoreName))
>>>>>>> 5b939c6fc (config: disable witness related schedulers by default (#7765))
// all removed
sches, _, err = storage.LoadAllSchedulerConfigs()
re.NoError(err)
Expand Down
27 changes: 27 additions & 0 deletions tests/integrations/mcs/scheduling/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ func (suite *serverTestSuite) TestSchedulerSync() {
api.MustDeleteScheduler(re, suite.backendEndpoints, schedulers.EvictLeaderName)
checkEvictLeaderSchedulerExist(re, schedulersController, false)

<<<<<<< HEAD
// TODO: test more schedulers.
// Fixme: the following code will fail because the scheduler is not removed but not synced.
// checkDelete := func(schedulerName string) {
Expand All @@ -277,6 +278,32 @@ func (suite *serverTestSuite) TestSchedulerSync() {
// checkDelete(schedulers.BalanceLeaderName)
// checkDelete(schedulers.BalanceRegionName)
// checkDelete(schedulers.HotRegionName)
=======
// The default scheduler could not be deleted, it could only be disabled.
defaultSchedulerNames := []string{
schedulers.BalanceLeaderName,
schedulers.BalanceRegionName,
schedulers.HotRegionName,
}
checkDisabled := func(name string, shouldDisabled bool) {
re.NotNil(schedulersController.GetScheduler(name), name)
testutil.Eventually(re, func() bool {
disabled, err := schedulersController.IsSchedulerDisabled(name)
re.NoError(err, name)
return disabled == shouldDisabled
})
}
for _, name := range defaultSchedulerNames {
checkDisabled(name, false)
api.MustDeleteScheduler(re, suite.backendEndpoints, name)
checkDisabled(name, true)
}
for _, name := range defaultSchedulerNames {
checkDisabled(name, true)
api.MustAddScheduler(re, suite.backendEndpoints, name, nil)
checkDisabled(name, false)
}
>>>>>>> 5b939c6fc (config: disable witness related schedulers by default (#7765))
}

func checkEvictLeaderSchedulerExist(re *require.Assertions, sc *schedulers.Controller, exist bool) {
Expand Down

0 comments on commit 2c0d131

Please sign in to comment.