Say a unit's restart count is its whole life, not since its state began
The count comes from systemd's NRestarts or the runtime's restart count; beside "since" it read as thousands of restarts tonight (novox/hq issue 458).
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/novox/mesh-controller/internal/inventory"
|
||||
"github.com/novox/mesh-controller/internal/link"
|
||||
)
|
||||
|
||||
// A restart count runs over the unit's whole life, so it is never said beside "since" as if it counted from
|
||||
// there (novox/hq issue 458): 3890 restarts beside "since 00:58" sent a reader after a crash loop that was not.
|
||||
func TestARestartCountSaysItIsTheWholeLife(t *testing.T) {
|
||||
since := time.Date(2026, 10, 11, 0, 58, 0, 0, time.UTC)
|
||||
r := inventory.ResourceHealth{Module: "messenger", Resource: "messenger.own-runtime", Kind: "process",
|
||||
Target: "messenger-runtime.service", State: link.StateUnhealthy, Reason: "restarting", Since: since,
|
||||
Streak: 2, Restarts: 3890}
|
||||
h := inventory.NodeHealth{HeardAt: since, Resources: []inventory.ResourceHealth{r},
|
||||
Streaks: map[string]int{"messenger": 2}}
|
||||
lines := strings.Join(healthLines(h, true, since.Add(time.Minute)), "\n")
|
||||
o := moduleUnhealthyObservation("messenger", "anchor", []inventory.ResourceHealth{r})
|
||||
for name, said := range map[string]string{"node show": lines, "evidence": o.Said, "summary": o.Summary} {
|
||||
if !strings.Contains(said, "3890 restart(s) over its whole life") || strings.Contains(said, "counted") {
|
||||
t.Errorf("%s says the restart count as if it were since then:\n%s", name, said)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user