Compare commits

..
Author SHA1 Message Date
mesh-tools bc138366af Merge pull request 'Design 47 H1: the views reader's test waits for the acknowledged floor, not the pending count (H-A-196, H-A-197)' (#205) from fix/47-H1-sdk-views-one-durable into main 2026-11-21 00:27:19 +00:00
jschoubben 4a5eb26f4e views: read the durable's ack floor up to a mark, not its pending count, after the handlers spoke
The views test read NumAckPending as soon as the picture and the adopted handler had said the last event, but the
reader acknowledges after both, and the bus takes acks on its own; on the loaded build node (pipeline main.54) one
ack was still pending. The reader binds the module's durable once (the hub's one pull); the guard of H-A-196 is not
involved. The test now publishes a mark the hub hands after every event before it, acknowledged with the bus's
answer, and reads that the ack floor reached the mark; an event the owner says after it may still wait.

Builds: design 47 H §774, H-A-196, H-A-197
2026-11-21 01:20:35 +01:00
+18 -3
View File
@@ -154,7 +154,9 @@ func subTheViewsReaderAndTwoHandlersShareTheModulesOneDurable(t *testing.T) {
hub := process.NewEventHub(t.Logf)
got := map[string]chan string{"a": make(chan string, 8), "b": make(chan string, 8)}
for name, pattern := range map[string]string{"a": "mesh.mod.p.event.a", "b": "mesh.mod.q.event.b.*"} {
if err := hub.Handle(pattern, func(m jetstream.Msg) { _ = m.Ack(); got[name] <- m.Subject() }); err != nil {
// The handlers' acknowledgement waits for the bus's answer, so a message a handler handed on is acknowledged
// on the bus, and every one the hub handed before it too (acks of one consumer are taken in order).
if err := hub.Handle(pattern, func(m jetstream.Msg) { _ = m.DoubleAck(ctx); got[name] <- m.Subject() }); err != nil {
t.Fatal(err)
}
}
@@ -230,12 +232,25 @@ func subTheViewsReaderAndTwoHandlersShareTheModulesOneDurable(t *testing.T) {
if len(got["a"])+len(got["b"])+len(seatHeard) != 0 {
t.Fatal("a handler heard a message that was another's, or one twice")
}
// The reader acknowledges an event after it took it into its picture and the adopted handler returned, so the
// picture and the handler say nothing of its ack: one more event, handed after them in order and acknowledged with
// the bus's answer, is the mark that every ack before it has landed (the build node, main.54, read one pending). An
// event said after the mark (the owner's own mark of its burst) may still wait for its ack, so the floor is read.
mark, err := js.Publish(ctx, "mesh.mod.p.event.a", []byte(`"the mark"`))
if err != nil {
t.Fatal(err)
}
select {
case <-got["a"]:
case <-time.After(10 * time.Second):
t.Fatal("the mark after the handled events was not heard")
}
cons, err := js.Consumer(ctx, process.EventsStream, cred.EventConsumerName())
if err != nil {
t.Fatal(err)
}
if info, err := cons.Info(ctx); err != nil || info.NumAckPending != 0 {
t.Fatalf("a message was left unacknowledged: %+v %v", info, err)
if info, err := cons.Info(ctx); err != nil || info.AckFloor.Stream < mark.Sequence {
t.Fatalf("a message up to the mark %d was left unacknowledged: %+v %v", mark.Sequence, info, err)
}
// H-A-169: the one event no handler takes is the module's finding event-unhandled, counted once, naming its subject,
// though the reader started twice.