Every caller composes through mesh-sdk's go/compose since issues 1386 to 1388; the controller's second copy of the composition is dead code. The parent of this commit isfb556d6b, whose try (build-1792493691274712799, 17m28s, 2026-10-20 11:12 UTC) ran the equality test green on the live facts: every machine was sent and compared both ways (ADR 0453, issue 1384). Deleted, 40 functions: in plan.go planFor, declarationWith, renderingFor, grantsFor, theRestOfTheMesh and their helpers (boundOfGrant, busCredentialIssued, carriedBuilds, carriedOn, composeBusUsers, engineJudgesRoot, engineReadsHealth, engineTakesHanded, takesHanded, givenUnderAnOldKey, issuedToHolder, keyFor, licencesFor, managerPublicKeyFor, movedProvider, providerMoved, providerModuleOf, sayLeftOut, seatsOn, wireBuilds, zonesInTheMesh); in network.go generators, whoResolves, namesInTheMesh, onThePrivateNetwork; composedAndValidated, adoptionFor, adoptionOf, engineOpensVaultBox, namedModules, localNetworksOf, keepRecorded, passSeatsOn, theMeshPassesSeatsOn, assignmentsOf. Choosing (Reading, Allocating, Foreseeing) is gone: coreBoxesFor and coreBoxesOf take a plain allocating flag. composeForPush no longer takes the private network it ignored. The seat pass of a send is performSeatPasses, over the passes the composition names. Measured: cmd/mesh-controller non-test code 67,643 -> 65,821 lines (-1,822), its tests 57,691 -> 57,286, with the integration part of the equality test removed here because it calls the deleted functions. Not the issue's 3,000: that counts all of plan.go (2,192 lines), of which the callers, the verbs, the perform step and the sends remain (sendable, recorded builds, the held-back and ready-node logic, the plan verb, the gate's trial); and the 37 functions a name walk lists as unreachable are called through interfaces and method sets and are kept. Tests dropped, each with the mesh-sdk go/compose test that holds its cases: - seat_pass_test.go TestACompositionWithTwoClaimantsRecordsNoneAndSaysSo, TestACompositionChangesNothingWhileTheHolderIsAssignedOrNobodyClaims, TestAHolderAssignedButNotOnTheShelfIsNotTakenForGone: rest_test.go TestNoSeatIsPassedForTwoClaimantsAnAssignedHolderOrNoClaimant, TestAHolderAssignedButNotOnTheShelfIsNotTakenForGone, TestASeatWhoseHolderIsAssignedNowhereGoesToItsOnlyClaimant. TestACompositionPassesTheSeatAndWritesOneHandActByTheController and TestALostPassWritesNoActAndAFailedOneLeavesTheRecord stay as tests of the send's step (performSeatPasses); TestAThrowawayMeshPassesTheSeatInMemoryAndWritesNothing stays as TestAThrowawayMeshWritesNoHandActForAPass. - seat_pass_test.go TestNoSeatIsPassedWhenAMachinesAssignmentsCouldNotBeRead: no counterpart, and none is needed: the adapter reads every machine's assignments for the Input and a machine whose read fails fails the Input, so no seat is passed on a partial read. - network_test.go TestOnlyAMachineOnThePrivateNetworkIsNamed: network_test.go TestANodeNotOnThePrivateNetworkGetsNoAddressAndNoNetwork. - held_back_test.go TestASendCarriesTheCurrentBuildsAndALeftOutModuleKeepsItsOwn: node_test.go TestAModuleLeftOutKeepsTheBuildItWasLastSent (and compose_sdk_test.go's table, now literal). - modules_wire_test.go TestTheBuildOfACarriedCommitIsTheAssignmentsOrTheOneBuiltFromIt: node_test.go TestTheBodyCarriesTheOrderTheInputGivesAndTheBuildsOnlyToAnEngineThatReadsThem. - compose_equal_integration_test.go: the old path it compares against is deleted; its last run is the parent's try. Rewritten against mesh-sdk, same cases: issued_test.go (needs now come from compose.Resolve: Needed.IssuedToHolder and ProviderMoved), module_health_test.go and merge_gate_handing tests (the contract in the Input), provisioner_account_integration_test.go (the composition's refusal), one_resolution_integration_test.go (sayFound). Every test of the send, perform, the adapter and the verbs is kept; the tests that used planFor, declarationWith, generators, renderingFor or grantsFor as setup use resolveNode, composeSend, composeQuestion, renderingOf and grantsOf. compose_callers_test.go now fails when any deleted name is declared or called again. Committed by copying the files of a staging branch (stage/r4b-1389 at198be8217c, built fromfb556d6bby patch commits and compared with the author's worktree), so that this commit's parent isfb556d6b.
112 lines
4.3 KiB
Go
112 lines
4.3 KiB
Go
//go:build integration
|
|
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"sort"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
// **Placement leaves the settings layers and no machine is told anything new** (novox/hq ADR 0348 clause
|
|
// 11, issue 651). A mesh is seeded as the store holds it before migration 0097 — `places`, `accesses` and a
|
|
// kept network among the settings, at the mesh's level and a machine's, one layer of placement only — then
|
|
// migrated, and every machine's declaration is composed. What each machine is told of the seeded modules is
|
|
// byte for byte what the controller before this change composed from the same seed: the golden files were
|
|
// written by the integration branch's controller at bfc79c6 running this same test (MESH_WRITE_GOLDEN=1),
|
|
// where there was no migration 0097 to run.
|
|
func TestADeclarationIsTheSameAfterPlacementMoves(t *testing.T) {
|
|
open, migrate := aMeshBefore(t, 97)
|
|
ctx := t.Context()
|
|
inv := open.inventory
|
|
image := "registry.invalid:5000/library@sha256:" + strings.Repeat("a", 64)
|
|
register(t, open, catalogue.Manifest{Module: "library", Version: "1",
|
|
Accesses: []catalogue.Access{{ID: "series"}, {ID: "downloads", Mode: catalogue.AccessRead}},
|
|
Resources: []map[string]any{
|
|
{"id": "config", "type": "directory", "mode": "0750"},
|
|
{"id": "server", "type": "container", "image": image,
|
|
"volumes": []any{"${dir:config}:/config", "${access:series}:/series", "${access:downloads}:/downloads:ro"}},
|
|
// Today's form: a mergeable file naming no keys takes every key of the layer (ADR 0326 §3).
|
|
{"id": "runtime-config", "type": "file", "path": "${dir:config}/runtime.json", "mode": "0640",
|
|
"content": `{"log":"info"}`, "merge": "json"},
|
|
}})
|
|
register(t, open, catalogue.Manifest{Module: "found", Version: "1",
|
|
Resources: []map[string]any{{"id": "server", "type": "container", "image": image}}})
|
|
if err := inv.SetAdopted(ctx, "anchor", true); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, l := range []struct{ node, module, values string }{
|
|
{"", "library", `{"accesses": {"downloads": "/storage/downloads"}, "log": "warn"}`},
|
|
{"anchor", "library", `{"places": {"config": {"path": "/var/lib/library/config", "owner": "1001:2000"}},
|
|
"accesses": {"series": "/storage/media/series"}, "workers": 4}`},
|
|
{"laptop", "library", `{"accesses": {"series": "/home/media/series"}}`},
|
|
{"anchor", "found", `{"networks": {"server": ["predecessor_default"]}}`},
|
|
} {
|
|
if l.node == "" {
|
|
inv.ExecForTest(t, `insert into settings (node, module, values) values (null, $1, $2)`, l.module, l.values)
|
|
continue
|
|
}
|
|
inv.ExecForTest(t, `insert into settings (node, module, values) select id, $2, $3 from node where name = $1`,
|
|
l.node, l.module, l.values)
|
|
}
|
|
|
|
migrate()
|
|
// Assigned once the store is migrated: an assignment reads the layers, as this controller holds them.
|
|
for _, a := range [][]string{{"anchor", "library", "found"}, {"laptop", "library"}} {
|
|
if _, err := assign(ctx, open, a[0], a[1:]...); err != nil {
|
|
t.Fatalf("assign %v: %v", a, err)
|
|
}
|
|
}
|
|
|
|
for _, node := range []string{"anchor", "laptop"} {
|
|
plan, _, err := resolveNode(ctx, open, node)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
with, err := madeAndRendered(ctx, open, node)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
composed, err := plan.Compose(with)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(composed.LeftOut) > 0 {
|
|
t.Fatalf("%s leaves out %v", node, composed.LeftOut)
|
|
}
|
|
var told []map[string]any
|
|
for _, r := range composed.Resources {
|
|
if owner := composed.Owner[r["id"].(string)]; owner == "library" || owner == "found" {
|
|
told = append(told, r)
|
|
}
|
|
}
|
|
sort.Slice(told, func(i, j int) bool { return told[i]["id"].(string) < told[j]["id"].(string) })
|
|
got, err := json.MarshalIndent(told, "", " ")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
golden := filepath.Join("testdata", "placement-moved", node+".json")
|
|
if os.Getenv("MESH_WRITE_GOLDEN") != "" {
|
|
if err := os.MkdirAll(filepath.Dir(golden), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(golden, append(got, '\n'), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
continue
|
|
}
|
|
want, err := os.ReadFile(golden)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if string(want) != string(got)+"\n" {
|
|
t.Errorf("%s is told something else after placement moved:\n%s\nwas:\n%s", node, got, want)
|
|
}
|
|
}
|
|
}
|