From f8f1c6d3780d80ed950697409fd5bfd302e86c17 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 11:36:49 +0100 Subject: [PATCH] I10: the indexer's whole test at import grain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The whole test now reports the import sets of two requirers of mesh-sdk: the importer of buildstep and a requirer importing announce alone. A mesh-sdk commit changing buildstep moves mesh-sdk, the importer and a module with no report (by its requirement), never the requirer. The release's re-pin names only the version-line module. The bed's durable hears the Go build seat's imports-reported, as the manifest's consumes names it. Builds: design 47 test 80; design 47 G §56; design 47 H2 H-A-520, H-A-521, H-A-528, H-A-530; H-A-532 DMC-7 --- .../mesh-delivery-indexer/integration_test.go | 4 +- .../packages_integration_test.go | 61 +++++++++++++------ 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/integration_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/integration_test.go index 8eace1c5a..bc4c1b7ba 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/integration_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/integration_test.go @@ -802,9 +802,9 @@ func serveAssignerAssignments(t *testing.T, ctx context.Context, js jetstream.Je if _, err := js.CreateOrUpdateConsumer(ctx, "EVENTS", jetstream.ConsumerConfig{Durable: "n1_mesh-delivery-indexer", AckPolicy: jetstream.AckExplicitPolicy, // and the build seat's step-ended the manifest's consumes names (design 47 G §713: the end of a validation ask), and the // builder's version-reserved, which no stream of its own keeps (design 47 H2 §805), and the Go package registry seat's - // published, a series' newest a pin names (H-A-495 addendum). + // published, a series' newest a pin names (H-A-495 addendum), and the Go build seat's imports-reported (design 47 H2 H-A-517). FilterSubjects: []string{"mesh.mod." + assignerHolderModule + ".event.views.>", meshcatalog.SubjectRoom, nodebuildgo.SubjectStepEndedAll, meshbuilds.SubjectVersionReserved, - gopackageregistry.SubjectPublished}}); err != nil { + gopackageregistry.SubjectPublished, nodebuildgo.SubjectImportsReportedAll}}); err != nil { t.Fatal(err) } em := views.Emitter{Owner: assignerHolderModule, Subject: process.Account{Node: "n1", Module: assignerHolderModule}.EventSubject, diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/packages_integration_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/packages_integration_test.go index 005612c6a..29eaca773 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/packages_integration_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/packages_integration_test.go @@ -64,16 +64,18 @@ func untilModule(t *testing.T, ctx context.Context, js jetstream.JetStream, name return m } -// TestASourceRevisionMovingMeshSDKNamesItAndItsImporters (design 47 H §743; A-476a; ADR 0593 §2 to §4): the indexer whole against -// the bus. Two Go modules of the catalogue, importer, whose go.mod requires mesh-sdk's Go module at the zero version (no -// go.sum line names it, ADR 0573 §2; design 47 H-A-157), and plain, which requires -// nothing of it, are taken in with mesh-sdk as main's first source revision. A source revision moving mesh-sdk to a commit -// changing its buildstep package is taken in as one revision whose movers are mesh-sdk and importer, of another repository, -// and not plain; the packages key of mesh-sdk/go names that commit with a digest per package. Design 47 H2 §804: a key a dry +// TestASourceRevisionMovingMeshSDKNamesItAndItsImporters (design 47 H §743; A-476a as H2 H-A-520 amends it; ADR 0593 §2 to +// §4; test 80): the indexer whole against the bus. Four Go modules of the catalogue are taken in with mesh-sdk as main's first +// source revision: importer, requirer and legacy, whose go.mod requires mesh-sdk's Go module at the zero version (no go.sum +// line names it, ADR 0573 §2; design 47 H-A-157), and plain, which requires nothing of it. importer's build reports that it +// imports mesh-sdk's buildstep package, requirer's that it imports announce (imports-reported, H-A-517), and legacy reports +// none. A source revision moving mesh-sdk to a commit changing buildstep alone is taken in as one revision whose movers are +// mesh-sdk, importer, of another repository, and legacy, by its requirement (H-A-528), never requirer, which imports none of +// it, nor plain (I10/AC1); the packages key of mesh-sdk/go names that commit with a digest per package. Design 47 H2 §804: a key a dry // run left in the state dry-runs is gone at the start, and the take-in of a branch moving mesh-sdk again, a dry run, leaves // the trunk's packages state byte for byte as before and no key in dry-runs once it answered. // -// Design 47 H2 §802 (H-A-453 (3)): the catalogue holds 36 modules, among them lib-a and lib-b, required by app-a (a require) and +// Design 47 H2 §802 (H-A-453 (3)): the catalogue holds 38 modules, among them lib-a and lib-b, required by app-a (a require) and // app-b (a require and a replace by a directory); a source revision moving the catalogue to a commit that changes a test file // of lib-a and one of lib-b, and so their trees alone, moves lib-a, lib-b and their importers alone, never the other 32 // modules whose repository's commit moved too. @@ -81,8 +83,9 @@ func untilModule(t *testing.T, ctx context.Context, js jetstream.JetStream, name // Design 47 H2 §805 (H-A-453 (3)) and H-A-495 with its addendum: the builder's twenty version-reserved of mesh-sdk in that // revision's pipeline (twenty artifacts of its Go package, as repin_test.go reads them) are kept in heard and gathered, and // they and its pipeline-started move no pin: a pin names only a published version. The release of the reserved version (the -// Go package registry seat's published and every artifact's package-published) keeps one re-pin revision of main, importer -// its mover pinned to it; the next pipeline's reservation keeps none, so the revision after it is the next release's. +// Go package registry seat's published and every artifact's package-published) keeps one re-pin revision of main, legacy, +// on the version line, its mover pinned to it, and importer, on the import form, never named again (I10/AC2; H-A-521, +// H-A-530); the next pipeline's reservation keeps none, so the revision after it is the next release's. func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { const ( sdkGo = "git.novox.be/novox/mesh-sdk/go" @@ -115,13 +118,17 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { "package.json": "3333333333333333333333333333333333333333", "package-lock.json": "4444444444444444444444444444444444444444", "tsconfig.json": "5555555555555555555555555555555555555555"}}} } - var packages, dryRuns, heardKV jetstream.KeyValue + var packages, imports, dryRuns, heardKV jetstream.KeyValue var heard *takeIns js, ctx, _, _ := startIndexer(t, func(context.Context, buildLog) {}, func(ctx context.Context, js jetstream.JetStream) { var err error if packages, err = js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, index.PackagesState), History: index.PackagesHistory}); err != nil { t.Fatal(err) } + // The state imports, where a reported import set is kept (H-A-527). + if imports, err = js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, index.ImportsState), History: 1}); err != nil { + t.Fatal(err) + } // The state taken, which names each repository's taken commit the packages are published at (ADR 0593 §2). if _, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, index.TakenState), History: 1}); err != nil { t.Fatal(err) @@ -171,15 +178,20 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { if _, err := dryRuns.Put(ctx, index.DryRunPrefix("beta", "0123")+index.PackagesState+".left", []byte(`{"value":"e30="}`)); err != nil { t.Fatal(err) } - catalogue := repoAt{trees: map[string]string{"modules/importer": "t1", "modules/plain": "t2"}, + catalogue := repoAt{trees: map[string]string{"modules/importer": "t1", "modules/plain": "t2", "modules/requirer": "t3", "modules/legacy": "t4"}, files: map[string]string{"modules/importer/module.json": named("importer"), "modules/plain/module.json": named("plain"), + "modules/requirer/module.json": named("requirer"), "modules/legacy/module.json": named("legacy"), + "modules/requirer/go.mod": goModContent, "modules/requirer/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n", + "modules/legacy/go.mod": goModContent, "modules/legacy/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n", "modules/importer/go.mod": goModContent, "modules/importer/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n", "modules/plain/go.mod": "module plain\n\nrequire golang.org/x/sys v0.1.0\n", "modules/plain/go.sum": "golang.org/x/sys v0.1.0 h1:x=\n"}, paths: map[string]map[string]string{"": {"modules/lib-a": "a1", "modules/lib-b": "b1"}}} registrations := []meshcatalog.Registration{{V: 1, Module: "importer", Origin: "novox/mesh-catalog", Path: "modules/importer", Branches: []string{"main"}}, {V: 1, Module: "plain", Origin: "novox/mesh-catalog", Path: "modules/plain", Branches: []string{"main"}}, + {V: 1, Module: "requirer", Origin: "novox/mesh-catalog", Path: "modules/requirer", Branches: []string{"main"}}, + {V: 1, Module: "legacy", Origin: "novox/mesh-catalog", Path: "modules/legacy", Branches: []string{"main"}}, {V: 1, Module: "mesh-sdk", Origin: "novox/mesh-sdk", Path: ".", Branches: []string{"main", "beta"}}} - // §802: 34 more modules of the catalogue, 36 with importer and plain: the libraries, their importers and 30 others. + // §802: 34 more modules of the catalogue, 38 with importer, requirer, legacy and plain: the libraries, their importers and 30 others. goMods := map[string]string{"lib-a": "module " + catalogModule + "lib-a\n", "lib-b": "module " + catalogModule + "lib-b\n", "app-a": "module app-a\n\nrequire " + catalogModule + "lib-a v0.0.0-00010101000000-000000000000\n", "app-b": "module app-b\n\nrequire " + catalogModule + "lib-b v0.0.0-00010101000000-000000000000\n\nreplace " + catalogModule + "lib-b => ../lib-b\n"} @@ -251,6 +263,17 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { if _, ok := plain.Packages[sdkGo]; ok { t.Fatalf("plain requires %s: %+v", sdkGo, plain.Packages) } + // importer's and requirer's builds end, reporting their import sets (H-A-517), kept in the state imports; their + // fingerprints stay as they were (ADR 0593 §4, H-A-529), so requirer is no mover below. + for module, imported := range map[string]string{"importer": sdkGo + "/buildstep", "requirer": sdkGo + "/announce"} { + held := untilModule(t, ctx, js, module, func(m meshcatalog.ModulesByModuleValue) bool { return m.Fp2 != "" }) + raw, _ := json.Marshal(nodebuildgo.ImportsReported{Node: "n1", Module: module, Fingerprint: held.Fp2, Commit: catalogMerge, Imports: []string{imported}}) + if _, err := js.Publish(ctx, nodebuildgo.SubjectImportsReported("n1"), raw); err != nil { + t.Fatal(err) + } + key, _ := meshcatalogclient.ModulesKey(module) + untilKey(t, ctx, imports, key, func(v []byte) bool { return v != nil }) + } say(11, false, meshdelivery.SourceMovedEventHeadsItem{Repository: "novox/mesh-sdk", Commit: m2}) taken := heard.next(t, "main", 11) @@ -259,8 +282,8 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { movers = append(movers, e.Module) } slices.Sort(movers) - if !slices.Equal(movers, []string{"importer", "mesh-sdk"}) { - t.Errorf("the take-in of mesh-sdk at %s names the movers %v, want mesh-sdk and its importer, not plain", m2, movers) + if !slices.Equal(movers, []string{"importer", "legacy", "mesh-sdk"}) { + t.Errorf("the take-in of mesh-sdk at %s names the movers %v, want mesh-sdk, the importer of buildstep and legacy by its requirement, not requirer or plain", m2, movers) } key, _ := index.PackagesKey(sdkGo) untilKey(t, ctx, packages, key, func(v []byte) bool { @@ -278,7 +301,7 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { } slices.Sort(movers) if !slices.Equal(movers, []string{"app-a", "app-b", "lib-a", "lib-b"}) { - t.Errorf("the catalogue's commit changing lib-a's and lib-b's tests moves %v of its 36 modules, want lib-a, lib-b and their importers alone", movers) + t.Errorf("the catalogue's commit changing lib-a's and lib-b's tests moves %v of its 38 modules, want lib-a, lib-b and their importers alone", movers) } // §805, H-A-495: twenty reservations of mesh-sdk's packages in main's revision of source 12, kept and gathered, and its @@ -365,17 +388,17 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) { started(r) release(r, "0.1.28") if rev := untilRevision(r + 1); rev.CallKind != meshcatalog.CatalogRevisionCallKindRelease || rev.Call != index.ReleaseCall("mesh-sdk", "0.1.28") || - len(rev.Movers) != 1 || rev.Movers[0].Module != "importer" { - t.Errorf("main.%d = %+v, want the re-pin revision of the release of mesh-sdk 0.1.28, importer its mover: twenty reservations move no pin", r+1, rev) + len(rev.Movers) != 1 || rev.Movers[0].Module != "legacy" { + t.Errorf("main.%d = %+v, want the re-pin revision of the release of mesh-sdk 0.1.28, legacy (the version line) its one mover: twenty reservations move no pin, and importer and requirer (the import form) are never named again", r+1, rev) } - untilModule(t, ctx, js, "importer", func(m meshcatalog.ModulesByModuleValue) bool { return m.Packages[sdkGo] == "v0.1.28" }) + untilModule(t, ctx, js, "legacy", func(m meshcatalog.ModulesByModuleValue) bool { return m.Packages[sdkGo] == "v0.1.28" }) reserve(r+1, "0.1.29", 1) started(r + 1) release(r+1, "0.1.29") if rev := untilRevision(r + 2); rev.Call != index.ReleaseCall("mesh-sdk", "0.1.29") { t.Errorf("main.%d = %+v, want the re-pin of the release of mesh-sdk 0.1.29: the reservation of 0.1.29 keeps no revision", r+2, rev) } - untilModule(t, ctx, js, "importer", func(m meshcatalog.ModulesByModuleValue) bool { return m.Packages[sdkGo] == "v0.1.29" }) + untilModule(t, ctx, js, "legacy", func(m meshcatalog.ModulesByModuleValue) bool { return m.Packages[sdkGo] == "v0.1.29" }) // A branch's take-in moving mesh-sdk to m3 is a dry run: its packages stay in dry-runs while it runs, the trunk's are // untouched, and its keys go once it answered (§804).