Name no node in messenger's fixtures (issue 1838)
This commit is contained in:
@@ -30,8 +30,8 @@ func (b *conditionBed) controllerEvent(t *testing.T, event string, body any) {
|
||||
func walkEvent(phase, outcome string, started, at time.Time) map[string]any {
|
||||
b := map[string]any{"id": "plan-bus", "state": "walking", "walk": "plan-bus", "phase": phase, "budget_class": "leaf",
|
||||
"bound_seconds": 600, "started_at": started.UTC().Format(time.RFC3339Nano),
|
||||
"touches": []map[string]any{{"machine": "novox", "modules": []string{"gitea"}},
|
||||
{"machine": "shanks", "modules": []string{"mesh-build-image"}, "declared": true}}}
|
||||
"touches": []map[string]any{{"machine": "node-c", "modules": []string{"gitea"}},
|
||||
{"machine": "node-d", "modules": []string{"mesh-build-image"}, "declared": true}}}
|
||||
if phase == WalkEnded {
|
||||
b["outcome"], b["ended_at"] = outcome, at.UTC().Format(time.RFC3339Nano)
|
||||
}
|
||||
@@ -64,23 +64,23 @@ func TestAWalksDeclaredMachineIsHeldUntilItSettledOverTheBus(t *testing.T) {
|
||||
b := newConditionBedWith(t, `{"settle-seconds": 2}`)
|
||||
started := time.Now()
|
||||
b.controllerEvent(t, EventPlanMoved, walkEvent(WalkStarted, "", started, started))
|
||||
b.controllerEvent(t, EventRaised, conditionEvent("machine.shanks.uncomposable", "machine", "shanks", "shanks",
|
||||
"Shanks cannot get new instructions"))
|
||||
b.controllerEvent(t, EventRaised, conditionEvent("machine.ace.silent", "machine", "ace", "ace", "Ace is silent"))
|
||||
b.controllerEvent(t, EventRaised, conditionEvent("machine.node-d.uncomposable", "machine", "node-d", "node-d",
|
||||
"Node-d cannot get new instructions"))
|
||||
b.controllerEvent(t, EventRaised, conditionEvent("machine.node-a.silent", "machine", "node-a", "node-a", "Node-a is silent"))
|
||||
b.r.until("the untouched machine's condition reaches the desk with its delivery line", 15*time.Second, func() bool {
|
||||
m := b.toldWith("Ace is silent")
|
||||
m := b.toldWith("Node-a is silent")
|
||||
return m != nil && strings.HasSuffix(*m, "\nNo delivery running.")
|
||||
})
|
||||
if b.toldWith("Shanks cannot get new instructions") != nil {
|
||||
if b.toldWith("Node-d cannot get new instructions") != nil {
|
||||
t.Fatalf("the declared machine's condition was told during the walk")
|
||||
}
|
||||
b.controllerEvent(t, EventPlanMoved, walkEvent(WalkEnded, WalkDelivered, started, time.Now()))
|
||||
time.Sleep(time.Second)
|
||||
if b.toldWith("Shanks cannot get new instructions") != nil || b.toldWith("Delivered") != nil {
|
||||
if b.toldWith("Node-d cannot get new instructions") != nil || b.toldWith("Delivered") != nil {
|
||||
t.Fatalf("told before the settle passed: %+v", b.told())
|
||||
}
|
||||
b.r.until("the walk's end tells what it held once it settled", 30*time.Second, func() bool {
|
||||
m := b.toldWith("Still open after the delivery of gitea to novox:")
|
||||
return m != nil && strings.Contains(*m, "Shanks cannot get new instructions") && !strings.Contains(*m, "shanks,")
|
||||
m := b.toldWith("Still open after the delivery of gitea to node-c:")
|
||||
return m != nil && strings.Contains(*m, "Node-d cannot get new instructions") && !strings.Contains(*m, "node-d,")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func controllerConditions(c *clock) []Condition {
|
||||
// open, whatever name their keys give the controller and whatever host they name.
|
||||
func TestTheControllersOwnConditionsAreHeldWhileAWalkMovesMeshController(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-c", WalkStarted, "", c.now(), 1200, novox("mesh-controller"))
|
||||
walk(t, h, "plan-c", WalkStarted, "", c.now(), 1200, nodeC("mesh-controller"))
|
||||
for _, k := range controllerConditions(c) {
|
||||
h.Condition(EventRaised, k)
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func TestTheControllersOwnConditionsAreHeldWhileAWalkMovesMeshController(t *test
|
||||
// ADR 0505 §2a: a walk that does not move mesh-controller holds none of them.
|
||||
func TestTheControllersOwnConditionsAreNotHeldByAWalkOfAnotherModule(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-g", WalkStarted, "", c.now(), 1200, Touch{Machine: "ace", Modules: []string{"gitea"}})
|
||||
walk(t, h, "plan-g", WalkStarted, "", c.now(), 1200, Touch{Machine: "node-a", Modules: []string{"gitea"}})
|
||||
for _, k := range controllerConditions(c) {
|
||||
h.Condition(EventRaised, k)
|
||||
}
|
||||
@@ -91,32 +91,32 @@ func TestTheControllersOwnConditionsAreNotHeldByAWalkOfAnotherModule(t *testing.
|
||||
}
|
||||
}
|
||||
|
||||
// shanksDeclared is a touch as the controller says a machine whose declaration the walk's merges change and to which
|
||||
// nodeDDeclared is a touch as the controller says a machine whose declaration the walk's merges change and to which
|
||||
// it sends nothing (mesh-controller walk_said.go walkTouch, `declared`, ADR 0505 §2b).
|
||||
var shanksDeclared = Touch{Machine: "shanks", Modules: []string{"mesh-build-image"}, Declared: true}
|
||||
var nodeDDeclared = Touch{Machine: "node-d", Modules: []string{"mesh-build-image"}, Declared: true}
|
||||
|
||||
// ADR 0505 §2b: a machine whose declaration a walk's merges change is held like a machine it sends to, and is not
|
||||
// named among the machines the walk reached.
|
||||
func TestAMachineWhoseDeclarationTheWalkChangesIsHeldAndNotNamedAsReached(t *testing.T) {
|
||||
ev, ok, err := DecodeWalk([]byte(`{"id":"plan-d","walk":"plan-d","phase":"started","budget_class":"leaf",` +
|
||||
`"bound_seconds":600,"touches":[{"machine":"novox","modules":["gitea"]},` +
|
||||
`{"machine":"shanks","modules":["mesh-build-image"],"declared":true}]}`))
|
||||
`"bound_seconds":600,"touches":[{"machine":"node-c","modules":["gitea"]},` +
|
||||
`{"machine":"node-d","modules":["mesh-build-image"],"declared":true}]}`))
|
||||
if err != nil || !ok || len(ev.Touches) != 2 || !ev.Touches[1].Declared || ev.Touches[0].Declared {
|
||||
t.Fatalf("a declared touch was not read: %+v %v %v", ev.Touches, ok, err)
|
||||
}
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-d", WalkStarted, "", c.now(), 600, novox("gitea"), shanksDeclared)
|
||||
k := cond("machine.shanks.uncomposable", Urgent, "shanks cannot get new instructions")
|
||||
k.Machine, k.Raised = "shanks", c.now()
|
||||
walk(t, h, "plan-d", WalkStarted, "", c.now(), 600, nodeC("gitea"), nodeDDeclared)
|
||||
k := cond("machine.node-d.uncomposable", Urgent, "node-d cannot get new instructions")
|
||||
k.Machine, k.Raised = "node-d", c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, time.Minute)
|
||||
if !has(outcomes(h, k.Key), "held") || heard(headlineOf(k.Key), tg, dt) {
|
||||
t.Fatalf("a condition on the declared machine was not held: %v", outcomes(h, k.Key))
|
||||
}
|
||||
if got := touchWords(mergeTouches([]Touch{novox("gitea"), shanksDeclared}, nil)); got != "gitea on novox" {
|
||||
t.Fatalf("what the walk reached reads %q, want only novox", got)
|
||||
if got := touchWords(mergeTouches([]Touch{nodeC("gitea"), nodeDDeclared}, nil)); got != "gitea on node-c" {
|
||||
t.Fatalf("what the walk reached reads %q, want only node-c", got)
|
||||
}
|
||||
if got := mergeTouches([]Touch{shanksDeclared}, []Touch{{Machine: "shanks", Modules: []string{"buildah"}}}); got[0].Declared {
|
||||
if got := mergeTouches([]Touch{nodeDDeclared}, []Touch{{Machine: "node-d", Modules: []string{"buildah"}}}); got[0].Declared {
|
||||
t.Fatalf("a machine the walk also sends to stayed declared: %+v", got)
|
||||
}
|
||||
}
|
||||
@@ -127,12 +127,12 @@ func TestAMachineWhoseDeclarationTheWalkChangesIsHeldAndNotNamedAsReached(t *tes
|
||||
func TestAConditionRaisedInTheSettleIsHeldAndToldAtItsEnd(t *testing.T) {
|
||||
for _, clears := range []bool{false, true} {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-s", WalkStarted, "", c.now(), 600, novox("gitea"))
|
||||
walk(t, h, "plan-s", WalkStarted, "", c.now(), 600, nodeC("gitea"))
|
||||
runFor(h, c, 3*time.Minute)
|
||||
walk(t, h, "plan-s", WalkEnded, WalkDelivered, c.now(), 0, novox("gitea"))
|
||||
walk(t, h, "plan-s", WalkEnded, WalkDelivered, c.now(), 0, nodeC("gitea"))
|
||||
c.pass(30 * time.Second)
|
||||
k := cond("machine.novox.uncomposable", Urgent, "novox cannot get new instructions")
|
||||
k.Machine, k.Raised = "novox", c.now()
|
||||
k := cond("machine.node-c.uncomposable", Urgent, "node-c cannot get new instructions")
|
||||
k.Machine, k.Raised = "node-c", c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, time.Minute)
|
||||
if heard(headlineOf(k.Key), tg, dt) || !has(outcomes(h, k.Key), "held") {
|
||||
@@ -146,7 +146,7 @@ func TestAConditionRaisedInTheSettleIsHeldAndToldAtItsEnd(t *testing.T) {
|
||||
}
|
||||
runFor(h, c, time.Minute)
|
||||
switch {
|
||||
case !clears && !heard("Still open after the delivery of gitea to novox:\n- Urgent: "+headlineOf(k.Key), tg, dt):
|
||||
case !clears && !heard("Still open after the delivery of gitea to node-c:\n- Urgent: "+headlineOf(k.Key), tg, dt):
|
||||
t.Fatalf("still open at the settle's end and not told under the delivery: %+v", dt.sends)
|
||||
case clears && (heard(headlineOf(k.Key), tg, dt) || !heard("1 problem it raised resolved during it.", dt)):
|
||||
t.Fatalf("cleared in the settle: told, or not counted: %+v", dt.sends)
|
||||
@@ -158,7 +158,7 @@ func TestAConditionRaisedInTheSettleIsHeldAndToldAtItsEnd(t *testing.T) {
|
||||
// any other message, and told at the settle's end only when the condition is still open.
|
||||
func TestAReminderDuringAWalkIsHeld(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.novox.network", Urgent, "novox lost its default route")
|
||||
k := cond("machine.node-c.network", Urgent, "node-c lost its default route")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, time.Minute)
|
||||
@@ -167,7 +167,7 @@ func TestAReminderDuringAWalkIsHeld(t *testing.T) {
|
||||
t.Fatalf("the condition was not said before the walk")
|
||||
}
|
||||
runFor(h, c, RemindUrgent-3*time.Minute)
|
||||
walk(t, h, "plan-r", WalkStarted, "", c.now(), 1200, novox("node-tools"))
|
||||
walk(t, h, "plan-r", WalkStarted, "", c.now(), 1200, nodeC("node-tools"))
|
||||
runFor(h, c, 5*time.Minute)
|
||||
if saidOn(tg, dt) != first {
|
||||
t.Fatalf("the reminder was said during the walk: %+v", dt.sends)
|
||||
@@ -177,7 +177,7 @@ func TestAReminderDuringAWalkIsHeld(t *testing.T) {
|
||||
}
|
||||
walk(t, h, "plan-r", WalkEnded, WalkDelivered, c.now(), 0)
|
||||
runFor(h, c, DefaultSettle+time.Minute)
|
||||
if !heard("Still open after the delivery of node-tools to novox:", dt) {
|
||||
if !heard("Still open after the delivery of node-tools to node-c:", dt) {
|
||||
t.Fatalf("the held reminder was not told at the settle's end: %+v", dt.sends)
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@ func TestAReminderDuringAWalkIsHeld(t *testing.T) {
|
||||
// ADR 0505 §3: a router that starts again while a walk settles holds on and tells its end once the settle passed.
|
||||
func TestAWalkThatSettlesSurvivesARouterRestart(t *testing.T) {
|
||||
h, tg, dt, c, st := newHolder(t)
|
||||
walk(t, h, "plan-x", WalkStarted, "", c.now(), 1200, novox("mesh-tools"))
|
||||
walk(t, h, "plan-x", WalkStarted, "", c.now(), 1200, nodeC("mesh-tools"))
|
||||
runFor(h, c, time.Minute)
|
||||
walk(t, h, "plan-x", WalkEnded, WalkDelivered, c.now(), 0)
|
||||
c.pass(10 * time.Second)
|
||||
@@ -194,7 +194,7 @@ func TestAWalkThatSettlesSurvivesARouterRestart(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
again.Start()
|
||||
k := cond("machine.novox.tools-silent", Urgent, "the tools on novox are silent")
|
||||
k := cond("machine.node-c.tools-silent", Urgent, "the tools on node-c are silent")
|
||||
k.Raised = c.now()
|
||||
again.Condition(EventRaised, k)
|
||||
runFor(again, c, time.Minute)
|
||||
@@ -202,10 +202,10 @@ func TestAWalkThatSettlesSurvivesARouterRestart(t *testing.T) {
|
||||
t.Fatalf("not held by the settling walk read back: %v", outcomes(again, k.Key))
|
||||
}
|
||||
runFor(again, c, DefaultSettle)
|
||||
if !heard("Still open after the delivery of mesh-tools to novox:\n- Urgent: "+headlineOf(k.Key), tg, dt) {
|
||||
if !heard("Still open after the delivery of mesh-tools to node-c:\n- Urgent: "+headlineOf(k.Key), tg, dt) {
|
||||
t.Fatalf("the settled walk's end was not told after the restart: %+v", dt.sends)
|
||||
}
|
||||
walk(t, again, "plan-x", WalkStarted, "", c.now().Add(-5*time.Minute), 1200, novox("mesh-tools"))
|
||||
walk(t, again, "plan-x", WalkStarted, "", c.now().Add(-5*time.Minute), 1200, nodeC("mesh-tools"))
|
||||
if len(again.walks) != 0 {
|
||||
t.Fatalf("its late start opened it again: %+v", again.walks)
|
||||
}
|
||||
@@ -216,13 +216,13 @@ func TestAWalkThatSettlesSurvivesARouterRestart(t *testing.T) {
|
||||
func TestAConditionJustAfterAFailedWalkIsSentAtOnceAndAfterADeliveredOneHeld(t *testing.T) {
|
||||
for _, outcome := range []string{WalkFailed, WalkStopped, WalkDelivered} {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-f", WalkStarted, "", c.now(), 600, novox("gitea"))
|
||||
walk(t, h, "plan-o", WalkStarted, "", c.now(), 1200, novox("mesh-issues"))
|
||||
walk(t, h, "plan-f", WalkStarted, "", c.now(), 600, nodeC("gitea"))
|
||||
walk(t, h, "plan-o", WalkStarted, "", c.now(), 1200, nodeC("mesh-issues"))
|
||||
runFor(h, c, 2*time.Minute)
|
||||
walk(t, h, "plan-f", WalkEnded, outcome, c.now(), 0, novox("gitea"))
|
||||
walk(t, h, "plan-f", WalkEnded, outcome, c.now(), 0, nodeC("gitea"))
|
||||
runFor(h, c, 30*time.Second)
|
||||
k := cond("machine.novox.uncomposable", Urgent, "novox cannot get new instructions")
|
||||
k.Machine, k.Raised = "novox", c.now()
|
||||
k := cond("machine.node-c.uncomposable", Urgent, "node-c cannot get new instructions")
|
||||
k.Machine, k.Raised = "node-c", c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, 30*time.Second)
|
||||
sent := heard(headlineOf(k.Key), tg, dt)
|
||||
@@ -238,12 +238,12 @@ func TestAConditionJustAfterAFailedWalkIsSentAtOnceAndAfterADeliveredOneHeld(t *
|
||||
// ADR 0505 §6: an urgent condition on a machine no open or settling walk touches is sent at once during a walk.
|
||||
func TestAnUrgentConditionOnAnUntouchedMachineIsSentAtOnceDuringAWalk(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-u", WalkStarted, "", c.now(), 1200, novox("gitea"))
|
||||
k := cond("machine.ace.silent", Urgent, "ace has not been heard")
|
||||
k.Machine, k.Raised = "ace", c.now()
|
||||
walk(t, h, "plan-u", WalkStarted, "", c.now(), 1200, nodeC("gitea"))
|
||||
k := cond("machine.node-a.silent", Urgent, "node-a has not been heard")
|
||||
k.Machine, k.Raised = "node-a", c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
if !heard(headlineOf(k.Key), tg, dt) {
|
||||
t.Fatalf("held, while no walk touches ace: %v", outcomes(h, k.Key))
|
||||
t.Fatalf("held, while no walk touches node-a: %v", outcomes(h, k.Key))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,30 +263,30 @@ func bodyOf(t *testing.T, h *Holder, key, what string) string {
|
||||
// walk's settle, after a failed walk, and with no walk.
|
||||
func TestEveryProblemMessageEndsWithWhetherADeliveryRan(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.novox.tools-silent", Urgent, "the tools on novox are silent")
|
||||
k := cond("machine.node-c.tools-silent", Urgent, "the tools on node-c are silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
if !strings.HasSuffix(tg.sends[0].Body, ".\nNo delivery running.") || !strings.Contains(tg.sends[0].Body, "\nSince ") {
|
||||
t.Fatalf("no walk: %q", tg.sends[0].Body)
|
||||
}
|
||||
walk(t, h, "plan-l", WalkStarted, "", c.now(), 600, novox("gitea", "mesh-issues"), shanksDeclared)
|
||||
if b := bodyOf(t, h, k.Key, "reminder"); !strings.HasSuffix(b, ".\nDuring the delivery of gitea, mesh-issues to novox.") {
|
||||
walk(t, h, "plan-l", WalkStarted, "", c.now(), 600, nodeC("gitea", "mesh-issues"), nodeDDeclared)
|
||||
if b := bodyOf(t, h, k.Key, "reminder"); !strings.HasSuffix(b, ".\nDuring the delivery of gitea, mesh-issues to node-c.") {
|
||||
t.Fatalf("during a walk: %q", b)
|
||||
}
|
||||
runFor(h, c, time.Minute)
|
||||
walk(t, h, "plan-l", WalkEnded, WalkDelivered, c.now(), 0)
|
||||
c.pass(40 * time.Second)
|
||||
if b := bodyOf(t, h, k.Key, "raised"); !strings.HasSuffix(b, "\n40 s after the delivery of gitea, mesh-issues to novox, which succeeded.") {
|
||||
if b := bodyOf(t, h, k.Key, "raised"); !strings.HasSuffix(b, "\n40 s after the delivery of gitea, mesh-issues to node-c, which succeeded.") {
|
||||
t.Fatalf("in the settle of a delivered walk: %q", b)
|
||||
}
|
||||
runFor(h, c, 3*time.Minute)
|
||||
if b := bodyOf(t, h, k.Key, "reminder"); !strings.HasSuffix(b, "\nNo delivery running.") {
|
||||
t.Fatalf("after the settle: %q", b)
|
||||
}
|
||||
walk(t, h, "plan-m", WalkStarted, "", c.now(), 600, novox("gitea"))
|
||||
walk(t, h, "plan-m", WalkStarted, "", c.now(), 600, nodeC("gitea"))
|
||||
walk(t, h, "plan-m", WalkEnded, WalkFailed, c.now(), 0)
|
||||
c.pass(30 * time.Second)
|
||||
if b := bodyOf(t, h, k.Key, "reminder"); !strings.HasSuffix(b, "\n30 s after the delivery of gitea to novox, which failed.") {
|
||||
if b := bodyOf(t, h, k.Key, "reminder"); !strings.HasSuffix(b, "\n30 s after the delivery of gitea to node-c, which failed.") {
|
||||
t.Fatalf("after a failed walk: %q", b)
|
||||
}
|
||||
keyless(t, dt.sends...)
|
||||
@@ -303,13 +303,13 @@ func TestEveryProblemMessageEndsWithWhetherADeliveryRan(t *testing.T) {
|
||||
|
||||
// ADR 0505 §1: the line names at most six modules and counts the rest, and says no name the content rule refuses.
|
||||
func TestTheDeliveryLineNamesAtMostSixModulesAndNothingTheRuleRefuses(t *testing.T) {
|
||||
many := novox("a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8")
|
||||
if got := deliveryWords([]Touch{many}); got != "a1, a2, a3, a4, a5, a6 and 2 more to novox" {
|
||||
many := nodeC("a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8")
|
||||
if got := deliveryWords([]Touch{many}); got != "a1, a2, a3, a4, a5, a6 and 2 more to node-c" {
|
||||
t.Fatalf("eight modules: %q", got)
|
||||
}
|
||||
h, _, _, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-p", WalkStarted, "", c.now(), 600, novox("/var/lib/mesh-tools"))
|
||||
k := cond("machine.novox.tools-silent", Urgent, "the tools on novox are silent")
|
||||
walk(t, h, "plan-p", WalkStarted, "", c.now(), 600, nodeC("/var/lib/mesh-tools"))
|
||||
k := cond("machine.node-c.tools-silent", Urgent, "the tools on node-c are silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
if b := bodyOf(t, h, k.Key, "raised"); !strings.HasSuffix(b, "\nDuring a delivery.") {
|
||||
@@ -323,18 +323,18 @@ func TestTheDeliveryLineNamesAtMostSixModulesAndNothingTheRuleRefuses(t *testing
|
||||
func TestADeclaredMachinesConditionAcrossThreeWalksIsSaidAtTheFirstWalksLimit(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
t0 := c.now()
|
||||
walk(t, h, "plan-1", WalkStarted, "", c.now(), 600, novox("gitea"), shanksDeclared) // limit: t0 + 10 + 2 min
|
||||
k := cond("machine.shanks.uncomposable", Urgent, "shanks cannot get new instructions")
|
||||
k.Machine, k.Raised = "shanks", c.now()
|
||||
walk(t, h, "plan-1", WalkStarted, "", c.now(), 600, nodeC("gitea"), nodeDDeclared) // limit: t0 + 10 + 2 min
|
||||
k := cond("machine.node-d.uncomposable", Urgent, "node-d cannot get new instructions")
|
||||
k.Machine, k.Raised = "node-d", c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, 5*time.Minute)
|
||||
walk(t, h, "plan-1", WalkEnded, WalkDelivered, c.now(), 0, novox("gitea"), shanksDeclared)
|
||||
walk(t, h, "plan-1", WalkEnded, WalkDelivered, c.now(), 0, nodeC("gitea"), nodeDDeclared)
|
||||
runFor(h, c, time.Minute)
|
||||
walk(t, h, "plan-2", WalkStarted, "", c.now(), 600, novox("mesh-issues"), shanksDeclared)
|
||||
walk(t, h, "plan-2", WalkStarted, "", c.now(), 600, nodeC("mesh-issues"), nodeDDeclared)
|
||||
runFor(h, c, 3*time.Minute)
|
||||
walk(t, h, "plan-2", WalkEnded, WalkDelivered, c.now(), 0, novox("mesh-issues"), shanksDeclared)
|
||||
walk(t, h, "plan-2", WalkEnded, WalkDelivered, c.now(), 0, nodeC("mesh-issues"), nodeDDeclared)
|
||||
runFor(h, c, time.Minute)
|
||||
walk(t, h, "plan-3", WalkStarted, "", c.now(), 1200, novox("gitea"), shanksDeclared)
|
||||
walk(t, h, "plan-3", WalkStarted, "", c.now(), 1200, nodeC("gitea"), nodeDDeclared)
|
||||
for c.now().Before(t0.Add(12*time.Minute - 10*time.Second)) {
|
||||
runFor(h, c, 5*time.Second)
|
||||
}
|
||||
@@ -351,14 +351,14 @@ func TestADeclaredMachinesConditionAcrossThreeWalksIsSaidAtTheFirstWalksLimit(t
|
||||
// once: one walk with both sayings' touches, and one end message.
|
||||
func TestAWalkSaidAgainWithItsDeclaredMachinesActsOnce(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-r", WalkStarted, "", c.now(), 600, novox("gitea"))
|
||||
walk(t, h, "plan-r", WalkStarted, "", c.now(), 600, novox("gitea"), shanksDeclared)
|
||||
walk(t, h, "plan-r", WalkStarted, "", c.now(), 600, nodeC("gitea"))
|
||||
walk(t, h, "plan-r", WalkStarted, "", c.now(), 600, nodeC("gitea"), nodeDDeclared)
|
||||
if len(h.walks) != 1 || len(h.walks["plan-r"].Touches) != 2 {
|
||||
t.Fatalf("said again it is not one walk with both touches: %+v", h.walks)
|
||||
}
|
||||
runFor(h, c, time.Minute)
|
||||
walk(t, h, "plan-r", WalkEnded, WalkFailed, c.now(), 0, novox("gitea"))
|
||||
walk(t, h, "plan-r", WalkEnded, WalkFailed, c.now(), 0, novox("gitea"), shanksDeclared)
|
||||
walk(t, h, "plan-r", WalkEnded, WalkFailed, c.now(), 0, nodeC("gitea"))
|
||||
walk(t, h, "plan-r", WalkEnded, WalkFailed, c.now(), 0, nodeC("gitea"), nodeDDeclared)
|
||||
runFor(h, c, 3*time.Minute)
|
||||
n := 0
|
||||
for _, m := range append(append([]Message(nil), dt.sends...), tg.sends...) {
|
||||
@@ -376,9 +376,9 @@ func TestAWalkSaidAgainWithItsDeclaredMachinesActsOnce(t *testing.T) {
|
||||
func TestAMessageTwoWalksFirstHeldIsSaidOnceAtTheSoonerLimit(t *testing.T) {
|
||||
for _, sev := range []string{Warning, Urgent} {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-a", WalkStarted, "", c.now(), 360, novox("gitea")) // its limit: 6 min and the settle
|
||||
walk(t, h, "plan-b", WalkStarted, "", c.now(), 1200, novox("mesh-issues")) // its limit: 22 min
|
||||
k := cond("machine.novox.network", sev, "novox lost its default route")
|
||||
walk(t, h, "plan-a", WalkStarted, "", c.now(), 360, nodeC("gitea")) // its limit: 6 min and the settle
|
||||
walk(t, h, "plan-b", WalkStarted, "", c.now(), 1200, nodeC("mesh-issues")) // its limit: 22 min
|
||||
k := cond("machine.node-c.network", sev, "node-c lost its default route")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, 7*time.Minute)
|
||||
@@ -402,7 +402,7 @@ func TestAMessageTwoWalksFirstHeldIsSaidOnceAtTheSoonerLimit(t *testing.T) {
|
||||
t.Fatalf("%s: said %d times on %s, want %d: %+v", sev, got, ch.name, n, ch.sends)
|
||||
}
|
||||
}
|
||||
if !heard("Still open after the delivery of gitea to novox:", dt) {
|
||||
if !heard("Still open after the delivery of gitea to node-c:", dt) {
|
||||
t.Fatalf("%s: not told in the sooner walk's end message: %+v", sev, dt.sends)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ func TestEveryAnswerThatIsNotTheOperatorsIsRefusedAndSaid(t *testing.T) {
|
||||
"a sender the service did not say": {"telegram", "42", false, 2 * time.Hour, "Release", 0, "did not authenticate"},
|
||||
"a link younger than an hour": {"telegram", "42", true, 59 * time.Minute, "Release", 0, "can answer this question from"},
|
||||
"an ask that expired": {"telegram", "42", true, 2 * time.Hour, "Release", 3 * time.Hour, "expired"},
|
||||
"a ticket shown on another kind": {"desktop", "g14", true, 2 * time.Hour, "Release", 0, "not offered here"},
|
||||
"a ticket shown on another kind": {"desktop", "node-b", true, 2 * time.Hour, "Release", 0, "not offered here"},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
h, tg, _, c, store, w := newRouter(t)
|
||||
@@ -532,13 +532,13 @@ func TestTheDeskAcknowledgesAndNeverApproves(t *testing.T) {
|
||||
submit(t, h, "mesh-delivery", ackAsk(c, "d-1"))
|
||||
settle(h, c)
|
||||
silence := ticketFor(dt.sends[0], "Silence for a week")
|
||||
ch := choiceOf(silence, "g14", c.now())
|
||||
ch := choiceOf(silence, "node-b", c.now())
|
||||
ch.Sender.Authenticated = false
|
||||
if out, err := h.Chosen("desktop", ch); err != nil || out != "chosen" {
|
||||
t.Fatalf("%s %v", out, err)
|
||||
}
|
||||
got := w.of("mesh-delivery")
|
||||
if len(got) != 1 || got[0].By.Verified != "a desk click: whoever was at the operator's session on g14" || len(got[0].Proofs) != 0 {
|
||||
if len(got) != 1 || got[0].By.Verified != "a desk click: whoever was at the operator's session on node-b" || len(got[0].Proofs) != 0 {
|
||||
t.Errorf("%+v", got)
|
||||
}
|
||||
// An approve ticket forged onto the desk is refused: the kind cannot carry it.
|
||||
@@ -553,7 +553,7 @@ func TestTheDeskAcknowledgesAndNeverApproves(t *testing.T) {
|
||||
rec.Tickets[release] = tk
|
||||
store2.asks["mesh-delivery.d-1"] = rec
|
||||
h2.keepAsk("mesh-delivery.d-1", rec, store2.revs["mesh-delivery.d-1"])
|
||||
if out, err := h2.Chosen("desktop", choiceOf(release, "g14", c2.now())); err == nil || out != "refused" ||
|
||||
if out, err := h2.Chosen("desktop", choiceOf(release, "node-b", c2.now())); err == nil || out != "refused" ||
|
||||
!strings.Contains(err.Error(), "cannot answer a question that asks for an approval") {
|
||||
t.Errorf("the desk approved: %s %v", out, err)
|
||||
}
|
||||
@@ -564,7 +564,7 @@ func TestTheDeskAcknowledgesAndNeverApproves(t *testing.T) {
|
||||
rec.Tickets[silence] = tk
|
||||
store2.asks["mesh-delivery.d-1"] = rec
|
||||
h2.keepAsk("mesh-delivery.d-1", rec, store2.revs["mesh-delivery.d-1"])
|
||||
if out, _ := h2.Chosen("desktop", choiceOf(silence, "g14", c2.now())); out != "refused" ||
|
||||
if out, _ := h2.Chosen("desktop", choiceOf(silence, "node-b", c2.now())); out != "refused" ||
|
||||
store2.asks["mesh-delivery.d-1"].State != StateOpen {
|
||||
t.Errorf("a desk click ended an ask that waits for an approval: %s", out)
|
||||
}
|
||||
@@ -681,7 +681,7 @@ func TestAnAskAboutAConditionIsAnsweredOnItsMessage(t *testing.T) {
|
||||
t.Errorf("the ask is shown on %q", store.asks["mesh-controller.d-1"].Record)
|
||||
}
|
||||
silence := ticketFor(shown, "Silence for a week")
|
||||
if out, err := h.Chosen("desktop", choiceOf(silence, "g14", c.now())); err != nil || out != "chosen" {
|
||||
if out, err := h.Chosen("desktop", choiceOf(silence, "node-b", c.now())); err != nil || out != "chosen" {
|
||||
t.Fatalf("%s %v", out, err)
|
||||
}
|
||||
if got := w.of("mesh-controller"); len(got) != 1 || got[0].About != "delivery.hq.held" {
|
||||
@@ -781,7 +781,7 @@ func TestALinkCodeExpiresAndFiveWrongTriesEndIt(t *testing.T) {
|
||||
t.Errorf("%+v", a)
|
||||
}
|
||||
// The desk cannot be linked: it proves nothing about who clicked.
|
||||
h.Link("desktop", asks.LinkAsked{ID: "l3", At: c.now(), Sender: asks.Sender{Identity: "g14"}})
|
||||
h.Link("desktop", asks.LinkAsked{ID: "l3", At: c.now(), Sender: asks.Sender{Identity: "node-b"}})
|
||||
if _, pending := store.links["desktop"]; pending {
|
||||
t.Error("the desk began a link")
|
||||
}
|
||||
@@ -1001,7 +1001,7 @@ func TestAWarningTheDeskCouldNotShowGoesAway(t *testing.T) {
|
||||
if len(dt.sends) != 1 {
|
||||
t.Fatalf("the desk was sent %d", len(dt.sends))
|
||||
}
|
||||
h.Failed("desktop", asks.Failed{Handle: "g14=1", Why: "no session answers", At: c.now()})
|
||||
h.Failed("desktop", asks.Failed{Handle: "node-b=1", Why: "no session answers", At: c.now()})
|
||||
c.pass(BurstWindow)
|
||||
h.Flush()
|
||||
if len(tg.sends) == 0 {
|
||||
|
||||
@@ -27,8 +27,8 @@ func TestTheEventsAreTheControllersSeat(t *testing.T) {
|
||||
|
||||
func TestAConditionAsTheStoreHoldsIt(t *testing.T) {
|
||||
body := `{
|
||||
"key": "machine.ace.silent", "kind": "silent",
|
||||
"subject": {"scope": "machine", "id": "ace", "machine": "ace"},
|
||||
"key": "machine.node-a.silent", "kind": "silent",
|
||||
"subject": {"scope": "machine", "id": "node-a", "machine": "node-a"},
|
||||
"severity": "urgent", "summary": "the home server has not been heard for 15 min",
|
||||
"evidence": [{"at": "2026-10-06T12:00:00Z", "what": "last heartbeat"}],
|
||||
"source": "S1", "raised": "2026-10-06T12:15:00Z", "last-observed": "2026-10-06T12:16:00Z",
|
||||
@@ -40,7 +40,7 @@ func TestAConditionAsTheStoreHoldsIt(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c.Key != "machine.ace.silent" || c.Kind != "silent" || c.Scope != "machine" || c.ID != "ace" ||
|
||||
if c.Key != "machine.node-a.silent" || c.Kind != "silent" || c.Scope != "machine" || c.ID != "node-a" ||
|
||||
c.Severity != Urgent || c.Source != "S1" || c.Observations != 3 || c.Resolver != "self" {
|
||||
t.Fatalf("%+v", c)
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func TestAConditionAsTheStoreHoldsIt(t *testing.T) {
|
||||
if !c.SilencedAt(time.Date(2026, 10, 6, 13, 0, 0, 0, time.UTC)) || c.SilencedAt(time.Date(2026, 10, 6, 15, 0, 0, 0, time.UTC)) {
|
||||
t.Fatalf("silenced: %v", c.SilencedTill)
|
||||
}
|
||||
if c.SubjectWords() != "machine ace" {
|
||||
if c.SubjectWords() != "machine node-a" {
|
||||
t.Fatalf("subject words: %q", c.SubjectWords())
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func TestOtherSpellingsAndAKeyMadeFromItsParts(t *testing.T) {
|
||||
if c.Key != "plan.41.stalled" || c.Source != "S3" || c.LastObserved.IsZero() || !c.SilencedTill.IsZero() {
|
||||
t.Fatalf("%+v", c)
|
||||
}
|
||||
c, err = DecodeCondition(EventRaised, []byte(`{"key":"provider.keycloak.ace.gitea.failing","subject":"keycloak",
|
||||
c, err = DecodeCondition(EventRaised, []byte(`{"key":"provider.keycloak.node-a.gitea.failing","subject":"keycloak",
|
||||
"severity":"warning","summary":"the identity provider fails gitea"}`))
|
||||
if err != nil || c.Scope != "provider" || c.Kind != "failing" || c.ID != "keycloak" {
|
||||
t.Fatalf("%+v %v", c, err)
|
||||
@@ -73,8 +73,8 @@ func TestOtherSpellingsAndAKeyMadeFromItsParts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAClearedEventNeedsOnlyItsKey(t *testing.T) {
|
||||
c, err := DecodeCondition(EventCleared, []byte(`{"key":"machine.ace.silent","cleared":"2026-10-06T12:30:00Z"}`))
|
||||
if err != nil || c.Key != "machine.ace.silent" || c.Cleared.IsZero() {
|
||||
c, err := DecodeCondition(EventCleared, []byte(`{"key":"machine.node-a.silent","cleared":"2026-10-06T12:30:00Z"}`))
|
||||
if err != nil || c.Key != "machine.node-a.silent" || c.Cleared.IsZero() {
|
||||
t.Fatalf("%+v %v", c, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ import "testing"
|
||||
func TestRolesAndWordsMayLeave(t *testing.T) {
|
||||
for _, s := range []string{
|
||||
"URGENT: the home server has not been heard for 15 min",
|
||||
"key: provider.keycloak.ace.gitea.failing",
|
||||
"more: conditions show machine.ace.silent",
|
||||
"key: provider.keycloak.node-a.gitea.failing",
|
||||
"more: conditions show machine.node-a.silent",
|
||||
"since: 2026-10-06 12:30 UTC",
|
||||
"call call-1759752000123456789-12 has run past its bound of 10 min",
|
||||
"ace/postgres.query answers no more",
|
||||
"node-a/postgres.query answers no more",
|
||||
"3/4 machines answered; plan 41 waits on build 7f3a9c1e",
|
||||
"the bus advisory slow-consumer for ace_records",
|
||||
"core.controller.novox.rolled-back",
|
||||
"the bus advisory slow-consumer for node-a_records",
|
||||
"core.controller.node-c.rolled-back",
|
||||
"seat node-notifier has no live holder",
|
||||
"HELD BACK: 5 message(s) over the cap of 20 an hour",
|
||||
"STILL OPEN after 1.5 h: the controller's event loop takes no message",
|
||||
@@ -32,7 +32,7 @@ func TestAnAddressAPathOrASecretMayNot(t *testing.T) {
|
||||
"fe80::1 answered": "address",
|
||||
"2001:db8:0:0:0:0:2:1 answered": "address",
|
||||
"see https://git.example.org/x": "address",
|
||||
"git.novox.internal does not answer": "address",
|
||||
"git.node-c.internal does not answer": "address",
|
||||
"the mail for admin@example.org bounced": "address",
|
||||
"zurag.be is down": "address",
|
||||
"localhost refused": "address",
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestDetailsWorksOnEachOfThreeWarningsOnceEach(t *testing.T) {
|
||||
var toks []string
|
||||
if same {
|
||||
// One problem said three times: raised, escalated, and reminded.
|
||||
k := cond("machine.novox.silent", Warning, "the anchor is silent")
|
||||
k := cond("machine.node-c.silent", Warning, "the anchor is silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
settle(h, c)
|
||||
@@ -49,7 +49,7 @@ func TestDetailsWorksOnEachOfThreeWarningsOnceEach(t *testing.T) {
|
||||
h.Tick()
|
||||
settle(h, c)
|
||||
} else {
|
||||
for _, key := range []string{"machine.ace.silent", "machine.shanks.units", "plan.41.stalled"} {
|
||||
for _, key := range []string{"machine.node-a.silent", "machine.node-d.units", "plan.41.stalled"} {
|
||||
k := cond(key, Warning, key+" needs a look")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
@@ -97,7 +97,7 @@ func TestDetailsWorksOnEachOfThreeWarningsOnceEach(t *testing.T) {
|
||||
func TestDetailsTicketsAreBoundedInNumberAndTime(t *testing.T) {
|
||||
h, tg, _, c, _ := newHolder(t)
|
||||
h.Desk = nil
|
||||
k := cond("machine.ace.silent", Warning, "the home server is silent")
|
||||
k := cond("machine.node-a.silent", Warning, "the home server is silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
settle(h, c)
|
||||
@@ -134,7 +134,7 @@ func TestDetailsTicketsAreBoundedInNumberAndTime(t *testing.T) {
|
||||
func TestDetailsOutlivesAChangeOfTheActions(t *testing.T) {
|
||||
h, tg, _, c, _ := newHolder(t)
|
||||
h.Desk = nil
|
||||
k := cond("machine.ace.silent", Warning, "the home server is silent")
|
||||
k := cond("machine.node-a.silent", Warning, "the home server is silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
settle(h, c)
|
||||
@@ -165,7 +165,7 @@ func TestDetailsOnAMessageWithAnOpenAskNeverAnswersIt(t *testing.T) {
|
||||
shown = m
|
||||
}
|
||||
for _, tok := range []string{older, detailsOf(t, shown)} {
|
||||
if out, err := h.Chosen("desktop", choiceOf(tok, "g14", c.now())); err != nil || out != "shown" {
|
||||
if out, err := h.Chosen("desktop", choiceOf(tok, "node-b", c.now())); err != nil || out != "shown" {
|
||||
t.Fatalf("Details: %q %v", out, err)
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ func TestDetailsOnAMessageWithAnOpenAskNeverAnswersIt(t *testing.T) {
|
||||
func TestAnUnreadyChannelPushesOutNoShownDetails(t *testing.T) {
|
||||
h, tg, _, c, _ := newHolder(t)
|
||||
h.Desk = nil
|
||||
k := cond("machine.ace.silent", Warning, "the home server is silent")
|
||||
k := cond("machine.node-a.silent", Warning, "the home server is silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
settle(h, c)
|
||||
|
||||
@@ -23,7 +23,7 @@ func decisionAsk(c *clock) asks.Ask {
|
||||
"• A deleted file is marked, and a newer change elsewhere outlives the deletion",
|
||||
Who: asks.Operator, Expires: c.now().Add(23*time.Hour + 50*time.Minute), OnExpiry: "the record stays proposed; nothing of it is in force",
|
||||
About: "knowledge.decision.343",
|
||||
Details: "ADR 0343, proposed by fix-367@g14; the knowledge base's own review approved it. Fingerprint a59f 361b f60e cb5e d237 a837.\n" +
|
||||
Details: "ADR 0343, proposed by fix-367@node-b; the knowledge base's own review approved it. Fingerprint a59f 361b f60e cb5e d237 a837.\n" +
|
||||
"Read its 13 clauses with the knowledge base's get, number 343.",
|
||||
Options: []asks.Option{
|
||||
{ID: "approve", Label: "Approve", Does: "the record is accepted and its clauses are in force", Level: asks.Approve, Binds: bound("approve")},
|
||||
@@ -50,7 +50,7 @@ func TestAnAsksMessageIsItsSummaryWithTheRestInItsNote(t *testing.T) {
|
||||
"Asked by mesh-knowledge at " + asked + ". Unanswered by tomorrow " + a.Expires.In(time.UTC).Format("15:04") +
|
||||
": the record stays proposed; nothing of it is in force.",
|
||||
"Approve: the record is accepted and its clauses are in force. Decline: the record stays proposed; nothing of it is in force.",
|
||||
"ADR 0343, proposed by fix-367@g14; the knowledge base's own review approved it. Fingerprint a59f 361b f60e cb5e d237 a837.",
|
||||
"ADR 0343, proposed by fix-367@node-b; the knowledge base's own review approved it. Fingerprint a59f 361b f60e cb5e d237 a837.",
|
||||
"Read its 13 clauses with the knowledge base's get, number 343.",
|
||||
}
|
||||
if strings.Join(note, "\n") != strings.Join(want, "\n") {
|
||||
|
||||
@@ -184,7 +184,7 @@ func TestTodaysBacklogWithAnUrgentStillOpenIsOneMessage(t *testing.T) {
|
||||
h, tg, dt, c := incidentHolder(t)
|
||||
// Suppose the merge never got acted on, and three machines stayed behind: still open at 09:49.
|
||||
stillOpen := map[string]bool{"merge.mesh-catalog.f2b51686.not-acted": true,
|
||||
"machine.ace.core-behind": true, "machine.g14.core-behind": true, "machine.shanks.core-behind": true}
|
||||
"machine.node-a.core-behind": true, "machine.node-b.core-behind": true, "machine.node-d.core-behind": true}
|
||||
var kept []backlogEvent
|
||||
for _, e := range backlog {
|
||||
c, _ := DecodeCondition(e.event, e.body)
|
||||
@@ -216,7 +216,7 @@ func TestTodaysBacklogWithAnUrgentStillOpenIsOneMessage(t *testing.T) {
|
||||
func TestAnEventOlderThanTheReadingIsNotActedOn(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
h.Sync(nil, c.now())
|
||||
k := cond("machine.ace.silent", Urgent, "the home server is silent")
|
||||
k := cond("machine.node-a.silent", Urgent, "the home server is silent")
|
||||
k.At = c.now().Add(-time.Minute)
|
||||
k.Raised = k.At
|
||||
h.Condition(EventRaised, k) // already cleared in the state read after it
|
||||
@@ -228,7 +228,7 @@ func TestAnEventOlderThanTheReadingIsNotActedOn(t *testing.T) {
|
||||
|
||||
func TestAnOldEventIsStateNeverAMessage(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.ace.silent", Urgent, "the home server is silent")
|
||||
k := cond("machine.node-a.silent", Urgent, "the home server is silent")
|
||||
k.At = c.now().Add(-FreshFor - time.Second)
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, 2*time.Minute)
|
||||
@@ -247,10 +247,10 @@ func TestAnOldEventIsStateNeverAMessage(t *testing.T) {
|
||||
t.Fatalf("a clearing of what was never said was said")
|
||||
}
|
||||
// The state, read now, says an urgent one is open that was never said: that is said, once.
|
||||
h.Condition(EventRaised, Condition{Key: "machine.shanks.silent", Scope: "machine", ID: "shanks", Kind: "silent",
|
||||
h.Condition(EventRaised, Condition{Key: "machine.node-d.silent", Scope: "machine", ID: "node-d", Kind: "silent",
|
||||
Severity: Urgent, Summary: "the desktop is silent", At: c.now().Add(-time.Hour)})
|
||||
h.Sync([]Condition{cond("machine.shanks.silent", Urgent, "the desktop is silent")}, c.now())
|
||||
h.Sync([]Condition{cond("machine.shanks.silent", Urgent, "the desktop is silent")}, c.now().Add(time.Second))
|
||||
h.Sync([]Condition{cond("machine.node-d.silent", Urgent, "the desktop is silent")}, c.now())
|
||||
h.Sync([]Condition{cond("machine.node-d.silent", Urgent, "the desktop is silent")}, c.now().Add(time.Second))
|
||||
if len(tg.sends) != 1 || len(dt.sends) != 1 {
|
||||
t.Fatalf("telegram %d desktop %d", len(tg.sends), len(dt.sends))
|
||||
}
|
||||
@@ -320,7 +320,7 @@ func TestTheDesktopIsGentle(t *testing.T) {
|
||||
runFor(h, c, 5*time.Minute)
|
||||
h.Condition(EventRaised, cond("plan.4.stalled", Warning, "plan 4 waits"))
|
||||
// Urgent is not held to the desktop's rhythm.
|
||||
h.Condition(EventRaised, cond("machine.ace.silent", Urgent, "the home server is silent"))
|
||||
h.Condition(EventRaised, cond("machine.node-a.silent", Urgent, "the home server is silent"))
|
||||
h.Flush()
|
||||
if len(dt.sends) != 2 || !strings.HasPrefix(dt.sends[1].Title, "Urgent: ") || len(tg.sends) != 1 {
|
||||
t.Fatalf("urgent: desktop %d telegram %d", len(dt.sends), len(tg.sends))
|
||||
@@ -346,7 +346,7 @@ func TestTheDesktopIsGentle(t *testing.T) {
|
||||
func TestNothingIsSentInTheFirstMinuteButTheUrgentOpenAsOne(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
h.Start()
|
||||
u1 := cond("machine.ace.silent", Urgent, "the home server is silent")
|
||||
u1 := cond("machine.node-a.silent", Urgent, "the home server is silent")
|
||||
u1.Raised = c.now().Add(-3 * time.Hour)
|
||||
u2 := cond("bus.controller.refused", Urgent, "the bus refuses the controller")
|
||||
u2.Raised = c.now().Add(-20 * time.Minute)
|
||||
@@ -365,7 +365,7 @@ func TestNothingIsSentInTheFirstMinuteButTheUrgentOpenAsOne(t *testing.T) {
|
||||
k := cond("plan.43.stalled", Warning, "plan 43 waits")
|
||||
k.At = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
u3 := cond("machine.shanks.silent", Urgent, "the desktop is silent")
|
||||
u3 := cond("machine.node-d.silent", Urgent, "the desktop is silent")
|
||||
u3.At = c.now()
|
||||
h.Condition(EventRaised, u3)
|
||||
runFor(h, c, 45*time.Second)
|
||||
@@ -378,14 +378,14 @@ func TestNothingIsSentInTheFirstMinuteButTheUrgentOpenAsOne(t *testing.T) {
|
||||
t.Fatalf("after the grace: telegram %d desktop %d", len(tg.sends), len(dt.sends))
|
||||
}
|
||||
if d := dt.sends[1]; !strings.Contains(d.Body, "plan 42 stalled") || !strings.Contains(d.Body, "plan 43 stalled") ||
|
||||
!strings.Contains(d.Body, "machine shanks silent") || strings.Contains(d.Body, "plan 41 stalled") {
|
||||
!strings.Contains(d.Body, "machine node-d silent") || strings.Contains(d.Body, "plan 41 stalled") {
|
||||
t.Fatalf("desktop digest: %q", d.Text())
|
||||
}
|
||||
}
|
||||
|
||||
func TestWhatEndedWhileAwayIsEndedQuietly(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.ace.silent", Urgent, "the home server is silent")
|
||||
k := cond("machine.node-a.silent", Urgent, "the home server is silent")
|
||||
k.At = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
if len(tg.sends) != 1 || len(dt.sends) != 1 {
|
||||
@@ -406,7 +406,7 @@ func TestWhatEndedWhileAwayIsEndedQuietly(t *testing.T) {
|
||||
|
||||
func TestARestartSaysNothingAgain(t *testing.T) {
|
||||
h, tg, dt, c, st := newHolder(t)
|
||||
k := cond("machine.ace.silent", Urgent, "the home server is silent")
|
||||
k := cond("machine.node-a.silent", Urgent, "the home server is silent")
|
||||
k.At = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
w := cond("plan.41.stalled", Warning, "plan 41 waits")
|
||||
@@ -426,7 +426,7 @@ func TestARestartSaysNothingAgain(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTheOpenSetIsReadInEveryShape(t *testing.T) {
|
||||
one := `{"key":"machine.ace.silent","kind":"silent","subject":{"scope":"machine","id":"ace"},"severity":"urgent","summary":"s","raised":"2026-10-06T09:00:00Z"}`
|
||||
one := `{"key":"machine.node-a.silent","kind":"silent","subject":{"scope":"machine","id":"node-a"},"severity":"urgent","summary":"s","raised":"2026-10-06T09:00:00Z"}`
|
||||
for _, raw := range []string{
|
||||
`{"conditions":[` + one + `],"open":1}`,
|
||||
`{"answer":{"conditions":[` + one + `]},"ok":true}`,
|
||||
@@ -434,7 +434,7 @@ func TestTheOpenSetIsReadInEveryShape(t *testing.T) {
|
||||
`{"content":[{"type":"text","text":"{\"conditions\":[` + strings.ReplaceAll(one, `"`, `\"`) + `]}"}]}`,
|
||||
} {
|
||||
got, err := DecodeOpen(json.RawMessage(raw))
|
||||
if err != nil || len(got) != 1 || got[0].Key != "machine.ace.silent" || got[0].Severity != Urgent {
|
||||
if err != nil || len(got) != 1 || got[0].Key != "machine.node-a.silent" || got[0].Severity != Urgent {
|
||||
t.Fatalf("%s: %+v %v", raw, got, err)
|
||||
}
|
||||
}
|
||||
@@ -449,7 +449,7 @@ func TestTheOpenSetIsReadInEveryShape(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAnEventSaysItsOwnTime(t *testing.T) {
|
||||
c, err := DecodeCondition(EventCleared, []byte(`{"key":"machine.ace.silent","at":"2026-10-06T08:36:50Z","raised":"2026-10-06T08:32:30Z"}`))
|
||||
c, err := DecodeCondition(EventCleared, []byte(`{"key":"machine.node-a.silent","at":"2026-10-06T08:36:50Z","raised":"2026-10-06T08:32:30Z"}`))
|
||||
if err != nil || !c.When(EventCleared).Equal(time.Date(2026, 10, 6, 8, 36, 50, 0, time.UTC)) {
|
||||
t.Fatalf("%v %v", c.When(EventCleared), err)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func (f *fakeChannel) Send(m Message) (string, error) {
|
||||
f.sends = append(f.sends, m)
|
||||
f.to = append(f.to, m.To)
|
||||
if f.name == "desktop" {
|
||||
return fmt.Sprintf("g14=%d", f.n), nil // as the desktop answers: the machine and the notification
|
||||
return fmt.Sprintf("node-b=%d", f.n), nil // as the desktop answers: the machine and the notification
|
||||
}
|
||||
return fmt.Sprint(f.n), nil
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func newHolder(t *testing.T) (*Holder, *fakeChannel, *fakeChannel, *clock, *memS
|
||||
|
||||
func TestARaisedConditionIsSentOnceByItsKey(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.ace.silent", Urgent, "the home server has not been heard for 15 min")
|
||||
k := cond("machine.node-a.silent", Urgent, "the home server has not been heard for 15 min")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
h.Condition(EventRaised, k) // a redelivery
|
||||
@@ -167,7 +167,7 @@ func TestARaisedConditionIsSentOnceByItsKey(t *testing.T) {
|
||||
t.Fatalf("urgent: telegram %d, desktop %d; want one each", len(tg.sends), len(dt.sends))
|
||||
}
|
||||
keyless(t, tg.sends...)
|
||||
if tg.sends[0].Title != "Urgent: machine ace silent" || !strings.HasPrefix(tg.sends[0].Body, "Needs you: look at it. What it means: ") ||
|
||||
if tg.sends[0].Title != "Urgent: machine node-a silent" || !strings.HasPrefix(tg.sends[0].Body, "Needs you: look at it. What it means: ") ||
|
||||
!strings.Contains(tg.sends[0].Body, "\nSince ") {
|
||||
t.Fatalf("message: %q", tg.sends[0].Text())
|
||||
}
|
||||
@@ -252,7 +252,7 @@ func TestAMessageCarryingAnAddressIsRefusedAndSaidWithItsWordsWithheld(t *testin
|
||||
h, tg, _, c, _ := newHolder(t)
|
||||
var emitted []string
|
||||
h.Emit = func(e string, _ any) error { emitted = append(emitted, e); return nil }
|
||||
h.Condition(EventRaised, cond("provider.keycloak.ace.failing", Urgent, "cannot reach 192.168.1.20:8443 with token=abc"))
|
||||
h.Condition(EventRaised, cond("provider.keycloak.node-a.failing", Urgent, "cannot reach 192.168.1.20:8443 with token=abc"))
|
||||
if len(tg.sends) != 1 {
|
||||
t.Fatalf("sends: %d", len(tg.sends))
|
||||
}
|
||||
@@ -260,7 +260,7 @@ func TestAMessageCarryingAnAddressIsRefusedAndSaidWithItsWordsWithheld(t *testin
|
||||
if strings.Contains(text, "192.168") || strings.Contains(text, "token=") {
|
||||
t.Fatalf("the address left: %q", text)
|
||||
}
|
||||
if !strings.Contains(text, "withheld, because it carried an IPv4 address") || !strings.Contains(text, "provider keycloak ace failing") {
|
||||
if !strings.Contains(text, "withheld, because it carried an IPv4 address") || !strings.Contains(text, "provider keycloak node-a failing") {
|
||||
t.Fatalf("not said as refused, by key: %q", text)
|
||||
}
|
||||
hist := h.History(10)["refusals"].([]RefusalNote)
|
||||
@@ -271,7 +271,7 @@ func TestAMessageCarryingAnAddressIsRefusedAndSaidWithItsWordsWithheld(t *testin
|
||||
t.Fatalf("emitted: %v", emitted)
|
||||
}
|
||||
// Its clearing keeps the words withheld.
|
||||
h.Condition(EventCleared, Condition{Key: "provider.keycloak.ace.failing"})
|
||||
h.Condition(EventCleared, Condition{Key: "provider.keycloak.node-a.failing"})
|
||||
c.pass(ClearSettle)
|
||||
h.Tick()
|
||||
for _, m := range tg.edits {
|
||||
@@ -330,7 +330,7 @@ func TestStillOpenPastItsBoundItIsSaidOnceMore(t *testing.T) {
|
||||
|
||||
func TestClearedEditsTheFirstMessageAndReopenedWithinTenMinutesIsNotNew(t *testing.T) {
|
||||
h, tg, dt, c, st := newHolder(t)
|
||||
k := cond("machine.ace.silent", Urgent, "the home server is silent")
|
||||
k := cond("machine.node-a.silent", Urgent, "the home server is silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
c.pass(14 * time.Minute)
|
||||
@@ -340,7 +340,7 @@ func TestClearedEditsTheFirstMessageAndReopenedWithinTenMinutesIsNotNew(t *testi
|
||||
if len(tg.sends) != 1 || len(tg.edits) != 1 || len(dt.edits) != 1 {
|
||||
t.Fatalf("telegram sends %d edits %d, desktop edits %d", len(tg.sends), len(tg.edits), len(dt.edits))
|
||||
}
|
||||
if m := tg.edits["1"]; m.Title != "Resolved: machine ace silent, after 14 min" || m.Body != "" {
|
||||
if m := tg.edits["1"]; m.Title != "Resolved: machine node-a silent, after 14 min" || m.Body != "" {
|
||||
t.Fatalf("edit: %q", m.Title)
|
||||
}
|
||||
if len(h.Open()) != 0 {
|
||||
@@ -369,7 +369,7 @@ func TestClearedEditsTheFirstMessageAndReopenedWithinTenMinutesIsNotNew(t *testi
|
||||
|
||||
func TestASilencedConditionSendsNothing(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.ace.silent", Urgent, "silent")
|
||||
k := cond("machine.node-a.silent", Urgent, "silent")
|
||||
k.SilencedTill = c.now().Add(2 * time.Hour)
|
||||
h.Condition(EventRaised, k)
|
||||
c.pass(90 * time.Minute)
|
||||
@@ -379,7 +379,7 @@ func TestASilencedConditionSendsNothing(t *testing.T) {
|
||||
t.Fatalf("a silenced condition said something")
|
||||
}
|
||||
// Silenced after it was sent: no reminder.
|
||||
k2 := cond("machine.shanks.silent", Urgent, "silent")
|
||||
k2 := cond("machine.node-d.silent", Urgent, "silent")
|
||||
k2.Raised = c.now()
|
||||
h.Condition(EventRaised, k2)
|
||||
k2.SilencedTill = c.now().Add(3 * time.Hour)
|
||||
@@ -393,7 +393,7 @@ func TestASilencedConditionSendsNothing(t *testing.T) {
|
||||
|
||||
func TestEscalationIsSaidOnce(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.novox.silent", Warning, "the anchor is silent")
|
||||
k := cond("machine.node-c.silent", Warning, "the anchor is silent")
|
||||
h.Condition(EventRaised, k)
|
||||
settle(h, c)
|
||||
k.Severity = Urgent
|
||||
@@ -401,12 +401,12 @@ func TestEscalationIsSaidOnce(t *testing.T) {
|
||||
h.Condition(EventChanged, k)
|
||||
settle(h, c)
|
||||
// The desktop's warning is replaced by the urgent message (issue 373); Telegram, which had none, is sent one.
|
||||
if len(dt.sends) != 1 || len(dt.replaced) != 1 || dt.replaced[0].id != "g14=1" ||
|
||||
if len(dt.sends) != 1 || len(dt.replaced) != 1 || dt.replaced[0].id != "node-b=1" ||
|
||||
!strings.HasPrefix(dt.replaced[0].m.Title, "Now urgent: ") || len(tg.sends) != 1 || !strings.HasPrefix(tg.sends[0].Title, "Now urgent: ") {
|
||||
t.Fatalf("desktop %d sends %d replaced, telegram %d", len(dt.sends), len(dt.replaced), len(tg.sends))
|
||||
}
|
||||
// Escalated while the warning still waited its window: one message, the urgent one.
|
||||
k2 := cond("machine.ace.silent", Warning, "the home server is silent")
|
||||
k2 := cond("machine.node-a.silent", Warning, "the home server is silent")
|
||||
h.Condition(EventRaised, k2)
|
||||
k2.Severity = Urgent
|
||||
h.Condition(EventChanged, k2)
|
||||
@@ -434,7 +434,7 @@ func TestAChannelThatCannotSendSaysSoAndIsTriedAgain(t *testing.T) {
|
||||
h, tg, _, c, _ := newHolder(t)
|
||||
h.Desk = nil
|
||||
tg.fail = errors.New("telegram sendMessage: cannot connect (dial)")
|
||||
h.Condition(EventRaised, cond("machine.ace.silent", Urgent, "silent"))
|
||||
h.Condition(EventRaised, cond("machine.node-a.silent", Urgent, "silent"))
|
||||
st := h.Status("listening")
|
||||
if !strings.HasPrefix(st.Verdict, "CANNOT SEND") || len(st.Unsent) != 1 || st.Channels[0].LastError == "" {
|
||||
t.Fatalf("status: %+v", st)
|
||||
@@ -464,7 +464,7 @@ func TestNothingConfiguredIsSaidInTheStatus(t *testing.T) {
|
||||
func TestARestartForgetsNothing(t *testing.T) {
|
||||
h, tg, _, c, st := newHolder(t)
|
||||
h.Desk = nil
|
||||
k := cond("machine.ace.silent", Urgent, "silent")
|
||||
k := cond("machine.node-a.silent", Urgent, "silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
again := &Holder{Away: tg, Store: st, Now: c.now, Logf: t.Logf}
|
||||
@@ -507,12 +507,12 @@ func TestAnUnreadableEventIsToldOnceAnHour(t *testing.T) {
|
||||
func TestNotifyIsKeptApartFromConditions(t *testing.T) {
|
||||
h, tg, _, c, _ := newHolder(t)
|
||||
h.Desk = nil
|
||||
out, err := h.Notify("backup.ace.failed", Warning, "last night's backup of the home server failed", "backup", false)
|
||||
out, err := h.Notify("backup.node-a.failed", Warning, "last night's backup of the home server failed", "backup", false)
|
||||
if err != nil || out["held"] != true {
|
||||
t.Fatalf("%v %v", out, err)
|
||||
}
|
||||
settle(h, c)
|
||||
if err != nil || out["key"] != "notify.backup.ace.failed" || len(tg.sends) != 1 {
|
||||
if err != nil || out["key"] != "notify.backup.node-a.failed" || len(tg.sends) != 1 {
|
||||
t.Fatalf("%v %v %d", out, err, len(tg.sends))
|
||||
}
|
||||
if _, err := h.Notify("x", "", "s", "", false); err == nil {
|
||||
@@ -529,7 +529,7 @@ func TestNotifyIsKeptApartFromConditions(t *testing.T) {
|
||||
func TestATellReachesEveryChannelOnceAndOffersOnlyDetails(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
c.pass(14 * time.Hour) // well past midnight: it is not held for being "night" — there is no such hold
|
||||
out, err := h.Tell("new mail arrived for ace", []string{"One message from the inbox you watch."}, "mail")
|
||||
out, err := h.Tell("new mail arrived for node-a", []string{"One message from the inbox you watch."}, "mail")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ func TestTheToolsAgreeWithTheManifest(t *testing.T) {
|
||||
if !reflect.DeepEqual(verbs, m.Claims[0].Serves) {
|
||||
t.Fatalf("verbs %v, claim %v", verbs, m.Claims[0].Serves)
|
||||
}
|
||||
for _, never := range []string{"/home/", "jochen", "g14", "shanks", "novox", "zurag", "telegram"} {
|
||||
for _, never := range []string{"/home/", "jochen", "node-b", "node-d", "node-c", "zurag", "telegram"} {
|
||||
if strings.Contains(strings.ToLower(raw), never) {
|
||||
t.Errorf("module.json names %q", never)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func saidOn(chs ...*fakeChannel) int {
|
||||
// "again, 22nd time", no "Resolved" — and once it stays cleared, its clearing is said once.
|
||||
func TestAFlappingConditionIsSaidOnceAndItsClearingOnceWhenItStops(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.shanks.units", Warning, "2 failed services on shanks")
|
||||
k := cond("machine.node-d.units", Warning, "2 failed services on node-d")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
settle(h, c)
|
||||
@@ -58,7 +58,7 @@ func TestAFlappingConditionIsSaidOnceAndItsClearingOnceWhenItStops(t *testing.T)
|
||||
t.Fatalf("open: %+v", open)
|
||||
}
|
||||
// A genuinely new problem meanwhile is said.
|
||||
n := cond("machine.ace.disk-full", Urgent, "the home server's disk is full")
|
||||
n := cond("machine.node-a.disk-full", Urgent, "the home server's disk is full")
|
||||
n.Raised = c.now()
|
||||
h.Condition(EventRaised, n)
|
||||
if len(tg.sends) != 1 || len(dt.sends) != 2 {
|
||||
@@ -67,7 +67,7 @@ func TestAFlappingConditionIsSaidOnceAndItsClearingOnceWhenItStops(t *testing.T)
|
||||
// The unit stays mended: its clearing is said once, in place of its message.
|
||||
h.Condition(EventCleared, Condition{Key: k.Key, At: c.now()})
|
||||
runFor(h, c, 30*time.Minute)
|
||||
if len(dt.edits) != 1 || !strings.HasPrefix(dt.edits["g14=1"].Title, "Resolved: ") || len(dt.sends) != 2 {
|
||||
if len(dt.edits) != 1 || !strings.HasPrefix(dt.edits["node-b=1"].Title, "Resolved: ") || len(dt.sends) != 2 {
|
||||
t.Fatalf("its clearing: edits %+v, sends %d", dt.edits, len(dt.sends))
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func TestAFlappingConditionIsSaidOnceAndItsClearingOnceWhenItStops(t *testing.T)
|
||||
// A clearing a few seconds long is never said, and the message continues; an urgent problem rang once.
|
||||
func TestAnUrgentBlipRingsOnceAndItsBlipsSayNothing(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.ace.silent", Urgent, "the home server is silent")
|
||||
k := cond("machine.node-a.silent", Urgent, "the home server is silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
for i := 0; i < 5; i++ {
|
||||
@@ -97,7 +97,7 @@ func TestAnUrgentBlipRingsOnceAndItsBlipsSayNothing(t *testing.T) {
|
||||
// said, not swallowed as the same message.
|
||||
func TestAConditionClearedBeforeItWasSaidAndBackIsSaid(t *testing.T) {
|
||||
h, _, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.shanks.units", Warning, "2 failed services on shanks")
|
||||
k := cond("machine.node-d.units", Warning, "2 failed services on node-d")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
c.pass(10 * time.Second)
|
||||
@@ -106,7 +106,7 @@ func TestAConditionClearedBeforeItWasSaidAndBackIsSaid(t *testing.T) {
|
||||
k.At = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, 2*time.Minute)
|
||||
if len(dt.sends) != 1 || !strings.Contains(dt.sends[0].Title, "machine shanks units") {
|
||||
if len(dt.sends) != 1 || !strings.Contains(dt.sends[0].Title, "machine node-d units") {
|
||||
t.Fatalf("desktop %+v", dt.sends)
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ func TestAnAsksExpiryIsSaidWithItsDay(t *testing.T) {
|
||||
func TestAnEndedQuestionLeavesNoMessageOfferingItsAnswers(t *testing.T) {
|
||||
h, tg, dt, c, store, _ := newRouter(t)
|
||||
link(h, store, c, "42", c.now().Add(-2*time.Hour))
|
||||
k := cond("machine.novox.secret-given", Urgent, "a secret was given at the terminal")
|
||||
k := cond("machine.node-c.secret-given", Urgent, "a secret was given at the terminal")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
settle(h, c)
|
||||
@@ -191,7 +191,7 @@ func TestAnEndedQuestionLeavesNoMessageOfferingItsAnswers(t *testing.T) {
|
||||
if len(ch.sends) != 1 {
|
||||
t.Fatalf("%s: %d messages for one problem", ch.name, len(ch.sends))
|
||||
}
|
||||
last := ch.edits[map[string]string{"telegram": "1", "desktop": "g14=1"}[ch.name]]
|
||||
last := ch.edits[map[string]string{"telegram": "1", "desktop": "node-b=1"}[ch.name]]
|
||||
if len(ch.replaced) == 0 || len(last.Actions) > 1 || !strings.Contains(last.Body, "No longer answerable") {
|
||||
t.Fatalf("%s: replaced %d, the message now: %q %v", ch.name, len(ch.replaced), last.Text(), labelsOf(last))
|
||||
}
|
||||
@@ -202,7 +202,7 @@ func TestAnEndedQuestionLeavesNoMessageOfferingItsAnswers(t *testing.T) {
|
||||
// warning back as urgent rings, and a reminder waiting to go out when it cleared still goes out.
|
||||
func TestABlipSwallowsNeitherAnEscalationNorAWaitingReminder(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.shanks.units", Warning, "2 failed services on shanks")
|
||||
k := cond("machine.node-d.units", Warning, "2 failed services on node-d")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
settle(h, c)
|
||||
@@ -274,7 +274,7 @@ func TestAReminderInABurstReplacesItsMessageAndIsNoDigestLine(t *testing.T) {
|
||||
func TestAClearingTheChannelCouldNotTakeIsSaidLater(t *testing.T) {
|
||||
h, tg, _, c, _ := newHolder(t)
|
||||
h.Desk = nil
|
||||
k := cond("machine.ace.silent", Urgent, "the home server is silent")
|
||||
k := cond("machine.node-a.silent", Urgent, "the home server is silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
tg.fail = errorf("telegram is away")
|
||||
@@ -297,7 +297,7 @@ func TestAClearingTheChannelCouldNotTakeIsSaidLater(t *testing.T) {
|
||||
func TestASilenceIsSaidOnTheShownMessageAndTheMessageIsOpenAgainWhenItEnds(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
h.Zone = func() *time.Location { return time.UTC }
|
||||
k := cond("machine.shanks.units", Warning, "2 failed services on shanks")
|
||||
k := cond("machine.node-d.units", Warning, "2 failed services on node-d")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
settle(h, c)
|
||||
@@ -307,8 +307,8 @@ func TestASilenceIsSaidOnTheShownMessageAndTheMessageIsOpenAgainWhenItEnds(t *te
|
||||
c.pass(time.Hour)
|
||||
k.SilencedTill, k.SilencedWhy = c.now().Add(7*24*time.Hour), "the mounts are gone for good"
|
||||
h.Condition(EventChanged, k)
|
||||
m, edited := dt.edits["g14=1"]
|
||||
if !edited || m.Title != "Silenced until Tue 13 Oct 13:00: machine shanks units" || !m.Quiet || m.Urgent ||
|
||||
m, edited := dt.edits["node-b=1"]
|
||||
if !edited || m.Title != "Silenced until Tue 13 Oct 13:00: machine node-d units" || !m.Quiet || m.Urgent ||
|
||||
len(m.Actions) != 0 || !strings.Contains(m.Body, "Because: the mounts are gone for good.") {
|
||||
t.Fatalf("silenced, and the desk's message says %q %q quiet=%v urgent=%v actions=%v", m.Title, m.Body, m.Quiet, m.Urgent, m.Actions)
|
||||
}
|
||||
@@ -324,7 +324,7 @@ func TestASilenceIsSaidOnTheShownMessageAndTheMessageIsOpenAgainWhenItEnds(t *te
|
||||
// The silence runs out and the condition is still open: its message is open again, on the same notification.
|
||||
c.pass(7 * 24 * time.Hour)
|
||||
h.Tick()
|
||||
if m := dt.edits["g14=1"]; m.Title != "machine shanks units" || m.Quiet || len(m.Actions) == 0 {
|
||||
if m := dt.edits["node-b=1"]; m.Title != "machine node-d units" || m.Quiet || len(m.Actions) == 0 {
|
||||
t.Fatalf("the silence ended, and the message says %q quiet=%v actions=%v", m.Title, m.Quiet, m.Actions)
|
||||
}
|
||||
if len(dt.sends) != 1 {
|
||||
@@ -336,18 +336,18 @@ func TestASilenceIsSaidOnTheShownMessageAndTheMessageIsOpenAgainWhenItEnds(t *te
|
||||
// desk's popup, which timed out, is not brought back.
|
||||
func TestAConditionResolvedWhileSilencedSaysSoOnlyWhereAnEditNotifiesNobody(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.ace.silent", Urgent, "the home server is silent")
|
||||
k := cond("machine.node-a.silent", Urgent, "the home server is silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
k.SilencedTill, k.SilencedWhy = c.now().Add(24*time.Hour), "ace is moving house"
|
||||
k.SilencedTill, k.SilencedWhy = c.now().Add(24*time.Hour), "node-a is moving house"
|
||||
h.Condition(EventChanged, k)
|
||||
if !strings.HasPrefix(tg.edits["1"].Title, "Silenced until ") || !strings.HasPrefix(dt.edits["g14=1"].Title, "Silenced until ") {
|
||||
t.Fatalf("telegram %q desk %q", tg.edits["1"].Title, dt.edits["g14=1"].Title)
|
||||
if !strings.HasPrefix(tg.edits["1"].Title, "Silenced until ") || !strings.HasPrefix(dt.edits["node-b=1"].Title, "Silenced until ") {
|
||||
t.Fatalf("telegram %q desk %q", tg.edits["1"].Title, dt.edits["node-b=1"].Title)
|
||||
}
|
||||
h.Condition(EventCleared, Condition{Key: k.Key, At: c.now()})
|
||||
runFor(h, c, ClearSettle+time.Minute)
|
||||
if !strings.HasPrefix(tg.edits["1"].Title, "Resolved: ") || !strings.HasPrefix(dt.edits["g14=1"].Title, "Silenced until ") {
|
||||
t.Fatalf("resolved while silenced: telegram %q desk %q", tg.edits["1"].Title, dt.edits["g14=1"].Title)
|
||||
if !strings.HasPrefix(tg.edits["1"].Title, "Resolved: ") || !strings.HasPrefix(dt.edits["node-b=1"].Title, "Silenced until ") {
|
||||
t.Fatalf("resolved while silenced: telegram %q desk %q", tg.edits["1"].Title, dt.edits["node-b=1"].Title)
|
||||
}
|
||||
if len(tg.sends)+len(dt.sends) != 2 || len(tg.replaced)+len(dt.replaced) != 0 {
|
||||
t.Fatalf("a new message was made: sends %d %d", len(tg.sends), len(dt.sends))
|
||||
@@ -358,7 +358,7 @@ func TestAConditionResolvedWhileSilencedSaysSoOnlyWhereAnEditNotifiesNobody(t *t
|
||||
// same way, and the reading that says it ended makes the message open again.
|
||||
func TestASilenceReadFromTheOpenSetIsSaidOnTheShownMessage(t *testing.T) {
|
||||
h, _, dt, c, _ := newHolder(t)
|
||||
k := cond("machine.shanks.units", Warning, "2 failed services on shanks")
|
||||
k := cond("machine.node-d.units", Warning, "2 failed services on node-d")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
settle(h, c)
|
||||
@@ -366,12 +366,12 @@ func TestASilenceReadFromTheOpenSetIsSaidOnTheShownMessage(t *testing.T) {
|
||||
s := k
|
||||
s.SilencedTill, s.SilencedWhy = c.now().Add(7*24*time.Hour), "the mounts are gone for good"
|
||||
h.Sync([]Condition{s}, c.now())
|
||||
if m := dt.edits["g14=1"]; !strings.HasPrefix(m.Title, "Silenced until ") || !m.Quiet || len(m.Actions) != 0 {
|
||||
if m := dt.edits["node-b=1"]; !strings.HasPrefix(m.Title, "Silenced until ") || !m.Quiet || len(m.Actions) != 0 {
|
||||
t.Fatalf("read silenced, and the desk's message says %q quiet=%v actions=%v", m.Title, m.Quiet, m.Actions)
|
||||
}
|
||||
c.pass(10 * time.Minute)
|
||||
h.Sync([]Condition{k}, c.now()) // the silence was lifted: the reading carries none
|
||||
if m := dt.edits["g14=1"]; m.Title != "machine shanks units" || len(dt.sends) != 1 {
|
||||
if m := dt.edits["node-b=1"]; m.Title != "machine node-d units" || len(dt.sends) != 1 {
|
||||
t.Fatalf("read unsilenced, and the desk's message says %q (sends %d)", m.Title, len(dt.sends))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ func TestAConditionsMessageIsReadWithoutBeingSent(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAPreviewSaysTheWordsTheChannelWasGiven(t *testing.T) {
|
||||
issues := []TrackedIssue{{Number: 386, Status: "fixing", Worker: "fix-386@g14", Since: at(21, 10)}}
|
||||
issues := []TrackedIssue{{Number: 386, Status: "fixing", Worker: "fix-386@node-b", Since: at(21, 10)}}
|
||||
h, tg, dt, c, st, k := previewHolder(t, issues)
|
||||
sent := dt.sends[len(dt.sends)-1] // the message the desk was actually handed
|
||||
was := mark(t, h, tg, dt, st, k.Key)
|
||||
@@ -126,7 +126,7 @@ func TestAPreviewSaysTheWordsTheChannelWasGiven(t *testing.T) {
|
||||
if out["title"] != sent.Title || out["body"] != sent.Body {
|
||||
t.Fatalf("preview %q / %q; the channel was given %q / %q", out["title"], out["body"], sent.Title, sent.Body)
|
||||
}
|
||||
if !strings.Contains(sent.Body, "Tracked as issue 386: fix-386 on g14 is fixing it since ") {
|
||||
if !strings.Contains(sent.Body, "Tracked as issue 386: fix-386 on node-b is fixing it since ") {
|
||||
t.Fatalf("the message this is compared against carries no tracking line: %q", sent.Body)
|
||||
}
|
||||
was.check(t, h, tg, dt, st, c, k.Key)
|
||||
@@ -187,11 +187,11 @@ func TestASilenceIsPreviewedOnlyWhileThereIsOne(t *testing.T) {
|
||||
func TestAPreviewOfWhatThisRouterDoesNotHoldIsRefusedByName(t *testing.T) {
|
||||
h, _, _, _, _, k := previewHolder(t, nil)
|
||||
|
||||
_, err := h.Preview("machine.ace.silent", "")
|
||||
_, err := h.Preview("machine.node-a.silent", "")
|
||||
if err == nil {
|
||||
t.Fatal("a condition this router does not hold was previewed")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "machine.ace.silent") || !strings.Contains(err.Error(), k.Key) {
|
||||
if !strings.Contains(err.Error(), "machine.node-a.silent") || !strings.Contains(err.Error(), k.Key) {
|
||||
t.Errorf("the refusal says neither what was asked nor what is held: %v", err)
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ func TestAPreviewSaysTheReducedWordsAndWhyWhenItsOwnMayNotLeave(t *testing.T) {
|
||||
stated := 0
|
||||
h.Emit = func(string, any) error { stated++; return nil }
|
||||
// A warning that needs nothing is held, not sent, so this refusal is one no send has met yet.
|
||||
k := cond("machine.ace.unreadable", Warning, "a file on it could not be read")
|
||||
k := cond("machine.node-a.unreadable", Warning, "a file on it could not be read")
|
||||
k.Explanation = "Nothing for you to do. A file at /home/someone/secrets.txt could not be read."
|
||||
k.Needs = ""
|
||||
k.Raised = c.now()
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestAReplacedAsksMessageEndsWithIt(t *testing.T) {
|
||||
t.Fatalf("open ask records: %v; want only the newer ask's", got)
|
||||
}
|
||||
for _, ch := range []*fakeChannel{tg, dt} {
|
||||
id := map[string]string{"telegram": "1", "desktop": "g14=1"}[ch.name]
|
||||
id := map[string]string{"telegram": "1", "desktop": "node-b=1"}[ch.name]
|
||||
m, edited := ch.edits[id]
|
||||
for _, r := range ch.replaced {
|
||||
if r.id == id {
|
||||
@@ -95,7 +95,7 @@ func TestAnAsksMessageLeftOpenAfterItsAskEndedIsEndedOnTheNextTick(t *testing.T)
|
||||
// restarts never says a held message of something that already ended.
|
||||
func TestAClearedRecordOwesNothing(t *testing.T) {
|
||||
h, _, _, c, st := newHolder(t)
|
||||
k := cond("machine.shanks.units", Warning, "2 failed services on shanks")
|
||||
k := cond("machine.node-d.units", Warning, "2 failed services on node-d")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
h.mu.Lock()
|
||||
|
||||
@@ -20,7 +20,7 @@ func TestLostAnswersGetOnlyWhatIsOpenAndUnansweredSaidAgain(t *testing.T) {
|
||||
h.Start()
|
||||
c.pass(2 * time.Minute)
|
||||
// Open, with a question the desk carries.
|
||||
open := cond("machine.shanks.units", Warning, "2 failed services on shanks")
|
||||
open := cond("machine.node-d.units", Warning, "2 failed services on node-d")
|
||||
open.Raised = c.now()
|
||||
h.Condition(EventRaised, open)
|
||||
settle(h, c)
|
||||
@@ -30,12 +30,12 @@ func TestLostAnswersGetOnlyWhatIsOpenAndUnansweredSaidAgain(t *testing.T) {
|
||||
ask := ackAsk(c, "silence-units")
|
||||
ask.About = open.Key
|
||||
submit(t, h, ConditionOwner, ask)
|
||||
if e := dt.edits["g14=1"]; ticketFor(e, "Silence for a week") == "" {
|
||||
if e := dt.edits["node-b=1"]; ticketFor(e, "Silence for a week") == "" {
|
||||
t.Fatalf("the question was not put on the open message: %+v", e)
|
||||
}
|
||||
// Silenced, with a question of its own, and its message says it is silenced.
|
||||
runFor(h, c, 20*time.Minute)
|
||||
sil := cond("machine.ace.agent-home", Warning, "Agent-home shrank")
|
||||
sil := cond("machine.node-a.agent-home", Warning, "Agent-home shrank")
|
||||
sil.Raised = c.now()
|
||||
h.Condition(EventRaised, sil)
|
||||
settle(h, c)
|
||||
@@ -46,12 +46,12 @@ func TestLostAnswersGetOnlyWhatIsOpenAndUnansweredSaidAgain(t *testing.T) {
|
||||
silAsk := ackAsk(c, "silence-home")
|
||||
silAsk.About = sil.Key
|
||||
submit(t, h, ConditionOwner, silAsk)
|
||||
if e := dt.edits["g14=2"]; ticketFor(e, "Silence for a week") == "" {
|
||||
if e := dt.edits["node-b=2"]; ticketFor(e, "Silence for a week") == "" {
|
||||
t.Fatalf("the question was not put on the message to be silenced: %+v", e)
|
||||
}
|
||||
sil.SilencedTill, sil.SilencedWhy, sil.At = c.now().Add(7*24*time.Hour), "known", c.now()
|
||||
h.Condition(EventChanged, sil)
|
||||
if e := dt.edits["g14=2"]; !strings.HasPrefix(e.Title, "Silenced until") {
|
||||
if e := dt.edits["node-b=2"]; !strings.HasPrefix(e.Title, "Silenced until") {
|
||||
t.Fatalf("the silence was not said: %+v", e)
|
||||
}
|
||||
// Open, told, and asking nothing: not unanswered, so not said again.
|
||||
@@ -74,10 +74,10 @@ func TestLostAnswersGetOnlyWhatIsOpenAndUnansweredSaidAgain(t *testing.T) {
|
||||
}
|
||||
h.Condition(EventCleared, Condition{Key: res.Key, At: c.now()})
|
||||
runFor(h, c, 3*time.Minute)
|
||||
if e := dt.edits["g14=4"]; !strings.HasPrefix(e.Title, "Resolved: ") {
|
||||
if e := dt.edits["node-b=4"]; !strings.HasPrefix(e.Title, "Resolved: ") {
|
||||
t.Fatalf("the clearing was not said: %+v", e)
|
||||
}
|
||||
delete(dt.edits, "g14=2") // so an edit said again would be seen as such
|
||||
delete(dt.edits, "node-b=2") // so an edit said again would be seen as such
|
||||
sends, edits, replaced, tgSaid := len(dt.sends), len(dt.edits), len(dt.replaced), saidOn(tg)
|
||||
// The desk's notifier started again: its standing says when the answers were lost.
|
||||
c.pass(time.Minute)
|
||||
@@ -87,20 +87,20 @@ func TestLostAnswersGetOnlyWhatIsOpenAndUnansweredSaidAgain(t *testing.T) {
|
||||
if len(dt.sends) != sends {
|
||||
t.Fatalf("a new message was sent instead of one under its handle: %+v", dt.sends[sends:])
|
||||
}
|
||||
if len(dt.replaced) != replaced+1 || dt.replaced[replaced].id != "g14=1" {
|
||||
if len(dt.replaced) != replaced+1 || dt.replaced[replaced].id != "node-b=1" {
|
||||
t.Fatalf("the open question was not said again under its handle, once and alone: %+v", dt.replaced[replaced:])
|
||||
}
|
||||
again := dt.replaced[replaced].m
|
||||
if ticketFor(again, "Silence for a week") == "" || !strings.Contains(again.Title, headlineOf(open.Key)) {
|
||||
t.Fatalf("said again without its answer or its words: %+v", again)
|
||||
}
|
||||
if e, said := dt.edits["g14=2"]; said {
|
||||
if e, said := dt.edits["node-b=2"]; said {
|
||||
t.Fatalf("the silenced one was said again for the restart: %+v", e)
|
||||
}
|
||||
if len(dt.edits) != edits {
|
||||
t.Fatalf("an edit reached the desk for the restart: %+v", dt.edits)
|
||||
}
|
||||
if e := dt.edits["g14=4"]; !strings.HasPrefix(e.Title, "Resolved: ") {
|
||||
if e := dt.edits["node-b=4"]; !strings.HasPrefix(e.Title, "Resolved: ") {
|
||||
t.Fatalf("the resolved one was changed: %+v", e)
|
||||
}
|
||||
if saidOn(tg) != tgSaid {
|
||||
@@ -115,14 +115,14 @@ func TestLostAnswersGetOnlyWhatIsOpenAndUnansweredSaidAgain(t *testing.T) {
|
||||
}
|
||||
// Its ticket is one-time still: one warrant, however often it is tapped, and refused from another machine.
|
||||
tk := ticketFor(again, "Silence for a week")
|
||||
ch := choiceOf(tk, "g14", c.now())
|
||||
ch := choiceOf(tk, "node-b", c.now())
|
||||
ch.Sender.Authenticated = false
|
||||
if got, err := h.Chosen("desktop", ch); got != "chosen" || err != nil {
|
||||
t.Fatalf("the answer on the message said again: %s, %v", got, err)
|
||||
}
|
||||
ch.ID = "c-second"
|
||||
_, _ = h.Chosen("desktop", ch) // the same tap again: said as recorded (issue 372), nothing more done
|
||||
other := choiceOf(tk, "shanks", c.now())
|
||||
other := choiceOf(tk, "node-d", c.now())
|
||||
other.Sender.Authenticated = false
|
||||
if got, _ := h.Chosen("desktop", other); got != "refused" {
|
||||
t.Fatalf("the ticket taken from another machine after it was used: %s", got)
|
||||
@@ -146,7 +146,7 @@ func TestLostAnswersAreJudgedPerMessageAndWaitForTheDesk(t *testing.T) {
|
||||
h, tg, dt, c, _, _ := newRouter(t)
|
||||
h.Start()
|
||||
c.pass(2 * time.Minute)
|
||||
open := cond("machine.shanks.units", Warning, "2 failed services on shanks")
|
||||
open := cond("machine.node-d.units", Warning, "2 failed services on node-d")
|
||||
open.Raised = c.now()
|
||||
h.Condition(EventRaised, open)
|
||||
settle(h, c)
|
||||
|
||||
@@ -297,7 +297,7 @@ func TestAnAccountInItsFirstHourIsUnlinkedFromTheDesk(t *testing.T) {
|
||||
if labelsOf(asked) != "Unlink it" || !strings.Contains(asked.Body, "number 666") {
|
||||
t.Fatalf("the desk was not asked: %+v", asked)
|
||||
}
|
||||
ch := choiceOf(ticketFor(asked, "Unlink it"), "g14", c.now())
|
||||
ch := choiceOf(ticketFor(asked, "Unlink it"), "node-b", c.now())
|
||||
ch.Sender.Authenticated = false
|
||||
if out, err := h.Chosen("desktop", ch); err != nil || out != "chosen" {
|
||||
t.Fatalf("%s %v", out, err)
|
||||
@@ -409,7 +409,7 @@ func TestAnUnlinkFromTheDeskInTheFirstHourBarsNothing(t *testing.T) {
|
||||
link(h, store, c, "42", c.now().Add(-10*time.Minute)) // the operator's own, linked just now
|
||||
h.Link("telegram", asks.LinkAsked{ID: "l1", At: c.now(), Sender: asks.Sender{Identity: "666", Display: "X", Authenticated: true}})
|
||||
asked := dt.sends[len(dt.sends)-1]
|
||||
ch := choiceOf(ticketFor(asked, "Unlink it"), "g14", c.now()) // a click nobody can prove was the operator's
|
||||
ch := choiceOf(ticketFor(asked, "Unlink it"), "node-b", c.now()) // a click nobody can prove was the operator's
|
||||
ch.Sender.Authenticated = false
|
||||
if out, err := h.Chosen("desktop", ch); err != nil || out != "chosen" {
|
||||
t.Fatalf("%s %v", out, err)
|
||||
|
||||
+446
-446
File diff suppressed because it is too large
Load Diff
@@ -44,15 +44,15 @@ func TestAConditionsMessageSaysWhereTheIssueThatTracksItStands(t *testing.T) {
|
||||
"Whether an issue tracks this could not be checked.", "Nothing for you to do."},
|
||||
{"nobody works on it", []TrackedIssue{{Number: 352, Status: "located"}}, true,
|
||||
"Tracked as issue 352: nobody is working on it.", "A person repaired"},
|
||||
{"an agent is fixing it", []TrackedIssue{{Number: 386, Status: "fixing", Worker: "fix-386@g14", Since: at(21, 10)}}, true,
|
||||
"Tracked as issue 386: fix-386 on g14 is fixing it since 21:10.", "Nothing for you to do."},
|
||||
{"an agent looks for its cause", []TrackedIssue{{Number: 386, Status: "diagnosing", Worker: "jochen@shanks", Since: at(18, 5)}}, true,
|
||||
"Tracked as issue 386: jochen on shanks is looking for its cause since 18:05.", "Nothing for you to do."},
|
||||
{"its worker went quiet", []TrackedIssue{{Number: 386, Status: "fixing", Worker: "fix-386@g14", Since: at(9, 0), Active: at(9, 30), Stale: true}}, true,
|
||||
{"an agent is fixing it", []TrackedIssue{{Number: 386, Status: "fixing", Worker: "fix-386@node-b", Since: at(21, 10)}}, true,
|
||||
"Tracked as issue 386: fix-386 on node-b is fixing it since 21:10.", "Nothing for you to do."},
|
||||
{"an agent looks for its cause", []TrackedIssue{{Number: 386, Status: "diagnosing", Worker: "jochen@node-d", Since: at(18, 5)}}, true,
|
||||
"Tracked as issue 386: jochen on node-d is looking for its cause since 18:05.", "Nothing for you to do."},
|
||||
{"its worker went quiet", []TrackedIssue{{Number: 386, Status: "fixing", Worker: "fix-386@node-b", Since: at(9, 0), Active: at(9, 30), Stale: true}}, true,
|
||||
"Tracked as issue 386: nobody has worked on it since 09:30.", "A person repaired"},
|
||||
{"a fix waits to be merged", []TrackedIssue{{Number: 386, Status: "located", Fix: "not-merged"}}, true,
|
||||
"Tracked as issue 386: a fix is written and waits to be merged.", "Nothing for you to do."},
|
||||
{"its fix is on its way", []TrackedIssue{{Number: 386, Status: "fixing", Worker: "fix-386@g14", Since: at(9, 0), Fix: "merged"}}, true,
|
||||
{"its fix is on its way", []TrackedIssue{{Number: 386, Status: "fixing", Worker: "fix-386@node-b", Since: at(9, 0), Fix: "merged"}}, true,
|
||||
"Tracked as issue 386: its fix is merged and on its way.", "Nothing for you to do."},
|
||||
{"the delivery was not heard yet", []TrackedIssue{{Number: 386, Status: "fixing", Fix: "unheard"}}, true,
|
||||
"Tracked as issue 386: a fix is named, and nothing is heard yet of its delivery.", "Nothing for you to do."},
|
||||
@@ -69,23 +69,23 @@ func TestAConditionsMessageSaysWhereTheIssueThatTracksItStands(t *testing.T) {
|
||||
{"one not fixed after one open", []TrackedIssue{{Number: 100, Status: "wontfix"}, {Number: 200, Status: "open"}}, true,
|
||||
"Tracked as issue 200: nobody is working on it. Also as issue 100: it will not be fixed.", "A person repaired"},
|
||||
{"its worker went quiet on one that waits for a decision", []TrackedIssue{{Number: 400, Status: "fixing", Needs: "decision",
|
||||
Worker: "fix-400@g14", Since: at(9, 0), Active: at(9, 30), Stale: true}}, true,
|
||||
Worker: "fix-400@node-b", Since: at(9, 0), Active: at(9, 30), Stale: true}}, true,
|
||||
"Tracked as issue 400: nobody has worked on it since 09:30.", "A person repaired"},
|
||||
{"it waits for the operator", []TrackedIssue{{Number: 336, Status: "open", Needs: "operator"}}, true,
|
||||
"Tracked as issue 336: it waits for your answer.", "Needs you: answer issue 336. A person repaired"},
|
||||
{"it waits for a decision", []TrackedIssue{{Number: 400, Status: "open", Needs: "decision"}}, true,
|
||||
"Tracked as issue 400: nobody is working on it; it waits for a decision first.", "A person repaired"},
|
||||
{"two issues, one worked on", []TrackedIssue{
|
||||
{Number: 386, Status: "fixing", Worker: "fix-386@g14", Since: at(21, 10)},
|
||||
{Number: 386, Status: "fixing", Worker: "fix-386@node-b", Since: at(21, 10)},
|
||||
{Number: 379, Status: "located"}}, true,
|
||||
"Tracked as issue 379: nobody is working on it. Also as issue 386: fix-386 on g14 is fixing it since 21:10.",
|
||||
"Tracked as issue 379: nobody is working on it. Also as issue 386: fix-386 on node-b is fixing it since 21:10.",
|
||||
"Nothing for you to do."},
|
||||
{"two issues, nobody on either", []TrackedIssue{{Number: 386, Status: "open"}, {Number: 379, Status: "located"}}, true,
|
||||
"Tracked as issue 379: nobody is working on it. Also as issue 386: nobody is working on it.", "A person repaired"},
|
||||
{"one of two waits for the operator", []TrackedIssue{
|
||||
{Number: 386, Status: "fixing", Worker: "fix-386@g14", Since: at(21, 10)},
|
||||
{Number: 386, Status: "fixing", Worker: "fix-386@node-b", Since: at(21, 10)},
|
||||
{Number: 379, Status: "open", Needs: "operator"}}, true,
|
||||
"Tracked as issue 379: it waits for your answer. Also as issue 386: fix-386 on g14 is fixing it since 21:10.",
|
||||
"Tracked as issue 379: it waits for your answer. Also as issue 386: fix-386 on node-b is fixing it since 21:10.",
|
||||
"Needs you: answer issue 379."},
|
||||
{"more than three", []TrackedIssue{{Number: 1, Status: "open"}, {Number: 2, Status: "open"}, {Number: 3, Status: "open"},
|
||||
{Number: 4, Status: "open"}, {Number: 5, Status: "resolved"}}, true,
|
||||
@@ -116,9 +116,9 @@ func TestAConditionsMessageSaysWhereTheIssueThatTracksItStands(t *testing.T) {
|
||||
func TestNothingForYouToDoIsNeverSaidWhileTheIssueWaitsOnTheOperatorOrNobodyWorksOnIt(t *testing.T) {
|
||||
for _, issues := range [][]TrackedIssue{
|
||||
{{Number: 336, Status: "open", Needs: "operator"}},
|
||||
{{Number: 336, Status: "fixing", Worker: "fix-336@g14", Since: at(9, 0), Needs: "operator"}},
|
||||
{{Number: 336, Status: "fixing", Worker: "fix-336@node-b", Since: at(9, 0), Needs: "operator"}},
|
||||
{{Number: 352, Status: "located"}},
|
||||
{{Number: 352, Status: "fixing", Worker: "fix-352@g14", Since: at(9, 0), Stale: true}},
|
||||
{{Number: 352, Status: "fixing", Worker: "fix-352@node-b", Since: at(9, 0), Stale: true}},
|
||||
} {
|
||||
if m := trackedMessage(issues, true); strings.Contains(m.Body, "Nothing for you to do") {
|
||||
t.Errorf("%+v: %q", issues, m.Body)
|
||||
@@ -128,11 +128,11 @@ func TestNothingForYouToDoIsNeverSaidWhileTheIssueWaitsOnTheOperatorOrNobodyWork
|
||||
|
||||
// A verdict that already needs the operator is left as it is; the line is added below it.
|
||||
func TestAVerdictThatNeedsTheOperatorStands(t *testing.T) {
|
||||
r := &Record{Key: "module.mounts.shanks.unhealthy", Origin: "condition", Severity: Urgent, Headline: "mounts not working on shanks",
|
||||
Explanation: "Needs you: give the share's login. mounts on shanks is not healthy.", Raised: trackNow.Add(-time.Hour)}
|
||||
r := &Record{Key: "module.mounts.node-d.unhealthy", Origin: "condition", Severity: Urgent, Headline: "mounts not working on node-d",
|
||||
Explanation: "Needs you: give the share's login. mounts on node-d is not healthy.", Raised: trackNow.Add(-time.Hour)}
|
||||
m, _ := withTracking(compose(r, "raised", trackNow, time.UTC, 0), r, "raised",
|
||||
[]TrackedIssue{{Number: 386, Status: "open", Needs: "operator"}}, true, trackNow, time.UTC)
|
||||
want := "Needs you: give the share's login. mounts on shanks is not healthy.\nTracked as issue 386: it waits for your answer.\nSince 18:30."
|
||||
want := "Needs you: give the share's login. mounts on node-d is not healthy.\nTracked as issue 386: it waits for your answer.\nSince 18:30."
|
||||
if m.Body != want {
|
||||
t.Fatalf("got %q\nwant %q", m.Body, want)
|
||||
}
|
||||
@@ -173,12 +173,12 @@ func TestTheRouterAsksTheTrackerAndSaysItsWordInTheMessage(t *testing.T) {
|
||||
if fail {
|
||||
return nil, errors.New("no responders")
|
||||
}
|
||||
return json.RawMessage(`{"conditions":{"module.mounts.shanks.unhealthy":[` +
|
||||
return json.RawMessage(`{"conditions":{"module.mounts.node-d.unhealthy":[` +
|
||||
`{"number":379,"status":"located"},` +
|
||||
`{"number":386,"status":"fixing","worker":"fix-386@g14","since":"2026-10-06T11:10:00Z"}]}}`), nil
|
||||
`{"number":386,"status":"fixing","worker":"fix-386@node-b","since":"2026-10-06T11:10:00Z"}]}}`), nil
|
||||
}
|
||||
k := cond("module.mounts.shanks.unhealthy", Urgent, "mounts on shanks is not healthy")
|
||||
k.Explanation, k.Needs = "Nothing for you to do. mounts on shanks is not healthy.", ""
|
||||
k := cond("module.mounts.node-d.unhealthy", Urgent, "mounts on node-d is not healthy")
|
||||
k.Explanation, k.Needs = "Nothing for you to do. mounts on node-d is not healthy.", ""
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
settle(h, c)
|
||||
@@ -186,7 +186,7 @@ func TestTheRouterAsksTheTrackerAndSaysItsWordInTheMessage(t *testing.T) {
|
||||
t.Fatalf("urgent: telegram %d, desktop %d", len(tg.sends), len(dt.sends))
|
||||
}
|
||||
body := tg.sends[0].Body
|
||||
if !strings.Contains(body, "\nTracked as issue 379: nobody is working on it. Also as issue 386: fix-386 on g14 is fixing it since 11:10.\n") {
|
||||
if !strings.Contains(body, "\nTracked as issue 379: nobody is working on it. Also as issue 386: fix-386 on node-b is fixing it since 11:10.\n") {
|
||||
t.Fatalf("body: %q", body)
|
||||
}
|
||||
if asked != 1 {
|
||||
@@ -199,7 +199,7 @@ func TestTheRouterAsksTheTrackerAndSaysItsWordInTheMessage(t *testing.T) {
|
||||
c.pass(TrackingKept + time.Minute)
|
||||
h.Tick()
|
||||
h.mu.Lock()
|
||||
r := h.open["module.mounts.shanks.unhealthy"]
|
||||
r := h.open["module.mounts.node-d.unhealthy"]
|
||||
h.mu.Unlock()
|
||||
if m := h.say(r, "reminder"); !strings.Contains(m.Body, "\nWhether an issue tracks this could not be checked.\n") {
|
||||
t.Fatalf("an old word was used: %q", m.Body)
|
||||
@@ -213,11 +213,11 @@ func TestTheRouterAsksTheTrackerAndSaysItsWordInTheMessage(t *testing.T) {
|
||||
// built without it.
|
||||
func TestARouterThatCannotAskAddsNothing(t *testing.T) {
|
||||
h, _, _, c, _ := newHolder(t)
|
||||
k := cond("machine.ace.silent", Urgent, "ace is silent")
|
||||
k := cond("machine.node-a.silent", Urgent, "node-a is silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
h.mu.Lock()
|
||||
r := h.open["machine.ace.silent"]
|
||||
r := h.open["machine.node-a.silent"]
|
||||
h.mu.Unlock()
|
||||
if m := h.say(r, "raised"); strings.Contains(m.Body, "issue") {
|
||||
t.Fatalf("%q", m.Body)
|
||||
|
||||
@@ -44,7 +44,7 @@ func walk(t *testing.T, h *Holder, id, phase, outcome string, at time.Time, boun
|
||||
h.Walked(ev)
|
||||
}
|
||||
|
||||
func novox(modules ...string) Touch { return Touch{Machine: "novox", Modules: modules} }
|
||||
func nodeC(modules ...string) Touch { return Touch{Machine: "node-c", Modules: modules} }
|
||||
|
||||
// heard says whether any message on the channels carries the words: sent, edited or said again in place.
|
||||
func heard(words string, chs ...*fakeChannel) bool {
|
||||
@@ -94,11 +94,11 @@ func has(list []string, want string) bool {
|
||||
// history says it was held — a module's condition, a machine's, and a module's notice alike.
|
||||
func TestDuringAWalkWhatItTouchesIsHeldAndTheHistorySaysSo(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-1", WalkStarted, "", c.now(), 600, novox("mesh-tools", "node-tools"))
|
||||
mod := cond("module.node-tools.novox.unhealthy", Urgent, "the tool runner on novox does not answer")
|
||||
mod.Machine, mod.Raised = "novox", c.now()
|
||||
walk(t, h, "plan-1", WalkStarted, "", c.now(), 600, nodeC("mesh-tools", "node-tools"))
|
||||
mod := cond("module.node-tools.node-c.unhealthy", Urgent, "the tool runner on node-c does not answer")
|
||||
mod.Machine, mod.Raised = "node-c", c.now()
|
||||
h.Condition(EventRaised, mod)
|
||||
machine := cond("machine.novox.claude-code.agent-home.data-shrank", Urgent, "the agent's home shrank")
|
||||
machine := cond("machine.node-c.claude-code.agent-home.data-shrank", Urgent, "the agent's home shrank")
|
||||
machine.Raised = c.now()
|
||||
h.Condition(EventRaised, machine)
|
||||
if _, err := h.Notify("tools.slow", Urgent, "tools answer slowly", "node-tools", false, "tools slow",
|
||||
@@ -123,24 +123,24 @@ func TestDuringAWalkWhatItTouchesIsHeldAndTheHistorySaysSo(t *testing.T) {
|
||||
// nothing of it.
|
||||
func TestAMessageTouchedByTwoOverlappingWalksIsHeldUntilTheSecondEnds(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-a", WalkStarted, "", c.now(), 1200, novox("mesh-tools"))
|
||||
walk(t, h, "plan-a", WalkStarted, "", c.now(), 1200, nodeC("mesh-tools"))
|
||||
c.pass(time.Minute)
|
||||
walk(t, h, "plan-b", WalkStarted, "", c.now(), 1200, novox("node-tools"), Touch{Machine: "ace", Modules: []string{"node-tools"}})
|
||||
k := cond("machine.novox.network", Urgent, "novox lost its default route")
|
||||
walk(t, h, "plan-b", WalkStarted, "", c.now(), 1200, nodeC("node-tools"), Touch{Machine: "node-a", Modules: []string{"node-tools"}})
|
||||
k := cond("machine.node-c.network", Urgent, "node-c lost its default route")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, time.Minute)
|
||||
walk(t, h, "plan-a", WalkEnded, WalkDelivered, c.now(), 0, novox("mesh-tools"))
|
||||
walk(t, h, "plan-a", WalkEnded, WalkDelivered, c.now(), 0, nodeC("mesh-tools"))
|
||||
runFor(h, c, DefaultSettle+time.Minute) // its end is told once it settled (ADR 0505 §3)
|
||||
if heard(headlineOf(k.Key), tg, dt) {
|
||||
t.Fatalf("said at the first walk's end, while the second still holds it: %+v %+v", tg.sends, dt.sends)
|
||||
}
|
||||
if !heard("Delivered: mesh-tools on novox", tg, dt) {
|
||||
if !heard("Delivered: mesh-tools on node-c", tg, dt) {
|
||||
t.Fatalf("the first walk's end was not told: %+v", dt.sends)
|
||||
}
|
||||
walk(t, h, "plan-b", WalkEnded, WalkDelivered, c.now(), 0)
|
||||
runFor(h, c, DefaultSettle+time.Minute)
|
||||
if !heard("Still open after the delivery of node-tools to ace, novox:\n- Urgent: "+headlineOf(k.Key), tg, dt) {
|
||||
if !heard("Still open after the delivery of node-tools to node-a, node-c:\n- Urgent: "+headlineOf(k.Key), tg, dt) {
|
||||
t.Fatalf("the second walk's end did not tell it: telegram %+v, desk %+v", tg.sends, dt.sends)
|
||||
}
|
||||
}
|
||||
@@ -149,18 +149,18 @@ func TestAMessageTouchedByTwoOverlappingWalksIsHeldUntilTheSecondEnds(t *testing
|
||||
// sent at once, while a walk touches the machine they are on.
|
||||
func TestWhatAWalkNeverHoldsIsSentAtOnce(t *testing.T) {
|
||||
h, tg, dt, c, _, _ := newRouter(t)
|
||||
walk(t, h, "plan-9", WalkStarted, "", c.now(), 1200, novox("telegram", "mesh-tools"))
|
||||
walk(t, h, "plan-9", WalkStarted, "", c.now(), 1200, nodeC("telegram", "mesh-tools"))
|
||||
for _, key := range []string{
|
||||
"machine.novox.telegram.telegram-token.secret-given", // a secret given, on a touched machine
|
||||
"machine.novox.mounts.smb.secret-replaced", // a secret replaced
|
||||
"machine.ace.silent", // a machine no walk touches
|
||||
"delivery.leaf.over-budget", // the walk's own delivery
|
||||
"plan.plan-9.failed", // the walk itself
|
||||
"machine.node-c.telegram.telegram-token.secret-given", // a secret given, on a touched machine
|
||||
"machine.node-c.mounts.smb.secret-replaced", // a secret replaced
|
||||
"machine.node-a.silent", // a machine no walk touches
|
||||
"delivery.leaf.over-budget", // the walk's own delivery
|
||||
"plan.plan-9.failed", // the walk itself
|
||||
} {
|
||||
k := cond(key, Urgent, "it happened")
|
||||
k.Raised = c.now()
|
||||
if !strings.HasPrefix(key, "machine.") {
|
||||
k.Machine = "novox" // a walk's own failure, on a machine it touches
|
||||
k.Machine = "node-c" // a walk's own failure, on a machine it touches
|
||||
}
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, time.Minute)
|
||||
@@ -175,7 +175,7 @@ func TestWhatAWalkNeverHoldsIsSentAtOnce(t *testing.T) {
|
||||
if !has(outcomes(h, "ask."+ConditionOwner+".own"), "sent") {
|
||||
t.Errorf("an ask waiting for the operator was held: %v", outcomes(h, "ask."+ConditionOwner+".own"))
|
||||
}
|
||||
held := cond("machine.novox.units", Urgent, "2 failed services on novox")
|
||||
held := cond("machine.node-c.units", Urgent, "2 failed services on node-c")
|
||||
held.Raised = c.now()
|
||||
h.Condition(EventRaised, held)
|
||||
runFor(h, c, time.Minute)
|
||||
@@ -195,15 +195,15 @@ func TestWhatAWalkNeverHoldsIsSentAtOnce(t *testing.T) {
|
||||
// still open, one line each; the one that cleared is only counted, and nothing more is said of them after.
|
||||
func TestAWalksEndIsToldOnceWithWhatIsStillOpen(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-3", WalkStarted, "", c.now(), 600, novox("mesh-tools"))
|
||||
still := cond("machine.novox.tools-silent", Warning, "the tools on novox are silent")
|
||||
walk(t, h, "plan-3", WalkStarted, "", c.now(), 600, nodeC("mesh-tools"))
|
||||
still := cond("machine.node-c.tools-silent", Warning, "the tools on node-c are silent")
|
||||
still.Raised = c.now()
|
||||
h.Condition(EventRaised, still)
|
||||
gone := cond("module.mesh-tools.novox.unhealthy", Warning, "mesh-tools is unhealthy on novox")
|
||||
gone := cond("module.mesh-tools.node-c.unhealthy", Warning, "mesh-tools is unhealthy on node-c")
|
||||
gone.Raised = c.now()
|
||||
h.Condition(EventRaised, gone)
|
||||
c.pass(time.Second)
|
||||
other := cond("machine.novox.core-behind", Urgent, "novox runs an older core")
|
||||
other := cond("machine.node-c.core-behind", Urgent, "node-c runs an older core")
|
||||
other.Raised = c.now()
|
||||
h.Condition(EventRaised, other)
|
||||
runFor(h, c, 2*time.Minute)
|
||||
@@ -219,10 +219,10 @@ func TestAWalksEndIsToldOnceWithWhatIsStillOpen(t *testing.T) {
|
||||
t.Fatalf("the end was not one message per kind: desk %+v, telegram %+v", dt.sends, tg.sends)
|
||||
}
|
||||
m := dt.sends[0]
|
||||
if m.Title != "Delivery failed: mesh-tools on novox" || !strings.Contains(m.Body, "It took 7 min.") {
|
||||
if m.Title != "Delivery failed: mesh-tools on node-c" || !strings.Contains(m.Body, "It took 7 min.") {
|
||||
t.Fatalf("the end does not say its outcome, what it reached and how long: %q", m.Text())
|
||||
}
|
||||
want := "Still open after the delivery of mesh-tools to novox:\n- " + headlineOf(still.Key) + "\n- Urgent: " + headlineOf(other.Key) +
|
||||
want := "Still open after the delivery of mesh-tools to node-c:\n- " + headlineOf(still.Key) + "\n- Urgent: " + headlineOf(other.Key) +
|
||||
"\n1 problem it raised resolved during it."
|
||||
if !strings.Contains(m.Body, want) || strings.Contains(m.Text(), headlineOf(gone.Key)) {
|
||||
t.Fatalf("the end message %q does not say %q", m.Body, want)
|
||||
@@ -238,18 +238,18 @@ func TestAWalksEndIsToldOnceWithWhatIsStillOpen(t *testing.T) {
|
||||
// to say only what needs the operator.
|
||||
func TestADeliveredWalkWithNothingHeldIsOneLineOrNothing(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-4", WalkStarted, "", c.now(), 600, novox("mesh-tools"), Touch{Machine: "ace", Modules: []string{"mesh-tools"}})
|
||||
walk(t, h, "plan-4", WalkStarted, "", c.now(), 600, nodeC("mesh-tools"), Touch{Machine: "node-a", Modules: []string{"mesh-tools"}})
|
||||
runFor(h, c, 3*time.Minute)
|
||||
walk(t, h, "plan-4", WalkEnded, WalkDelivered, c.now(), 0)
|
||||
runFor(h, c, DefaultSettle+time.Minute)
|
||||
if len(dt.sends) != 1 || len(tg.sends) != 0 {
|
||||
t.Fatalf("desk %+v, telegram %+v", dt.sends, tg.sends)
|
||||
}
|
||||
if m := dt.sends[0]; m.Title != "Delivered: mesh-tools on ace, novox, in 3 min" || m.Body != "" {
|
||||
if m := dt.sends[0]; m.Title != "Delivered: mesh-tools on node-a, node-c, in 3 min" || m.Body != "" {
|
||||
t.Fatalf("not one line: %q", m.Text())
|
||||
}
|
||||
h.NeedsOnly = func(kind string) bool { return kind == "desktop" }
|
||||
walk(t, h, "plan-5", WalkStarted, "", c.now(), 600, novox("mesh-tools"))
|
||||
walk(t, h, "plan-5", WalkStarted, "", c.now(), 600, nodeC("mesh-tools"))
|
||||
runFor(h, c, 3*time.Minute)
|
||||
walk(t, h, "plan-5", WalkEnded, WalkDelivered, c.now(), 0)
|
||||
runFor(h, c, DefaultSettle+time.Minute)
|
||||
@@ -279,11 +279,11 @@ func TestAHoldEndsAtTheWalksBound(t *testing.T) {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
started := c.now()
|
||||
walk(t, h, "plan-7", WalkStarted, "", started, tc.given, novox("node-tools"))
|
||||
open := cond("machine.novox.tools-silent", Urgent, "the tools on novox are silent")
|
||||
walk(t, h, "plan-7", WalkStarted, "", started, tc.given, nodeC("node-tools"))
|
||||
open := cond("machine.node-c.tools-silent", Urgent, "the tools on node-c are silent")
|
||||
open.Raised = c.now()
|
||||
h.Condition(EventRaised, open)
|
||||
gone := cond("module.node-tools.novox.unhealthy", Urgent, "node-tools is unhealthy")
|
||||
gone := cond("module.node-tools.node-c.unhealthy", Urgent, "node-tools is unhealthy")
|
||||
gone.Raised = c.now()
|
||||
h.Condition(EventRaised, gone)
|
||||
c.pass(30 * time.Second)
|
||||
@@ -305,7 +305,7 @@ func TestAHoldEndsAtTheWalksBound(t *testing.T) {
|
||||
}
|
||||
}
|
||||
// Past its bound the walk holds nothing: a new message about what it touches goes at once.
|
||||
late := cond("machine.novox.disk", Urgent, "a disk fails on novox")
|
||||
late := cond("machine.node-c.disk", Urgent, "a disk fails on node-c")
|
||||
late.Raised = c.now()
|
||||
h.Condition(EventRaised, late)
|
||||
runFor(h, c, time.Minute)
|
||||
@@ -319,8 +319,8 @@ func TestAHoldEndsAtTheWalksBound(t *testing.T) {
|
||||
// §2, kept: what a walk holds survives the router's restart, and is told at the walk's end.
|
||||
func TestHeldMessagesSurviveARouterRestart(t *testing.T) {
|
||||
h, tg, dt, c, st := newHolder(t)
|
||||
walk(t, h, "plan-8", WalkStarted, "", c.now(), 1200, novox("mesh-tools"))
|
||||
k := cond("machine.novox.tools-silent", Urgent, "the tools on novox are silent")
|
||||
walk(t, h, "plan-8", WalkStarted, "", c.now(), 1200, nodeC("mesh-tools"))
|
||||
k := cond("machine.node-c.tools-silent", Urgent, "the tools on node-c are silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, time.Minute)
|
||||
@@ -345,8 +345,8 @@ func TestARestartSaysNothingItHasSaid(t *testing.T) {
|
||||
h, tg, dt, c, _, _ := newRouter(t)
|
||||
h.Start()
|
||||
c.pass(2 * time.Minute)
|
||||
keys := []string{"machine.novox.telegram.telegram-token.secret-given", "machine.novox.claude-code.agent-home.data-shrank",
|
||||
"machine.shanks.mounts.smb-password-recalbox.secret-given", "machine.ace.nzbgeek.api-key.secret-given"}
|
||||
keys := []string{"machine.node-c.telegram.telegram-token.secret-given", "machine.node-c.claude-code.agent-home.data-shrank",
|
||||
"machine.node-d.mounts.smb-password-recalbox.secret-given", "machine.node-a.nzbgeek.api-key.secret-given"}
|
||||
var silenced []Condition
|
||||
for i, key := range keys {
|
||||
k := cond(key, Urgent, "it happened")
|
||||
@@ -359,7 +359,7 @@ func TestARestartSaysNothingItHasSaid(t *testing.T) {
|
||||
stand(h, c)
|
||||
silenced = append(silenced, k)
|
||||
}
|
||||
withheldOpen := cond("machine.novox.units", Urgent, "2 failed services")
|
||||
withheldOpen := cond("machine.node-c.units", Urgent, "2 failed services")
|
||||
withheldOpen.Explanation = "Needs you: read /etc/systemd/system/x.service."
|
||||
withheldOpen.Raised = c.now()
|
||||
h.Condition(EventRaised, withheldOpen)
|
||||
@@ -415,14 +415,14 @@ func TestARestartSaysNothingItHasSaid(t *testing.T) {
|
||||
// The controller's walk events are read as ADR 0308 §1 says them; any other plan-moved is not a walk's.
|
||||
func TestTheWalkEventsAreReadAsTheControllerSaysThem(t *testing.T) {
|
||||
at := time.Date(2026, 10, 12, 11, 12, 0, 0, time.UTC)
|
||||
ev, ok, err := DecodeWalk(walkBody(t, "plan-1", WalkStarted, "", at, 1200, novox("mesh-tools", "node-tools")))
|
||||
ev, ok, err := DecodeWalk(walkBody(t, "plan-1", WalkStarted, "", at, 1200, nodeC("mesh-tools", "node-tools")))
|
||||
if err != nil || !ok || ev.Walk != "plan-1" || ev.BoundSeconds != 1200 || ev.Class != "leaf" || !ev.At.Equal(at) ||
|
||||
len(ev.Touches) != 1 || ev.Touches[0].Machine != "novox" || len(ev.Touches[0].Modules) != 2 {
|
||||
len(ev.Touches) != 1 || ev.Touches[0].Machine != "node-c" || len(ev.Touches[0].Modules) != 2 {
|
||||
t.Fatalf("%+v %v %v", ev, ok, err)
|
||||
}
|
||||
// As mesh-controller's walk events (its pull request 247) say an end: ended_at, and carried beside modules.
|
||||
end, ok, err := DecodeWalk([]byte(`{"id":"plan-1","walk":"plan-1","phase":"ended","outcome":"stopped",` +
|
||||
`"touches":[{"machine":"novox","modules":["node-tools","messenger"],"carried":["messenger"]}],` +
|
||||
`"touches":[{"machine":"node-c","modules":["node-tools","messenger"],"carried":["messenger"]}],` +
|
||||
`"started_at":"2026-10-12T11:12:00Z","ended_at":"2026-10-12T11:19:00Z","updated":"2026-10-12T11:19:01Z"}`))
|
||||
if err != nil || !ok || end.Outcome != WalkStopped || !end.At.Equal(at.Add(7*time.Minute)) || len(end.Touches[0].Modules) != 2 {
|
||||
t.Fatalf("%+v %v %v", end, ok, err)
|
||||
@@ -439,7 +439,7 @@ func TestTheWalkEventsAreReadAsTheControllerSaysThem(t *testing.T) {
|
||||
}
|
||||
// A start older than its bound is history: nothing is held.
|
||||
h, _, _, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-old", WalkStarted, "", c.now().Add(-time.Hour), 1200, novox("mesh-tools"))
|
||||
walk(t, h, "plan-old", WalkStarted, "", c.now().Add(-time.Hour), 1200, nodeC("mesh-tools"))
|
||||
if len(h.walks) != 0 {
|
||||
t.Fatalf("an old start opened a walk: %+v", h.walks)
|
||||
}
|
||||
@@ -452,8 +452,8 @@ func TestWhatAWalkHeldIsSaidOnceAChannelCanSendAgain(t *testing.T) {
|
||||
for _, at := range []string{"end", "bound"} {
|
||||
t.Run(at, func(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-c", WalkStarted, "", c.now(), 600, novox("mesh-tools"))
|
||||
k := cond("machine.novox.tools-silent", Urgent, "the tools on novox are silent")
|
||||
walk(t, h, "plan-c", WalkStarted, "", c.now(), 600, nodeC("mesh-tools"))
|
||||
k := cond("machine.node-c.tools-silent", Urgent, "the tools on node-c are silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, 2*time.Minute)
|
||||
@@ -485,12 +485,12 @@ func TestWhatAWalkHeldIsSaidOnceAChannelCanSendAgain(t *testing.T) {
|
||||
// limit (its start, bound and settle) has passed, while B still runs, with B's delivery line.
|
||||
func TestAMessageIsHeldOnByALaterWalkThatTouchesIt(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-a", WalkStarted, "", c.now(), 360, novox("mesh-tools")) // its limit: 6 min and the settle
|
||||
k := cond("machine.novox.network", Urgent, "novox lost its default route")
|
||||
walk(t, h, "plan-a", WalkStarted, "", c.now(), 360, nodeC("mesh-tools")) // its limit: 6 min and the settle
|
||||
k := cond("machine.node-c.network", Urgent, "node-c lost its default route")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, time.Minute)
|
||||
walk(t, h, "plan-b", WalkStarted, "", c.now(), 1200, novox("node-tools"))
|
||||
walk(t, h, "plan-b", WalkStarted, "", c.now(), 1200, nodeC("node-tools"))
|
||||
runFor(h, c, time.Minute)
|
||||
walk(t, h, "plan-a", WalkEnded, WalkDelivered, c.now(), 0)
|
||||
runFor(h, c, DefaultSettle+time.Minute)
|
||||
@@ -501,7 +501,7 @@ func TestAMessageIsHeldOnByALaterWalkThatTouchesIt(t *testing.T) {
|
||||
t.Fatalf("the second walk does not hold it on: %v", got)
|
||||
}
|
||||
runFor(h, c, 4*time.Minute) // past the first walk's limit, 8 minutes after it was held
|
||||
if !heard("During the delivery of node-tools to novox.", tg, dt) || !heard(headlineOf(k.Key), tg, dt) {
|
||||
if !heard("During the delivery of node-tools to node-c.", tg, dt) || !heard(headlineOf(k.Key), tg, dt) {
|
||||
t.Fatalf("held past its first hold's limit: %+v %+v", tg.sends, dt.sends)
|
||||
}
|
||||
}
|
||||
@@ -510,8 +510,8 @@ func TestAMessageIsHeldOnByALaterWalkThatTouchesIt(t *testing.T) {
|
||||
// what it held is said, with the still-running line, before the walk is forgotten.
|
||||
func TestAWalkReadBackADayLateSaysWhatItHeldBeforeItIsForgotten(t *testing.T) {
|
||||
h, tg, dt, c, st := newHolder(t)
|
||||
walk(t, h, "plan-d", WalkStarted, "", c.now(), 600, novox("mesh-tools"))
|
||||
k := cond("machine.novox.tools-silent", Urgent, "the tools on novox are silent")
|
||||
walk(t, h, "plan-d", WalkStarted, "", c.now(), 600, nodeC("mesh-tools"))
|
||||
k := cond("machine.node-c.tools-silent", Urgent, "the tools on node-c are silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, time.Minute)
|
||||
@@ -540,14 +540,14 @@ func TestAStartHeardAfterItsEndOpensNothing(t *testing.T) {
|
||||
h, tg, dt, c, st := newHolder(t)
|
||||
started := c.now()
|
||||
c.pass(20 * time.Second)
|
||||
end, _, err := DecodeWalk([]byte(`{"walk":"plan-e","phase":"ended","outcome":"delivered","touches":[{"machine":"novox","modules":["mesh-tools"]}],` +
|
||||
end, _, err := DecodeWalk([]byte(`{"walk":"plan-e","phase":"ended","outcome":"delivered","touches":[{"machine":"node-c","modules":["mesh-tools"]}],` +
|
||||
`"started_at":"` + started.Format(time.RFC3339Nano) + `","ended_at":"` + c.now().Format(time.RFC3339Nano) + `"}`))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h.Walked(end)
|
||||
c.pass(time.Second)
|
||||
walk(t, h, "plan-e", WalkStarted, "", started, 600, novox("mesh-tools"))
|
||||
walk(t, h, "plan-e", WalkStarted, "", started, 600, nodeC("mesh-tools"))
|
||||
if len(h.walks) != 0 {
|
||||
t.Fatalf("a start heard after its end opened a walk: %+v", h.walks)
|
||||
}
|
||||
@@ -556,11 +556,11 @@ func TestAStartHeardAfterItsEndOpensNothing(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
again.Start()
|
||||
walk(t, again, "plan-e", WalkStarted, "", started, 600, novox("mesh-tools"))
|
||||
walk(t, again, "plan-e", WalkStarted, "", started, 600, nodeC("mesh-tools"))
|
||||
if len(again.walks) != 0 {
|
||||
t.Fatalf("after a restart, a start heard after its end opened a walk: %+v", again.walks)
|
||||
}
|
||||
k := cond("machine.novox.tools-silent", Urgent, "the tools on novox are silent")
|
||||
k := cond("machine.node-c.tools-silent", Urgent, "the tools on node-c are silent")
|
||||
k.Raised = c.now()
|
||||
again.Condition(EventRaised, k)
|
||||
runFor(again, c, time.Minute)
|
||||
@@ -568,7 +568,7 @@ func TestAStartHeardAfterItsEndOpensNothing(t *testing.T) {
|
||||
t.Fatalf("held by a walk that had ended: %v", outcomes(again, k.Key))
|
||||
}
|
||||
// Retried: the same id walks again, started after the end.
|
||||
walk(t, again, "plan-e", WalkStarted, "", c.now(), 600, novox("mesh-tools"))
|
||||
walk(t, again, "plan-e", WalkStarted, "", c.now(), 600, nodeC("mesh-tools"))
|
||||
if len(again.walks) != 1 {
|
||||
t.Fatalf("a walk started after the last end did not open: %+v", again.walks)
|
||||
}
|
||||
@@ -581,8 +581,8 @@ func TestARestartSaysAgainAnAskedMessageAWalkTookBeforeItsAsk(t *testing.T) {
|
||||
h, _, dt, c, _, _ := newRouter(t)
|
||||
h.Start()
|
||||
stand(h, c)
|
||||
walk(t, h, "plan-f", WalkStarted, "", c.now(), 1200, novox("mesh-tools"))
|
||||
k := cond("machine.novox.units", Urgent, "2 failed services on novox")
|
||||
walk(t, h, "plan-f", WalkStarted, "", c.now(), 1200, nodeC("mesh-tools"))
|
||||
k := cond("machine.node-c.units", Urgent, "2 failed services on node-c")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, time.Minute)
|
||||
@@ -607,8 +607,8 @@ func TestARestartSaysAgainAnAskedMessageAWalkTookBeforeItsAsk(t *testing.T) {
|
||||
// file path) is said in its plain form, and what it held, still open, is said on its own, not marked told.
|
||||
func TestWhatAWalksPlainEndCannotCarryIsSaidOnItsOwn(t *testing.T) {
|
||||
h, tg, dt, c, _ := newHolder(t)
|
||||
walk(t, h, "plan-g", WalkStarted, "", c.now(), 600, novox("/var/lib/mesh-tools"))
|
||||
k := cond("machine.novox.tools-silent", Urgent, "the tools on novox are silent")
|
||||
walk(t, h, "plan-g", WalkStarted, "", c.now(), 600, nodeC("/var/lib/mesh-tools"))
|
||||
k := cond("machine.node-c.tools-silent", Urgent, "the tools on node-c are silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, time.Minute)
|
||||
@@ -634,8 +634,8 @@ func TestAHeldMessageIsToldOnlyOnceTheWalksMessageWasSent(t *testing.T) {
|
||||
if then == "restart warning" {
|
||||
sev = Warning
|
||||
}
|
||||
walk(t, h, "plan-h", WalkStarted, "", c.now(), 1200, novox("mesh-tools"))
|
||||
k := cond("machine.novox.tools-silent", sev, "the tools on novox are silent")
|
||||
walk(t, h, "plan-h", WalkStarted, "", c.now(), 1200, nodeC("mesh-tools"))
|
||||
k := cond("machine.node-c.tools-silent", sev, "the tools on node-c are silent")
|
||||
k.Raised = c.now()
|
||||
h.Condition(EventRaised, k)
|
||||
runFor(h, c, time.Minute)
|
||||
@@ -652,7 +652,7 @@ func TestAHeldMessageIsToldOnlyOnceTheWalksMessageWasSent(t *testing.T) {
|
||||
tg.fail, dt.fail = nil, nil
|
||||
if then == "sent" {
|
||||
runFor(h, c, 2*time.Minute)
|
||||
if !heard("Still open after the delivery of mesh-tools to novox:\n- Urgent: "+headlineOf(k.Key), tg, dt) || saidOn(tg, dt) != 2 {
|
||||
if !heard("Still open after the delivery of mesh-tools to node-c:\n- Urgent: "+headlineOf(k.Key), tg, dt) || saidOn(tg, dt) != 2 {
|
||||
t.Fatalf("not told once in the walk's message: telegram %+v, desk %+v", tg.sends, dt.sends)
|
||||
}
|
||||
if r := h.open[k.Key]; r == nil || !r.told() || r.Owed != "" || r.Sent["telegram"] != "" || r.Sent["desktop"] != "" {
|
||||
@@ -694,11 +694,11 @@ func TestAWalksEndHandsOnOnlyWhatALaterWalkWouldHold(t *testing.T) {
|
||||
h, tg, dt, c, _, _ := newRouter(t)
|
||||
h.Start()
|
||||
stand(h, c)
|
||||
walk(t, h, "plan-a", WalkStarted, "", c.now(), 1200, novox("mesh-tools"))
|
||||
quiet := cond("machine.novox.network", Urgent, "novox lost its default route")
|
||||
walk(t, h, "plan-a", WalkStarted, "", c.now(), 1200, nodeC("mesh-tools"))
|
||||
quiet := cond("machine.node-c.network", Urgent, "node-c lost its default route")
|
||||
quiet.Raised = c.now()
|
||||
h.Condition(EventRaised, quiet)
|
||||
asked := cond("machine.novox.units", Urgent, "2 failed services on novox")
|
||||
asked := cond("machine.node-c.units", Urgent, "2 failed services on node-c")
|
||||
asked.Raised = c.now()
|
||||
h.Condition(EventRaised, asked)
|
||||
runFor(h, c, time.Minute)
|
||||
@@ -713,7 +713,7 @@ func TestAWalksEndHandsOnOnlyWhatALaterWalkWouldHold(t *testing.T) {
|
||||
submit(t, h, ConditionOwner, ask)
|
||||
runFor(h, c, time.Minute)
|
||||
stand(h, c)
|
||||
walk(t, h, "plan-b", WalkStarted, "", c.now(), 1200, novox("node-tools"))
|
||||
walk(t, h, "plan-b", WalkStarted, "", c.now(), 1200, nodeC("node-tools"))
|
||||
runFor(h, c, time.Minute)
|
||||
stand(h, c)
|
||||
helds := func(key string) int {
|
||||
@@ -747,7 +747,7 @@ func TestAStartHeardAfterItsEndOpensNothingWhenTheControllersClockIsAhead(t *tes
|
||||
h, _, _, c, _ := newHolder(t)
|
||||
ended := c.now().Add(10 * time.Minute) // by the controller's clock
|
||||
started := ended.Add(-20 * time.Second)
|
||||
body := `{"walk":"plan-k","phase":"ended","outcome":"delivered","touches":[{"machine":"novox","modules":["mesh-tools"]}],` +
|
||||
body := `{"walk":"plan-k","phase":"ended","outcome":"delivered","touches":[{"machine":"node-c","modules":["mesh-tools"]}],` +
|
||||
`"ended_at":"` + ended.Format(time.RFC3339Nano) + `"`
|
||||
if said == "both" {
|
||||
body += `,"started_at":"` + started.Format(time.RFC3339Nano) + `"`
|
||||
@@ -758,11 +758,11 @@ func TestAStartHeardAfterItsEndOpensNothingWhenTheControllersClockIsAhead(t *tes
|
||||
}
|
||||
h.Walked(end)
|
||||
c.pass(time.Second)
|
||||
walk(t, h, "plan-k", WalkStarted, "", started, 600, novox("mesh-tools"))
|
||||
walk(t, h, "plan-k", WalkStarted, "", started, 600, nodeC("mesh-tools"))
|
||||
if len(h.walks) != 0 {
|
||||
t.Fatalf("a start heard after its end opened a walk: %+v", h.walks)
|
||||
}
|
||||
walk(t, h, "plan-k", WalkStarted, "", ended.Add(time.Minute), 600, novox("mesh-tools"))
|
||||
walk(t, h, "plan-k", WalkStarted, "", ended.Add(time.Minute), 600, nodeC("mesh-tools"))
|
||||
if len(h.walks) != 1 {
|
||||
t.Fatalf("the next walk under its id, started after the end, did not open: %+v", h.walks)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
// with them whole, and Details with the fingerprint and where to read it, which the note shows.
|
||||
func proposalAsk(c *clock, id string) asks.Ask {
|
||||
a := heldAsk(c, id)
|
||||
a.Headline = "Set mounts on shanks?"
|
||||
a.Headline = "Set mounts on node-d?"
|
||||
a.Options = a.Options[:2]
|
||||
a.Explanation = "+ shares: media=‹path›\n+ sources: recalbox=‹address›@‹path›\nProposed by an agent at 15:11."
|
||||
a.Whole = "+ shares: media=/storage/media\n+ sources: recalbox=smb://nas.lan/recalbox@/mnt/recalbox\nProposed by an agent at 15:11."
|
||||
@@ -46,7 +46,7 @@ func TestAnAsksWholeWordsAreShownWhereTheSenderIsProvenAndMaskedElsewhere(t *tes
|
||||
!strings.Contains(phone.Note, "Read it whole: settings proposals s-1 at the controller's terminal.") {
|
||||
t.Errorf("the phone's note lacks the Details:\n%s", phone.Note)
|
||||
}
|
||||
if phone.Title != "Set mounts on shanks?" || ticketFor(phone, "Release") == "" || ticketFor(phone, DetailsLabel) != "" {
|
||||
if phone.Title != "Set mounts on node-d?" || ticketFor(phone, "Release") == "" || ticketFor(phone, DetailsLabel) != "" {
|
||||
t.Errorf("the phone's message: %q offering %s", phone.Title, labelsOf(phone))
|
||||
}
|
||||
// The desk proves nothing: the same record composed for it shows the explanation, its values masked.
|
||||
@@ -69,7 +69,7 @@ func TestAnAsksWholeWordsAreShownWhereTheSenderIsProvenAndMaskedElsewhere(t *tes
|
||||
if !ok {
|
||||
t.Fatalf("the phone's message was not edited: %+v", tg.edits)
|
||||
}
|
||||
if edited.Title != "Set mounts on shanks?" || edited.Body == "" ||
|
||||
if edited.Title != "Set mounts on node-d?" || edited.Body == "" ||
|
||||
!strings.HasPrefix(edited.Note, "You chose Release at ") || len(edited.Actions) != 0 {
|
||||
t.Errorf("the edited message: %q\n%s\nactions %+v", edited.Title, edited.Body, edited.Actions)
|
||||
}
|
||||
@@ -176,7 +176,7 @@ func TestEveryKeyAndItsWholeValueIsInTheNoteWhereTheSenderIsProven(t *testing.T)
|
||||
return strings.Join(out, "\n")
|
||||
}
|
||||
a := proposalAsk(c, "s-9")
|
||||
a.Explanation = "Changes 5 setting(s) of mounts on shanks.\n+ a: 1\n+ b: 2\nand 3 more, each whole below: c, d, shares"
|
||||
a.Explanation = "Changes 5 setting(s) of mounts on node-d.\n+ a: 1\n+ b: 2\nand 3 more, each whole below: c, d, shares"
|
||||
a.Whole = ""
|
||||
a.Details = "Fingerprint 1234 5678 9abc def0 1234 5678.\n" + lines(masked)
|
||||
a.WholeDetails = "Fingerprint 1234 5678 9abc def0 1234 5678.\n" + lines(keys)
|
||||
|
||||
@@ -64,58 +64,58 @@ var examples = []example{{
|
||||
cleared: "Resolved: openrazer delivery no longer waiting, after 5.0 h", openFor: 5 * time.Hour,
|
||||
}, {
|
||||
name: "a module unhealthy",
|
||||
before: "WARNING: openrazer on g14 is not healthy: its unit openrazer-daemon.service failed in the account's own " +
|
||||
"service manager (exit-code)\nabout: module openrazer.g14 on g14 (module-unhealthy)\nsince: 2026-10-08 " +
|
||||
"10:40 UTC\nkey: module.openrazer.g14.unhealthy\nmore: conditions show module.openrazer.g14.unhealthy",
|
||||
key: "module.openrazer.g14.unhealthy", kind: "module-unhealthy", severity: Warning,
|
||||
subject: map[string]string{"scope": "module", "id": "openrazer.g14", "machine": "g14"},
|
||||
summary: "openrazer on g14 is not healthy: its unit openrazer-daemon.service failed in the account's own " +
|
||||
before: "WARNING: openrazer on node-b is not healthy: its unit openrazer-daemon.service failed in the account's own " +
|
||||
"service manager (exit-code)\nabout: module openrazer.node-b on node-b (module-unhealthy)\nsince: 2026-10-08 " +
|
||||
"10:40 UTC\nkey: module.openrazer.node-b.unhealthy\nmore: conditions show module.openrazer.node-b.unhealthy",
|
||||
key: "module.openrazer.node-b.unhealthy", kind: "module-unhealthy", severity: Warning,
|
||||
subject: map[string]string{"scope": "module", "id": "openrazer.node-b", "machine": "node-b"},
|
||||
summary: "openrazer on node-b is not healthy: its unit openrazer-daemon.service failed in the account's own " +
|
||||
"service manager (exit-code)",
|
||||
headline: "openrazer not working on g14",
|
||||
needs: "restart its service openrazer-daemon on g14; if it fails again, the details say why.",
|
||||
explanation: "Needs you: restart its service openrazer-daemon on g14; if it fails again, the details say why. " +
|
||||
"openrazer on g14 is not healthy: its service openrazer-daemon stopped with an error. It clears as soon as " +
|
||||
headline: "openrazer not working on node-b",
|
||||
needs: "restart its service openrazer-daemon on node-b; if it fails again, the details say why.",
|
||||
explanation: "Needs you: restart its service openrazer-daemon on node-b; if it fails again, the details say why. " +
|
||||
"openrazer on node-b is not healthy: its service openrazer-daemon stopped with an error. It clears as soon as " +
|
||||
"it runs again.",
|
||||
resolved: "openrazer works again on g14", popup: true,
|
||||
title: "openrazer not working on g14",
|
||||
body: "Needs you: restart its service openrazer-daemon on g14; if it fails again, the details say why. openrazer " +
|
||||
"on g14 is not healthy: its service openrazer-daemon stopped with an error. It clears as soon as it runs " +
|
||||
resolved: "openrazer works again on node-b", popup: true,
|
||||
title: "openrazer not working on node-b",
|
||||
body: "Needs you: restart its service openrazer-daemon on node-b; if it fails again, the details say why. openrazer " +
|
||||
"on node-b is not healthy: its service openrazer-daemon stopped with an error. It clears as soon as it runs " +
|
||||
"again.\nNo issue tracks this yet.\nSince 12:40.\nNo delivery running.",
|
||||
offers: "Details", choose: "Details",
|
||||
cleared: "Resolved: openrazer works again on g14, after 2.0 h", openFor: 2 * time.Hour,
|
||||
cleared: "Resolved: openrazer works again on node-b, after 2.0 h", openFor: 2 * time.Hour,
|
||||
}, {
|
||||
name: "failed units on a machine",
|
||||
before: "WARNING: shanks's service manager is degraded: 3 failed unit(s) no module places — mnt-recalbox.mount, " +
|
||||
before: "WARNING: node-d's service manager is degraded: 3 failed unit(s) no module places — mnt-recalbox.mount, " +
|
||||
"storage-media.mount, greenclip.service (the account's own manager). Each is the machine's own: mend or " +
|
||||
"remove it there, or have a module place it\nabout: machine shanks on shanks (machine-units)\nsince: " +
|
||||
"2026-10-08 10:40 UTC\nkey: machine.shanks.units\nmore: conditions show machine.shanks.units",
|
||||
key: "machine.shanks.units", kind: "machine-units", severity: Warning,
|
||||
subject: map[string]string{"scope": "machine", "id": "shanks", "machine": "shanks"},
|
||||
summary: "shanks's service manager is degraded: 3 failed unit(s) no module places — mnt-recalbox.mount, " +
|
||||
"remove it there, or have a module place it\nabout: machine node-d on node-d (machine-units)\nsince: " +
|
||||
"2026-10-08 10:40 UTC\nkey: machine.node-d.units\nmore: conditions show machine.node-d.units",
|
||||
key: "machine.node-d.units", kind: "machine-units", severity: Warning,
|
||||
subject: map[string]string{"scope": "machine", "id": "node-d", "machine": "node-d"},
|
||||
summary: "node-d's service manager is degraded: 3 failed unit(s) no module places — mnt-recalbox.mount, " +
|
||||
"storage-media.mount, greenclip.service (the account's own manager). Each is the machine's own: mend or " +
|
||||
"remove it there, or have a module place it",
|
||||
headline: "3 failed services on shanks", needs: "mend or remove them on shanks, or silence this if they do not matter.",
|
||||
explanation: "Needs you: mend or remove them on shanks, or silence this if they do not matter. On shanks, " +
|
||||
headline: "3 failed services on node-d", needs: "mend or remove them on node-d, or silence this if they do not matter.",
|
||||
explanation: "Needs you: mend or remove them on node-d, or silence this if they do not matter. On node-d, " +
|
||||
"mnt-recalbox (a mount), storage-media (a mount) and greenclip failed. No module manages them, so the mesh " +
|
||||
"does not repair them.",
|
||||
actions: []Action{{Label: "Silence for a week", Verb: "mesh-controller.conditions",
|
||||
Arguments: map[string]string{"silence": "machine.shanks.units", "for": "7d", "why": "", "cause": "operator-answer"}}},
|
||||
resolved: "No failed services on shanks any more", popup: true,
|
||||
title: "3 failed services on shanks",
|
||||
body: "Needs you: mend or remove them on shanks, or silence this if they do not matter. On shanks, mnt-recalbox " +
|
||||
Arguments: map[string]string{"silence": "machine.node-d.units", "for": "7d", "why": "", "cause": "operator-answer"}}},
|
||||
resolved: "No failed services on node-d any more", popup: true,
|
||||
title: "3 failed services on node-d",
|
||||
body: "Needs you: mend or remove them on node-d, or silence this if they do not matter. On node-d, mnt-recalbox " +
|
||||
"(a mount), storage-media (a mount) and greenclip failed. No module manages them, so the mesh does not repair " +
|
||||
"them.\nNo issue tracks this yet.\nSince 12:40.\nNo delivery running.",
|
||||
offers: "Details", choose: "Details",
|
||||
cleared: "Resolved: no failed services on shanks any more, after 45 min", openFor: 45 * time.Minute,
|
||||
cleared: "Resolved: no failed services on node-d any more, after 45 min", openFor: 45 * time.Minute,
|
||||
}, {
|
||||
name: "a healer wanted",
|
||||
before: "WARNING: \"push\" was repaired by hand 35 times in 14 days, the last by g14.node-tools, through the " +
|
||||
before: "WARNING: \"push\" was repaired by hand 35 times in 14 days, the last by node-b.node-tools, through the " +
|
||||
"mesh-controller seat: a healer is wanted for it\nabout: mesh hand-acts.push (healer-wanted)\nsince: " +
|
||||
"2026-10-08 10:40 UTC\nkey: mesh.hand-acts.push.healer-wanted\nmore: conditions show " +
|
||||
"mesh.hand-acts.push.healer-wanted",
|
||||
key: "mesh.hand-acts.push.healer-wanted", kind: "healer-wanted", severity: Warning,
|
||||
subject: map[string]string{"scope": "mesh", "id": "hand-acts.push"},
|
||||
summary: "\"push\" was repaired by hand 35 times in 14 days, the last by g14.node-tools, through the " +
|
||||
summary: "\"push\" was repaired by hand 35 times in 14 days, the last by node-b.node-tools, through the " +
|
||||
"mesh-controller seat: a healer is wanted for it",
|
||||
headline: "Push keeps being fixed by hand",
|
||||
explanation: "Nothing for you to do. A person repaired push by hand 35 times in 14 days, so an automatic repair " +
|
||||
@@ -217,7 +217,7 @@ func TestRealNotificationsReadInOneGlanceAndAreAnsweredFromTheNotification(t *te
|
||||
}
|
||||
// The router performs nothing: Details is shown where it was chosen, and the condition's own actions
|
||||
// are never called from here (novox/hq ADR 0259) — the controller asks for them.
|
||||
outcome, err := h.Chosen("desktop", choiceOf(tok, "g14", c.now()))
|
||||
outcome, err := h.Chosen("desktop", choiceOf(tok, "node-b", c.now()))
|
||||
done := dt.sends[len(dt.sends)-1]
|
||||
if err != nil || outcome != "shown" || len(asked) != 0 || done.Title != "Details: "+e.headline {
|
||||
t.Fatalf("details: %q %v %v %q", outcome, err, asked, done.Title)
|
||||
@@ -230,7 +230,7 @@ func TestRealNotificationsReadInOneGlanceAndAreAnsweredFromTheNotification(t *te
|
||||
h.Condition(EventCleared, cleared)
|
||||
c.pass(ClearSettle)
|
||||
h.Tick()
|
||||
end := dt.edits["g14=1"]
|
||||
end := dt.edits["node-b=1"]
|
||||
if end.Title != e.cleared || end.Body != "" || len(end.Actions) != 0 {
|
||||
t.Errorf("clearance %q / %q / %v, want one line %q", end.Title, end.Body, end.Actions, e.cleared)
|
||||
}
|
||||
@@ -275,7 +275,7 @@ func TestDetailsAreShownOnTheMachineThatAsked(t *testing.T) {
|
||||
if details.Label != DetailsLabel {
|
||||
t.Fatalf("%+v", m.Actions)
|
||||
}
|
||||
if _, err := h.Chosen("desktop", choiceOf(details.Token, "g14", c.now())); err != nil {
|
||||
if _, err := h.Chosen("desktop", choiceOf(details.Token, "node-b", c.now())); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
shown := dt.sends[len(dt.sends)-1]
|
||||
@@ -283,7 +283,7 @@ func TestDetailsAreShownOnTheMachineThatAsked(t *testing.T) {
|
||||
!strings.Contains(shown.Body, "Since: 8 Oct 10:40") {
|
||||
t.Errorf("details: %q / %q", shown.Title, shown.Body)
|
||||
}
|
||||
if _, err := h.Chosen("desktop", choiceOf("not-a-token", "g14", c.now())); err == nil {
|
||||
if _, err := h.Chosen("desktop", choiceOf("not-a-token", "node-b", c.now())); err == nil {
|
||||
t.Error("an unknown answer was taken")
|
||||
}
|
||||
}
|
||||
@@ -292,11 +292,11 @@ func TestDetailsAreShownOnTheMachineThatAsked(t *testing.T) {
|
||||
func TestAConditionWithoutPlainWordsIsSaidFromItsSummary(t *testing.T) {
|
||||
h, tg, _, c, _ := newHolder(t)
|
||||
h.Zone = func() *time.Location { return time.UTC }
|
||||
k := Condition{Key: "machine.ace.silent", Scope: "machine", ID: "ace", Kind: "silent", Severity: Urgent,
|
||||
Summary: "ace has not been heard from: `push ace` sends it again", Raised: c.now()}
|
||||
k := Condition{Key: "machine.node-a.silent", Scope: "machine", ID: "node-a", Kind: "silent", Severity: Urgent,
|
||||
Summary: "node-a has not been heard from: `push node-a` sends it again", Raised: c.now()}
|
||||
h.Condition(EventRaised, k)
|
||||
m := tg.sends[0]
|
||||
if m.Title != "Urgent: Silent on ace" || m.Body != "Ace has not been heard from: a command sends it again\nSince 12:00.\nNo delivery running." {
|
||||
if m.Title != "Urgent: Silent on node-a" || m.Body != "Node-a has not been heard from: a command sends it again\nSince 12:00.\nNo delivery running." {
|
||||
t.Errorf("%q / %q", m.Title, m.Body)
|
||||
}
|
||||
keyless(t, m)
|
||||
|
||||
Reference in New Issue
Block a user