Skip to content

Commit

Permalink
make TestGetAllByKey stable
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Nov 21, 2023
1 parent 0dfc784 commit 11c72ac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pkg/utils/apiutil/serverapi/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ func (h *redirector) matchMicroServiceRedirectRules(r *http.Request) (bool, stri
} else {
r.URL.Path = rule.targetPath
}
log.Info("redirect to micro service", zap.String("path", r.URL.Path), zap.String("origin-path", origin),
zap.String("target", addr), zap.String("method", r.Method), zap.Any("query", r.URL.Query()))
log.Debug("redirect to micro service", zap.String("path", r.URL.Path), zap.String("origin-path", origin),
zap.String("target", addr), zap.String("method", r.Method))
return true, addr
}
}
Expand Down
14 changes: 8 additions & 6 deletions tests/pdctl/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,18 +646,20 @@ func TestForwardSchedulerRequest(t *testing.T) {
server := cluster.GetLeaderServer()
re.NoError(server.BootstrapCluster())
backendEndpoints := server.GetAddr()
tc, err := tests.NewTestSchedulingCluster(ctx, 2, backendEndpoints)
tc, err := tests.NewTestSchedulingCluster(ctx, 1, backendEndpoints)
re.NoError(err)
defer tc.Destroy()
tc.WaitForPrimaryServing(re)

cmd := pdctlCmd.GetRootCmd()
args := []string{"-u", backendEndpoints, "scheduler", "show"}
var slice []string
output, err := pdctl.ExecuteCommand(cmd, args...)
re.NoError(err)
re.NoError(json.Unmarshal(output, &slice))
re.Contains(slice, "balance-leader-scheduler")
var sches []string
testutil.Eventually(re, func() bool {
output, err := pdctl.ExecuteCommand(cmd, args...)
re.NoError(err)
re.NoError(json.Unmarshal(output, &sches))
return slice.Contains(sches, "balance-leader-scheduler")
})

mustUsage := func(args []string) {
output, err := pdctl.ExecuteCommand(cmd, args...)
Expand Down
6 changes: 4 additions & 2 deletions tests/server/api/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,10 @@ func (suite *ruleTestSuite) checkGetAllByKey(cluster *tests.TestCluster) {
var resp []*placement.Rule
url := fmt.Sprintf("%s/rules/key/%s", urlPrefix, testCase.key)
if testCase.success {
err = tu.ReadGetJSON(re, testDialClient, url, &resp)
suite.Len(resp, testCase.respSize)
tu.Eventually(re, func() bool {
err = tu.ReadGetJSON(re, testDialClient, url, &resp)
return len(resp) == testCase.respSize
})
} else {
err = tu.CheckGetJSON(testDialClient, url, nil, tu.Status(re, testCase.code))
}
Expand Down

0 comments on commit 11c72ac

Please sign in to comment.