From 66eb822bc0bf6679723ce5aa53222b0008a5cb05 Mon Sep 17 00:00:00 2001 From: Cabinfever_B Date: Wed, 10 Jan 2024 10:34:38 +0800 Subject: [PATCH] fix conflict Signed-off-by: Cabinfever_B --- pkg/schedule/schedulers/evict_slow_store.go | 48 --------------------- server/api/server_test.go | 12 ++---- tests/pdctl/scheduler/scheduler_test.go | 31 ------------- 3 files changed, 3 insertions(+), 88 deletions(-) diff --git a/pkg/schedule/schedulers/evict_slow_store.go b/pkg/schedule/schedulers/evict_slow_store.go index 515d257e95b..a6665c3e5e7 100644 --- a/pkg/schedule/schedulers/evict_slow_store.go +++ b/pkg/schedule/schedulers/evict_slow_store.go @@ -92,54 +92,6 @@ func (conf *evictSlowStoreSchedulerConfig) clearAndPersist() (oldID uint64, err return } -<<<<<<< HEAD -======= -type evictSlowStoreHandler struct { - rd *render.Render - config *evictSlowStoreSchedulerConfig -} - -func newEvictSlowStoreHandler(config *evictSlowStoreSchedulerConfig) http.Handler { - h := &evictSlowStoreHandler{ - config: config, - rd: render.New(render.Options{IndentJSON: true}), - } - router := mux.NewRouter() - router.HandleFunc("/config", h.UpdateConfig).Methods(http.MethodPost) - router.HandleFunc("/list", h.ListConfig).Methods(http.MethodGet) - return router -} - -func (handler *evictSlowStoreHandler) UpdateConfig(w http.ResponseWriter, r *http.Request) { - var input map[string]interface{} - if err := apiutil.ReadJSONRespondError(handler.rd, w, r.Body, &input); err != nil { - return - } - recoveryDurationGapFloat, ok := input["recovery-duration"].(float64) - if !ok { - handler.rd.JSON(w, http.StatusInternalServerError, errors.New("invalid argument for 'recovery-duration'").Error()) - return - } - handler.config.Lock() - defer handler.config.Unlock() - prevRecoveryDurationGap := handler.config.RecoveryDurationGap - recoveryDurationGap := uint64(recoveryDurationGapFloat) - handler.config.RecoveryDurationGap = recoveryDurationGap - if err := handler.config.persistLocked(); err != nil { - handler.rd.JSON(w, http.StatusInternalServerError, err.Error()) - handler.config.RecoveryDurationGap = prevRecoveryDurationGap - return - } - log.Info("evict-slow-store-scheduler update 'recovery-duration' - unit: s", zap.Uint64("prev", prevRecoveryDurationGap), zap.Uint64("cur", recoveryDurationGap)) - handler.rd.JSON(w, http.StatusOK, "Config updated.") -} - -func (handler *evictSlowStoreHandler) ListConfig(w http.ResponseWriter, r *http.Request) { - conf := handler.config.Clone() - handler.rd.JSON(w, http.StatusOK, conf) -} - ->>>>>>> 8b8c78a78 (scheduler: add aduit log for scheduler config API and add resp msg for evict-leader (#7674)) type evictSlowStoreScheduler struct { *BaseScheduler conf *evictSlowStoreSchedulerConfig diff --git a/server/api/server_test.go b/server/api/server_test.go index 8e747d063ae..98c9070c348 100644 --- a/server/api/server_test.go +++ b/server/api/server_test.go @@ -220,18 +220,12 @@ func (suite *serviceTestSuite) TestServiceLabels() { suite.Equal("Profile", serviceLabel) accessPaths = suite.svr.GetServiceLabels("GetSchedulerConfig") -<<<<<<< HEAD suite.Len(accessPaths, 1) suite.Equal("/pd/api/v1/scheduler-config", accessPaths[0].Path) - suite.Equal("", accessPaths[0].Method) -======= - re.Len(accessPaths, 1) - re.Equal("/pd/api/v1/scheduler-config", accessPaths[0].Path) - re.Equal("GET", accessPaths[0].Method) + suite.Equal("GET", accessPaths[0].Method) accessPaths = suite.svr.GetServiceLabels("HandleSchedulerConfig") - re.Len(accessPaths, 4) - re.Equal("/pd/api/v1/scheduler-config", accessPaths[0].Path) ->>>>>>> 8b8c78a78 (scheduler: add aduit log for scheduler config API and add resp msg for evict-leader (#7674)) + suite.Len(accessPaths, 4) + suite.Equal("/pd/api/v1/scheduler-config", accessPaths[0].Path) accessPaths = suite.svr.GetServiceLabels("ResignLeader") suite.Len(accessPaths, 1) diff --git a/tests/pdctl/scheduler/scheduler_test.go b/tests/pdctl/scheduler/scheduler_test.go index 16c5f3197e5..9caea7c975c 100644 --- a/tests/pdctl/scheduler/scheduler_test.go +++ b/tests/pdctl/scheduler/scheduler_test.go @@ -411,39 +411,8 @@ func (suite *schedulerTestSuite) checkScheduler(cluster *tests.TestCluster) { echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", "balance-leader-scheduler"}, nil) re.Contains(echo, "Success!") -<<<<<<< HEAD:tests/pdctl/scheduler/scheduler_test.go // test evict-slow-trend scheduler config echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", "evict-slow-trend-scheduler"}, nil) -======= - // test evict-slow-store && evict-slow-trend schedulers config - evictSlownessSchedulers := []string{"evict-slow-store-scheduler", "evict-slow-trend-scheduler"} - for _, schedulerName := range evictSlownessSchedulers { - echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", schedulerName}, nil) - if strings.Contains(echo, "Success!") { - re.Contains(echo, "Success!") - } else { - re.Contains(echo, "scheduler existed") - } - testutil.Eventually(re, func() bool { - echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "show"}, nil) - return strings.Contains(echo, schedulerName) - }) - echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "config", schedulerName, "set", "recovery-duration", "100"}, nil) - re.Contains(echo, "Success! Config updated.") - conf = make(map[string]interface{}) - testutil.Eventually(re, func() bool { - mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "config", schedulerName, "show"}, &conf) - return conf["recovery-duration"] == 100. - }) - echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "remove", schedulerName}, nil) - re.Contains(echo, "Success!") - testutil.Eventually(re, func() bool { - echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "show"}, nil) - return !strings.Contains(echo, schedulerName) - }) - } - echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", "evict-slow-store-scheduler"}, nil) ->>>>>>> 8b8c78a78 (scheduler: add aduit log for scheduler config API and add resp msg for evict-leader (#7674)):tools/pd-ctl/tests/scheduler/scheduler_test.go re.Contains(echo, "Success!") echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "show"}, nil) re.Contains(echo, "evict-slow-trend-scheduler")