Count the asks the builder puts and read their kind in its integration test, so 1887/AC1 is proven on the real bus (issue 1887, review round 2 item 3)
This commit is contained in:
@@ -707,6 +707,7 @@ func TestTheBuilderAsksTheBuildSeatsAndCallsNoNode(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer s.Unsubscribe()
|
||||
asked := b.asksPut(t, sub)
|
||||
b.start(t, "n1", nil)
|
||||
v := b.await(t, "netcheck", isState(delivery.BuildDone))
|
||||
for _, a := range v.Artifacts {
|
||||
@@ -717,4 +718,39 @@ func TestTheBuilderAsksTheBuildSeatsAndCallsNoNode(t *testing.T) {
|
||||
if n := calls.Load(); n != 0 {
|
||||
t.Errorf("%d tool calls reached a build module", n)
|
||||
}
|
||||
// 1887/AC1: one ask per build module the build needs (netcheck: a Go and a TypeScript bundle), each on its seat's
|
||||
// delivery stream.
|
||||
got := asked()
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("asks put = %+v, want one Go and one Node delivery ask", got)
|
||||
}
|
||||
for _, a := range got {
|
||||
if a.Kind != delivery.AskDelivery || a.Build == nil || a.Build.FP != fp {
|
||||
t.Errorf("ask %+v, want a delivery ask of the fingerprint", a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// asksPut hears every ask put on a build seat's accept subjects (a core subscription beside the stream) and answers the
|
||||
// asks heard so far.
|
||||
func (b *bed) asksPut(t *testing.T, nc *nats.Conn) func() []delivery.StepAsk {
|
||||
t.Helper()
|
||||
var mu sync.Mutex
|
||||
var asks []delivery.StepAsk
|
||||
s, err := nc.Subscribe("mesh.seat.*.accept.>", func(m *nats.Msg) {
|
||||
if a, err := delivery.DecodeStepAsk(m.Data); err == nil {
|
||||
mu.Lock()
|
||||
asks = append(asks, a)
|
||||
mu.Unlock()
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = s.Unsubscribe() })
|
||||
return func() []delivery.StepAsk {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
return append([]delivery.StepAsk(nil), asks...)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user