Skip to content

Commit

Permalink
ms: make TestBootstrapDefaultKeyspaceGroup stable (#8510)
Browse files Browse the repository at this point in the history
close #8395

Signed-off-by: lhy1024 <admin@liudos.us>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
lhy1024 and ti-chi-bot[bot] authored Aug 9, 2024
1 parent 92adb24 commit 6783814
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions pkg/keyspace/tso_keyspace_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func (m *GroupManager) allocNodesToAllKeyspaceGroups(ctx context.Context) {
log.Error("failed to alloc nodes for keyspace group", zap.Uint32("keyspace-group-id", group.ID), zap.Error(err))
continue
}
log.Info("alloc nodes for keyspace group", zap.Uint32("keyspace-group-id", group.ID), zap.Any("nodes", nodes))
group.Members = nodes
}
}
Expand Down
32 changes: 17 additions & 15 deletions tests/integrations/mcs/tso/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,22 +598,24 @@ func (suite *CommonTestSuite) TestAdvertiseAddr() {
func (suite *CommonTestSuite) TestBootstrapDefaultKeyspaceGroup() {
re := suite.Require()

// check the default keyspace group
// check the default keyspace group and wait for alloc tso nodes for the default keyspace group
check := func() {
resp, err := tests.TestDialClient.Get(suite.pdLeader.GetServer().GetConfig().AdvertiseClientUrls + "/pd/api/v2/tso/keyspace-groups")
re.NoError(err)
defer resp.Body.Close()
re.Equal(http.StatusOK, resp.StatusCode)
respString, err := io.ReadAll(resp.Body)
re.NoError(err)
var kgs []*endpoint.KeyspaceGroup
re.NoError(json.Unmarshal(respString, &kgs))
re.Len(kgs, 1)
re.Equal(utils.DefaultKeyspaceGroupID, kgs[0].ID)
re.Equal(endpoint.Basic.String(), kgs[0].UserKind)
re.Empty(kgs[0].SplitState)
re.Empty(kgs[0].Members)
re.Empty(kgs[0].KeyspaceLookupTable)
testutil.Eventually(re, func() bool {
resp, err := tests.TestDialClient.Get(suite.pdLeader.GetServer().GetConfig().AdvertiseClientUrls + "/pd/api/v2/tso/keyspace-groups")
re.NoError(err)
defer resp.Body.Close()
re.Equal(http.StatusOK, resp.StatusCode)
respString, err := io.ReadAll(resp.Body)
re.NoError(err)
var kgs []*endpoint.KeyspaceGroup
re.NoError(json.Unmarshal(respString, &kgs))
re.Len(kgs, 1)
re.Equal(utils.DefaultKeyspaceGroupID, kgs[0].ID)
re.Equal(endpoint.Basic.String(), kgs[0].UserKind)
re.Empty(kgs[0].SplitState)
re.Empty(kgs[0].KeyspaceLookupTable)
return len(kgs[0].Members) == 1
})
}
check()

Expand Down

0 comments on commit 6783814

Please sign in to comment.