Tool runner bus: the per-node state test waits on the watch, not a 5 s poll
Under load TestAPerNodeStateIsServedAcrossEveryNodesBucket failed 2 of 30: a bucket made during the watch is taken in on the bus's creation advisory, which a loaded machine delivers after mt.Until's fixed five seconds. The test now waits as the watch hands each change over, bounded only for a watch that never hears. Builds: design 47 H H-A-363 (fix-a-bug-met-twice: a fixed bound a loaded machine overruns)
This commit is contained in:
@@ -69,6 +69,7 @@ func TestAPerNodeStateIsServedAcrossEveryNodesBucket(t *testing.T) {
|
||||
|
||||
var mu sync.Mutex
|
||||
var current, live []string
|
||||
heard := make(chan struct{}, 1)
|
||||
stop, err := conn.StateWatch("mesh-provisioner", "mesh-host.composed", "", func(ch bus.StateChange) error {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
@@ -77,6 +78,10 @@ func TestAPerNodeStateIsServedAcrossEveryNodesBucket(t *testing.T) {
|
||||
} else {
|
||||
live = append(live, ch.Key)
|
||||
}
|
||||
select {
|
||||
case heard <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@@ -98,7 +103,10 @@ func TestAPerNodeStateIsServedAcrossEveryNodesBucket(t *testing.T) {
|
||||
if _, err := a.Put("a.m1.f5", []byte(`{"v":1}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mt.Until(t, func() error {
|
||||
// Waited for as the watch hands each change over, not polled within a fixed five seconds: the new bucket is taken
|
||||
// in on the bus's creation advisory, which a loaded machine delivers later (design 47 H, H-A-363). The bound only
|
||||
// ends a watch that never hears it.
|
||||
missing := func() error {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
got := strings.Join(append(append([]string(nil), current...), live...), ",")
|
||||
@@ -108,5 +116,13 @@ func TestAPerNodeStateIsServedAcrossEveryNodesBucket(t *testing.T) {
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
bound := time.After(30 * time.Second)
|
||||
for err := missing(); err != nil; err = missing() {
|
||||
select {
|
||||
case <-heard:
|
||||
case <-bound:
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user