Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ms: make TestBootstrapDefaultKeyspaceGroup stable #8510

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading