Skip to content

Commit

Permalink
br: reduce sleep seconds for unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
3pointer committed Aug 6, 2021
1 parent fe28074 commit 389b4e1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions br/pkg/lightning/restore/checksum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -276,26 +276,26 @@ 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
}()

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))

// after remove the job, there are no job remain, gc ttl needn't to be updated
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)
}

Expand Down

0 comments on commit 389b4e1

Please sign in to comment.