0d52a42c17
gates / gates (push) Successful in 12s
Nothing ever verified that the off-site copies are still readable. The whole-guest tier has verify jobs; the tier holding the customer's documents and photos had none -- the complete set of restic verbs this controller used contained no `check`. We would have found out at restore time, with a customer waiting. On 2026-08-21 a deliberately damaged pack was caught at once by plain `restic check`; we had never run it. R-397: NotifyIntegrityOK/NotifyIntegrityFailed existed with no caller, the hub allowlists both event types and carries the Hungarian text for both, the settings checkbox exists, and the debug button posts to /api/debug/backup/ integrity. Everything was built except the part that runs. SIXTH instance of that shape in this project. THE HAZARD SHAPES THE WHOLE DESIGN. resticStep self-heals a crash lock by running `unlock --remove-all` and retrying, and its own comment records why that is safe: every caller holds the in-process single-flight mutex, so any lock it meets is stale. A check that did not take that flag could meet a LIVE prune's lock from this same box, remove it, and retry over the top of it. So the check TAKES THE FLAG and SKIPS rather than waits -- waiting would pin the nightly backup behind it, and a skip costs nothing because due-ness makes tomorrow try again. TestR359_SkipsWhenRunningFlagHeld asserts the NON-EFFECTS: restic never invoked, `unlock` never in any argv. Its red-proof prints the real thing -- restic running `check` while the flag was held. DUE-NESS, NOT A WEEKDAY. Daily job, weekly behaviour: "is the last successful check older than 7 days?" not "is it Sunday?". R-341 is exactly the other shape, a dated check quietly missed and never caught up. No Weekly primitive added. THREE OUTCOMES, NOT TWO. Skipped, Unreachable and failed are different facts. "I could not look" is not "I looked and it is broken" -- R-339 already owns reachability, and a second alarm for the same fact trains the operator to discount the one alarm that means the backups are damaged. A timeout is unreachable, never damage. A failure advances due-ness (a broken store must not be re-checked nightly); a skip and an unreachable store do not. Success is severity `info`, which severityNotifies DROPS -- it mails NOBODY, by design. A weekly success e-mail is how people stop reading their alerts. The customer gets a SENTENCE; restic's words go to the log, truncated (R-379: 615 bytes of raw database text reached a customer once). read-data-subset ships OFF and a malformed value is refused at read time rather than handed to restic, where one typo would fail the whole check. Published on OffboxReportStatus, NOT on report.BackupReport's IntegrityOK -- those were retired by R-331 YESTERDAY and TestBackupReport_DeadFieldsStayZero still passes unmodified. Also: the monitoring page stopped promising a Sunday job that never existed, and the debug button got its dispatch case. PART 0 WAS NOT BUILT, AND R-398 WAS MY OWN MISTAKE. The seam it asked for already exists: offboxRunner/SetOffboxRunner/m.runner() has been injectable since the off-site tier shipped, and other tests drive restic-backed paths through it. A resticStepFn seam would have been WORSE here -- it would replace the `unlock --remove-all` escalation and hide it from the assertions that must see it. R-358's AST ordering test is converted to a real execution test instead, which immediately surfaced something the AST walk could not: unlockStale legitimately runs before the restore. Four red-proofs, each printing the pre-fix behaviour. Green gate: 28 packages, rc 0. All 12 controller gates OK.
117 lines
3.6 KiB
Go
117 lines
3.6 KiB
Go
package main
|
|
|
|
import (
|
|
"go/ast"
|
|
"go/parser"
|
|
"go/token"
|
|
"testing"
|
|
)
|
|
|
|
// R-359 — the scheduled job must be PROVEN WIRED.
|
|
//
|
|
// `func main()` cannot be called from a test, so this walks its AST. A `strings.Contains` would not
|
|
// do: a commented-out call still contains the string, and this project has a recorded case of a
|
|
// text-based wiring test passing the very red-proof it existed to fail (2026-07-21).
|
|
//
|
|
// This is the check for the class that has now bitten seven times here — a complete mechanism with no
|
|
// caller. R-397 is one instance (the notifiers), R-400 another (the debug button that posted to
|
|
// nothing). A job that exists and is never registered would be the third in this one release.
|
|
func TestR359_JobIsRegisteredInMain(t *testing.T) {
|
|
body := mainBody(t)
|
|
|
|
var found, named bool
|
|
ast.Inspect(body, func(n ast.Node) bool {
|
|
call, ok := n.(*ast.CallExpr)
|
|
if !ok {
|
|
return true
|
|
}
|
|
sel, ok := call.Fun.(*ast.SelectorExpr)
|
|
if !ok || sel.Sel.Name != "Daily" {
|
|
return true
|
|
}
|
|
if len(call.Args) == 0 {
|
|
return true
|
|
}
|
|
lit, ok := call.Args[0].(*ast.BasicLit)
|
|
if !ok || lit.Kind != token.STRING {
|
|
return true
|
|
}
|
|
if lit.Value == `"offsite-integrity"` {
|
|
found = true
|
|
// The schedule argument must be a literal time, not a variable that could resolve to "".
|
|
if len(call.Args) > 1 {
|
|
if s, ok := call.Args[1].(*ast.BasicLit); ok && s.Kind == token.STRING && len(s.Value) > 2 {
|
|
named = true
|
|
}
|
|
}
|
|
}
|
|
return true
|
|
})
|
|
|
|
if !found {
|
|
t.Fatal("func main() never registers the `offsite-integrity` daily job — the check exists and " +
|
|
"nothing would ever run it, which is the built-but-never-wired class this release closes " +
|
|
"two instances of")
|
|
}
|
|
if !named {
|
|
t.Error("the job is registered without a literal HH:MM schedule")
|
|
}
|
|
}
|
|
|
|
// TestR359_DebugCallbackIsWired pins the other caller. The debug button posted to a route that did not
|
|
// exist for its entire life (R-400); a route that exists but whose callback is nil is the same defect
|
|
// one layer down, and it would answer „Nem bekötött" forever.
|
|
func TestR359_DebugCallbackIsWired(t *testing.T) {
|
|
body := mainBody(t)
|
|
|
|
var wired bool
|
|
ast.Inspect(body, func(n ast.Node) bool {
|
|
as, ok := n.(*ast.AssignStmt)
|
|
if !ok {
|
|
return true
|
|
}
|
|
for _, lhs := range as.Lhs {
|
|
sel, ok := lhs.(*ast.SelectorExpr)
|
|
if ok && sel.Sel.Name == "RunIntegrityCheck" {
|
|
wired = true
|
|
}
|
|
}
|
|
return true
|
|
})
|
|
if !wired {
|
|
t.Fatal("DebugCallbacks.RunIntegrityCheck is never assigned in func main() — the debug route " +
|
|
"would answer „Nem bekötött" + " forever, which is exactly the shape of the button this " +
|
|
"release is fixing")
|
|
}
|
|
}
|
|
|
|
func TestR359_OutcomeMessagesCarryNoMachineDetail(t *testing.T) {
|
|
// The customer gets a sentence; restic's words go to the log. R-379: 615 bytes of raw database
|
|
// text reached a customer once.
|
|
for _, bad := range []string{"sftp:", "restic", "exit status", "@", "/srv/"} {
|
|
if contains(integrityFailedMsg, bad) {
|
|
t.Errorf("the failure sentence carries machine detail %q: %q", bad, integrityFailedMsg)
|
|
}
|
|
}
|
|
// It must still tell them what to do — and what NOT to do.
|
|
for _, want := range []string{"Ne törölj semmit", "vedd fel velünk a kapcsolatot"} {
|
|
if !contains(integrityFailedMsg, want) {
|
|
t.Errorf("the failure sentence is a dead end; missing %q", want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func contains(s, sub string) bool {
|
|
return len(sub) > 0 && len(s) >= len(sub) && (func() bool {
|
|
for i := 0; i+len(sub) <= len(s); i++ {
|
|
if s[i:i+len(sub)] == sub {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
})()
|
|
}
|
|
|
|
var _ = parser.ParseFile
|
|
var _ = token.NewFileSet
|