fix(tests): test-created devices and fixture dirs now meet the cleanup contract
Test suites that attach devices to the SHARED admin (testuser, the live
dev account) escaped the harness sweeps whenever their names lacked
"test": createContractDeviceNamed named its devices by surface type
("koreader" — the web progress push adopts the device name as sync
source, so conflict tests drive a second named source without a
separate account), the reinstall regression test uses the web flow's
real "Reinstall Device" label, and opds_test.go's folders test named
its device "OPDS Folders Device". None had self-cleanup either, so
every suite run left 3 more rows on the dev account's device grid —
476 by the time anyone looked. TestDeviceSetup.CreateDevice also never
cleanup-registered, so any CURRENT or future helper-created device was
one rename away from the same leak.
Changes:
- TestDeviceSetup.CreateDevice self-deletes its row at test end
(t.Cleanup): callers owe nothing to name hygiene any more.
- createContractDeviceNamed self-deletes likewise (contract-% prefix).
- device_test.go: core via cleanupDeviceByIdentifier on every device it
attaches to the admin ("Reinstall Device" by unique identifier —
the NAME is user-facing-labeled, sweeps must never torch it).
- Harness setup-time admin-device sweep gains the unambiguous harness
patterns (dev_contract_* tokens, contract-%/opds-%/repro-reinstall-%
identifiers) as the drift net; ran once with the rebuilt tests image
and that sweep alone already purged the existing 476 rows.
- metadata_write_test.go now globs ALL test-metadata-write-* dirs in
its RemoveAll instead of only its own pid's — killed runs left root-
owned dirs on the user's uploads bind mount (7 found, deleted).
audits: collections/saved-filters/libraries/sync_queue are clean;
the only "test"-named media rows left are scans of the user's own
on-disk test files (Test/, Bookhoard Test/, embedded " test" in two
real books' metadata) — content, not suite debris.
Verified: filtered runs (contract/OPDS/reinstall/pairing/metadata)
green, zero device residue after the run, uploads mount clean.
This commit is contained in:
1 parent
0c31e9b88d
commit
7d88ec5184
5 files changed
+68
-4
No files matched your search
@@ -438,7 +438,15 @@ func TestMetadataWriteToFile(t *testing.T) {
|
||||
assert.Equal(t, "Comic Series", series)
|
||||
})
|
||||
|
||||
// Sweep ALL generations of the fixture dirs, not just this
|
||||
// process's: a killed run never reaches its RemoveAll, and the stale
|
||||
// root-owned dirs then sit on the user's bind mount forever (seven
|
||||
// of them were found in uploads/ in Nov 2026, one per past run —
|
||||
// each surviving run's cleanup skipped them by pid).
|
||||
matches, _ := filepath.Glob(filepath.Join(uploadsDir, "test-metadata-write-*"))
|
||||
t.Cleanup(func() {
|
||||
_ = os.RemoveAll(filepath.Join(uploadsDir, fmt.Sprintf("test-metadata-write-%d", os.Getpid())))
|
||||
for _, dir := range matches {
|
||||
_ = os.RemoveAll(dir)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user