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:
@@ -19,17 +19,22 @@ func TestAHolderPullsOneMessageWhenItHasRoom(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
first, err := conn.SeatPull("messenger", "SEAT_OPERATOR_CHANNEL_worker", 0)
|
||||
// A pull that wants a message waits for it: the worker learns of a stored message after the publish is answered, so
|
||||
// a pull that waits for nothing can find none yet on a loaded machine (design 47 H, H-A-363). A wait is a bound, not a
|
||||
// measure: it ends at the delivery.
|
||||
first, err := conn.SeatPull("messenger", "SEAT_OPERATOR_CHANNEL_worker", 10*time.Second)
|
||||
if err != nil || first == nil || string(first.Body) != `{"id":"a1"}` || first.Delivered != 1 {
|
||||
t.Fatalf("the first pull = %+v, %v", first, err)
|
||||
}
|
||||
// One pulled, one still waiting on the stream: nothing was fetched ahead.
|
||||
// One pulled and in hand, the other never delivered: nothing was fetched ahead. What is in hand is the worker's own
|
||||
// count, set by the delivery itself; the count still waiting is the worker's figure of the stream, learnt later, so
|
||||
// the second message's first delivery says it instead.
|
||||
info, err := js.ConsumerInfo("SEAT_OPERATOR_CHANNEL", "SEAT_OPERATOR_CHANNEL_worker")
|
||||
if err != nil || info.NumPending != 1 || info.NumAckPending != 1 {
|
||||
t.Fatalf("after one pull: pending %d, in hand %d (%v); want 1 and 1", info.NumPending, info.NumAckPending, err)
|
||||
if err != nil || info.NumAckPending != 1 {
|
||||
t.Fatalf("after one pull: in hand %d (%v); want 1", info.NumAckPending, err)
|
||||
}
|
||||
second, err := conn.SeatPull("messenger", "SEAT_OPERATOR_CHANNEL_worker", 0)
|
||||
if err != nil || second == nil || string(second.Body) != `{"id":"a2"}` {
|
||||
second, err := conn.SeatPull("messenger", "SEAT_OPERATOR_CHANNEL_worker", 10*time.Second)
|
||||
if err != nil || second == nil || string(second.Body) != `{"id":"a2"}` || second.Delivered != 1 {
|
||||
t.Fatalf("the second pull = %+v, %v", second, err)
|
||||
}
|
||||
if none, err := conn.SeatPull("messenger", "SEAT_OPERATOR_CHANNEL_worker", 0); err != nil || none != nil {
|
||||
@@ -54,22 +59,23 @@ func TestAHolderPullsOneMessageWhenItHasRoom(t *testing.T) {
|
||||
if err := conn.SeatSettle("messenger", second.ID, bus.SettleNak); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
again, err := conn.SeatPull("messenger", "SEAT_OPERATOR_CHANNEL_worker", time.Second)
|
||||
again, err := conn.SeatPull("messenger", "SEAT_OPERATOR_CHANNEL_worker", 10*time.Second)
|
||||
if err != nil || again == nil || string(again.Body) != `{"id":"a2"}` || again.Delivered != 2 {
|
||||
t.Fatalf("the message handed back = %+v, %v", again, err)
|
||||
}
|
||||
// Issue 1748: a message settled with a delay is not given again at once, is after it, one delivery higher; a delay
|
||||
// of 0 settles nothing.
|
||||
// of 0 settles nothing. The delay is what the next pull must come within to see nothing, so it is a second, not a
|
||||
// moment a loaded machine can spend between two calls.
|
||||
if err := conn.SeatSettleAfter("messenger", again.ID, 0); err == nil {
|
||||
t.Error("a delay of 0 was accepted")
|
||||
}
|
||||
if err := conn.SeatSettleAfter("messenger", again.ID, 300*time.Millisecond); err != nil {
|
||||
if err := conn.SeatSettleAfter("messenger", again.ID, time.Second); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if early, err := conn.SeatPull("messenger", "SEAT_OPERATOR_CHANNEL_worker", 0); err != nil || early != nil {
|
||||
t.Fatalf("a message given again after a delay came at once: %+v, %v", early, err)
|
||||
}
|
||||
late, err := conn.SeatPull("messenger", "SEAT_OPERATOR_CHANNEL_worker", 2*time.Second)
|
||||
late, err := conn.SeatPull("messenger", "SEAT_OPERATOR_CHANNEL_worker", 10*time.Second)
|
||||
if err != nil || late == nil || late.Delivered != 3 {
|
||||
t.Fatalf("the message given again after its delay = %+v, %v", late, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user