From 3ea35a5d5dd2282a27a64520098c8af87d7a4f10 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Tue, 1 Dec 2026 17:33:54 -0800 Subject: [PATCH] storage: tests attach after the upgrade compare pass, unless they watch it An attach after an unclean v1.0 upgrade runs the compare pass and refuses cuts until it ends, so the attach helper now waits for it as it waits for reconciliation (its own bound: a 262,144-chunk test volume takes seconds). Tests that act while the pass runs opt out (withoutPassWait). Co-Authored-By: Claude Opus 5.5 --- .../core/storage/chunk_fake_remote_test.go | 27 +++++++++++++++++++ .../storage/chunk_upgrade_pass_attach_test.go | 1 + .../core/storage/chunk_upgrade_wire_test.go | 1 + 3 files changed, 29 insertions(+) diff --git a/seaweed-block/core/storage/chunk_fake_remote_test.go b/seaweed-block/core/storage/chunk_fake_remote_test.go index 063fa98807..d7b1c1ef59 100644 --- a/seaweed-block/core/storage/chunk_fake_remote_test.go +++ b/seaweed-block/core/storage/chunk_fake_remote_test.go @@ -1130,6 +1130,33 @@ func waitReconciledForTest(t *testing.T, layer chunkLayer) { } time.Sleep(time.Millisecond) } + // An attach after an unclean v1.0 upgrade runs the compare pass, and + // cuts are refused until it ends; contract tests start after it, unless + // the test acts while it runs (withoutPassWait). + if skipPassWaitForTest { + return + } + // The pass reads every unknown chunk: a large test volume (262,144 + // chunks) takes seconds, so its bound is its own. + passDeadline := time.Now().Add(2 * time.Minute) + for layer.Stats().UpgradePass.State == "running" { + if time.Now().After(passDeadline) { + t.Fatalf("upgrade compare pass still running after 2m: %+v", layer.Stats().UpgradePass) + } + time.Sleep(time.Millisecond) + } +} + +// skipPassWaitForTest: the test attaches and acts while the upgrade compare +// pass runs (withoutPassWait). +var skipPassWaitForTest bool + +// withoutPassWait makes the attach helpers return without waiting for the +// upgrade compare pass, for a test that acts while it runs. +func withoutPassWait(t *testing.T) { + t.Helper() + skipPassWaitForTest = true + t.Cleanup(func() { skipPassWaitForTest = false }) } // crashOwnedMap closes the owned-map file of a crashed store without diff --git a/seaweed-block/core/storage/chunk_upgrade_pass_attach_test.go b/seaweed-block/core/storage/chunk_upgrade_pass_attach_test.go index 098401800c..217f4c4de7 100644 --- a/seaweed-block/core/storage/chunk_upgrade_pass_attach_test.go +++ b/seaweed-block/core/storage/chunk_upgrade_pass_attach_test.go @@ -21,6 +21,7 @@ import ( // its completion, that signal can replace it. func TestV11UncleanUpgradeLeavesNoUnknownAfterThePass(t *testing.T) { withV11Format(t) + withoutPassWait(t) // the test watches the pass from the attach on s, _ := v11Store(t) if err := s.SetLayoutIdentity("claim-a", false); err != nil { t.Fatal(err) diff --git a/seaweed-block/core/storage/chunk_upgrade_wire_test.go b/seaweed-block/core/storage/chunk_upgrade_wire_test.go index 2eb3ef46e9..b0be549e9b 100644 --- a/seaweed-block/core/storage/chunk_upgrade_wire_test.go +++ b/seaweed-block/core/storage/chunk_upgrade_wire_test.go @@ -59,6 +59,7 @@ func waitPass(t *testing.T, l *chunkLayerImpl, what string, ok func(UpgradePassS func slowPass(t *testing.T) { t.Helper() + withoutPassWait(t) upgradePassTestInterval, upgradePassTestPersistEvery = 40*time.Millisecond, 2 t.Cleanup(func() { upgradePassTestInterval, upgradePassTestPersistEvery, upgradeCompareTestHook = 0, 0, nil }) }