T5 checker-name-gone: the state-watch tests use a state of a module that stays
The fixture state mesh-delivery-checker.owed, which the retiring checker keeps, is the assigner's `pins`: the three tests of the file assert the same of a state watched by a module that is granted it. Builds: design 47 H §764 (The checker), H-A-61 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
@@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// **A watch whose current values take longer than the bound to hand over still holds** (novox/hq issue
|
// **A watch whose current values take longer than the bound to hand over still holds** (novox/hq issue
|
||||||
// 1726). The gitea module watches the checker's owed: one key per pull request head, each a round trip
|
// 1726). The gitea module watches another module's state (the assigner's pins stand for it): one key per pull request head, each a round trip
|
||||||
// to the bundle. With a few hundred keys the hand-over outlasted StateTimeout at every attempt, the
|
// to the bundle. With a few hundred keys the hand-over outlasted StateTimeout at every attempt, the
|
||||||
// watch was refused, and the newest keys, handed over last, never reached mesh/check: a group's passing
|
// watch was refused, and the newest keys, handed over last, never reached mesh/check: a group's passing
|
||||||
// verdict was never written on its members' heads. The bound is on progress: a watch fails only when
|
// verdict was never written on its members' heads. The bound is on progress: a watch fails only when
|
||||||
@@ -45,7 +45,7 @@ func TestAWatchHoldsWhileItsCurrentValuesKeepArriving(t *testing.T) {
|
|||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
var current, live []string
|
var current, live []string
|
||||||
// Each value takes 40 ms to be taken: 33 values take about 1.3 s, three times the bound.
|
// Each value takes 40 ms to be taken: 33 values take about 1.3 s, three times the bound.
|
||||||
stop, err := conn.StateWatch("gitea", "mesh-delivery-checker.owed", "", func(ch bus.StateChange) error {
|
stop, err := conn.StateWatch("gitea", "mesh-delivery-assigner.pins", "", func(ch bus.StateChange) error {
|
||||||
if ch.Current {
|
if ch.Current {
|
||||||
time.Sleep(40 * time.Millisecond)
|
time.Sleep(40 * time.Millisecond)
|
||||||
}
|
}
|
||||||
@@ -127,12 +127,12 @@ func TestAWatchHoldsWhileItsCurrentValuesKeepArriving(t *testing.T) {
|
|||||||
}
|
}
|
||||||
var stop func()
|
var stop func()
|
||||||
if tc.refused {
|
if tc.refused {
|
||||||
if _, err := conn.StateWatch("gitea", "mesh-delivery-checker.owed", "", deliver); err == nil {
|
if _, err := conn.StateWatch("gitea", "mesh-delivery-assigner.pins", "", deliver); err == nil {
|
||||||
t.Fatal("the watch whose bundle took nothing was not refused")
|
t.Fatal("the watch whose bundle took nothing was not refused")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var err error
|
var err error
|
||||||
if stop, err = conn.StateWatch("gitea", "mesh-delivery-checker.owed", "", deliver); err != nil {
|
if stop, err = conn.StateWatch("gitea", "mesh-delivery-assigner.pins", "", deliver); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for i := 0; i < 4; i++ {
|
for i := 0; i < 4; i++ {
|
||||||
@@ -173,7 +173,7 @@ func TestAWatchIsRefusedWhenNoCurrentValueIsTakenWithinTheBound(t *testing.T) {
|
|||||||
release := make(chan struct{})
|
release := make(chan struct{})
|
||||||
t.Cleanup(func() { close(release) })
|
t.Cleanup(func() { close(release) })
|
||||||
began := time.Now()
|
began := time.Now()
|
||||||
_, err := conn.StateWatch("gitea", "mesh-delivery-checker.owed", "", func(bus.StateChange) error {
|
_, err := conn.StateWatch("gitea", "mesh-delivery-assigner.pins", "", func(bus.StateChange) error {
|
||||||
<-release
|
<-release
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@@ -229,16 +229,16 @@ func TestAMembershipTheGrantsPartWroteWrappedIsServed(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// owedWatcher is the gitea module's view of the checker's owed: the bucket, and a runtime connection
|
// owedWatcher is the gitea module's view of another module's state: the bucket, and a runtime connection
|
||||||
// that serves gitea with the owed issued for reading.
|
// that serves gitea with that state issued for reading.
|
||||||
func owedWatcher(t *testing.T) (*bus.Conn, interface {
|
func owedWatcher(t *testing.T) (*bus.Conn, interface {
|
||||||
Put(string, []byte) (uint64, error)
|
Put(string, []byte) (uint64, error)
|
||||||
}) {
|
}) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
mesh := mt.New(t)
|
mesh := mt.New(t)
|
||||||
kv := mesh.Bucket(t, "mesh-delivery-checker_owed")
|
kv := mesh.Bucket(t, "mesh-delivery-assigner_pins")
|
||||||
gitea := mt.MembershipOf("gitea", "anchor", false, nil)
|
gitea := mt.MembershipOf("gitea", "anchor", false, nil)
|
||||||
gitea.State = []bus.StateIssued{{Name: "mesh-delivery-checker.owed", Bucket: "mesh-delivery-checker_owed"}}
|
gitea.State = []bus.StateIssued{{Name: "mesh-delivery-assigner.pins", Bucket: "mesh-delivery-assigner_pins"}}
|
||||||
mesh.Issue(t, gitea)
|
mesh.Issue(t, gitea)
|
||||||
conn, err := bus.Connect(bus.Credential{URL: mt.URL(t), Module: "node-tools", Node: "anchor"})
|
conn, err := bus.Connect(bus.Credential{URL: mt.URL(t), Module: "node-tools", Node: "anchor"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user