mesh/merge-gate pass: builds build-agent, mesh-controller, route-proxy → ace, g14, novox, shanks; no bus step; every machine composes with the change as it…
mesh/repo-check pass: its merge-check.sh passed
mesh/delivery superseded: a newer delivery to the same trunk took over its walk
The store's tools and a machine's image pruning decide from the records, so the controller says them: artifacts (every recorded artifact, kept and why, eligible, collected on request), collect (the after-build sweep on demand, a dry run unless confirmed with a why, recorded as a hand act) and images (what a machine's declaration names, now and as last sent). The sweep is one implementation with two sets of bounds.
67 lines
2.1 KiB
Go
67 lines
2.1 KiB
Go
package inventory
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/novox/mesh-controller/internal/catalogue"
|
|
)
|
|
|
|
// **Every artifact made has one state, and a kept one says why** (novox/hq ADR 0251): what the
|
|
// store's own tools set beside what the store holds, so an operator reads why something stays.
|
|
func TestEveryArtifactMadeHasAStateAndAKeptOneSaysWhy(t *testing.T) {
|
|
inv := fresh(t)
|
|
ctx := context.Background()
|
|
var made []string
|
|
for i := 1; i <= 8; i++ {
|
|
made = append(made, built(t, inv, fmt.Sprintf("b%02d", i), "web", i))
|
|
}
|
|
// The definition names the oldest and the newest: the newest is kept for both reasons.
|
|
m := catalogue.Manifest{Module: "web", Version: "1", Resources: []map[string]any{
|
|
{"id": "app", "type": "container", "name": "web", "image": made[0]},
|
|
{"id": "next", "type": "container", "name": "web-next", "image": made[7]},
|
|
}}
|
|
if err := inv.RegisterModule(ctx, m, Source{Repository: "https://forge.invalid/web.git"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := inv.MarkCollected(ctx, []string{made[1]}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
states, err := inv.Artifacts(ctx)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(states) != len(made) {
|
|
t.Fatalf("%d states for %d artifacts made", len(states), len(made))
|
|
}
|
|
want := []struct {
|
|
state string
|
|
why []string
|
|
}{
|
|
{ArtifactKept, []string{KeptByDefinition}},
|
|
{ArtifactCollected, nil},
|
|
{ArtifactEligible, nil},
|
|
{ArtifactKept, []string{KeptByRecentBuild}},
|
|
{ArtifactKept, []string{KeptByRecentBuild}},
|
|
{ArtifactKept, []string{KeptByRecentBuild}},
|
|
{ArtifactKept, []string{KeptByRecentBuild}},
|
|
{ArtifactKept, []string{KeptByRecentBuild, KeptByDefinition}},
|
|
}
|
|
for i, s := range states {
|
|
if s.Reference != made[i] {
|
|
t.Fatalf("state %d is of %s, want %s: the oldest first", i, s.Reference, made[i])
|
|
}
|
|
if s.State != want[i].state || fmt.Sprint(s.Why) != fmt.Sprint(want[i].why) {
|
|
t.Errorf("%s: %s %v, want %s %v", s.Reference, s.State, s.Why, want[i].state, want[i].why)
|
|
}
|
|
}
|
|
collect, err := inv.ToCollect(ctx)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(collect) != 1 || collect[0] != made[2] {
|
|
t.Errorf("ToCollect is %v, want only the eligible %s", collect, made[2])
|
|
}
|
|
}
|