node-tools: a test's wait on the bus takes the test's own deadline (issue 1754, review round 1)
The lead's answer on issue 1754 (note of 2026-11-23 20:00, principles 11 and 7): no bound written into the code. meshtest.Bound(t) is t.Deadline() less 30 s for the test's cleanup, go test's default of 10 min where a run names no deadline, and what is left, at least 1 ms, once less than the margin is (the lead's round-2 answer, note 11; principles 3 and 7). Until stops at it; callWithin is gone, call() takes it. The guard now refuses any constant bound of a second or more. Each upper limit is half the bound it tells apart: the watch's refusal is held to half the default StateTimeout the test replaced (a watch timer fixed at 10 s failed it in 10.0 s, round 1 passed it); the console's close to half its backstop ShutdownWithin (a Close that never cancels failed it in 5.1 s, round 1 passed it); the console waits to half WaitDefault. Builds: issue 1754 notes 10 (lead answer, 20:00) and 11 (round 2: margin, AC1, AC4); principles 3, 7 and 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, mt.Bound)
|
||||
msg, err := nc.Request("$SRV.INFO.node-tools.anchor", nil, mt.Bound(t))
|
||||
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, mt.Bound); err != nil || !strings.Contains(string(msg.Data), micro.PingResponseType) {
|
||||
if msg, err := nc.Request("$SRV.PING", nil, mt.Bound(t)); 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 deadline := time.Now().Add(mt.Bound); time.Now().Before(deadline); {
|
||||
for deadline := time.Now().Add(mt.Bound(t)); 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, mt.Bound)
|
||||
msg, err := nc.Request("$SRV.PING.node-tools.anchor", nil, mt.Bound(t))
|
||||
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, mt.Bound)
|
||||
answer, err := raw.RequestMsg(msg, mt.Bound(t))
|
||||
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, mt.Bound)
|
||||
msg, err := old.Request(subject, body, mt.Bound(t))
|
||||
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(mt.Bound); c.rereadWaiting() < 2; runtime.Gosched() {
|
||||
for deadline := time.Now().Add(mt.Bound(t)); 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(mt.Bound)
|
||||
deadline := time.Now().Add(mt.Bound(t))
|
||||
for time.Now().Before(deadline) {
|
||||
if countLines(t, log, "handled 2") == 1 && countLines(t, log, "handled 3") == 1 {
|
||||
break
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestALedgerIsWrittenOnlyOnItsModulesLedgerConnection(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
go s.Start()
|
||||
if !s.ReadyForConnections(mt.Bound) {
|
||||
if !s.ReadyForConnections(mt.Bound(t)) {
|
||||
t.Fatal("the bus did not come up")
|
||||
}
|
||||
t.Cleanup(s.Shutdown)
|
||||
|
||||
@@ -39,7 +39,7 @@ func TestTheLedgerRepairsAreToolsOfEveryLedgerOwner(t *testing.T) {
|
||||
defer stop()
|
||||
asker := connect(t, "console", "workstation")
|
||||
listed := func(module string) (string, error) {
|
||||
answered, err := asker.AskWithin(module+"."+ToolsVerb, map[string]any{}, "", callWithin)
|
||||
answered, err := asker.AskWithin(module+"."+ToolsVerb, map[string]any{}, "", mt.Bound(t))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func TestTheLedgerRepairsAreToolsOfEveryLedgerOwner(t *testing.T) {
|
||||
plain.Bindings = owner.Bindings
|
||||
}
|
||||
mesh.Issue(t, plain)
|
||||
if _, err := asker.AskWithin("plain.who@anchor", map[string]any{}, "", callWithin); err != nil {
|
||||
if _, err := asker.AskWithin("plain.who@anchor", map[string]any{}, "", mt.Bound(t)); err != nil {
|
||||
t.Fatalf("binding change %d: the first call of plain.who failed: %v — dropped while its tools were served again", round, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(mt.Bound):
|
||||
case <-time.After(mt.Bound(t)):
|
||||
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(mt.Bound):
|
||||
case <-time.After(mt.Bound(t)):
|
||||
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, mt.Bound)
|
||||
msg, err := nc.Request("$SRV.INFO.node-tools.anchor", nil, mt.Bound(t))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -26,14 +26,12 @@ func connect(t *testing.T, module, node string) *bus.Conn {
|
||||
return c
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
// call waits the test's own bound, meshtest.Bound(t), where 2 s were what a loaded build node overran (1754/AC1; the lead's
|
||||
// answer on issue 1754 of 2026-11-23 20:00): a call that is never answered fails there, and Until, a deadline of the same
|
||||
// bound, does not try it again past it.
|
||||
func call(t *testing.T, asker *bus.Conn, key string, args any) (string, error) {
|
||||
t.Helper()
|
||||
got, err := asker.AskWithin(key, args, "", callWithin)
|
||||
got, err := asker.AskWithin(key, args, "", mt.Bound(t))
|
||||
return string(got.Result), err
|
||||
}
|
||||
|
||||
@@ -120,7 +118,7 @@ func TestTheNodesRuntimeServesFiveModulesAndFollowsAReissuedMembership(t *testin
|
||||
if subject != "mesh.mod.alpha.event.happened" {
|
||||
t.Errorf("the event landed on %s", subject)
|
||||
}
|
||||
case <-time.After(mt.Bound):
|
||||
case <-time.After(mt.Bound(t)):
|
||||
t.Error("the event never landed")
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestABundlesSeatTrafficGoesThroughItsModulesBus(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
deadline := time.Now().Add(mt.Bound)
|
||||
deadline := time.Now().Add(mt.Bound(t))
|
||||
for {
|
||||
mu.Lock()
|
||||
n := len(taken)
|
||||
|
||||
@@ -140,8 +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. 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).
|
||||
// on an update. 1754/AC2: each change the watch is to hear is waited meshtest.Bound(t), the test's own deadline:
|
||||
// the 5 s it was given for a 1 s key's expire were overrun on a loaded build node (main.505).
|
||||
func TestAStaleWriteIsRefusedAndWritesNothing(t *testing.T) {
|
||||
b := counterBus(t)
|
||||
state := func(verb string, extra map[string]any) (uint64, error) {
|
||||
@@ -266,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(mt.Bound):
|
||||
case <-time.After(mt.Bound(t)):
|
||||
t.Fatalf("the watch heard %q, want %q", strings.Join(ops, " "), want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user