node-tools: every wait on the bus in a test waits the shared bound, not a few seconds (issue 1754)
TestAStaleWriteIsRefusedAndWritesNothing gave the watch 5 s to hear a 1 s key's expire and failed main.505's integration step on a loaded build node; TestARunnerAtItsStopAnswersNoCallAndItsCallersMeetNoResponders failed its rerun while it asked 1 s of two round trips and 5 s and 10 s of its waits. The second of a kind after3850eb8, so the kind is fixed: meshtest.Bound (30 s, Until's bound, named once) is what every node-tools test that starts a bus waits for what the bus carries; Until becomes a deadline of it, so a try that waits does not multiply it; an upper bound on how long a call or a wait took is half the bound it tells apart (bus.RequestTimeout, the call's or the wait's own), at most meshtest.Bound. A wait that hears ends then: no passing test is longer (per-test durations before and after, equal). A guard (meshtest waits_test.go) reads every test file that imports meshtest and refuses a wait whose constant bound is a second or more under meshtest.Bound; it names 34 such waits at309069de. Builds: issue 1754 note 8 (the quick fix), note 9 (1754/AC1 to AC4); principle 11
This commit is contained in:
@@ -44,7 +44,7 @@ func TestTheRuntimeAnnouncesWhatItServesInTheServicesProtocol(t *testing.T) {
|
||||
defer nc.Close()
|
||||
info := func() micro.Info {
|
||||
t.Helper()
|
||||
msg, err := nc.Request("$SRV.INFO.node-tools.anchor", nil, 2*time.Second)
|
||||
msg, err := nc.Request("$SRV.INFO.node-tools.anchor", nil, mt.Bound)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -102,13 +102,13 @@ func TestTheRuntimeAnnouncesWhatItServesInTheServicesProtocol(t *testing.T) {
|
||||
}
|
||||
|
||||
// PING answers with the same identity, and a request for another service is not answered.
|
||||
if msg, err := nc.Request("$SRV.PING", nil, 2*time.Second); err != nil || !strings.Contains(string(msg.Data), micro.PingResponseType) {
|
||||
if msg, err := nc.Request("$SRV.PING", nil, mt.Bound); err != nil || !strings.Contains(string(msg.Data), micro.PingResponseType) {
|
||||
t.Errorf("ping: %v %v", msg, err)
|
||||
}
|
||||
// alpha is re-issued a plain subject: the announcement says so, and says it is interchangeable.
|
||||
mesh.Issue(t, mt.MembershipOf("alpha", "anchor", true, nil))
|
||||
var after string
|
||||
for i := 0; i < 40; i++ {
|
||||
for deadline := time.Now().Add(mt.Bound); time.Now().Before(deadline); {
|
||||
after = subjects(info())
|
||||
if strings.Contains(after, "mesh.mod.alpha.tool.one|serve.alpha|tool|alpha|||true") {
|
||||
break
|
||||
@@ -139,7 +139,7 @@ func TestTheRunnerStatesTheCapabilitiesOfItsCallsInItsPing(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
msg, err := nc.Request("$SRV.PING.node-tools.anchor", nil, 2*time.Second)
|
||||
msg, err := nc.Request("$SRV.PING.node-tools.anchor", nil, mt.Bound)
|
||||
if err != nil {
|
||||
t.Fatalf("ping of the instance: %v", err)
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func TestACallOnTheCallerNamedSubjectReachesTheModuleWithItsCaller(t *testing.T)
|
||||
Result saidCaller `json:"result"`
|
||||
}
|
||||
mt.Until(t, func() error {
|
||||
answer, err := raw.RequestMsg(msg, 5*time.Second)
|
||||
answer, err := raw.RequestMsg(msg, mt.Bound)
|
||||
if err == nil {
|
||||
err = json.Unmarshal(answer.Data, &reply)
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func TestTheSubjectThatNamesNoCallerStillWorksAndNamesNone(t *testing.T) {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
mt.Until(t, func() error {
|
||||
msg, err := old.Request(subject, body, 5*time.Second)
|
||||
msg, err := old.Request(subject, body, mt.Bound)
|
||||
if err == nil {
|
||||
err = json.Unmarshal(msg.Data, &reply)
|
||||
}
|
||||
@@ -254,7 +254,7 @@ func TestTheSubjectThatNamesNoCallerStillWorksAndNamesNone(t *testing.T) {
|
||||
for i := 0; i < 3; i++ {
|
||||
go func() { got, err := c.chunkedAsked("seat:mesh-wants.input"); done <- got && err == nil }()
|
||||
}
|
||||
for deadline := time.Now().Add(5 * time.Second); c.rereadWaiting() < 2; runtime.Gosched() {
|
||||
for deadline := time.Now().Add(mt.Bound); c.rereadWaiting() < 2; runtime.Gosched() {
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatal("two asks never joined the read running")
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ func TestTheRuntimeHandsAModulesEventsToItsBundleAndAcknowledgesThemOnlyWhenTake
|
||||
// The bundle dies on the first offer: not acknowledged, the bundle is started again and the
|
||||
// event is offered again once its ack wait has passed.
|
||||
mesh.Emit(t, "mesh.mod.alpha.event.happened", map[string]any{"n": 3, "die": true})
|
||||
deadline := time.Now().Add(20 * time.Second)
|
||||
deadline := time.Now().Add(mt.Bound)
|
||||
for time.Now().Before(deadline) {
|
||||
if countLines(t, log, "handled 2") == 1 && countLines(t, log, "handled 3") == 1 {
|
||||
break
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscompose"
|
||||
@@ -42,7 +41,7 @@ func TestALedgerIsWrittenOnlyOnItsModulesLedgerConnection(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
go s.Start()
|
||||
if !s.ReadyForConnections(30 * time.Second) {
|
||||
if !s.ReadyForConnections(mt.Bound) {
|
||||
t.Fatal("the bus did not come up")
|
||||
}
|
||||
t.Cleanup(s.Shutdown)
|
||||
|
||||
@@ -247,7 +247,7 @@ func TestALogAnswersEachVerbOnTheBus(t *testing.T) {
|
||||
if e.Sequence != want || e.Key != "12" {
|
||||
t.Fatalf("the watch handed %d %s, want %d", e.Sequence, e.Key, want)
|
||||
}
|
||||
case <-time.After(5 * time.Second):
|
||||
case <-time.After(mt.Bound):
|
||||
t.Fatalf("the watch did not hand entry %d", want)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ func TestABundlesWatchIsHandedTheValueAndEachChange(t *testing.T) {
|
||||
select {
|
||||
case c := <-handed:
|
||||
return c
|
||||
case <-time.After(5 * time.Second):
|
||||
case <-time.After(mt.Bound):
|
||||
t.Fatalf("nothing handed: %s", what)
|
||||
}
|
||||
return ProvisionChange{}
|
||||
|
||||
@@ -201,7 +201,7 @@ func announced(t *testing.T) string {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
msg, err := nc.Request("$SRV.INFO.node-tools.anchor", nil, 2*time.Second)
|
||||
msg, err := nc.Request("$SRV.INFO.node-tools.anchor", nil, mt.Bound)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -26,9 +26,10 @@ func connect(t *testing.T, module, node string) *bus.Conn {
|
||||
return c
|
||||
}
|
||||
|
||||
// callWithin is the tests' own bound on a call (principle 11, design 47 H, H-A-158): a call that is never answered
|
||||
// fails the try it is part of within it, never after the tool runner's own 30 s.
|
||||
const callWithin = 2 * time.Second
|
||||
// callWithin is the tests' own bound on a call (principle 11): the shared meshtest.Bound, which a loaded build node stays
|
||||
// within where 2 s did not (1754/AC1); a call that is never answered fails there, and Until, a deadline of the same bound,
|
||||
// does not try it again past it.
|
||||
const callWithin = mt.Bound
|
||||
|
||||
func call(t *testing.T, asker *bus.Conn, key string, args any) (string, error) {
|
||||
t.Helper()
|
||||
@@ -119,7 +120,7 @@ func TestTheNodesRuntimeServesFiveModulesAndFollowsAReissuedMembership(t *testin
|
||||
if subject != "mesh.mod.alpha.event.happened" {
|
||||
t.Errorf("the event landed on %s", subject)
|
||||
}
|
||||
case <-time.After(5 * time.Second):
|
||||
case <-time.After(mt.Bound):
|
||||
t.Error("the event never landed")
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestABundlesSeatTrafficGoesThroughItsModulesBus(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
deadline := time.Now().Add(10 * time.Second)
|
||||
deadline := time.Now().Add(mt.Bound)
|
||||
for {
|
||||
mu.Lock()
|
||||
n := len(taken)
|
||||
|
||||
@@ -140,7 +140,8 @@ func TestTwoWritersIncrementingOneCounterOnTheBusLoseNoUpdate(t *testing.T) {
|
||||
// revision it read, never zero.
|
||||
// A key's own time to live (issue 1952, mesh-sdk process.State.CreateTTL and RenewTTL): created once, renewed whole by a
|
||||
// put, its end heard by a watch as an expiry; refused, writing nothing, on a bucket that takes none, under a second, and
|
||||
// on an update.
|
||||
// on an update. 1754/AC2: each change the watch is to hear is waited meshtest.Bound, which a loaded build node stays within:
|
||||
// the 5 s it was given for a 1 s key's expire were overrun on one (main.505).
|
||||
func TestAStaleWriteIsRefusedAndWritesNothing(t *testing.T) {
|
||||
b := counterBus(t)
|
||||
state := func(verb string, extra map[string]any) (uint64, error) {
|
||||
@@ -265,7 +266,7 @@ func TestAStaleWriteIsRefusedAndWritesNothing(t *testing.T) {
|
||||
if c.Op == "put" && len(ops) == 3 && string(c.Value) != "3" {
|
||||
t.Fatalf("the renewed key holds %s", c.Value)
|
||||
}
|
||||
case <-time.After(5 * time.Second):
|
||||
case <-time.After(mt.Bound):
|
||||
t.Fatalf("the watch heard %q, want %q", strings.Join(ops, " "), want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user