The controller asks no build of anybody (ADR 0501 §5, ADR 0525 clause 6, ADR 0503 §3). Every module of a walk is taken from the builder's done key; a key not done yet waits, named in the plan, and never fails it. - C2b/C2c: internal/builder and cmd/mesh-controller's asks go (askABuild, onlyTheBuildersOwn, buildOneAsked, takeIn from an outcome, buildAgentsOwn, the builder's say and its fallback, the daemon hearing an outcome). The server follows the retired seats' built subjects only to let go of them, because the installer's carried user list names them. - C2d: replay, queue, cancel, clear, kill, pause, resume, delivery-check, check-here and merge-gate are refused by name. - C3: the check queues (CHECKS_READY, CHECKS_OTHER) and their workers, the checks-running and plans-building buckets and their grants, the build queue and its hold (plans_building.go, queue.go, link/holds.go, builds_nats.go, checks_nats.go). - C4: merge_gate*.go, the pull request's repo-check path, the Checked event and its layers; a pull request asks the controller nothing but to tell mesh-config what its head declares. - C5: the builds bucket is written only by key_takein. - C10 (help and refusals): the terminal's help lists only what is served. Integration tests of the plan's tiers, sends, stops and retries now run on a stand-in builder with a done key for every module (walk_keys_scaffold_integration_test.go); the tests of the asks, the queue, the merge gate and the replays are deleted.
68 lines
1.8 KiB
Go
68 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/novox/mesh-controller/internal/broker"
|
|
)
|
|
|
|
// holding reports one message held by each named consumer (stream/name), nothing by the rest.
|
|
func holdingOne(names ...string) func(broker.Consumer) (uint64, error) {
|
|
return func(c broker.Consumer) (uint64, error) {
|
|
for _, n := range names {
|
|
if n == c.Stream+"/"+c.Name {
|
|
return 1, nil
|
|
}
|
|
}
|
|
return 0, nil
|
|
}
|
|
}
|
|
|
|
func deafObservations(now time.Time, held func(broker.Consumer) (uint64, error)) (string, int) {
|
|
f := calm(now)
|
|
loop, err := readLoop(now.Add(-loopDeafAfter-time.Minute), loopConsumers(), held)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
f.loop = loop
|
|
obs := watchLoop(f)
|
|
if len(obs) == 0 {
|
|
return "", 0
|
|
}
|
|
return obs[0].Said, len(obs)
|
|
}
|
|
|
|
// 1063/AC2: a message held by one of the controller's own consumers is still deaf, naming its stream.
|
|
func TestDeafLookStillCountsOwnConsumers(t *testing.T) {
|
|
now := time.Now()
|
|
for _, c := range loopConsumers() {
|
|
said, n := deafObservations(now, holdingOne(c.Stream+"/"+c.Name))
|
|
if n != 1 || !strings.Contains(said, "1 on "+c.Stream) {
|
|
t.Fatalf("%s/%s holding one message: %d observation(s), said %q", c.Stream, c.Name, n, said)
|
|
}
|
|
}
|
|
}
|
|
|
|
// 1063/AC3: the list is the controller's consumers: the mesh defines no other durable consumer the loop could read (the
|
|
// check workers went with the checks' queues, ADR 0525 clause 6).
|
|
func TestDeafLookReadsExactlyTheControllersOwnConsumers(t *testing.T) {
|
|
want := map[string]bool{}
|
|
for _, c := range broker.MeshConsumers() {
|
|
want[c.Stream+"/"+c.Name] = true
|
|
}
|
|
got := map[string]bool{}
|
|
for _, c := range loopConsumers() {
|
|
got[c.Stream+"/"+c.Name] = true
|
|
}
|
|
if len(got) != len(want) {
|
|
t.Fatalf("deaf look reads %v, want %v", got, want)
|
|
}
|
|
for k := range want {
|
|
if !got[k] {
|
|
t.Errorf("the deaf look does not read %s", k)
|
|
}
|
|
}
|
|
}
|