From 34ad5b87a81febb92fbd8b49ee7f3dc713d49d88 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Mon, 15 Jan 2024 17:05:16 +0800 Subject: [PATCH] rename Signed-off-by: Ryan Leung --- server/config/config.go | 10 +++++----- .../mcs/scheduling/server_test.go | 8 ++++---- tools/pd-ctl/tests/config/config_test.go | 20 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/server/config/config.go b/server/config/config.go index 89f01528c32b..e59d2892b7d8 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -252,7 +252,7 @@ const ( minCheckRegionSplitInterval = 1 * time.Millisecond maxCheckRegionSplitInterval = 100 * time.Millisecond - defaultEnableDynamicSwitch = true + defaultEnableSchedulingFallback = true ) // Special keys for Labels @@ -855,12 +855,12 @@ func (c *DRAutoSyncReplicationConfig) adjust(meta *configutil.ConfigMetaData) { // MicroServiceConfig is the configuration for micro service. type MicroServiceConfig struct { - EnableDynamicSwitch bool `toml:"enable-dynamic-switch" json:"enable-dynamic-switch,string"` + EnableSchedulingFallback bool `toml:"enable-scheduling-fallback" json:"enable-scheduling-fallback,string"` } func (c *MicroServiceConfig) adjust(meta *configutil.ConfigMetaData) { - if !meta.IsDefined("enable-dynamic-switch") { - c.EnableDynamicSwitch = defaultEnableDynamicSwitch + if !meta.IsDefined("enable-scheduling-fallback") { + c.EnableSchedulingFallback = defaultEnableSchedulingFallback } } @@ -872,7 +872,7 @@ func (c *MicroServiceConfig) Clone() *MicroServiceConfig { // IsDynamicSwitchEnabled returns whether to enable dynamic switch. func (c *MicroServiceConfig) IsDynamicSwitchEnabled() bool { - return c.EnableDynamicSwitch + return c.EnableSchedulingFallback } // KeyspaceConfig is the configuration for keyspace management. diff --git a/tests/integrations/mcs/scheduling/server_test.go b/tests/integrations/mcs/scheduling/server_test.go index 1901402ea645..7b933df0e873 100644 --- a/tests/integrations/mcs/scheduling/server_test.go +++ b/tests/integrations/mcs/scheduling/server_test.go @@ -208,7 +208,7 @@ func (suite *serverTestSuite) TestDynamicSwitch() { leaderServer := suite.pdLeader.GetServer() conf := leaderServer.GetMicroServiceConfig().Clone() // Change back to the default value. - conf.EnableDynamicSwitch = true + conf.EnableSchedulingFallback = true leaderServer.SetMicroServiceConfig(*conf) // API server will execute scheduling jobs since there is no scheduling server. testutil.Eventually(re, func() bool { @@ -256,13 +256,13 @@ func (suite *serverTestSuite) TestDisableDynamicSwitch() { leaderServer := suite.pdLeader.GetServer() // After Disabling dynamic switch, the API server will stop scheduling. conf := leaderServer.GetMicroServiceConfig().Clone() - conf.EnableDynamicSwitch = false + conf.EnableSchedulingFallback = false leaderServer.SetMicroServiceConfig(*conf) testutil.Eventually(re, func() bool { return !suite.pdLeader.GetServer().GetRaftCluster().IsSchedulingControllerRunning() }) // Enable dynamic switch again, the API server will restart scheduling. - conf.EnableDynamicSwitch = true + conf.EnableSchedulingFallback = true leaderServer.SetMicroServiceConfig(*conf) testutil.Eventually(re, func() bool { return suite.pdLeader.GetServer().GetRaftCluster().IsSchedulingControllerRunning() @@ -281,7 +281,7 @@ func (suite *serverTestSuite) TestDisableDynamicSwitch() { return tc.GetPrimaryServer().GetCluster().IsBackgroundJobsRunning() }) // Disable dynamic switch and stop scheduling server. API server won't execute scheduling jobs again. - conf.EnableDynamicSwitch = false + conf.EnableSchedulingFallback = false leaderServer.SetMicroServiceConfig(*conf) tc.GetPrimaryServer().Close() time.Sleep(time.Second) diff --git a/tools/pd-ctl/tests/config/config_test.go b/tools/pd-ctl/tests/config/config_test.go index 6c090b6d3394..4a5858512274 100644 --- a/tools/pd-ctl/tests/config/config_test.go +++ b/tools/pd-ctl/tests/config/config_test.go @@ -1115,30 +1115,30 @@ func (suite *configTestSuite) TestMicroServiceConfig() { suite.env.RunTestInTwoModes(suite.checkMicroServiceConfig) } -func (suite *configTestSuite) checkMicroServiceConfig(cluster *tests.TestCluster) { +func (suite *configTestSuite) checkMicroServiceConfig(cluster *pdTests.TestCluster) { re := suite.Require() leaderServer := cluster.GetLeaderServer() pdAddr := leaderServer.GetAddr() - cmd := pdctlCmd.GetRootCmd() + cmd := ctl.GetRootCmd() store := &metapb.Store{ Id: 1, State: metapb.StoreState_Up, LastHeartbeat: time.Now().UnixNano(), } - tests.MustPutStore(re, cluster, store) + pdTests.MustPutStore(re, cluster, store) svr := leaderServer.GetServer() - output, err := pdctl.ExecuteCommand(cmd, "-u", pdAddr, "config", "show", "all") + output, err := tests.ExecuteCommand(cmd, "-u", pdAddr, "config", "show", "all") re.NoError(err) cfg := config.Config{} re.NoError(json.Unmarshal(output, &cfg)) - re.True(svr.GetMicroServiceConfig().EnableDynamicSwitch) - re.True(cfg.MicroService.EnableDynamicSwitch) - // config set enable-dynamic-switch - args := []string{"-u", pdAddr, "config", "set", "enable-dynamic-switch", "false"} - _, err = pdctl.ExecuteCommand(cmd, args...) + re.True(svr.GetMicroServiceConfig().EnableSchedulingFallback) + re.True(cfg.MicroService.EnableSchedulingFallback) + // config set enable-scheduling-fallback + args := []string{"-u", pdAddr, "config", "set", "enable-scheduling-fallback", "false"} + _, err = tests.ExecuteCommand(cmd, args...) re.NoError(err) - re.False(svr.GetMicroServiceConfig().EnableDynamicSwitch) + re.False(svr.GetMicroServiceConfig().EnableSchedulingFallback) } func assertBundles(re *require.Assertions, a, b []placement.GroupBundle) {