diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go index 41a5a5170..169dcc0c1 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go @@ -303,8 +303,10 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { // 1984/AC9; H-A-628 (3), (4); H-A-629 (1), (2): x's build not published yet: each run waits, its value naming x/go in `waits` // with the time its wait began, its bound bound. armed for package-wait-minutes, the step saying fetch naming the // package; at the publish heard each reads published again and puts its run ask with the pin, `waits` and the bound gone, the - // step saying run; past the bound each ends could not run naming the package and the bound, no run ask put. - for _, publish := range []bool{true, false} { + // step saying run; past the bound each ends could not run naming the package and the bound, no run ask put. H-A-630 (2): a + // bind of the consumer, the publish said while it was not bound, wakes each to read it published. + for _, how := range []string{"published", "bind", "past its bound"} { + publish := how != "past its bound" u := newRunStand(t, "src2:e1", "src2:e1", "d1") u.publishedAt = nil journal := newLogLines() @@ -344,12 +346,24 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { t.Errorf("the waiting run %s of %v holds %+v, its bound %s; want x/go in waits and package-wait-minutes' bound", key, keys, run.Waits, ttl) } } - if !publish { + switch how { + case "past its bound": for _, key := range keys { kv.expire(runBoundPrefix + key) u.runs.expired(runBoundPrefix + key) } - } else { + case "bind": + hub := &eventsOf{handle: map[string]func(jetstream.Msg){}} + if err := hearPublished(hub, u.runs, t.Logf); err != nil { + t.Fatal(err) + } + u.mu.Lock() + u.publishedAt = map[string]string{"src2:x1": "0.1.9"} + u.mu.Unlock() + for _, bound := range hub.bound { + bound(time.Now()) + } + default: // H-A-630 (1): a package-published of another package wakes no run waiting for x/go, so it asks no published; x's own // wakes each. hub := &eventsOf{handle: map[string]func(jetstream.Msg){}} @@ -376,7 +390,7 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { select { case out = <-done: case <-time.After(10 * time.Second): - t.Fatalf("publish %v: the waiting step said no end", publish) + t.Fatalf("%s: the waiting step said no end", how) } journal.await(t, "the composition step of m says run", 1) if !publish { diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns.go index 24ac30c72..2e6038923 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns.go @@ -332,10 +332,13 @@ func (r *compositionRuns) publishWake(artifact string) <-chan struct{} { // hearPublished hears the seat mesh-builds' package-published on the assigner's durable consumer: the runs waiting for the // package its artifact publishes are woken (heardPublished, design 47 H2 H-A-630 (1)); one that does not read wakes none and is -// journaled. +// journaled. Each bind of the consumer wakes every waiting run (heardBind, H-A-630 (2)): an event said while it was not bound is +// never heard, so no run waits until its bound alone ends it while its package stands published. func hearPublished(hub interface { Handle(string, func(jetstream.Msg)) error + OnBound(func(time.Time)) }, r *compositionRuns, logf func(string, ...any)) error { + hub.OnBound(func(time.Time) { r.heardBind() }) return hub.Handle(meshbuilds.SubjectPackagePublished, func(m jetstream.Msg) { ev, _, err := meshbuilds.DecodePackagePublishedEvent(m.Data()) if err != nil || ev.Artifact == "" { diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go index d656ec854..4a68a428d 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go @@ -518,11 +518,10 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber, } // The seat mesh-builds' package-published wakes the runs waiting for the package its artifact publishes, which read published // again; each bind of the consumer, which hears no event said before it was made, wakes every waiting run (design 47 H2 - // H-A-628 (3), H-A-630 (1); H-A-326, H-A-328). + // H-A-628 (3), H-A-630 (1), (2); H-A-326, H-A-328). if err := hearPublished(hub, runs, logger.Printf); err != nil { - logger.Printf("the seat mesh-builds' package-published is not heard, so a composition run waiting for a package reads published only at its start: %v", err) + logger.Printf("the seat mesh-builds' package-published is not heard, so a composition run waiting for a package reads published only at its start and at each bind: %v", err) } - hub.OnBound(func(time.Time) { runs.heardBind() }) } if inputs != nil { var runEnded func(buildstep.StepEnded) error