ops: Signal disk-full and eviction capacity pressure #46
@@ -1050,13 +1050,21 @@ func TestP1_03_EvictionAlgorithmsDistinct(t *testing.T) {
|
||||
// TestDiskOnlyDelayedAttach covers pure disk-only mode (mem=0 + disk>0) hitting the exact delayed attach path.
|
||||
// During init window (pre Size barrier), TieredCache has no slow tier so Create returns ErrNotFound (proxy semantics, no disk caching).
|
||||
// Post-barrier + attach, Create succeeds. Uses real temp dir.
|
||||
// An init hold keeps the empty-dir attach from finishing before the pending assertions (CI race).
|
||||
func TestDiskOnlyDelayedAttach(t *testing.T) {
|
||||
t.Parallel()
|
||||
td := t.TempDir()
|
||||
diskPath := filepath.Join(td, "disk")
|
||||
if err := os.MkdirAll(diskPath, 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hold := make(chan struct{})
|
||||
var holdOnce sync.Once
|
||||
closeHold := func() { holdOnce.Do(func() { close(hold) }) }
|
||||
disk.RegisterInitHold(diskPath, hold)
|
||||
t.Cleanup(func() {
|
||||
closeHold()
|
||||
disk.ClearInitHold(diskPath)
|
||||
})
|
||||
|
||||
// mem=0, disk>0 -> pure disk delayed path (go func)
|
||||
sc, err := New("localhost:0", "0", "10MB", diskPath, "", "lru", "lru", 10, 1, "0", nil, "")
|
||||
@@ -1064,6 +1072,7 @@ func TestDiskOnlyDelayedAttach(t *testing.T) {
|
||||
t.Fatalf("New disk-only: %v", err)
|
||||
}
|
||||
t.Cleanup(func() { sc.Shutdown() })
|
||||
t.Cleanup(closeHold) // before Shutdown: attach is blocked in Size() until the hold closes
|
||||
|
||||
// Immediately in window: no slow tier attached yet -> Create must ErrNotFound (proxy, no disk write)
|
||||
_, err = sc.vfs.Create("during-init-key", 100)
|
||||
@@ -1077,6 +1086,7 @@ func TestDiskOnlyDelayedAttach(t *testing.T) {
|
||||
t.Errorf("during pending attach, DiskTierReady=%d, want 0", got)
|
||||
}
|
||||
|
||||
closeHold()
|
||||
// Wait the barrier (exercises the attach go's Size wait)
|
||||
_ = sc.disk.Size()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user