Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <admin@liudos.us>
  • Loading branch information
lhy1024 committed Nov 21, 2023
1 parent 2b06e2f commit 07e96f0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions pkg/mcs/scheduling/server/apis/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,12 +1291,11 @@ func splitRegions(c *gin.Context) {
c.String(http.StatusBadRequest, "split_keys should be provided.")
return
}
rawSplitKeys := s.([]string)
rawSplitKeys := s.([]interface{})
if len(rawSplitKeys) < 1 {
c.String(http.StatusBadRequest, "empty split keys.")
return
}
fmt.Println(rawSplitKeys)
retryLimit := 5
if rl, ok := input["retry_limit"].(float64); ok {
retryLimit = int(rl)
Expand Down
4 changes: 2 additions & 2 deletions pkg/schedule/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1221,14 +1221,14 @@ type SplitRegionsResponse struct {
}

// SplitRegions splits regions by split keys.
func (h *Handler) SplitRegions(ctx context.Context, rawSplitKeys []string, retryLimit int) (*SplitRegionsResponse, error) {
func (h *Handler) SplitRegions(ctx context.Context, rawSplitKeys []interface{}, retryLimit int) (*SplitRegionsResponse, error) {
co := h.GetCoordinator()
if co == nil {
return nil, errs.ErrNotBootstrapped.GenWithStackByArgs()
}
splitKeys := make([][]byte, 0, len(rawSplitKeys))
for _, rawKey := range rawSplitKeys {
key, err := hex.DecodeString(rawKey)
key, err := hex.DecodeString(rawKey.(string))
if err != nil {
return nil, err
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/utils/apiutil/serverapi/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ func (h *redirector) matchMicroServiceRedirectRules(r *http.Request) (bool, stri
// It will be helpful when matching the redirect rules "schedulers" or "schedulers/{name}"
r.URL.Path = strings.TrimRight(r.URL.Path, "/")
for _, rule := range h.microserviceRedirectRules {
if strings.HasPrefix(r.URL.Path, rule.matchPath) && slice.Contains(rule.matchMethods, r.Method) {
if h.s.IsServiceIndependent(rule.targetServiceName) &&
strings.HasPrefix(r.URL.Path, rule.matchPath) &&
slice.Contains(rule.matchMethods, r.Method) {
if rule.filter != nil && !rule.filter(r) {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion server/api/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ func (h *regionsHandler) SplitRegions(w http.ResponseWriter, r *http.Request) {
h.rd.JSON(w, http.StatusBadRequest, "split_keys should be provided.")
return
}
rawSplitKeys := s.([]string)
rawSplitKeys := s.([]interface{})
if len(rawSplitKeys) < 1 {
h.rd.JSON(w, http.StatusBadRequest, "empty split keys.")
return
Expand Down
2 changes: 1 addition & 1 deletion server/api/region_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func (suite *regionTestSuite) TestScatterRegions() {
func (suite *regionTestSuite) TestSplitRegions() {
re := suite.Require()
r1 := core.NewTestRegionInfo(601, 13, []byte("aaa"), []byte("ggg"))
r1.GetMeta().Peers = append(r1.GetMeta().Peers, &metapb.Peer{Id: 5, StoreId: 13}, &metapb.Peer{Id: 6, StoreId: 13})
r1.GetMeta().Peers = append(r1.GetMeta().Peers, &metapb.Peer{Id: 5, StoreId: 14}, &metapb.Peer{Id: 6, StoreId: 15})
mustRegionHeartbeat(re, suite.svr, r1)
mustPutStore(re, suite.svr, 13, metapb.StoreState_Up, metapb.NodeState_Serving, []*metapb.StoreLabel{})
newRegionID := uint64(11)
Expand Down

0 comments on commit 07e96f0

Please sign in to comment.