hub v0.137.0 source + burn-down round 2 in felhom.eu: R-277 R-581 R-600 R-544 R-855 R-134 R-92 R-292 R-599 R-725 R-728 (hub), R-819 R-857 R-555 R-364 R-587 (gates/tools), R-571 R-129 R-124-runbook (docs); 28 rows closed incl. catalog + agent v0.147.0 rows, R-350 merged into R-132, R-888 opened, R-887 mechanism (249 -> 222)
gates / gates (push) Successful in 2m3s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
2026-10-05 19:43:37 +02:00
parent e0d884565f
commit 557629d2bf
65 changed files with 2680 additions and 122 deletions
+63
View File
@@ -0,0 +1,63 @@
package web
import (
"strings"
"testing"
"time"
"gitea.dooplex.hu/admin/felhom-hub/internal/monitor"
)
// R-277(b): a small but non-empty off-site repo must not render as "0.0 GB" on the Offsite page — that
// reading is how a healthy tier was reported to the operator as absent.
func TestOffsiteRow_SmallRepoNotZeroGB(t *testing.T) {
s, st := newRenderServer(t)
s.SetOffsiteBox(func() (monitor.BoxSnapshot, bool) {
return monitor.BoxSnapshot{CapacityBytes: 1 << 40, FillBand: "ok", OversubBand: "ok", FetchedAt: time.Now().UTC()}, true
})
saveCfg(t, st, "tiny", `{"offsite":{"enabled":true,"type":"shared","quota_gb":500}}`)
if err := st.SaveReport("tiny", []byte(`{"customer_id":"tiny","offsite":{"enabled":true,"repo_size_bytes":165888}}`)); err != nil {
t.Fatal(err)
}
rows := s.offsiteCustomerRows()
if len(rows) != 1 {
t.Fatalf("want 1 row, got %d", len(rows))
}
if rows[0].UsageStr == "0.0 GB" || rows[0].UsageStr != "162.0 KB" {
t.Fatalf("162 KB repo rendered as %q, want \"162.0 KB\"", rows[0].UsageStr)
}
body := renderOffsite(t, s)
if !strings.Contains(body, "162.0 KB") {
t.Fatal("Offsite page must show the small repo's real size")
}
// Above 1 GB the unit stays GB (same as the quota column).
if got := fmtBytesAuto(200 * gib); got != "200.0 GB" {
t.Fatalf("200 GiB = %q, want 200.0 GB", got)
}
}
// R-92: two PBS DR polls 50 MB apart read identically at 0.1 GB granularity; the page must show a value
// that differs between them, so a small delta (a prune, a GC) is verifiable from the hub.
func TestPBSDRPanel_ExactBytesShowsSmallDelta(t *testing.T) {
render := func(used int64) string {
s, _ := newRenderServer(t)
s.SetPBSDRBox(func() (monitor.PBSBoxSnapshot, bool) {
return monitor.PBSBoxSnapshot{
CapacityBytes: 40 * gib, UsedBytes: used, FillPercent: 20, FillBand: "ok",
State: monitor.PBSStateOK, FetchedAt: time.Now().UTC(),
}, true
})
return pbsSection(renderOffsite(t, s))
}
a := render(8 * gib)
b := render(8*gib + 50_000_000)
if !strings.Contains(a, "8 589 934 592 bytes") {
t.Fatalf("PBS DR panel must show exact bytes:\n%s", a)
}
if !strings.Contains(b, "8 639 934 592 bytes") {
t.Fatalf("PBS DR panel must show the +50 MB exact value:\n%s", b)
}
if fmtBytesExact(999) != "999 bytes" || fmtBytesExact(1000) != "1 000 bytes" {
t.Fatalf("grouping wrong: %q %q", fmtBytesExact(999), fmtBytesExact(1000))
}
}