agent v0.36.0: guest boot-id on /disks (deterministic guest-reboot recreate)
GET /disks emits guest_boot_id = <host-btime>-<guest-init-starttime>: changes on every guest/host boot, stable across controller-only restarts. The controller persists it + deterministically recreates drive-backed apps on change (replaces the timed state-sample). Non-hollow parser test + companion. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,23 @@ import (
|
||||
"gitea.dooplex.hu/admin/felhom-agent/internal/storage"
|
||||
)
|
||||
|
||||
// TestStarttimeFromStat parses field 22 (starttime) from a /proc/<pid>/stat line whose comm contains
|
||||
// spaces AND an inner ')' — the case naive whitespace-splitting (or split-on-FIRST-')') mis-parses.
|
||||
//
|
||||
// COMPANION GUARD: a pre-fix impl that splits the whole line on whitespace reads the wrong field (the
|
||||
// multi-token comm shifts every index); one that splits on the FIRST ')' splits inside the comm. Both
|
||||
// return != "9988776655" here.
|
||||
func TestStarttimeFromStat(t *testing.T) {
|
||||
// pid=42, comm="(weird ) name)" (spaces + an inner ')'), state 'S', then fields; field 22 = 9988776655.
|
||||
stat := "42 (weird ) name) S 1 42 42 0 -1 4194560 100 0 0 0 5 6 0 0 20 0 1 0 9988776655 12345 67 1 1 1 0 0 0 0\n"
|
||||
if got := starttimeFromStat(stat); got != "9988776655" {
|
||||
t.Fatalf("starttimeFromStat = %q, want 9988776655 (comm with spaces+')' must not break the parse)", got)
|
||||
}
|
||||
if got := starttimeFromStat("garbage no parens"); got != "" {
|
||||
t.Fatalf("malformed stat should yield \"\", got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStablePathForRaw_DriveName(t *testing.T) {
|
||||
cases := []struct {
|
||||
where, name, stable string
|
||||
|
||||
Reference in New Issue
Block a user