Skip to content

Commit d72a784

Browse files
authored
br/pkg/streamhelper: fix flaky TestGCServiceSafePoint assertion (pingcap#66755)
close pingcap#66731
1 parent b66d3e0 commit d72a784

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

br/pkg/streamhelper/advancer_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,15 @@ func TestGCServiceSafePoint(t *testing.T) {
209209

210210
req.NoError(adv.OnTick(ctx))
211211
req.Equal(env.serviceGCSafePoint, cp-1)
212+
env.fakeCluster.mu.Lock()
213+
req.True(env.serviceGCSafePointSet)
214+
env.fakeCluster.mu.Unlock()
212215

213216
env.unregisterTask()
214217
req.Eventually(func() bool {
215218
env.fakeCluster.mu.Lock()
216219
defer env.fakeCluster.mu.Unlock()
217-
return env.serviceGCSafePoint != 0 && env.serviceGCSafePointDeleted
220+
return env.serviceGCSafePointDeleted
218221
}, 3*time.Second, 100*time.Millisecond)
219222
}
220223

br/pkg/streamhelper/basic_lib_for_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ type fakeCluster struct {
108108
onGetClient func(uint64) error
109109
onClearCache func(uint64) error
110110
serviceGCSafePoint uint64
111+
serviceGCSafePointSet bool
111112
serviceGCSafePointDeleted bool
112113
currentTS uint64
113114
}
@@ -279,6 +280,7 @@ func (f *fakeCluster) BlockGCUntil(ctx context.Context, at uint64) (uint64, erro
279280
return f.serviceGCSafePoint, errors.Errorf("minimal safe point %d is greater than the target %d", f.serviceGCSafePoint, at)
280281
}
281282
f.serviceGCSafePoint = at
283+
f.serviceGCSafePointSet = true
282284
return at, nil
283285
}
284286

0 commit comments

Comments
 (0)