From b303e32a4135ab916cbed19674cfe65d46233434 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 23 Oct 2026 23:03:38 +0200 Subject: [PATCH] Close the builder test's nodes from the bed's start, so no pull in hand takes the first ask (issue 1928) --- .../mesh-delivery-builder/integration_test.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go index 51580bf..5a37fc5 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/integration_test.go @@ -179,7 +179,11 @@ type bed struct { // startBed starts the bus, the buckets the controller makes from the builder's and the build modules' manifests, the // build modules' streams and the builder's durable consumers on them, two nodes' toolchains, the indexer's manifests, and // the fake build modules. It runs no builder. -func startBed(t *testing.T) *bed { +func startBed(t *testing.T) *bed { return startBedWith(t, false) } + +// startBedWith is startBed with the nodes' capacity 0 from the start when closed: a puller that reads its capacity before a +// test could close the nodes may be in a pull already and takes the first ask put (issue 1928). +func startBedWith(t *testing.T, closed bool) *bed { dir, err := os.MkdirTemp(os.Getenv("TMPDIR"), "b") if err != nil { t.Fatal(err) @@ -243,6 +247,7 @@ func startBed(t *testing.T) *bed { b.builds = mk(delivery.BuilderBuildsBucket, delivery.BuilderBuildsHistory) b.instances = mk(instancesBucket, 1) b.fake = &fakeBuildModules{js: js, ctx: ctx, calls: map[string]int{}} + b.fake.closed.Store(closed) b.fake.serve(t, "mesh-build-go", "n1", "n2") b.fake.serve(t, "mesh-build-node", "n1", "n2") b.fake.serve(t, "mesh-build-image", "n1") // the image build module runs on n1 only @@ -781,8 +786,7 @@ func (b *bed) asksPut(t *testing.T, nc *nats.Conn) func() []delivery.StepAsk { // 1887/AC3: a builder that started again while its asks waited in the streams (no node had a free slot) puts no second // ask: it waits for the asks its building key names, and the key is done once a node took them. func TestARestartedBuilderPutsNoSecondAsk(t *testing.T) { - b := startBed(t) - b.fake.closed.Store(true) + b := startBedWith(t, true) // 1928/AC1: no node can take an ask from the start, so no pull in hand takes the first one b.module(t, "netcheck", "catalogue-a67f0196-netcheck.module.json", "modules/netcheck") sub, err := nats.Connect(b.srvURL, nats.UserInfo("ctl", "pw")) if err != nil { @@ -792,11 +796,13 @@ func TestARestartedBuilderPutsNoSecondAsk(t *testing.T) { asked := b.asksPut(t, sub) b.start(t, "n1", nil) v := b.await(t, "netcheck", func(v delivery.BuilderBuild) bool { return v.State == delivery.BuildBuilding && len(v.Asks) == 2 }) - for deadline := time.Now().Add(5 * time.Second); len(asked()) < 2 && time.Now().Before(deadline); time.Sleep(20 * time.Millisecond) { + for deadline := time.Now().Add(20 * time.Second); len(asked()) < 2; time.Sleep(20 * time.Millisecond) { + if time.Now().After(deadline) { + t.Fatalf("asks put = %+v within 20 s, want the two the key names", asked()) + } } b.stop() b.start(t, "n1", nil) // the same builder, started again, while both asks wait - time.Sleep(500 * time.Millisecond) b.fake.open() done := b.await(t, "netcheck", isState(delivery.BuildDone)) if got := asked(); len(got) != 2 {