A-476a: a commit moves its own repository's modules and the importers of what it moved; A-471 toolchain test data
The recompute of a merge leaves a module of another repository as held unless its imported package versions changed (ADR 0593 §3 stands). TestIndexerCountsOnlyThePlacedBuildNodesToolchains reports language versions (A-471). Builds: design 47 G A-476a, A-471
This commit is contained in:
@@ -1418,7 +1418,8 @@ func TestIndexerCountsOnlyThePlacedBuildNodesToolchains(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
toolchains = kv
|
||||
for node, version := range map[string]string{"n1": "go1.27.3", "n2": "go1.27.2"} {
|
||||
// A-471: a toolchain is agreed by its language version (go1.27), not its patch; n2 reports another language version.
|
||||
for node, version := range map[string]string{"n1": "go1.27", "n2": "go1.28.1"} {
|
||||
key, _ := index.ToolchainKey(node, "go")
|
||||
value, err := index.EncodeToolchain(nodebuildgo.Toolchain{Language: "go", Version: version, Recipe: "1", At: ptr(time.Now())})
|
||||
if err != nil {
|
||||
@@ -1462,15 +1463,15 @@ func TestIndexerCountsOnlyThePlacedBuildNodesToolchains(t *testing.T) {
|
||||
return got
|
||||
}
|
||||
agreed := func(m meshcatalog.ModulesByModuleValue) bool {
|
||||
return m.Fp2 != "" && m.Toolchains["go"].Version == "go1.27.3"
|
||||
return m.Fp2 != "" && m.Toolchains["go"].Version == "go1.27"
|
||||
}
|
||||
held := read(agreed)
|
||||
if !agreed(held) {
|
||||
t.Fatalf("within 20 s avahi has fp2 %q, none2 %q, toolchains %v: want a fingerprint of n1's go1.27.3 alone", held.Fp2, held.None2, held.Toolchains)
|
||||
t.Fatalf("within 20 s avahi has fp2 %q, none2 %q, toolchains %v: want a fingerprint of n1's go1.27 alone", held.Fp2, held.None2, held.Toolchains)
|
||||
}
|
||||
place(ctx, t, "n2", "mesh-build-go")
|
||||
key, _ := index.ToolchainKey("n2", "go")
|
||||
value, err := index.EncodeToolchain(nodebuildgo.Toolchain{Language: "go", Version: "go1.27.2", Recipe: "1", At: ptr(time.Now().Add(time.Second))})
|
||||
value, err := index.EncodeToolchain(nodebuildgo.Toolchain{Language: "go", Version: "go1.28.1", Recipe: "1", At: ptr(time.Now().Add(time.Second))})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -1493,7 +1494,7 @@ func TestIndexerCountsOnlyThePlacedBuildNodesToolchains(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
disagree := func(m meshcatalog.ModulesByModuleValue) bool {
|
||||
return m.Fp2 == "" && strings.HasPrefix(m.None2, "builders disagree: go1.27.2 recipe 1 on n2")
|
||||
return m.Fp2 == "" && strings.HasPrefix(m.None2, "builders disagree: go1.27 recipe 1 on n1; go1.28 recipe 1 on n2")
|
||||
}
|
||||
if m := read(disagree); !disagree(m) {
|
||||
t.Fatalf("within 20 s of a merge after n2's assignments avahi has fp2 %q, none2 %q: want the builders to disagree", m.Fp2, m.None2)
|
||||
|
||||
+1
-9
@@ -206,15 +206,7 @@ func TestAMeshSDKMergeMovesOnlyTheModulesImportingAChangedPackage(t *testing.T)
|
||||
if pub.Commit != m2 || len(pub.Packages) != 3 {
|
||||
t.Fatalf("packages.%s = %+v within 20 s, want the merge %s with a digest of go, announce and buildstep", key, pub, m2)
|
||||
}
|
||||
// A-476 c: mesh-sdk's merge moved no module registered for another repository: importer stands as it was.
|
||||
if now := module("importer", func(meshcatalog.ModulesByModuleValue) bool { return true }); now.Fp2 != importer.Fp2 || now.Packages[sdkGo] != m1 {
|
||||
t.Errorf("mesh-sdk's merge moved importer of novox/mesh-catalog: %+v, want it unmoved at %s", now.Packages, m1)
|
||||
}
|
||||
// The next merge of its own repository moves it, built against the package published meanwhile.
|
||||
merged("novox/mesh-catalog", 302, "8888888888888888888888888888888888888888", forgemsg.Forge{Root: "r0",
|
||||
Trees: map[string]string{"modules/importer": "t1", "modules/plain": "t2"},
|
||||
Manifests: map[string]string{"modules/importer": named("importer"), "modules/plain": named("plain")},
|
||||
Locks: map[string]map[string]string{"modules/importer": {"go.sum": goSumHash}, "modules/plain": {"go.sum": goSumHash}}})
|
||||
// A-476a: mesh-sdk's merge moves importer, of another repository, which imports a package it moved.
|
||||
moved := module("importer", func(m meshcatalog.ModulesByModuleValue) bool { return m.Fp2 != importer.Fp2 })
|
||||
if moved.Packages[sdkGo] != m2 {
|
||||
t.Errorf("importer moved to %+v, want it built against %s", moved.Packages, m2)
|
||||
|
||||
@@ -134,7 +134,7 @@ func (ix *Indexer) Recompute(ctx context.Context) error { return ix.recomputeWit
|
||||
// of what the bucket holds, are computed with the others, and are written once, with their final fingerprint or reason
|
||||
// (issue 1444: a merge writes each module once). A record of the overlay that has no kept inputs is written as it is. w is
|
||||
// the merge's write (order.go), nil for none; it is told each module written. A merge's recompute names its repository
|
||||
// (A-476 c): only the modules registered for it are moved, none of another repository; "" moves every module (a toolchain
|
||||
// (A-476 c, A-476a): the modules registered for it are moved, and those of another repository only when they import a package it moved; "" moves every module (a toolchain
|
||||
// report, a hand recompute).
|
||||
func (ix *Indexer) recomputeWith(ctx context.Context, overlay map[string]meshcatalog.ModulesByModuleValue, w *mergeWrite, repository string) error {
|
||||
if err := ix.fillPaths(ctx); err != nil {
|
||||
@@ -310,8 +310,10 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc
|
||||
for _, key := range slices.Sorted(maps.Keys(all)) {
|
||||
k := all[key]
|
||||
r := of(key, nil)
|
||||
if _, merged := overlay[key]; !merged && repository != "" && !trunk.SameRepository(k.cur.Repository, repository) {
|
||||
// A module registered for another repository is not moved by this repository's commit (A-476 c): it stands as held.
|
||||
if _, merged := overlay[key]; !merged && repository != "" && !trunk.SameRepository(k.cur.Repository, repository) &&
|
||||
maps.Equal(k.held.Packages, map[string]string(r.pkgs)) {
|
||||
// A module registered for another repository is moved by this repository's commit only when it imports a package the
|
||||
// commit moved (A-476a, ADR 0593 §3); any other stands as held (A-476 c).
|
||||
r = result{fp: k.held.Fp2, none: k.held.None2, tcs: k.held.Toolchains, pkgs: sdkstep.PackageVersions(k.held.Packages)}
|
||||
edges[key] = graphEdges{module: key, cur: k.cur, manifest: k.manifest, fp: r.fp, none: r.none, tcs: r.tcs, pkgs: r.pkgs}
|
||||
continue
|
||||
|
||||
@@ -829,18 +829,11 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) {
|
||||
t.Helper()
|
||||
f := forgemsg.Forge{V: keys.Version, Kind: forgemsg.ForgeMerged, Repository: "novox/mesh-sdk", Branch: "feat/x", Number: 3, Head: h1,
|
||||
Merge: commit, Root: tree, Trees: map[string]string{"": tree}, Manifests: map[string]string{"": `{"module":"mesh-sdk","version":"1.0"}`}}
|
||||
prev, _ := moduleOf(t, mods, "avahi")
|
||||
if err := ix.Apply(context.Background(), f); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// A-476 c: a commit of mesh-sdk moves no module registered for another repository; the next recompute (a hand one here)
|
||||
// moves avahi, which imports its package.
|
||||
if after, _ := moduleOf(t, mods, "avahi"); after.Fp2 != prev.Fp2 || !reflect.DeepEqual(after.Packages, prev.Packages) {
|
||||
t.Fatalf("a commit of mesh-sdk moved avahi, registered for another repository: fp2 %q (was %q) packages %v (were %v)", after.Fp2, prev.Fp2, after.Packages, prev.Packages)
|
||||
}
|
||||
if err := ix.Recompute(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// A-476a: a commit of mesh-sdk moves avahi, of another repository, which imports its package, and leaves mesh-tools,
|
||||
// which imports nothing it moved.
|
||||
a, _ := moduleOf(t, mods, "avahi")
|
||||
if a.Fp2 == "" || !reflect.DeepEqual(a.Packages, map[string]string{sdk: commit}) {
|
||||
t.Fatalf("after mesh-sdk's merge %.8s: fp2 %q none2 %q packages %v", commit, a.Fp2, a.None2, a.Packages)
|
||||
|
||||
Reference in New Issue
Block a user