Wait for the build's log lines to be stored before counting them (hq issue 507)
mesh/merge-gate pass: the change touches no module of the mesh's graph
mesh/repo-check pass: its merge-check.sh passed
mesh/delivery delivered

A line is said with a plain publish, so a live subscriber can hold both
lines while the stream has stored one or none yet; the test read the
stream once and failed under load. It now waits up to 5 s for both.
This commit is contained in:
2026-10-11 21:05:04 +02:00
parent afc7dd8f68
commit 8d73f705af
+17 -8
View File
@@ -123,15 +123,24 @@ func TestNatsABuildIsTakenAndItsOutcomeReachesEverybody(t *testing.T) {
t.Fatalf("line %d came back as %s (%v)", want, msg.Data, err) t.Fatalf("line %d came back as %s (%v)", want, msg.Data, err)
} }
} }
// And it is in the stream for a reader who comes later. // And it is in the stream for a reader who comes later. **Waited for, with a bound, rather
info, err := js.Context().StreamInfo(broker.EventsStream, &nats.StreamInfoRequest{SubjectsFilter: BuildLog("b-1")}) // than read once** (novox/hq issue 507): a line is said with a plain publish, so the server
if err != nil { // hands it to a live subscriber and stores it in the stream independently, and under load the
t.Fatal(err) // subscriber above had both lines while the stream still held one, or none.
var held map[string]uint64
for until := time.Now().Add(5 * time.Second); ; {
info, err := js.Context().StreamInfo(broker.EventsStream, &nats.StreamInfoRequest{SubjectsFilter: BuildLog("b-1")})
if err != nil {
t.Fatal(err)
}
held = info.State.Subjects
if held[BuildLog("b-1")] >= 2 || time.Now().After(until) {
break
}
time.Sleep(10 * time.Millisecond)
} }
if info.State.Subjects[BuildLog("b-1")] != 2 { if held[BuildLog("b-1")] != 2 {
t.Fatalf("the stream holds %v under the build's subject, want 2", info.State.Subjects) t.Fatalf("the stream holds %v under the build's subject, want 2", held)
}
if err == nil {
} }
if result.ID != "b-1" || result.Commit != "abc1234" { if result.ID != "b-1" || result.Commit != "abc1234" {
t.Fatalf("the asker got %+v", result) t.Fatalf("the asker got %+v", result)