package stacks import ( "io" "log" "os" "strings" "testing" "gitea.dooplex.hu/admin/felhom-controller/internal/config" ) // R-1125: the install page and the install check read memory the SAME way. „Used" is the installed (running) apps' // committed requests — never /proc's host-wide figure, which the page used before 2026-10-17 (on scratch 9202 it // showed 12,637 MB „needed" while the check counted 2,648 MB). // RED-PROOF (2026-10-17): the deploy handler back on system.GetMemoryMB fails the source half. func TestR1125_InstallMemoryIsTheChecksReading(t *testing.T) { cfg := config.Default() m := &Manager{cfg: cfg, logger: log.New(io.Discard, "", 0), stacks: map[string]*Stack{ "a": {Deployed: true, State: StateRunning, Meta: Metadata{Resources: ResourceHints{MemRequest: "600M", MemLimit: "1664M"}}}, "b": {Deployed: true, State: StateRunning, Meta: Metadata{Resources: ResourceHints{MemRequest: "2048M", MemLimit: "4096M"}}}, "c": {Deployed: true, State: StateStopped, Meta: Metadata{Resources: ResourceHints{MemRequest: "900M"}}}, "d": {Deployed: false, Meta: Metadata{Resources: ResourceHints{MemRequest: "500M"}}}, }} _, reserved, used, ok := m.InstallMemory() if !ok { t.Skip("no memory reading on this platform") } if used != 2648 { t.Fatalf("„used\" must be the running installed apps' requests (600+2048), got %d", used) } if reserved != cfg.System.ReservedMemoryMB { t.Fatalf("reserve %d, want the configured %d", reserved, cfg.System.ReservedMemoryMB) } src, err := os.ReadFile("../web/handlers.go") if err != nil { t.Fatal(err) } body := string(src) i := strings.Index(body, "// Memory info for deploy page") if i < 0 { t.Fatal("the deploy page's memory block moved — re-point this test") } block := body[i : i+1200] if !strings.Contains(block, "s.stackMgr.InstallMemory()") || strings.Contains(block, "system.GetMemoryMB()") { t.Fatalf("the install page must read memory through InstallMemory, the check's own reading:\n%s", block) } }