Skip to content

Commit

Permalink
tools: support get all groups (tikv#6714)
Browse files Browse the repository at this point in the history
ref tikv#5895, ref tikv#6706

Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx authored Jun 29, 2023
1 parent 7d43f69 commit 3b59a78
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
12 changes: 12 additions & 0 deletions tests/pdctl/keyspace/keyspace_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ func TestSplitKeyspaceGroup(t *testing.T) {
return strings.Contains(string(output), "Success")
})

// get all keyspaces
args := []string{"-u", pdAddr, "keyspace-group"}
output, err := pdctl.ExecuteCommand(cmd, args...)
re.NoError(err)
strings.Contains(string(output), "Success")
var keyspaceGroups []*endpoint.KeyspaceGroup
err = json.Unmarshal(output, &keyspaceGroups)
re.NoError(err)
re.Len(keyspaceGroups, 2)
re.Equal(keyspaceGroups[0].ID, uint32(0))
re.Equal(keyspaceGroups[1].ID, uint32(1))

re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/keyspace/acceleratedAllocNodes"))
re.NoError(failpoint.Disable("github.com/tikv/pd/server/delayStartServerLoop"))
}
Expand Down
16 changes: 9 additions & 7 deletions tools/pd-ctl/pdctl/command/keyspace_group_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ func showKeyspaceGroupsCommandFunc(cmd *cobra.Command, args []string) {
cmd.Printf("Failed to get state: %s\n", err)
}
stateValue := ""
state = strings.ToLower(state)
switch state {
case "merge", "split":
stateValue = fmt.Sprintf("state=%v", state)
default:
cmd.Println("Unknown state: " + state)
return
if len(state) != 0 {
state = strings.ToLower(state)
switch state {
case "merge", "split":
stateValue = fmt.Sprintf("state=%v", state)
default:
cmd.Println("Unknown state: " + state)
return
}
}

if len(stateValue) != 0 {
Expand Down
1 change: 0 additions & 1 deletion tools/pd-ctl/pdctl/command/store_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ func labelStoreCommandFunc(cmd *cobra.Command, args []string) {
} else if rewrite, _ := cmd.Flags().GetBool("rewrite"); rewrite {
prefix += "?force=true"
}
cmd.Println(prefix)
postJSON(cmd, prefix, labels)
}

Expand Down

0 comments on commit 3b59a78

Please sign in to comment.