From 389b4e19bbd9f776fb5354d968e947b9ec502c2e Mon Sep 17 00:00:00 2001 From: 3pointer Date: Thu, 5 Aug 2021 19:41:28 +0800 Subject: [PATCH] br: reduce sleep seconds for unit test --- br/pkg/lightning/restore/checksum_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/br/pkg/lightning/restore/checksum_test.go b/br/pkg/lightning/restore/checksum_test.go index 50d1584e32ac2..d63358c37256b 100644 --- a/br/pkg/lightning/restore/checksum_test.go +++ b/br/pkg/lightning/restore/checksum_test.go @@ -157,7 +157,7 @@ func (s *checksumSuite) TestDoChecksumWithTikv(c *C) { // set up mock tikv checksum manager pdClient := &testPDClient{} resp := tipb.ChecksumResponse{Checksum: 123, TotalKvs: 10, TotalBytes: 1000} - kvClient := &mockChecksumKVClient{checksum: resp, respDur: time.Second * 5} + kvClient := &mockChecksumKVClient{checksum: resp, respDur: time.Millisecond * 200} // mock a table info p := parser.New() @@ -276,8 +276,8 @@ func (s *checksumSuite) TestGcTTLManagerSingle(c *C) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() oldTTL := serviceSafePointTTL - // set serviceSafePointTTL to 3 second, so lightning will update it in each 1 seconds. - serviceSafePointTTL = 3 + // set serviceSafePointTTL to 1 second, so lightning will update it in each 1/3 seconds. + serviceSafePointTTL = 1 defer func() { serviceSafePointTTL = oldTTL }() @@ -285,9 +285,9 @@ func (s *checksumSuite) TestGcTTLManagerSingle(c *C) { err := manager.addOneJob(ctx, "test", uint64(time.Now().Unix())) c.Assert(err, IsNil) - time.Sleep(6*time.Second + 10*time.Millisecond) + time.Sleep(2*time.Second + 10*time.Millisecond) - // after 6 seconds, must at least update 5 times + // after 2 seconds, must at least update 5 times val := atomic.LoadInt32(&pdClient.count) c.Assert(val, GreaterEqual, int32(5)) @@ -295,7 +295,7 @@ func (s *checksumSuite) TestGcTTLManagerSingle(c *C) { manager.removeOneJob("test") time.Sleep(10 * time.Millisecond) val = atomic.LoadInt32(&pdClient.count) - time.Sleep(3*time.Second + 10*time.Millisecond) + time.Sleep(1*time.Second + 10*time.Millisecond) c.Assert(atomic.LoadInt32(&pdClient.count), Equals, val) }