A profile's cpu_cores is reserved out of its node's CPUs by placement, as memory is, and becomes the engine's thread count. Agents report their CPU count in registration and heartbeats. New CPU models must declare memory; model views show reserved against measured memory with warnings, and ctl model resources sets both for a stored model. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
46 lines
1.6 KiB
Go
46 lines
1.6 KiB
Go
package adminapi
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/control/catalog"
|
|
)
|
|
|
|
func TestAClaimedActorIsOneShortName(t *testing.T) {
|
|
for claimed, want := range map[string]string{
|
|
"ilker": "ilker",
|
|
"": "unknown",
|
|
"ilker\nlevel=ERROR msg=x": "ilkerlevelERRORmsgx",
|
|
strings.Repeat("a", 500): strings.Repeat("a", 64),
|
|
"ops@example.org": "ops@example.org",
|
|
"\x1b[31m": "31m",
|
|
} {
|
|
r := httptest.NewRequest("POST", "/", nil)
|
|
r.Header.Set("X-Llmgw-Actor", claimed)
|
|
if got := actorOf(r); got != want {
|
|
t.Errorf("%q: %q, expected %q", claimed, got, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestAReservationThatPlacementCannotTrustIsSaid(t *testing.T) {
|
|
cpu := func(mem int) catalog.Model {
|
|
return catalog.Model{Name: "m", Profiles: []catalog.Profile{{Name: "cpu", Engine: "llamacpp", MinMemoryGB: mem}}}
|
|
}
|
|
if w := reservationWarnings(cpu(0), 0); len(w) != 1 || !strings.Contains(w[0], "declares no memory") {
|
|
t.Errorf("no memory declared: %v", w)
|
|
}
|
|
if w := reservationWarnings(cpu(6), 8.2); len(w) != 1 || !strings.Contains(w[0], "uses 8.2 GB and reserves 6") {
|
|
t.Errorf("under-declared: %v", w)
|
|
}
|
|
if w := reservationWarnings(cpu(6), 6.4); len(w) != 0 {
|
|
t.Errorf("within a tenth is mapped weights, not a wrong figure: %v", w)
|
|
}
|
|
gpu := catalog.Model{Name: "g", Profiles: []catalog.Profile{{Name: "tp1", Engine: "vllm", GPUClass: "h100-80g"}}}
|
|
if w := reservationWarnings(gpu, 3); len(w) != 0 {
|
|
t.Errorf("a GPU model needs no host memory figure: %v", w)
|
|
}
|
|
}
|