The builder finds a build module as the indexer's seed does: the build seat whose acting rule `build` has an `on` matching the artifact's language or kind:image, and that seat's holder, read from the seat list's definitions and the claims of the catalog half's manifests. Task.Module, every lane key, the unpublished modules, the toolchain sources, the ends watched, the sayer and builder_stuck (through `<seat>.steps`) derive from it; the floor's sources are the holders of the seats git and mesh-catalog. buildrun.GoBuildModule, NodeBuildModule, LanguageOf, buildstep.BuildModuleOf use, build.ImageBuildModule and StuckBuildModules are gone from the builder (the checker keeps its own names in two small files until its part reads them from the list). Builds: design 47 G §7, §428, §704, §204, A-82 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
62 lines
2.0 KiB
Go
62 lines
2.0 KiB
Go
//go:build integration
|
|
|
|
package buildrun
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/nats-io/nats.go"
|
|
"github.com/nats-io/nats.go/jetstream"
|
|
|
|
"git.novox.be/novox/mesh-delivery/sdk/buildstep"
|
|
"git.novox.be/novox/mesh-sdk/go/testbus"
|
|
)
|
|
|
|
// 1887/A4a, 1887/AC3 on the real bus: an ask put twice under one id is one message, and the asker reads the step a node
|
|
// wrote under `<node>.<ask id>`.
|
|
func TestAnAskIsPutOnceAndItsStepIsRead(t *testing.T) {
|
|
nc, err := nats.Connect(testbus.URL(t))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer nc.Close()
|
|
js, _ := jetstream.New(nc)
|
|
ctx := context.Background()
|
|
if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: "SEAT_NODE_BUILD_GO", Subjects: []string{"mesh.seat.node-build-go.accept.>"},
|
|
Retention: jetstream.WorkQueuePolicy}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
kv, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: StepsBucket("mesh-build-go")})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
bus := JetStreamAsks{JS: js}
|
|
k := Asker{Seats: testSeats(), Publisher: bus, Waiter: bus, Bound: 5 * time.Second}
|
|
a := goAsk("mvl0frv18d1960")
|
|
for i := 0; i < 2; i++ {
|
|
if err := k.Put(ctx, a); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
s, _ := js.Stream(ctx, "SEAT_NODE_BUILD_GO")
|
|
if info, _ := s.Info(ctx); info.State.Msgs != 1 {
|
|
t.Fatalf("%d messages for one ask put twice", info.State.Msgs)
|
|
}
|
|
go func() {
|
|
time.Sleep(100 * time.Millisecond)
|
|
key, _ := buildstep.AskStepKey("ace", a.ID)
|
|
running, _ := buildstep.EncodeStep(buildstep.Step{ID: a.ID, Tool: "delivery ask", Node: "ace", State: buildstep.StepRunning, Started: time.Now()})
|
|
_, _ = kv.Put(ctx, key, running)
|
|
passed, _ := buildstep.EncodeStep(buildstep.Step{ID: a.ID, Tool: "delivery ask", Node: "ace", State: buildstep.StepPassed, Started: time.Now(),
|
|
Result: json.RawMessage(`{"artifacts":[]}`)})
|
|
_, _ = kv.Put(ctx, key, passed)
|
|
}()
|
|
step, err := k.Passed(k.Wait(ctx, a))
|
|
if err != nil || step.Node != "ace" {
|
|
t.Fatalf("step %+v, %v", step, err)
|
|
}
|
|
}
|