73efb091d9
gates / gates (push) Successful in 9s
appbackup's path helpers take a NAMESPACE ROOT. Five call sites passed a bare DRIVE path.
On an enrolled drive the two coincide, so nothing showed; on the system-data fallback they
differ by exactly the felhom-data segment, and the app then bound a directory the off-site
capture set never looked at -- while the run reported ok. Measured live on demo-hp: the app
wrote to /mnt/sys_drive/userdata/media/books, the capture set looked for
/mnt/sys_drive/felhom-data/userdata/media/books.
THE RULE NOW HAS ONE EXPRESSION. appbackup.NamespaceRootFor / IsEnrolledDrive encode the
drive-kind comparison; backup.Manager.namespaceRoot and stacks.Manager.inGuest delegate to
it. There were already TWO copies and they differed -- the backup package's compared without
filepath.Clean, the stacks package's with it, so a trailing slash from config would have
flipped the mode in one and not the other.
Sites routed through it:
- stacks/deploy.go withPathVars -> ${USERDATA_PATH} (the live defect)
- appexport/fabplan.go + export.go (via a new provider method)
- web/handlers.go FileBrowser mounts (latent: the system drive is
deliberately never a registered StoragePath, so this is the identity today)
ComputeFabBuckets now receives the namespace root, which is what ComputeCaptureSet has always
received -- so the export's classified paths and the backup's capture set describe the same
directories by construction instead of by coincidence.
Tests are table-driven over BOTH drive kinds, because this survived by being invisible on the
kind that already worked. Red-proofs observed: restoring the bare-path call fails the
system-drive row with the two paths differing by /felhom-data; inverting the drive-kind
comparison fails every enrolled row.
61 lines
2.3 KiB
Go
61 lines
2.3 KiB
Go
package stacks
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/appbackup"
|
|
)
|
|
|
|
// R-203 Scenario A/B — what the DEPLOY sets as ${USERDATA_PATH}, table-driven over both drive kinds.
|
|
// This is the site the drill caught: on the system-data fallback the app bound a directory the
|
|
// off-site capture set never looked at, and the run still reported ok.
|
|
func TestWithPathVars_UserdataRootByDriveKind(t *testing.T) {
|
|
const sys = "/mnt/sys_drive"
|
|
const importRoot = "/mnt/sys_drive/felhom-data/userdata/import"
|
|
cases := []struct{ name, hdd, want string }{
|
|
// Scenario B — enrolled drives: BYTE-IDENTICAL to pre-R-203.
|
|
{"enrolled usb", "/mnt/felhom-usb", "/mnt/felhom-usb/userdata"},
|
|
{"enrolled hdd", "/mnt/felhom-drives/hdd_1", "/mnt/felhom-drives/hdd_1/userdata"},
|
|
// Scenario A — the system-data fallback: the canonical namespace root, which is what the
|
|
// skeleton builder creates and what the capture set resolves against.
|
|
{"system drive", "/mnt/sys_drive", "/mnt/sys_drive/felhom-data/userdata"},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
got := withPathVars([]string{"DOMAIN=x"}, tc.hdd, sys, importRoot)
|
|
want := "USERDATA_PATH=" + tc.want
|
|
for _, e := range got {
|
|
if e == want {
|
|
return
|
|
}
|
|
}
|
|
var actual string
|
|
for _, e := range got {
|
|
if strings.HasPrefix(e, "USERDATA_PATH=") {
|
|
actual = e
|
|
}
|
|
}
|
|
t.Fatalf("USERDATA_PATH = %q, want %q — the app would bind a directory the backup does not capture", actual, want)
|
|
})
|
|
}
|
|
}
|
|
|
|
// The deploy-time bind and the backup-time capture root must be the SAME directory. Asserted against
|
|
// the resolver the off-site capture set actually uses, so the two cannot drift apart again silently.
|
|
func TestDeployBindMatchesCaptureRoot(t *testing.T) {
|
|
const sys = "/mnt/sys_drive"
|
|
for _, hdd := range []string{"/mnt/felhom-usb", "/mnt/felhom-drives/hdd_1", "/mnt/sys_drive"} {
|
|
var bind string
|
|
for _, e := range withPathVars(nil, hdd, sys, "") {
|
|
if strings.HasPrefix(e, "USERDATA_PATH=") {
|
|
bind = strings.TrimPrefix(e, "USERDATA_PATH=")
|
|
}
|
|
}
|
|
captureRoot := appbackup.UserdataDir(appbackup.NamespaceRootFor(hdd, sys))
|
|
if bind != captureRoot {
|
|
t.Fatalf("drive %q: deploy binds %q, backup captures %q", hdd, bind, captureRoot)
|
|
}
|
|
}
|
|
}
|