Safe removal (R-1044), found on Tester 1 G4: the drive gate leaves a safely removed drive alone (no false RETURNED/ABSENT, no mail); presence = backing device, not the agent's state
gates / gates (push) Successful in 46s

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
2026-10-15 10:25:08 +02:00
parent a09cab124a
commit 37ffa3beb5
5 changed files with 87 additions and 14 deletions
@@ -3,6 +3,9 @@ package web
import (
"testing"
"time"
"gitea.dooplex.hu/admin/felhom-controller/internal/agentapi"
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
)
// „Later" is tonight 03:30 Budapest time — or tomorrow's when it is already past 03:30.
@@ -18,3 +21,25 @@ func TestNextMediaLater(t *testing.T) {
}
}
}
// R-1044, the records measured on Tester 1 (Part G4): a pulled, registered disk keeps state „attached" with an EMPTY
// backing device; the decision must read the backing device. COMPANION RED-PROOF: use `disk.State == "attached"` as
// presence → the „gone" case fails (the box never notices the disk left — what rc.2 did on Tester 1). Restored.
func TestEjectStep_G4(t *testing.T) {
sp := settings.StoragePath{Path: "/mnt/felhom-drives/media_d", EjectedAt: "2026-10-15T08:10:20Z", EjectDurableID: "uuid:8a31"}
in := agentapi.DiskInfo{DurableID: "uuid:8a31", State: "attached", BackingDevice: "/dev/sdd", MountPath: "/mnt/media_d", TotalBytes: 21474836480}
gone := agentapi.DiskInfo{DurableID: "uuid:8a31", State: "attached", BackingDevice: "", MountPath: "/mnt/media_d"}
if st, _ := ejectStep(sp, []agentapi.DiskInfo{in}); st != ejectWaitGone {
t.Fatalf("still in the box right after the removal: want wait-gone, got %d", st)
}
if st, _ := ejectStep(sp, []agentapi.DiskInfo{gone}); st != ejectGone {
t.Fatalf("pulled (state attached, no backing device): want gone, got %d", st)
}
sp.EjectSeenGone = true
if st, _ := ejectStep(sp, []agentapi.DiskInfo{gone}); st != ejectWaitBack {
t.Fatalf("still gone: want wait-back, got %d", st)
}
if st, d := ejectStep(sp, []agentapi.DiskInfo{in}); st != ejectBack || d == nil {
t.Fatalf("plugged back: want back, got %d", st)
}
}