Tool runner bus: pulled workers belong to their connection; two tests wait for what they assert
A worker bound for a pull was kept for the process, so a later connection's pull used a worker bound on a closed connection and answered "connection closed" (every run of TestAHolderPullsOneMessageWhenItHasRoom after the first). The bound workers and the pulled messages are now the Conn's. The two tests that failed main.165 and main.115 asserted on bus figures before the bus had delivered them: the worker's pending count right after a publish, a no-wait pull right after a publish, a callback counter read when a flush returned, a 300 ms delay and a 2 s ack wait a loaded machine overruns. They now count binds on a channel the watcher's reader fills, pull with a wait that ends at the delivery, prove "nothing fetched ahead" by the second message's first delivery, and use bounds a loaded machine stays within. Builds: design 47 H H-A-363 (fix-a-bug-met-twice; whole-module tests under load, H-A-327)
This commit is contained in:
@@ -4,7 +4,6 @@ package bus_test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
|
||||
"github.com/nats-io/nats.go"
|
||||
@@ -26,8 +25,11 @@ func TestAStateReadOnTheBusBindsItsBucketOnce(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(watcher.Close)
|
||||
var infos atomic.Int32
|
||||
if _, err := watcher.Subscribe("$JS.API.STREAM.INFO.KV_"+bucket, func(*nats.Msg) { infos.Add(1) }); err != nil {
|
||||
// Each bind the runtime asks is heard onto a channel by the watcher's reader itself, so what the bus sent before a
|
||||
// flush's answer is on it when the flush returns. A counter a callback raised was read before the callback ran, on a
|
||||
// loaded machine, and counted one bind short (design 47 H, H-A-363).
|
||||
infos := make(chan *nats.Msg, 16)
|
||||
if _, err := watcher.ChanSubscribe("$JS.API.STREAM.INFO.KV_"+bucket, infos); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := watcher.Flush(); err != nil {
|
||||
@@ -46,7 +48,7 @@ func TestAStateReadOnTheBusBindsItsBucketOnce(t *testing.T) {
|
||||
if err := watcher.Flush(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := infos.Load(); got != 1 {
|
||||
if got := len(infos); got != 1 {
|
||||
t.Fatalf("three reads asked the bucket's stream info %d times, want once", got)
|
||||
}
|
||||
|
||||
@@ -75,7 +77,7 @@ func TestAStateReadOnTheBusBindsItsBucketOnce(t *testing.T) {
|
||||
if err := watcher.Flush(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := infos.Load(); got != 3 {
|
||||
if got := len(infos); got != 3 {
|
||||
t.Fatalf("the bucket's stream info was asked %d times in all, want 3: once, once more when it was gone, once when made afresh", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user