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 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-12-01 17:33:54 -08:00
1 parent 812fcffb35
commit 3ea35a5d5d
3 files changed
+29

No files matched your search

@@ -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
@@ -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)
@@ -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 })
}