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:
@@ -57,9 +57,9 @@ func URL(t *testing.T) string {
|
||||
t.Fatalf("a bus for this test could not be made: %v", err)
|
||||
}
|
||||
go s.Start()
|
||||
if !s.ReadyForConnections(30 * time.Second) {
|
||||
if !s.ReadyForConnections(Bound) {
|
||||
s.Shutdown()
|
||||
t.Fatal("a bus for this test did not come up within 30s")
|
||||
t.Fatalf("a bus for this test did not come up within %s", Bound)
|
||||
}
|
||||
url := s.ClientURL()
|
||||
buses.Store(t, url)
|
||||
@@ -260,17 +260,26 @@ func Fixture(name string) string {
|
||||
return filepath.Join(filepath.Dir(here), "..", "..", "test", "fixtures", name)
|
||||
}
|
||||
|
||||
// Until retries while the bus answers "no responders" — something not yet served. Its bound only ends a wait that never
|
||||
// hears what it waits for: 30 s, which a loaded machine stays within, where the earlier 5 s did not (design 47 H,
|
||||
// H-A-363; fix-a-bug-met-twice: a fixed bound a loaded machine overruns, fixed for every package that waits here).
|
||||
// Bound is how long a test waits for what the bus is to carry (an event, an answer, a watch's change, a key's expiry, a
|
||||
// bus coming up) before it fails: 30 s, which a loaded build node stays within, where a few seconds did not (issue 1754:
|
||||
// a 1 s key's expire not heard in 5 s on a loaded build node; fix-a-bug-met-twice). It only ends a wait that never hears
|
||||
// what it waits for: a wait that hears ends then, so a passing test is no longer for it. One bound for every such wait,
|
||||
// well under the integration step's own 30 minutes (principle 11), never a few seconds written into a test (1754/AC1).
|
||||
const Bound = 30 * time.Second
|
||||
|
||||
// Until retries while the bus answers "no responders" — something not yet served — until Bound has passed: a deadline, so
|
||||
// a try that itself waits does not multiply it (fix-a-bug-met-twice: a fixed bound a loaded machine overruns, fixed for
|
||||
// every package that waits here).
|
||||
func Until(t *testing.T, try func() error) {
|
||||
t.Helper()
|
||||
var err error
|
||||
for i := 0; i < 300; i++ {
|
||||
for deadline := time.Now().Add(Bound); ; time.Sleep(100 * time.Millisecond) {
|
||||
if err = try(); err == nil {
|
||||
return
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
if time.Now().After(deadline) {
|
||||
break
|
||||
}
|
||||
}
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -381,7 +390,7 @@ func (m *Mesh) BucketKeyTTL(t *testing.T, name string) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), Bound)
|
||||
defer cancel()
|
||||
if _, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: name, History: 1, MaxValueSize: 256 * 1024,
|
||||
LimitMarkerTTL: time.Minute}); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user