package storage import ( "context" "testing" "gitea.dooplex.hu/admin/felhom-agent/internal/proxmox" ) // R-672 (v0.133.0): a thin pool crossing 90 % requests an out-of-band host report ONCE, through the // watchdog's own read path (Known — every few seconds), so the hub's storage-fill alarm sees the pool in // seconds, not at the next 15-minute report. Re-armed below 85 %. // // COMPANION RED-PROOF (REPORT): remove the noteThinFill call from the data path → "no report was // requested when the pool crossed 90 %". func TestThinHigh_RequestsOneReportPerCrossing(t *testing.T) { pool := proxmox.Storage{Storage: "local-lvm", Type: "lvmthin", Content: "rootdir,images", Total: 1000, Active: 1} api := &fakeStorageAPI{node: "n", cluster: []proxmox.Storage{pool}} o := NewObserver(api, &fakeHostReader{}, nil, quietLogger()) asked := 0 o.SetThinHighTrigger(func() { asked++ }) for i, used := range []int64{800, 910, 950, 1000, 840, 920} { p := pool p.Used, p.Avail, p.UsedFraction = used, 1000-used, float64(used)/1000 api.nodeSt = []proxmox.Storage{p} if _, err := o.Known(context.Background()); err != nil { t.Fatal(err) } want := map[int]int{0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 5: 2}[i] if asked != want { t.Fatalf("after %d/1000 used: %d report requests, want %d", used, asked, want) } } }