A reconcile pass that does something is a trace, with placement (where it went, or every candidate turned down), scale-up/down, drain, stop, eviction, preemption, reaping and restarts beneath it. A replica's start is a span open from placement until it serves; the start command carries its context in a new ControlMessage.trace field, and the agent continues the trace through the weights fetch, engine launch, rendezvous and readiness wait. Stops, drains, adoption and engine installs are traced on the node, model jobs are a trace with a span per step linked to the replica's start, and agent.yaml takes the same tracing block as server.yaml. Off, every span is the no-op one and commands carry nothing. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
44 lines
1.5 KiB
Go
44 lines
1.5 KiB
Go
package weights
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/obs/obstest"
|
|
)
|
|
|
|
func TestAFetchSaysInItsTraceWhetherItDownloadedAndHowMuch(t *testing.T) {
|
|
rec := obstest.Record(t)
|
|
srv := serveBytes(t, []byte("forty gigabytes, give or take"), nil)
|
|
f := &Fetcher{CacheDir: t.TempDir()}
|
|
src := strings.Replace(srv.URL, "http://", "http://user:secret@", 1) + "/m/model.gguf?token=hunter2"
|
|
|
|
if _, err := f.Ensure(t.Context(), src); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
fetch := rec.One(t, [16]byte{}, "fetch weights")
|
|
a := obstest.Attrs(fetch)
|
|
if a["llmgw.weights.outcome"] != "downloaded" {
|
|
t.Errorf("the first fetch says %v", a)
|
|
}
|
|
if strings.Contains(a["llmgw.weights.source"], "secret") || strings.Contains(a["llmgw.weights.source"], "hunter2") {
|
|
t.Errorf("the trace holds the source's credentials: %s", a["llmgw.weights.source"])
|
|
}
|
|
dl := rec.One(t, fetch.SpanContext().TraceID(), "download")
|
|
if !obstest.ChildOf(dl, fetch) || obstest.Attrs(dl)["llmgw.weights.bytes"] != "29" {
|
|
t.Errorf("the download does not say how much it moved: %v", obstest.Attrs(dl))
|
|
}
|
|
|
|
// The second start on this node finds it here.
|
|
if _, err := f.Ensure(t.Context(), src); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
again := rec.Named("fetch weights")
|
|
if len(again) != 2 || obstest.Attrs(again[1])["llmgw.weights.outcome"] != "cached" {
|
|
t.Errorf("the second fetch says %v", obstest.Attrs(again[len(again)-1]))
|
|
}
|
|
if len(rec.Named("download")) != 1 {
|
|
t.Error("a cached file was downloaded again")
|
|
}
|
|
}
|