Files
Ilker ManapandClaude Opus 5 c1ac2f022f Onboard a node with a script, and find two examples that never worked
New nodes had been joined by hand, four times, by me. There was no procedure,
so there was nothing to be wrong — and nothing to be right either. Two scripts
now: provision-node.sh makes the VM on Proxmox, onboard-node.sh gives it an
identity. They are separate because they are run by different people with
different access, and the second must run where the certificate authority is,
which is the one part that cannot be delegated.

Running them turned up why phase 4 was never verified. FabricAttachment
carried no koanf tags, so the `name:` key the shipped example documents bound
to nothing and `rate_gbps` was never read at all. An agent configured exactly
as instructed refused to start with "fabrics[0]: name is required" — naming
the key the operator had just written. Every fabric in this project had been
configured in a Go test, where the tags do not matter.

The server example did not load either: its models had no source, so it failed
validation the moment anything tried to parse it.

Both examples are now parsed by a test. A published example that has never
been loaded is a guess, and these two had been guesses since they were
written.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 12:28:36 +02:00

63 lines
1.9 KiB
Go

package config
import (
"os"
"path/filepath"
"testing"
)
// TestTheDocumentedAgentExampleLoads parses the file shipped in deploy/examples.
//
// It exists because the example was wrong for the entire life of the project
// and nothing noticed. The fabric struct carried no koanf tags, so the `name:`
// key the example documents bound to nothing, and an agent configured exactly
// as instructed refused to start with "fabrics[0]: name is required" — naming
// the key the operator had just written.
//
// Every fabric until then had been configured in a Go test, where the tags do
// not matter. A published example that has never been parsed is a guess.
func TestTheDocumentedAgentExampleLoads(t *testing.T) {
path := filepath.Join("..", "..", "deploy", "examples", "agent.yaml")
if _, err := os.Stat(path); err != nil {
t.Skipf("no example to check: %v", err)
}
cfg, err := LoadAgent(path)
if err != nil {
t.Fatalf("the documented example does not load: %v", err)
}
if len(cfg.Fabrics) == 0 {
t.Fatal("the example documents a fabric and none was parsed")
}
f := cfg.Fabrics[0]
if f.Fabric == "" {
t.Error("the fabric name did not bind")
}
if len(f.HCAs) == 0 {
t.Error("the fabric's adapters did not bind")
}
if f.RateGbps == 0 {
t.Error("the fabric's rate did not bind")
}
if cfg.NodeID == "" || cfg.Server == "" {
t.Errorf("node_id=%q server=%q", cfg.NodeID, cfg.Server)
}
}
func TestTheDocumentedServerExampleLoads(t *testing.T) {
path := filepath.Join("..", "..", "deploy", "examples", "server.yaml")
if _, err := os.Stat(path); err != nil {
t.Skipf("no example to check: %v", err)
}
cfg, err := Load(path)
if err != nil {
t.Fatalf("the documented example does not load: %v", err)
}
if err := cfg.Validate(); err != nil {
t.Fatalf("the documented example does not validate: %v", err)
}
if cfg.Listen == "" || len(cfg.Models) == 0 {
t.Errorf("listen=%q models=%d", cfg.Listen, len(cfg.Models))
}
}