Files
llmgw/internal/control/agentsvc/installable_test.go
T
Ilker ManapandClaude Opus 5.5 e313f32696 Decide engines per node, and let a node join without one it cannot run
engine_overrides give nodes picked by GPU class, id or labels their own
engine versions; node add --disable-engine keeps one off a node; what
vLLM cannot do on a node is a warning rather than a refused node; the
CUDA requirement follows the version; a hand-named binary is no longer
replaced by an installed one.

Refs #2 (items 4 and 7).

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

57 lines
2.1 KiB
Go

package agentsvc
import (
"slices"
"testing"
llmgwv1 "gitea.mynodes.xyz/ilker/llmgw/api/gen/llmgw/v1"
"gitea.mynodes.xyz/ilker/llmgw/internal/agent/provision"
"gitea.mynodes.xyz/ilker/llmgw/internal/control/inventory"
)
func TestANodeIsAskedOnlyForEnginesItCanInstall(t *testing.T) {
// An agent older than the list says nothing, and could install llama.cpp
// alone. Asked for vLLM, it showed as failing until it was upgraded.
if got := installable(&llmgwv1.Register{}); !slices.Equal(got, []string{"llamacpp"}) {
t.Errorf("an agent that said nothing: %v", got)
}
// This agent says what it can, and that is vLLM and SGLang besides.
now := &llmgwv1.Register{InstallableEngines: provision.Installable()}
for _, e := range []string{"llamacpp", "vllm", "sglang"} {
if !slices.Contains(installable(now), e) {
t.Errorf("this agent does not offer %s: %v", e, installable(now))
}
}
if slices.Contains(installable(now), "uv") {
t.Error("uv, a tool for the others, is offered as an engine")
}
}
func TestEachNodeIsToldTheEnginesDecidedForIt(t *testing.T) {
s := &Service{}
s.SetEnginesFor(func(n inventory.Node) map[string]string {
if n.ID == "volta" {
return map[string]string{"llamacpp": "b1", "vllm": "0.25.1"}
}
return map[string]string{"llamacpp": "b1", "vllm": "0.30.0"}
})
reg := &llmgwv1.Register{InstallableEngines: []string{"llamacpp", "vllm"}}
want := func(p *llmgwv1.Provision) map[string]string {
out := map[string]string{}
for _, e := range p.GetEngines() {
out[e.GetEngine()] = e.GetVersion()
}
return out
}
if got := want(s.provisionFor(inventory.Node{ID: "volta"}, reg)); got["vllm"] != "0.25.1" {
t.Errorf("the Volta node: %v", got)
}
if got := want(s.provisionFor(inventory.Node{ID: "hopper"}, reg)); got["vllm"] != "0.30.0" {
t.Errorf("the Hopper node: %v", got)
}
// A node that disabled vLLM does not offer it, and is not asked for it.
if got := want(s.provisionFor(inventory.Node{ID: "hopper"}, &llmgwv1.Register{InstallableEngines: []string{"llamacpp"}})); got["vllm"] != "" {
t.Errorf("asked a node for an engine it does not install: %v", got)
}
}