diff --git a/tools/pd-ctl/pdctl/command/store_command.go b/tools/pd-ctl/pdctl/command/store_command.go index bc024d5a2e6..188d36e25de 100644 --- a/tools/pd-ctl/pdctl/command/store_command.go +++ b/tools/pd-ctl/pdctl/command/store_command.go @@ -706,7 +706,11 @@ func showAllStoresLimitCommandFunc(cmd *cobra.Command, args []string) { cmd.Println(r) } -func removeTombStoneCommandFunc(cmd *cobra.Command, _ []string) { +func removeTombStoneCommandFunc(cmd *cobra.Command, args []string) { + if len(args) != 0 { + cmd.Usage() + return + } prefix := path.Join(storesPrefix, "remove-tombstone") _, err := doRequest(cmd, prefix, http.MethodDelete, http.Header{}) if err != nil { diff --git a/tools/pd-ctl/pdctl/ctl.go b/tools/pd-ctl/pdctl/ctl.go index fbacd65dc53..5f8c6485c42 100644 --- a/tools/pd-ctl/pdctl/ctl.go +++ b/tools/pd-ctl/pdctl/ctl.go @@ -29,7 +29,7 @@ import ( ) func init() { - cobra.EnablePrefixMatching = true + cobra.EnablePrefixMatching = false cobra.EnableTraverseRunHooks = true } diff --git a/tools/pd-ctl/tests/store/store_test.go b/tools/pd-ctl/tests/store/store_test.go index 0f522b8bd44..2e1e7ac9444 100644 --- a/tools/pd-ctl/tests/store/store_test.go +++ b/tools/pd-ctl/tests/store/store_test.go @@ -339,9 +339,14 @@ func TestStore(t *testing.T) { // store delete command storeInfo.Store.State = metapb.StoreState(metapb.StoreState_value[storeInfo.Store.StateName]) re.Equal(metapb.StoreState_Up, storeInfo.Store.State) + args = []string{"-u", pdAddr, "store", "remove", "1"} // it means remove-tombstone + output, err = tests.ExecuteCommand(cmd, args...) + re.NoError(err) + re.NotContains(string(output), "Success") args = []string{"-u", pdAddr, "store", "delete", "1"} - _, err = tests.ExecuteCommand(cmd, args...) + output, err = tests.ExecuteCommand(cmd, args...) re.NoError(err) + re.Contains(string(output), "Success") args = []string{"-u", pdAddr, "store", "1"} output, err = tests.ExecuteCommand(cmd, args...) re.NoError(err)