Skip to content

Commit

Permalink
pd-ctl: fix scheduler config balance-hot-region-scheduler list (#2321)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx authored Apr 2, 2020
1 parent fccb3d4 commit a22224d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pO
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
Expand Down
23 changes: 23 additions & 0 deletions tests/pdctl/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,27 @@ func (s *schedulerTestSuite) TestScheduler(c *C) {
c.Assert(strings.Contains(echo, "Success!"), IsTrue)
echo = pdctl.GetEcho([]string{"-u", pdAddr, "scheduler", "remove", "balance-region-scheduler"})
c.Assert(strings.Contains(echo, "Success!"), IsFalse)

// test hot region config
var conf map[string]interface{}
mustExec([]string{"-u", pdAddr, "scheduler", "config", "balance-hot-region-scheduler", "list"}, &conf)
expected1 := map[string]interface{}{
"min-hot-byte-rate": float64(100),
"min-hot-key-rate": float64(10),
"max-zombie-rounds": float64(3),
"max-peer-number": float64(1000),
"byte-rate-rank-step-ratio": 0.05,
"key-rate-rank-step-ratio": 0.05,
"count-rank-step-ratio": 0.01,
"great-dec-ratio": 0.95,
"minor-dec-ratio": 0.99,
"src-tolerance-ratio": 1.02,
"dst-tolerance-ratio": 1.02,
}
c.Assert(conf, DeepEquals, expected1)
mustExec([]string{"-u", pdAddr, "scheduler", "config", "balance-hot-region-scheduler", "set", "src-tolerance-ratio", "1.05"}, nil)
expected1["src-tolerance-ratio"] = 1.05
var conf1 map[string]interface{}
mustExec([]string{"-u", pdAddr, "scheduler", "config", "balance-hot-region-scheduler"}, &conf1)
c.Assert(conf1, DeepEquals, expected1)
}
6 changes: 5 additions & 1 deletion tools/pd-ctl/pdctl/command/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,11 @@ func listSchedulerConfigCommandFunc(cmd *cobra.Command, args []string) {
cmd.Println(cmd.UsageString())
return
}
path := path.Join(schedulerConfigPrefix, cmd.Name(), "list")
p := cmd.Name()
if p == "list" {
p = cmd.Parent().Name()
}
path := path.Join(schedulerConfigPrefix, p, "list")
r, err := doRequest(cmd, path, http.MethodGet)
if err != nil {
cmd.Println(err)
Expand Down

0 comments on commit a22224d

Please sign in to comment.