Skip to content

Commit

Permalink
*: make TestConcurrentlyReset stable (#8082)
Browse files Browse the repository at this point in the history
close #6898

Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
rleungx and ti-chi-bot[bot] authored Apr 18, 2024
1 parent 956684a commit ad5ba18
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/api/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (suite *adminTestSuite) TestPersistFile() {

func makeTS(offset time.Duration) uint64 {
physical := time.Now().Add(offset).UnixNano() / int64(time.Millisecond)
return uint64(physical << 18)
return uint64(physical) << 18
}

func (suite *adminTestSuite) TestResetTS() {
Expand Down
6 changes: 3 additions & 3 deletions tests/integrations/tso/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ func (suite *tsoServerTestSuite) TestConcurrentlyReset() {
for i := 0; i < 2; i++ {
go func() {
defer wg.Done()
for j := 0; j <= 100; j++ {
for j := 0; j <= 50; j++ {
// Get a copy of now then call base.add, because now is shared by all goroutines
// and now.add() will add to itself which isn't atomic and multi-goroutine safe.
base := now
physical := base.Add(time.Duration(2*j)*time.Minute).UnixNano() / int64(time.Millisecond)
ts := uint64(physical << 18)
physical := base.Add(time.Duration(j)*time.Minute).UnixNano() / int64(time.Millisecond)
ts := uint64(physical) << 18
suite.resetTS(ts, false, false)
}
}()
Expand Down

0 comments on commit ad5ba18

Please sign in to comment.