Skip to content

Commit

Permalink
Fix flaky TestGetMinTS() test
Browse files Browse the repository at this point in the history
Signed-off-by: Bin Shi <binshi.bing@gmail.com>
  • Loading branch information
binshi-bing committed May 12, 2023
1 parent 9a26efa commit f6c82ab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/integrations/mcs/tso/keyspace_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,22 @@ func (suite *tsoKeyspaceGroupManagerTestSuite) TestKeyspacesServedByDefaultKeysp
// a keyspace group before, will be served by the default keyspace group.
re := suite.Require()
testutil.Eventually(re, func() bool {
for _, server := range suite.tsoCluster.GetServers() {
allServed := true
for _, keyspaceID := range []uint32{0, 1, 2} {
for _, keyspaceID := range []uint32{0, 1, 2} {
served := false
for _, server := range suite.tsoCluster.GetServers() {
if server.IsKeyspaceServing(keyspaceID, mcsutils.DefaultKeyspaceGroupID) {
tam, err := server.GetTSOAllocatorManager(mcsutils.DefaultKeyspaceGroupID)
re.NoError(err)
re.NotNil(tam)
} else {
allServed = false
served = true
break
}
}
return allServed
if !served {
return false
}
}
return false
return true
}, testutil.WithWaitFor(5*time.Second), testutil.WithTickInterval(50*time.Millisecond))

// Any keyspace that was assigned to a keyspace group before, except default keyspace,
Expand Down
18 changes: 18 additions & 0 deletions tests/integrations/tso/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,24 @@ func (suite *tsoClientTestSuite) SetupSuite() {
suite.keyspaceIDs = append(suite.keyspaceIDs, keyspaceGroup.keyspaceIDs...)
}

// Make sure all keyspace groups are available.
testutil.Eventually(re, func() bool {
for _, keyspaceID := range suite.keyspaceIDs {
served := false
for _, server := range suite.tsoCluster.GetServers() {
if server.IsKeyspaceServing(keyspaceID, mcsutils.DefaultKeyspaceGroupID) {
served = true
break
}
}
if !served {
return false
}
}
return true
}, testutil.WithWaitFor(5*time.Second), testutil.WithTickInterval(50*time.Millisecond))

// Create clients and make sure they all have discovered the tso service.
suite.clients = mcs.WaitForMultiKeyspacesTSOAvailable(
suite.ctx, re, suite.keyspaceIDs, strings.Split(suite.backendEndpoints, ","))
re.Equal(len(suite.keyspaceIDs), len(suite.clients))
Expand Down

0 comments on commit f6c82ab

Please sign in to comment.