From 63b44f8c37a07d5c685827f998e834cf010e776c Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 18:58:20 +0100 Subject: [PATCH] A8 review-tests: AC-A6b's holder-stopped case, the unplaced finding cleared by a restarted passer, want-unversioned's node-gone row The bed's catalog stand-in can be stopped and served again (b.cat.stop, b.cat.serve). Builds: design 47 H2 H-A-708 (3), H-A-722, H-A-706 --- .../compositionstep_integration_test.go | 11 +++++ .../integration_test.go | 41 +++++++++++++------ .../mesh-delivery-assigner/seat_tools_test.go | 15 ++++++- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep_integration_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep_integration_test.go index 09a0cac1c..249429e97 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep_integration_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionstep_integration_test.go @@ -152,8 +152,19 @@ func TestTheCompositionStepComposesEachMachineThroughTheBuildSeat(t *testing.T) case <-time.After(30 * time.Second): t.Fatal("the assigner did not read the seat list within 30 s") } + // H2 H-A-708 (3), AC-A6b: the seat mesh-catalog's holder is stopped while the composition reads its entry: the read is a kept + // call, the journal says the seat does not answer, and the step goes on and passes once the holder answers again. + b.cat.stop() + outage := b.journal.mark() putStep(b.ctx, t, b.js, "step-ask-1", meshwants.StepRun{Pipeline: "main.3.m", Step: meshwants.StepRunStepComposition, Module: "m", Branch: trunkBranch, Revision: 3, Commit: engineCommit, Fingerprint: "src2:m1"}) + // The kept call's own journal line goes to the process's standard error, so the outage is a few seconds of the clock, over which + // the step must go no further. + time.Sleep(3 * time.Second) + if b.journal.has(outage, "the composition step of m says fetch") { + t.Fatal("the step went on while the seat mesh-catalog's holder was stopped") + } + b.cat.serve() // Each machine's run waits for x/go's publish, the step saying fetch; the publish heard, each puts its run ask (1984/AC11). for _, node := range []string{"n1", "n2"} { b.journal.await(t, from, "the composition run main=2e3."+node+" waits for package "+pkg, "the run of "+node+" waits", 30*time.Second) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go index 0531f2932..b5ad3d75a 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go @@ -98,6 +98,8 @@ type catalogBed struct { // at is, by branch and revision, a revision's entries a test keeps whole: the verb revision answers a revision asked by its // number from here, and the current one otherwise. at map[string]map[int64][]meshcatalog.CatalogEntry + // stop makes the seat's holder unheard, as a holder stopped is (no responders); serve makes it heard again (serveCatalog). + stop, serve func() } // journal is a program's journal as the bed hears it: a test awaits a line in it (await) where the line is the only sign @@ -124,6 +126,13 @@ func (j *journal) mark() int { return j.text.Len() } +// has says whether the journal holds, after from (mark), a line with words. +func (j *journal) has(from int, words string) bool { + j.mu.Lock() + defer j.mu.Unlock() + return strings.Contains(j.text.String()[from:], words) +} + // await returns once the journal holds, after from (mark), a line with words, and fails the test when none came within // bound. func (j *journal) await(t *testing.T, from int, words, what string, bound time.Duration) { @@ -1831,13 +1840,6 @@ func serveCatalog(t *testing.T, b *bed, nc *nats.Conn) { } t.Cleanup(func() { _ = sub.Unsubscribe() }) } - for _, subject := range []string{"mesh.seat.mesh-catalog.tool.revision", "mesh.seat.mesh-catalog.call.revision.*", "mesh.seat.mesh-catalog.tool.revision.*"} { - sub, err := nc.Subscribe(subject, answer) - if err != nil { - t.Fatal(err) - } - t.Cleanup(func() { _ = sub.Unsubscribe() }) - } // The verb entry answers an entry by its fingerprint from every branch's half, and a fingerprint no half holds as not found, // as the seat's holder does: an entry the assigner asks for a form change is answered, never left asked (orderwaits.go). entry := func(m *nats.Msg) { @@ -1856,14 +1858,27 @@ func serveCatalog(t *testing.T, b *bed, nc *nats.Conn) { } _ = m.Respond([]byte(`{"error":"no catalog entry has the fingerprint ` + in.Fingerprint + `","node":"n0"}`)) } - for _, subject := range []string{"mesh.seat.mesh-catalog.tool.entry", "mesh.seat.mesh-catalog.call.entry.*"} { - sub, err := nc.Subscribe(subject, entry) - if err != nil { - t.Fatal(err) + var subs []*nats.Subscription + b.cat.serve = func() { + for subject, handler := range map[string]nats.MsgHandler{"mesh.seat.mesh-catalog.tool.revision": answer, "mesh.seat.mesh-catalog.call.revision.*": answer, + "mesh.seat.mesh-catalog.tool.revision.*": answer, "mesh.seat.mesh-catalog.tool.entry": entry, "mesh.seat.mesh-catalog.call.entry.*": entry} { + sub, err := nc.Subscribe(subject, handler) + if err != nil { + t.Fatal(err) + } + subs = append(subs, sub) } - t.Cleanup(func() { _ = sub.Unsubscribe() }) + subscribed(t, nc) } - subscribed(t, nc) + b.cat.stop = func() { + for _, sub := range subs { + _ = sub.Unsubscribe() + } + subs = nil + _ = nc.Flush() + } + b.cat.serve() + t.Cleanup(b.cat.stop) } // A-181: the assigner reads the builder's stream of build ends whole at its start (the last of each fingerprint, a failed one's error diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools_test.go index 978545b59..63b9ca8df 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools_test.go @@ -295,7 +295,9 @@ func TestTheSeatsVerbs(t *testing.T) { t.Fatalf("findings = %v", findings) } putAssignments(w, mma.Assignments{V: keys.Version, Node: "g14", Modules: []mma.PlacedModule{{Module: "web"}}}) - p.unplacedFindings() + // A process that starts again knows nothing of what the first said: it clears the finding from the bucket (H-A-722). + restarted := &passer{w: w, logf: func(string, ...any) {}, findings: p.findings} + restarted.unplacedFindings() if len(findings) != 0 { t.Errorf("placed again: findings %v", findings) } @@ -313,7 +315,9 @@ func TestTheSeatsVerbs(t *testing.T) { mod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: digest, Repository: "novox/web", Commit: strings.Repeat("1", 40), Path: meshcatalogclient.RootPath}) putModuleRaw(p.w, trunkBranch, "web", mod) p.w.manifests[digest] = parsed{module: "web", manifest: catalogue.Manifest{Module: "web"}} - placeOn(t, p.w, "g14", assigned...) + if len(assigned) > 0 { // none: the node is gone, no assignments name it + placeOn(t, p.w, "g14", assigned...) + } raw, _ := mwc.EncodeWant(mwc.Want{Fp: fp, Version: version}) key, _ := mwc.WantKey("g14", "web") wantsKV.values[key] = raw @@ -338,6 +342,13 @@ func TestTheSeatsVerbs(t *testing.T) { if len(findings) != 0 { t.Errorf("the module is no longer assigned to the node: findings %v", findings) } + if pass("", "web").wants(context.Background()); len(findings) != 1 { + t.Fatalf("a want of no version again: findings %v", findings) + } + pass("").wants(context.Background()) // the node is gone: no assignments name it + if len(findings) != 0 { + t.Errorf("the node is gone: findings %v", findings) + } }) t.Run("1955/L7 (ADR 0571 ยง4): seat-holders is written from assignments, only the keys a change moves, and answered by assignments seats", func(t *testing.T) { writes := 0