R-1192 follow-up: report host swap vs the guests' swap allowance (log once, hub alarm, local API); R-1194: no OOB stanza before the first felhom-sshd pass; unreleased
gates / gates (push) Successful in 1m56s
gates / gates (push) Successful in 1m56s
This commit is contained in:
1 parent
286a7e3ecf
commit
0da792e670
10 files changed
+215
-3
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package localapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// R-1192 follow-up (night 2026-10-21): GET /guest/memory carries the host's swap and this guest's swap allowance, so
|
||||
// the controller's install page can say when the host has no swap behind the guest. 0 is a real answer (no swap);
|
||||
// absent means an older agent.
|
||||
// RED-PROOF: without the two MemoryInfo fields the keys are missing → fails on „host_swap_mb absent".
|
||||
func TestR1192_GuestMemoryCarriesHostAndGuestSwap(t *testing.T) {
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
hostB, guestMB int64
|
||||
wantHost, wantG int64
|
||||
}{
|
||||
{"installer host (7.75 GB swap), guest swap = RAM", 7935 * mib, 8192, 7935, 8192},
|
||||
{"a host with NO swap", 0, 8192, 0, 8192},
|
||||
} {
|
||||
f := stdFixture()
|
||||
f.hostSwapB, f.guestSwapMB = c.hostB, c.guestMB
|
||||
w := do(t, memServer(t, f).Handler(), "GET", "/guest/memory", "A", "")
|
||||
var m struct {
|
||||
Data map[string]any `json:"data"`
|
||||
}
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hs, ok := m.Data["host_swap_mb"].(float64)
|
||||
if !ok {
|
||||
t.Fatalf("%s: host_swap_mb absent: %s", c.name, w.Body.String())
|
||||
}
|
||||
gs, _ := m.Data["guest_swap_mb"].(float64)
|
||||
if int64(hs) != c.wantHost || int64(gs) != c.wantG {
|
||||
t.Fatalf("%s: host %v guest %v, want %d / %d", c.name, hs, gs, c.wantHost, c.wantG)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user