T1 teller-widening-row: a pipeline-ended carrying a widening, heard on its kept stream by the teller's one Start, gives one message
Builds: design 47 H2b §836 1., acceptance 1984/AC-836p (G §335), from mesh-sdk S1 9d0478d1
This commit is contained in:
@@ -25,8 +25,10 @@ import (
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||
"git.novox.be/novox/mesh-sdk/go/process"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-view/viewstate"
|
||||
|
||||
@@ -81,6 +83,9 @@ func user(name string, pub, sub []string) string {
|
||||
`, name, q(pub), q(append([]string{"_INBOX." + name + ".>"}, sub...)))
|
||||
}
|
||||
|
||||
// keptEnded is the stream of the seat mesh-pipeline-runner's kept event pipeline-ended.
|
||||
var keptEnded = seatdef.KeptStream(mpr.Seat, seatdef.Message{Name: mpr.EventPipelineEnded})
|
||||
|
||||
const (
|
||||
tellerAnswers = "mesh-delivery-teller_answers"
|
||||
tellerAsked = "mesh-delivery-teller_asked"
|
||||
@@ -110,6 +115,11 @@ func fullConf(dir string) string {
|
||||
// The finding writer finds the stream of the keeper's findings-asked (design 47 G §384): the bed has none, so it is
|
||||
// said and the findings stay in the state.
|
||||
teller = append(teller, "$JS.API.STREAM.NAMES")
|
||||
// pipeline-ended is a kept seat event on a stream of its own, with the teller's durable the grants part composes (design 47
|
||||
// H2b §836 1.); the teller tells a widening through the seat operator-channel's notify.
|
||||
teller = append(teller, "$JS.API.STREAM.INFO."+keptEnded, "$JS.API.STREAM.INFO.EVENTS", "$JS.API.CONSUMER.INFO."+keptEnded+"."+tellerConsumer,
|
||||
"$JS.API.CONSUMER.MSG.NEXT."+keptEnded+"."+tellerConsumer, "$JS.ACK."+keptEnded+"."+tellerConsumer+".>",
|
||||
"mesh.seat.operator-channel.call.notify", "mesh.seat.operator-channel.call.notify.>")
|
||||
// The manifest's emits (ADR 0596 §2; design 47 G A-175: its answers as its views family) and its marks state (A-178).
|
||||
teller = append(teller, "mesh.mod.mesh-delivery-teller.event.answered", "mesh.mod.mesh-delivery-teller.event.ask-ended", "mesh.mod.mesh-delivery-teller.event.views.answers")
|
||||
teller = append(teller, keepsOf(bucketsOf(tellerModule).marks)...)
|
||||
@@ -139,7 +149,8 @@ accounts {
|
||||
}
|
||||
}
|
||||
`, filepath.Join(dir, "js"),
|
||||
user("n1.mesh-delivery-teller", teller, nil),
|
||||
// The hub's wake on the grants part's durables-composed for this module (design 47 H2b §836 2.).
|
||||
user("n1.mesh-delivery-teller", teller, []string{"mesh.seat.mesh-grants.event.durables-composed.n1.mesh-delivery-teller"}),
|
||||
user("n1.mesh-delivery-view", view, nil),
|
||||
user("n1.mesh-delivery-assigner", assigner, nil))
|
||||
}
|
||||
@@ -206,6 +217,13 @@ func startFull(t *testing.T) *fullBed {
|
||||
AckPolicy: jetstream.AckExplicitPolicy}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
endedSubjects := []string{"mesh.seat." + mpr.Seat + ".event." + mpr.EventPipelineEnded, "mesh.seat." + mpr.Seat + ".event." + mpr.EventPipelineEnded + ".>"}
|
||||
if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: keptEnded, Subjects: endedSubjects}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := js.CreateOrUpdateConsumer(ctx, keptEnded, process.Account{Node: "n1", Module: tellerModule}.SeatEventConsumerConfig(endedSubjects, false)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The assigner as the owner of its asks: its read tool and its views family (ADR 0615).
|
||||
viewstest.Serve(t, ctx, js, ctl, assignerModule, "asks", assignerModule+"."+meshwants.StateAsks, tellerConsumer)
|
||||
// The view as the owner of its answers, as the teller follows them (A-175, A-178).
|
||||
@@ -487,6 +505,36 @@ func TestTellerCarriesAnAskAndWritesTheAnswer(t *testing.T) { // 1343/AC1, AC2
|
||||
if err != nil || string(raw.Data) != `{"id":"`+ask2.ID+`"}` {
|
||||
t.Errorf("the ask taken away was not cancelled: %v %v\n%s", raw, err, logs.String())
|
||||
}
|
||||
// A pipeline-ended carrying a widening, a kept seat event the teller's one Start binds, is told once on every channel
|
||||
// (design 47 H2b §836 1., G §335, acceptance test 121): one message through the seat operator-channel's notify.
|
||||
told := make(chan map[string]any, 4)
|
||||
sub, err := b.ctl.Subscribe("mesh.seat.operator-channel.call.notify.>", func(m *nats.Msg) {
|
||||
var body map[string]any
|
||||
_ = json.Unmarshal(m.Data, &body)
|
||||
told <- body
|
||||
_ = m.Respond([]byte(`{"result":{},"node":"n0"}`))
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = sub.Unsubscribe() })
|
||||
end, _ := json.Marshal(mpr.PipelineEnded{Branch: "release", Movers: []mpr.MoverEnded{{Module: "plex", Commit: "0123456789abcdef", Widens: []mpr.Widening{{What: "grant", Name: "seat:mesh-wants.input"}}}}})
|
||||
if _, err := b.js.Publish(b.ctx, "mesh.seat."+mpr.Seat+".event."+mpr.EventPipelineEnded+".release.7", end); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
select {
|
||||
case body := <-told:
|
||||
if s, _ := body["summary"].(string); !strings.Contains(s, "plex 0123456 on release widens grant seat:mesh-wants.input") {
|
||||
t.Errorf("the widening was told as %v", body)
|
||||
}
|
||||
case <-time.After(15 * time.Second):
|
||||
t.Fatalf("no widening was told after a pipeline-ended carrying one\n%s", logs.String())
|
||||
}
|
||||
select {
|
||||
case body := <-told:
|
||||
t.Errorf("a second message was told: %v", body)
|
||||
case <-time.After(500 * time.Millisecond):
|
||||
}
|
||||
}
|
||||
|
||||
// TestTellerFillsAnAskFromTheViewsAnswerOnce starts the program against the bus with the permissions above: the assigner's
|
||||
|
||||
Reference in New Issue
Block a user