Files
mesh-controller/cmd/mesh-controller/same_program_integration_test.go
T

52 lines
2.1 KiB
Go

//go:build integration
package main
import (
"strings"
"testing"
"time"
"git.novox.be/novox/mesh-sdk/go/catalogue"
"github.com/novox/mesh-controller/internal/inventory"
)
// R4e A9 (ADR 0453 §6, ADR 0499; issue 1851), against the store and a real bus: a merge of a file no module reads moves
// nothing. Its module's fingerprint at the merge, as the indexer wrote it, is the fingerprint of the build the mesh holds,
// so the walk is cut done with nothing to walk, and its record names the module unchanged and why — the walk
// mesh-delivery reads as delivered, never stranded; no build is asked.
func TestAWalkWhoseEveryFingerprintIsUnchangedIsDone(t *testing.T) {
open := windowed(t)
endsItsLine(t)
noBuildAsked(t)
b := aBuilderOnTheBus(t)
ctx := t.Context()
inv := open.inventory
fp := fpOf('5')
if err := inv.RecordBuild(ctx, inventory.Build{ID: "key-held", Repository: "novox/one", Ref: "main",
Module: "one", Commit: "c0", On: "ace", SourceFingerprint: fp,
Made: []inventory.Artifact{{Name: "one", Kind: "image", Reference: "store/one@sha256:aaaa"}}}); err != nil {
t.Fatal(err)
}
if err := inv.RegisterModule(ctx, catalogue.Manifest{Module: "one", Version: "1", Resources: []map[string]any{
{"id": "app", "type": "container", "name": "one", "image": "store/one@sha256:aaaa"}}},
inventory.Source{Repository: "novox/one", Ref: "main", BuiltFrom: "c0", Asked: time.Now()}); err != nil {
t.Fatal(err)
}
code := repoMerge("one", "one1aaaaaaaa", t0)
b.indexed(t, "one", "1", "novox/one", "", code.Commit, fp)
hear(t, open, code, t0.Add(time.Second))
cutAt(t, open, t0.Add(2*time.Minute))
ws, _ := walks(t, open)
if len(ws) != 1 {
t.Fatalf("walks: %+v", ws)
}
w := ws[0]
if w.State != inventory.PlanDone || len(w.Tiers) != 0 || len(w.Modules) != 0 {
t.Fatalf("the walk reads %s, tiers %v, modules %v; want done with nothing to walk", w.State, w.Tiers, w.Modules)
}
if w.Delivery == nil || !strings.Contains(w.Delivery.Unchanged["one"], "is the build the mesh holds") {
t.Fatalf("the walk does not say one's fingerprint is unchanged: %+v", w.Delivery)
}
}