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: make TestFallbackTSOConsistency stable #7408

Merged
merged 2 commits into from
Nov 22, 2023
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
19 changes: 11 additions & 8 deletions tests/integrations/tso/consistency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
tso "github.com/tikv/pd/pkg/mcs/tso/server"
tsopkg "github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/tempurl"
pd "github.com/tikv/pd/pkg/utils/testutil"
tu "github.com/tikv/pd/pkg/utils/testutil"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use the original package name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most places, it is called tu

"github.com/tikv/pd/pkg/utils/tsoutil"
"github.com/tikv/pd/tests"
"google.golang.org/grpc"
Expand Down Expand Up @@ -82,7 +82,7 @@ func (suite *tsoConsistencyTestSuite) SetupSuite() {
suite.pdLeaderServer = suite.cluster.GetServer(leaderName)
backendEndpoints := suite.pdLeaderServer.GetAddr()
if suite.legacy {
suite.pdClient = pd.MustNewGrpcClient(re, backendEndpoints)
suite.pdClient = tu.MustNewGrpcClient(re, backendEndpoints)
} else {
suite.tsoServer, suite.tsoServerCleanup = tests.StartSingleTSOTestServer(suite.ctx, re, backendEndpoints, tempurl.Alloc())
suite.tsoClientConn, suite.tsoClient = tso.MustNewGrpcClient(re, suite.tsoServer.GetAddr())
Expand Down Expand Up @@ -127,12 +127,15 @@ func (suite *tsoConsistencyTestSuite) request(ctx context.Context, count uint32)
DcLocation: tsopkg.GlobalDCLocation,
Count: count,
}
tsoClient, err := suite.tsoClient.Tso(ctx)
re.NoError(err)
defer tsoClient.CloseSend()
re.NoError(tsoClient.Send(req))
resp, err := tsoClient.Recv()
re.NoError(err)
var resp *tsopb.TsoResponse
tu.Eventually(re, func() bool {
tsoClient, err := suite.tsoClient.Tso(ctx)
re.NoError(err)
defer tsoClient.CloseSend()
re.NoError(tsoClient.Send(req))
resp, err = tsoClient.Recv()
return err == nil && resp != nil
})
return checkAndReturnTimestampResponse(re, resp)
}

Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/tso/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
tso "github.com/tikv/pd/pkg/mcs/tso/server"
tsopkg "github.com/tikv/pd/pkg/tso"
"github.com/tikv/pd/pkg/utils/tempurl"
pd "github.com/tikv/pd/pkg/utils/testutil"
tu "github.com/tikv/pd/pkg/utils/testutil"
"github.com/tikv/pd/tests"
"google.golang.org/grpc"
)
Expand Down Expand Up @@ -80,7 +80,7 @@ func (suite *tsoServerTestSuite) SetupSuite() {
suite.pdLeaderServer = suite.cluster.GetServer(leaderName)
backendEndpoints := suite.pdLeaderServer.GetAddr()
if suite.legacy {
suite.pdClient = pd.MustNewGrpcClient(re, backendEndpoints)
suite.pdClient = tu.MustNewGrpcClient(re, backendEndpoints)
} else {
suite.tsoServer, suite.tsoServerCleanup = tests.StartSingleTSOTestServer(suite.ctx, re, backendEndpoints, tempurl.Alloc())
suite.tsoClientConn, suite.tsoClient = tso.MustNewGrpcClient(re, suite.tsoServer.GetAddr())
Expand Down
Loading