From 349bcd609d338453f18bd651d3f0552dd2ababe0 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Fri, 24 Jun 2022 10:56:44 +0800 Subject: [PATCH] Address the comments Signed-off-by: JmPotato --- pkg/cache/cache_test.go | 4 ++-- server/api/tso_test.go | 2 +- server/schedule/operator/status_tracker_test.go | 4 ++-- tests/client/client_test.go | 8 ++++---- tests/server/member/member_test.go | 2 +- tests/server/tso/allocator_test.go | 2 +- tests/server/tso/manager_test.go | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/cache/cache_test.go b/pkg/cache/cache_test.go index f708f966401..5bcff65f704 100644 --- a/pkg/cache/cache_test.go +++ b/pkg/cache/cache_test.go @@ -50,7 +50,7 @@ func TestExpireRegionCache(t *testing.T) { re.True(ok) re.Equal(expV, v2.(string)) - cache.PutWithTTL(11, "11", 1*time.Second) + cache.PutWithTTL(11, "11", time.Second) time.Sleep(5 * time.Second) k, v, success = cache.pop() re.False(success) @@ -58,7 +58,7 @@ func TestExpireRegionCache(t *testing.T) { re.Nil(v) // Test Get - cache.PutWithTTL(1, 1, 1*time.Second) + cache.PutWithTTL(1, 1, time.Second) cache.PutWithTTL(2, "v2", 5*time.Second) cache.PutWithTTL(3, 3.0, 5*time.Second) diff --git a/server/api/tso_test.go b/server/api/tso_test.go index f14941cc999..07770b130d8 100644 --- a/server/api/tso_test.go +++ b/server/api/tso_test.go @@ -58,7 +58,7 @@ func (suite *tsoTestSuite) TestTransferAllocator() { suite.svr.GetTSOAllocatorManager().ClusterDCLocationChecker() _, err := suite.svr.GetTSOAllocatorManager().GetAllocator("dc-1") return err == nil - }, tu.WithWaitFor(time.Second*15), tu.WithTickInterval(3*time.Second)) + }, tu.WithWaitFor(15*time.Second), tu.WithTickInterval(3*time.Second)) addr := suite.urlPrefix + "/tso/allocator/transfer/pd1?dcLocation=dc-1" err := tu.CheckPostJSON(testDialClient, addr, nil, tu.StatusOK(re)) suite.NoError(err) diff --git a/server/schedule/operator/status_tracker_test.go b/server/schedule/operator/status_tracker_test.go index d4441b0e7b6..04eb16d6ecd 100644 --- a/server/schedule/operator/status_tracker_test.go +++ b/server/schedule/operator/status_tracker_test.go @@ -123,11 +123,11 @@ func TestCheckStepTimeout(t *testing.T) { status OpStatus }{{ step: AddLearner{}, - start: time.Now().Add(-(SlowOperatorWaitTime - 1*time.Second)), + start: time.Now().Add(-(SlowOperatorWaitTime - time.Second)), status: STARTED, }, { step: AddLearner{}, - start: time.Now().Add(-(SlowOperatorWaitTime + 1*time.Second)), + start: time.Now().Add(-(SlowOperatorWaitTime + time.Second)), status: TIMEOUT, }} diff --git a/tests/client/client_test.go b/tests/client/client_test.go index 97a80c7c837..2709c7cbc24 100644 --- a/tests/client/client_test.go +++ b/tests/client/client_test.go @@ -424,14 +424,14 @@ func TestCustomTimeout(t *testing.T) { defer cluster.Destroy() endpoints := runServer(re, cluster) - cli := setupCli(re, ctx, endpoints, pd.WithCustomTimeoutOption(1*time.Second)) + cli := setupCli(re, ctx, endpoints, pd.WithCustomTimeoutOption(time.Second)) start := time.Now() re.NoError(failpoint.Enable("github.com/tikv/pd/server/customTimeout", "return(true)")) _, err = cli.GetAllStores(context.TODO()) re.NoError(failpoint.Disable("github.com/tikv/pd/server/customTimeout")) re.Error(err) - re.GreaterOrEqual(time.Since(start), 1*time.Second) + re.GreaterOrEqual(time.Since(start), time.Second) re.Less(time.Since(start), 2*time.Second) } @@ -1306,7 +1306,7 @@ func (suite *clientTestSuite) TestScatterRegion() { return resp.GetRegionId() == regionID && string(resp.GetDesc()) == "scatter-region" && resp.GetStatus() == pdpb.OperatorStatus_RUNNING - }, testutil.WithTickInterval(1*time.Second)) + }, testutil.WithTickInterval(time.Second)) // Test interface `ScatterRegion`. // TODO: Deprecate interface `ScatterRegion`. @@ -1323,5 +1323,5 @@ func (suite *clientTestSuite) TestScatterRegion() { return resp.GetRegionId() == regionID && string(resp.GetDesc()) == "scatter-region" && resp.GetStatus() == pdpb.OperatorStatus_RUNNING - }, testutil.WithTickInterval(1*time.Second)) + }, testutil.WithTickInterval(time.Second)) } diff --git a/tests/server/member/member_test.go b/tests/server/member/member_test.go index 46c3b2a8713..15819bb4bf4 100644 --- a/tests/server/member/member_test.go +++ b/tests/server/member/member_test.go @@ -199,7 +199,7 @@ func waitEtcdLeaderChange(re *require.Assertions, server *tests.TestServer, old return false } return leader != old - }, testutil.WithWaitFor(time.Second*90), testutil.WithTickInterval(time.Second)) + }, testutil.WithWaitFor(90*time.Second), testutil.WithTickInterval(time.Second)) return leader } diff --git a/tests/server/tso/allocator_test.go b/tests/server/tso/allocator_test.go index d35a551ac4b..4640a74239a 100644 --- a/tests/server/tso/allocator_test.go +++ b/tests/server/tso/allocator_test.go @@ -166,7 +166,7 @@ func TestPriorityAndDifferentLocalTSO(t *testing.T) { defer wg.Done() testutil.Eventually(re, func() bool { return cluster.WaitAllocatorLeader(dc) == serName - }, testutil.WithWaitFor(time.Second*90), testutil.WithTickInterval(time.Second)) + }, testutil.WithWaitFor(90*time.Second), testutil.WithTickInterval(time.Second)) }(serverName, dcLocation) } wg.Wait() diff --git a/tests/server/tso/manager_test.go b/tests/server/tso/manager_test.go index 586a9b72a89..5d19b3edea3 100644 --- a/tests/server/tso/manager_test.go +++ b/tests/server/tso/manager_test.go @@ -182,7 +182,7 @@ func TestNextLeaderKey(t *testing.T) { cluster.CheckClusterDCLocation() currName := cluster.WaitAllocatorLeader("dc-1") return currName == name - }, testutil.WithTickInterval(1*time.Second)) + }, testutil.WithTickInterval(time.Second)) return } }