From 127a122785a2c42d0002d43d4ee4eff8c81b2c8d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Fri, 20 Nov 2026 10:13:02 -0800 Subject: [PATCH] test(storage): reproduce over-budget retry and drain controls --- .../core/storage/chunk_precopy_detach_test.go | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/seaweed-block/core/storage/chunk_precopy_detach_test.go b/seaweed-block/core/storage/chunk_precopy_detach_test.go index e7a8b5dfb6..41b33c5fce 100644 --- a/seaweed-block/core/storage/chunk_precopy_detach_test.go +++ b/seaweed-block/core/storage/chunk_precopy_detach_test.go @@ -350,7 +350,19 @@ func TestPrecopyDetachExcludesServingPreparationFromFreezeCost(t *testing.T) { } func TestPrecopyDetachRetryResolvesPreviouslyAppliedDetachedCut(t *testing.T) { + precopyAppliedDetachRetryControl(t, false) +} + +func TestPrecopyDetachAppliedRetryRetainsSlowFixedCost(t *testing.T) { + precopyAppliedDetachRetryControl(t, true) +} + +func precopyAppliedDetachRetryControl(t *testing.T, slow bool) { + t.Helper() _, f, l, _ := precopyLayer(t, 1024, 1) + if slow { + f.beforeCAS = func(*fakeChunkRemote) { time.Sleep(1300 * time.Millisecond) } + } if _, err := l.Cut(ctTimeout(t)); err != nil { t.Fatal(err) } @@ -456,7 +468,23 @@ func TestPrecopyDrainLetsAnAdmittedWriterReachTheBarrier(t *testing.T) { } func TestPrecopyAttemptDiagnosticsSeparateTimeoutFromFit(t *testing.T) { - _, _, l, _ := precopyLayer(t, 1024, 0) + precopyAttemptDiagnosticsControl(t, false) +} + +func TestPrecopyAttemptDiagnosticsRetainSlowFixedCost(t *testing.T) { + precopyAttemptDiagnosticsControl(t, true) +} + +func precopyAttemptDiagnosticsControl(t *testing.T, slow bool) { + t.Helper() + s, f, l, w := precopyLayer(t, 1024, 0) + if slow { + w.write(t, s, 1, 0x10) + f.beforeCAS = func(*fakeChunkRemote) { time.Sleep(1300 * time.Millisecond) } + if _, err := l.Cut(ctTimeout(t)); err != nil { + t.Fatal(err) + } + } calls := 0 r, err := l.PrecopyDetachWithAdmission(ctTimeout(t), func(ctx context.Context) (func(), error) { calls++