test(chunkstore): a read failure of a deleting volume's root is returned, not skipped

A root whose read fails with an ordinary error (not missing, not corrupt)
on a deleting HEAD makes the re-run return that error, skip nothing and
leave HEAD unchanged; the fake filer gains a failLookup hook (test only).
Skipping every error on a deleting HEAD fails it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-26 05:48:57 -08:00
1 parent a6a2d4433c
commit a9dbdd756c
2 files changed
+55

No files matched your search

@@ -160,6 +160,53 @@ func TestBCatalog_DeleteRerunSkipsOnlyMissingRootsOfADeletingVolume(t *testing.T
}
})
t.Run("read failure of a root of a deleting HEAD", func(t *testing.T) {
c, f, _, _, tgt := rerunFixture(t)
// Interrupt at the source's release: HEAD is deleting, roots intact.
n := 0
f.mu.Lock()
f.failUpdate = func(string) error {
n++
if n == 2 {
return errors.New("injected: interrupted")
}
return nil
}
f.mu.Unlock()
if _, err := c.DeleteVolume(ctx, tgt, okDeleteAuthority{}); err == nil {
t.Fatal("fixture: the delete was not interrupted")
}
ts, _, err := c.open(tgt)
if err != nil {
t.Fatal(err)
}
before, _, err := ts.ReadHead(ctx)
if err != nil || before.State != layout.StateDeleting {
t.Fatalf("fixture: HEAD %+v %v; want deleting", before, err)
}
root := rootOf(t, f, tgt)
sentinel := errors.New("injected: filer read failed")
f.mu.Lock()
f.failUpdate = nil
f.failLookup = func(p string) error {
if p == root {
return sentinel
}
return nil
}
f.mu.Unlock()
skipped, err := c.DeleteVolume(ctx, tgt, okDeleteAuthority{})
f.mu.Lock()
f.failLookup = nil
f.mu.Unlock()
if !errors.Is(err, sentinel) || len(skipped) != 0 {
t.Fatalf("re-run with a root read failure: skipped=%v err=%v; want the read error and nothing skipped", skipped, err)
}
if after, _, err := ts.ReadHead(ctx); err != nil || after.Gen != before.Gen || after.State != layout.StateDeleting {
t.Fatalf("HEAD after the failed re-run %+v %v; want it unchanged (gen %d, deleting)", after, err, before.Gen)
}
})
t.Run("missing root of a live HEAD", func(t *testing.T) {
c, f, _, _, tgt := rerunFixture(t)
root := rootOf(t, f, tgt)
@@ -35,6 +35,9 @@ type fakeFiler struct {
// failDelete, if set, is called before a DeleteEntry is applied; a
// non-nil return fails the call and the entry is NOT deleted.
failDelete func(p string) error
// failLookup, if set, is called before a LookupEntry reads p; a non-nil
// return is the lookup's error (a read or transport failure).
failLookup func(p string) error
// beforeCreate, if set, runs under the lock just before an entry is
// created (it may read f.entries but must not call f's methods).
beforeCreate func(p string)
@@ -65,6 +68,11 @@ func (f *fakeFiler) LookupEntry(_ context.Context, dir, name string) (*filerpb.E
f.mu.Lock()
defer f.mu.Unlock()
p := path.Join(dir, name)
if f.failLookup != nil {
if err := f.failLookup(p); err != nil {
return nil, err
}
}
e, ok := f.entries[p]
var out *filerpb.Entry
if ok {