mirror.peers names the mirrors kept in step with mirror.api. The mirror's management calls go to the first that can be reached, and each mirror is asked every fifteen seconds whether it answers: a shard is sent its model's and adapters' address on one that does while the mirror the catalog names is down. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
39 lines
1.7 KiB
Go
39 lines
1.7 KiB
Go
package agentsvc
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/agent/engines"
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/control/reconciler"
|
|
)
|
|
|
|
func TestAdaptersTravelToTheAgentInOrder(t *testing.T) {
|
|
cmd := reconciler.ShardCommand{ReplicaID: "r", ShardID: "s", Spec: engines.ShardSpec{
|
|
Profile: engines.Profile{Name: "cpu", Engine: "llamacpp", ModelPath: "/m.gguf",
|
|
Adapters: []engines.Adapter{{Name: "sql", Path: "http://mirror/sql.gguf"}, {Name: "docs", Path: "http://mirror/docs.gguf"}}},
|
|
}}
|
|
spec, _ := ShardSpecFromStart(StartShardFromCommand(cmd))
|
|
got := spec.Profile.Adapters
|
|
if len(got) != 2 || got[0].Name != "sql" || got[1].Path != "http://mirror/docs.gguf" {
|
|
t.Errorf("adapters %+v", got)
|
|
}
|
|
}
|
|
|
|
// While its mirror is down, a shard is sent its model and adapters on the
|
|
// mirror the rewrite names, and the command it was made from is left as it is.
|
|
func TestAShardIsSentItsModelOnAMirrorThatAnswers(t *testing.T) {
|
|
SetSourceRewrite(func(s string) string { return strings.Replace(s, "http://mirror-a", "http://mirror-b", 1) })
|
|
t.Cleanup(func() { SetSourceRewrite(func(s string) string { return s }) })
|
|
ads := []engines.Adapter{{Name: "sql", Path: "http://mirror-a/sql.gguf"}}
|
|
cmd := reconciler.ShardCommand{ReplicaID: "r", ShardID: "s", Spec: engines.ShardSpec{
|
|
Profile: engines.Profile{Name: "cpu", Engine: "llamacpp", ModelPath: "http://mirror-a/qwen/v1/", Adapters: ads}}}
|
|
spec, _ := ShardSpecFromStart(StartShardFromCommand(cmd))
|
|
if spec.Profile.ModelPath != "http://mirror-b/qwen/v1/" || spec.Profile.Adapters[0].Path != "http://mirror-b/sql.gguf" {
|
|
t.Errorf("sent %+v", spec.Profile)
|
|
}
|
|
if ads[0].Path != "http://mirror-a/sql.gguf" {
|
|
t.Error("the catalog's adapter was changed in place")
|
|
}
|
|
}
|