Skip to content

Commit

Permalink
test: fix TestClearCache (#52279)
Browse files Browse the repository at this point in the history
close #52123
  • Loading branch information
zxc111 committed Apr 1, 2024
1 parent f7d66f4 commit c9a250a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions br/pkg/streamhelper/advancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,20 @@ func TestClearCache(t *testing.T) {
return nil
}
failedStoreID := uint64(0)
hasFailed := false
hasFailed := atomic.NewBool(false)
for _, s := range c.stores {
s.clientMu.Lock()
sid := s.GetID()
s.onGetRegionCheckpoint = func(glftrr *logbackup.GetLastFlushTSOfRegionRequest) error {
// mark this store cache cleared
failedStoreID = s.GetID()
if !hasFailed {
hasFailed = true
// mark one store failed is enough
if hasFailed.CompareAndSwap(false, true) {
// mark this store cache cleared
failedStoreID = sid
return errors.New("failed to get checkpoint")
}
return nil
}
s.clientMu.Unlock()
// mark one store failed is enough
break
}
env := &testEnv{fakeCluster: c, testCtx: t}
adv := streamhelper.NewCheckpointAdvancer(env)
Expand Down

0 comments on commit c9a250a

Please sign in to comment.