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

tests: enable TestTSOKeyspaceGroupSplitClient #6398

Merged
Merged
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
27 changes: 21 additions & 6 deletions tests/integrations/mcs/tso/keyspace_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package tso

import (
"context"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -251,9 +252,6 @@ func (suite *tsoKeyspaceGroupManagerTestSuite) TestTSOKeyspaceGroupSplitElection
}

func (suite *tsoKeyspaceGroupManagerTestSuite) TestTSOKeyspaceGroupSplitClient() {
// TODO: remove the skip after the client is able to support multi-keyspace-group.
suite.T().SkipNow()

re := suite.Require()
// Create the keyspace group 1 with keyspaces [111, 222, 333].
handlersutil.MustCreateKeyspaceGroup(re, suite.pdLeaderServer, &handlers.CreateKeyspaceGroupParams{
Expand Down Expand Up @@ -287,13 +285,27 @@ func (suite *tsoKeyspaceGroupManagerTestSuite) TestTSOKeyspaceGroupSplitClient()
for {
select {
case <-ctx.Done():
// Make sure at least one TSO request is successful.
re.NotEmpty(lastPhysical)
return
default:
}
physical, logical, err := tsoClient.GetTS(ctx)
re.NoError(err)
re.Greater(physical, lastPhysical)
re.Greater(logical, lastLogical)
if err != nil {
errMsg := err.Error()
// Ignore the errors caused by the split and context cancellation.
if strings.Contains(errMsg, "context canceled") ||
strings.Contains(errMsg, "not leader") ||
strings.Contains(errMsg, "ErrKeyspaceNotAssigned") {
continue
}
re.FailNow(errMsg)
}
if physical == lastPhysical {
re.Greater(logical, lastLogical)
} else {
re.Greater(physical, lastPhysical)
}
lastPhysical, lastLogical = physical, logical
}
}()
Expand All @@ -308,6 +320,9 @@ func (suite *tsoKeyspaceGroupManagerTestSuite) TestTSOKeyspaceGroupSplitClient()
re.True(kg2.IsSplitTarget())
// Finish the split.
handlersutil.MustFinishSplitKeyspaceGroup(re, suite.pdLeaderServer, 2)
// Wait for a while to make sure the client has received the new TSO.
time.Sleep(time.Second)
// Stop the client.
cancel()
wg.Wait()
}