Skip to content

Commit

Permalink
make TestGetAllByKey stable
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 56e08d7 commit 88bcd4a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/server/api/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/tikv/pd/pkg/errs"
"github.com/tikv/pd/pkg/schedule/labeler"
"github.com/tikv/pd/pkg/schedule/placement"
"github.com/tikv/pd/pkg/utils/testutil"

Check failure on line 31 in tests/server/api/rule_test.go

View workflow job for this annotation

GitHub Actions / statics

ST1019: package "github.com/tikv/pd/pkg/utils/testutil" is being imported more than once (stylecheck)
tu "github.com/tikv/pd/pkg/utils/testutil"

Check failure on line 32 in tests/server/api/rule_test.go

View workflow job for this annotation

GitHub Actions / statics

ST1019(related information): other import of "github.com/tikv/pd/pkg/utils/testutil" (stylecheck)
"github.com/tikv/pd/server/config"
"github.com/tikv/pd/tests"
Expand Down Expand Up @@ -565,8 +566,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)
testutil.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 88bcd4a

Please sign in to comment.