Skip to content

Commit

Permalink
pd-ctl: fix the output trim (#8309)
Browse files Browse the repository at this point in the history
ref #4399

Fix the output trim of the pd-ctl command.

Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato authored Jun 19, 2024
1 parent 6f8286b commit 9804702
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tools/pd-ctl/pdctl/command/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,11 @@ func requestJSON(cmd *cobra.Command, method, prefix string, input map[string]any
return nil
})
if err != nil {
cmd.Printf("Failed! %s\n", err)
cmd.Printf("Failed! %s\n", strings.TrimSpace(err.Error()))
return
}
cmd.Printf("Success! %s\n", strings.Trim(string(msg), "\""))
msg = bytes.Trim(bytes.TrimSpace(msg), "\"")
cmd.Printf("Success! %s\n", string(msg))
}

func postJSON(cmd *cobra.Command, prefix string, input map[string]any) {
Expand Down
4 changes: 2 additions & 2 deletions tools/pd-ctl/tests/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ func (suite *schedulerTestSuite) checkScheduler(cluster *pdTests.TestCluster) {
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", "balance-region-scheduler"}, nil)
re.Contains(echo, "Success!")
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", "evict-leader-scheduler", "1"}, nil)
re.Contains(echo, "Success! The scheduler is created.")
re.Equal("Success! The scheduler is created.\n", echo)
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", "evict-leader-scheduler", "2"}, nil)
re.Contains(echo, "Success! The scheduler has been applied to the store.")
re.Equal("Success! The scheduler has been applied to the store.\n", echo)
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "remove", "evict-leader-scheduler-1"}, nil)
re.Contains(echo, "Success!")
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "remove", "evict-leader-scheduler-2"}, nil)
Expand Down

0 comments on commit 9804702

Please sign in to comment.