Skip to content

Commit

Permalink
*: fix TestLogicalOverflow (#6320)
Browse files Browse the repository at this point in the history
close #6277

Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx authored Apr 17, 2023
1 parent 0e42a50 commit 8c9b4fb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/server/tso/global_tso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestLogicalOverflow(t *testing.T) {
defer tsoClient.CloseSend()

begin := time.Now()
for i := 0; i < 2; i += 1 { // the 2nd request may (but not must) overflow, as max logical interval is 262144
for i := 0; i < 3; i++ {
req := &pdpb.TsoRequest{
Header: testutil.NewRequestHeader(clusterID),
Count: 150000,
Expand All @@ -163,12 +163,13 @@ func TestLogicalOverflow(t *testing.T) {
re.NoError(tsoClient.Send(req))
_, err = tsoClient.Recv()
re.NoError(err)
if i == 1 {
// the 2nd request may (but not must) overflow, as max logical interval is 262144
re.Less(time.Since(begin), updateInterval+20*time.Millisecond) // additional 20ms for gRPC latency
}
}
elapse := time.Since(begin)
if updateInterval >= 20*time.Millisecond { // on small interval, the physical may update before overflow
re.GreaterOrEqual(elapse, updateInterval)
}
re.Less(elapse, updateInterval+20*time.Millisecond) // additional 20ms for gRPC latency
// the 3rd request must overflow
re.GreaterOrEqual(time.Since(begin), updateInterval)
}

for _, updateInterval := range []int{1, 5, 30, 50} {
Expand Down

0 comments on commit 8c9b4fb

Please sign in to comment.