From 5ef54543d653df67a60a4b7f9dbdba44a417be6d Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Thu, 30 Nov 2023 15:32:42 +0800 Subject: [PATCH] make TestDisable stable Signed-off-by: Ryan Leung --- pkg/schedule/coordinator.go | 1 + server/cluster/cluster.go | 5 +++++ tests/server/api/scheduler_test.go | 2 ++ 3 files changed, 8 insertions(+) diff --git a/pkg/schedule/coordinator.go b/pkg/schedule/coordinator.go index 6a02e68811d..e276589a4e9 100644 --- a/pkg/schedule/coordinator.go +++ b/pkg/schedule/coordinator.go @@ -513,6 +513,7 @@ func (c *Coordinator) InitSchedulers(needRun bool) { if err := c.cluster.GetSchedulerConfig().Persist(c.cluster.GetStorage()); err != nil { log.Error("cannot persist schedule config", errs.ZapError(err)) } + log.Info("scheduler config is updated", zap.Reflect("scheduler-config", scheduleCfg.Schedulers)) c.markSchedulersInitialized() } diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index ec8ca3a0d65..78f6ddd4364 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -467,6 +467,10 @@ func (c *RaftCluster) startGCTuner() { func (c *RaftCluster) runStoreConfigSync() { defer logutil.LogPanic() defer c.wg.Done() + // TODO: After we fix the atomic problem of config, we can remove this failpoint. + failpoint.Inject("skipStoreConfigSync", func() { + failpoint.Return() + }) var ( synced, switchRaftV2Config, needPersist bool @@ -491,6 +495,7 @@ func (c *RaftCluster) runStoreConfigSync() { if err := c.opt.Persist(c.storage); err != nil { log.Warn("store config persisted failed", zap.Error(err)) } + log.Info("store config is updated") } select { case <-c.ctx.Done(): diff --git a/tests/server/api/scheduler_test.go b/tests/server/api/scheduler_test.go index 86b932b0a7a..df924b1b03f 100644 --- a/tests/server/api/scheduler_test.go +++ b/tests/server/api/scheduler_test.go @@ -564,8 +564,10 @@ func (suite *scheduleTestSuite) checkAPI(cluster *tests.TestCluster) { } func (suite *scheduleTestSuite) TestDisable() { + suite.NoError(failpoint.Enable("github.com/tikv/pd/server/cluster/skipStoreConfigSync", `return(true)`)) env := tests.NewSchedulingTestEnvironment(suite.T()) env.RunTestInTwoModes(suite.checkDisable) + suite.NoError(failpoint.Disable("github.com/tikv/pd/server/cluster/skipStoreConfigSync")) } func (suite *scheduleTestSuite) checkDisable(cluster *tests.TestCluster) {