Skip to content

Commit

Permalink
test: fix unstable test TestBasicResourceGroupCURD (#6801)
Browse files Browse the repository at this point in the history
close #6798

Signed-off-by: glorv <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
glorv and ti-chi-bot[bot] authored Jul 13, 2023
1 parent dbee3ef commit 4a4c567
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion client/resource_manager_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const (
groupSettingsPathPrefix = "resource_group/settings"
// errNotPrimary is returned when the requested server is not primary.
errNotPrimary = "not primary"
// errNotLeader is returned when the requested server is not pd leader.
errNotLeader = "not leader"
)

// GroupSettingsPathPrefixBytes is used to watch or get resource groups.
Expand Down Expand Up @@ -65,7 +67,7 @@ func (c *client) resourceManagerClient() (rmpb.ResourceManagerClient, error) {

// gRPCErrorHandler is used to handle the gRPC error returned by the resource manager service.
func (c *client) gRPCErrorHandler(err error) {
if strings.Contains(err.Error(), errNotPrimary) {
if strings.Contains(err.Error(), errNotPrimary) || strings.Contains(err.Error(), errNotLeader) {
c.pdSvcDiscovery.ScheduleCheckMemberChanged()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,12 @@ func (suite *resourceManagerClientTestSuite) TestBasicResourceGroupCURD() {
}
re.NoError(suite.cluster.RunServers(serverList))
suite.cluster.WaitLeader()
newGroups, err := cli.ListResourceGroups(suite.ctx)
re.NoError(err)
var newGroups []*rmpb.ResourceGroup
testutil.Eventually(suite.Require(), func() bool {
var err error
newGroups, err = cli.ListResourceGroups(suite.ctx)
return err == nil
}, testutil.WithWaitFor(time.Second))
re.Equal(groups, newGroups)
}

Expand Down

0 comments on commit 4a4c567

Please sign in to comment.