Skip to content

Commit

Permalink
make TestGlobalAndLocalTSO stable
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Apr 10, 2023
1 parent bfdc7ec commit 62d7b1b
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/integrations/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
pd "github.com/tikv/pd/client"
"github.com/tikv/pd/client/errs"
"github.com/tikv/pd/pkg/core"
"github.com/tikv/pd/pkg/mock/mockid"
"github.com/tikv/pd/pkg/storage/endpoint"
Expand Down Expand Up @@ -453,13 +454,26 @@ func requestGlobalAndLocalTSO(
var lastTS uint64
for i := 0; i < tsoRequestRound; i++ {
globalPhysical1, globalLogical1, err := cli.GetTS(context.TODO())
re.NoError(err)
// The allocator leader may be changed due to the environment issue.
if err != nil {
re.ErrorContains(err, errs.NotLeaderErr)
} else {
re.NoError(err)
}
globalTS1 := tsoutil.ComposeTS(globalPhysical1, globalLogical1)
localPhysical, localLogical, err := cli.GetLocalTS(context.TODO(), dc)
re.NoError(err)
if err != nil {
re.ErrorContains(err, errs.NotLeaderErr)
} else {
re.NoError(err)
}
localTS := tsoutil.ComposeTS(localPhysical, localLogical)
globalPhysical2, globalLogical2, err := cli.GetTS(context.TODO())
re.NoError(err)
if err != nil {
re.ErrorContains(err, errs.NotLeaderErr)
} else {
re.NoError(err)
}
globalTS2 := tsoutil.ComposeTS(globalPhysical2, globalLogical2)
re.Less(lastTS, globalTS1)
re.Less(globalTS1, localTS)
Expand Down

0 comments on commit 62d7b1b

Please sign in to comment.