carlos / platform Public

Start checkpoint loss only after the test upload blocks

Paul Campbell pushed by paul@keymail.dev b3a7ff5b4d13c1a8930131240d88808b6ca0e3ae parent e8fbf9e
1 file changed, +10 −3
  • internal/lease/checkpoint_test.go +10 −3
diff --git a/internal/lease/checkpoint_test.go b/internal/lease/checkpoint_test.go
index b3047e00b..2727cfda4 100644
--- a/internal/lease/checkpoint_test.go
+++ b/internal/lease/checkpoint_test.go
@@ -467,10 +467,20 @@ func TestAcquireLateSuccessGrantsNoHandle(t *testing.T) {
}
func TestCheckpointLossCancelsBlockedSync(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "source.db")
+ seedDB(t, path)
+ b := &blockedReplica{ReplicaClient: lsfile.NewReplicaClient(t.TempDir()), entered: make(chan struct{}), release: make(chan struct{})}
entered := make(chan struct{})
var once sync.Once
backend := &lockStore{beforePut: func(ctx context.Context, p *s3.PutObjectInput) error {
if p.IfMatch != nil {
+ // Keep renewal healthy until the upload is actually blocked.
+ // Setup and filesystem latency must not consume the test lease.
+ select {
+ case <-b.entered:
+ default:
+ return nil
+ }
once.Do(func() { close(entered) })
<-ctx.Done()
return ctx.Err()
@@ -478,9 +488,6 @@ func TestCheckpointLossCancelsBlockedSync(t *testing.T) {
return nil
}}
h := localHeld(t, backend, 600*time.Millisecond)
- path := filepath.Join(t.TempDir(), "source.db")
- seedDB(t, path)
- b := &blockedReplica{ReplicaClient: lsfile.NewReplicaClient(t.TempDir()), entered: make(chan struct{}), release: make(chan struct{})}
h.replicaClient = b
done := make(chan error, 1)
go func() { _, e := h.Checkpoint(context.Background(), path); done <- e }()