From 8c9b4fb28aae73c1e5575b2bdc2a5f22a297bb4f Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Mon, 17 Apr 2023 17:27:19 +0800 Subject: [PATCH] *: fix `TestLogicalOverflow` (#6320) close tikv/pd#6277 Signed-off-by: Ryan Leung --- tests/server/tso/global_tso_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/server/tso/global_tso_test.go b/tests/server/tso/global_tso_test.go index 88534a33323..a6340e2671c 100644 --- a/tests/server/tso/global_tso_test.go +++ b/tests/server/tso/global_tso_test.go @@ -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, @@ -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} {