Files
llmgw/internal/config/facility_test.go
T
Ilker ManapandClaude Opus 5.5 0d3eb82b9b Facility-aware placement: racks, PDUs, holds and power caps
Nodes say where they are with llmgw.io/site, room, row, rack and pdu labels,
from agent.yaml or `llmgw ctl label` (kept in the store, over the agent's).
Placement spreads a model's replicas across racks and PDUs, keeps a
multi-node replica within one domain when its profile says keep_within,
places nothing in a domain held with `llmgw ctl facility hold` (optionally
draining it), and refuses a shard that would take a domain past its power
cap from facility.budgets, counting declared, derived and measured draw.
Explain-placement names the domain, and keeps the rejections of a placed
replica; `ctl nodes` gains LOCATION and --domain; `ctl facility` lists the
domains; the console's Nodes view shows and sets location and holds.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 01:17:49 +02:00

53 lines
1.5 KiB
Go

package config
import (
"strings"
"testing"
)
func TestFacilityBudgetsAreReadFromServerYAML(t *testing.T) {
p := write(t, `
facility:
margin: 0.1
gpu_watts: 700
node_watts: 350
budgets:
- domain: rack:r12-07
cap_watts: 16000
other_watts: 800
- domain: pdu:r12-07-a
cap_watts: 7400
`)
cfg, err := Load(p)
if err != nil {
t.Fatal(err)
}
pol, err := cfg.Facility.Policy()
if err != nil {
t.Fatal(err)
}
if b := pol.Budgets["rack:r12-07"]; b.CapWatts != 16000 || b.OtherWatts != 800 {
t.Errorf("rack budget %+v", b)
}
if pol.Limit("pdu:r12-07-a") != 7400*0.9 || pol.GPUWatts != 700 || pol.NodeWatts != 350 {
t.Errorf("policy %+v", pol)
}
}
func TestAFacilityBudgetThatCannotBeUsedIsRefused(t *testing.T) {
for yaml, want := range map[string]string{
"facility:\n budgets:\n - domain: r12-07\n cap_watts: 1000\n": "level:name",
"facility:\n budgets:\n - domain: rack:r1\n": "cap_watts must be above zero",
"facility:\n margin: 1.5\n": "facility.margin",
"facility:\n budgets:\n - {domain: rack:r1, cap_watts: 1}\n - {domain: rack:r1, cap_watts: 2}\n": "given twice",
} {
cfg, err := Load(write(t, yaml))
if err == nil {
err = cfg.Validate()
}
if err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("%q: got %v, want %q", yaml, err, want)
}
}
}