Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Jan 15, 2024
1 parent 91fed1b commit 34ad5b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ const (
minCheckRegionSplitInterval = 1 * time.Millisecond
maxCheckRegionSplitInterval = 100 * time.Millisecond

defaultEnableDynamicSwitch = true
defaultEnableSchedulingFallback = true
)

// Special keys for Labels
Expand Down Expand Up @@ -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
}
}

Expand All @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions tests/integrations/mcs/scheduling/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions tools/pd-ctl/tests/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <value>
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 <value>
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) {
Expand Down

0 comments on commit 34ad5b8

Please sign in to comment.