Repository navigation
test(tracker-core): [#2902] keep each test database in a temporary directory - #2923
josecelano merged 15 commits into
Conversation
…temporary directory The shared unit-test configurations put their SQLite file under the system temporary directory and nothing removed it, so every run left dozens of data_*.db files behind (finding F5). ephemeral_configuration() and ephemeral_configuration_for_listed_tracker() now return an EphemeralConfiguration whose private TempDir removes the database when the test drops it, also after a panic; ephemeral_tracker_configuration() does the same for the shared full configurations. The test owns the value: helpers that open a database take the configuration by reference. Adds tempfile as a dev-dependency (the workspace's 3.27.0). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e in a temporary directory The integration fixture now returns an EphemeralConfiguration whose TempDir removes the SQLite database when the test ends (finding F5). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ase helpers The SQLite driver, schema migrator and persisted key repository tests had their own copies of the leaking helper (finding F5). The driver and key repository tests use the shared EphemeralConfiguration; the schema migrator's new_pool() returns its TempDir with the pool. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…se fix The plan of the F5 fix (decisions, the early-drop probe and the 0-file result), F5 marked fixed, Q7 answered, the ownership map updated and a progress log entry. Split from S1 because torrust#2907 plans the same fix for the shared test-helpers function. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
No open issues 🎉
What changed in this PR
Updates torrust-tracker-core test fixtures to ensure each test’s SQLite database is created inside a per-test temporary directory that is automatically cleaned up, preventing /tmp database-file leaks (related to #2902 / #2907).
Changes:
- Introduces
TempDir-guarded ephemeral configuration wrappers so tests own the cleanup lifetime. - Refactors unit and integration tests to keep the guard value alive for as long as the database is in use.
- Adds
tempfileas a dev-dependency and documents the plan/spec for this refactor.
| File | Description |
|---|---|
| packages/tracker-core/tests/integration.rs | Keeps an EphemeralConfiguration guard alive for integration tests using SQLite. |
| packages/tracker-core/tests/common/fixtures.rs | Adds TempDir-owned EphemeralConfiguration for integration-test fixtures. |
| packages/tracker-core/src/whitelist/test_helpers.rs | Exposes a listed_tracker() fixture that returns a tempdir-guarded tracker configuration. |
| packages/tracker-core/src/whitelist/repository/persisted.rs | Refactors tests to pass &Core and retain the ephemeral guard. |
| packages/tracker-core/src/whitelist/mod.rs | Updates whitelist module tests to use the new guarded fixture pattern. |
| packages/tracker-core/src/whitelist/manager.rs | Updates manager tests to retain guarded config while exercising persisted storage. |
| packages/tracker-core/src/torrent/manager.rs | Refactors torrent manager tests to keep ephemeral database directories alive. |
| packages/tracker-core/src/test_helpers.rs | Introduces EphemeralConfiguration / EphemeralTrackerConfiguration with TempDir guards and helper constructors. |
| packages/tracker-core/src/statistics/persisted/downloads.rs | Updates stats repository tests to use &Core and keep ephemeral guard alive. |
| packages/tracker-core/src/statistics/event/listener.rs | Refactors listener tests to keep tempdir guard alive while DB-backed repository is used. |
| packages/tracker-core/src/statistics/event/handler.rs | Refactors handler tests to keep tempdir guard alive while DB-backed repository is used. |
| packages/tracker-core/src/lib.rs | Updates tracker tests to use guarded tracker configuration fixtures. |
| packages/tracker-core/src/databases/setup.rs | Updates database setup tests to retain ephemeral configuration guard. |
| packages/tracker-core/src/databases/driver/sqlite/schema_migrator.rs | Makes schema migrator tests use a TempDir guard tied to pool lifetime. |
| packages/tracker-core/src/databases/driver/sqlite/mod.rs | Removes private temp-path helper; reuses shared guarded ephemeral_configuration(). |
| packages/tracker-core/src/container.rs | Updates container tests to keep ephemeral guard alive while persistence is used. |
| packages/tracker-core/src/authentication/mod.rs | Refactors authentication tests to use guarded tracker configuration fixtures. |
| packages/tracker-core/src/authentication/key/repository/persisted.rs | Removes private temp-path helper; reuses guarded ephemeral_configuration(). |
| packages/tracker-core/src/authentication/handler.rs | Refactors handler tests to use guarded tracker configuration fixtures. |
| packages/tracker-core/src/announce_handler.rs | Updates announce handler tests to use guarded tracker configuration fixtures. |
| packages/tracker-core/Cargo.toml | Adds tempfile as a dev-dependency for test-only temp directory management. |
| docs/issues/open/2902-1347-add-tests-tracker-core/test-refactor-plans/test-support-ephemeral-database-tests.md | Adds a detailed test plan/spec for the ephemeral DB refactor. |
| docs/issues/open/2902-1347-add-tests-tracker-core/ISSUE.md | Updates the issue spec to mark F5 as fixed and records implementation details. |
Review effort: Lite
There was a problem hiding this comment.
Reviewed at 35efb4af5259da8b0351eaa335b1be64ba5f006a. Recomputed from the bytes at this head, against the merge base a14a41ad4; git merge-tree against develop a14a41ad4 is clean and yields this head's own tree.
Process: a test-support change with issue-spec updates, held to write-unit-test (lifecycle fixture review), add-rust-dependency, commit-changes, open-pull-request, write-markdown-docs and the spec's own per-file workflow for test-refactor-plans/.
The change against its claim: every test in tracker-core that opens SQLite now takes its path from a TempDir the test owns: EphemeralConfiguration and EphemeralTrackerConfiguration in src/test_helpers.rs, a separate EphemeralConfiguration in tests/common/fixtures.rs, and new_pool() returning its directory. Each guard is bound before the handlers that use it, so it drops last; ephemeral_sqlite_database has no caller left in the package, and the shared configurations only compose a path, so replacing it creates no file. Every Rust hunk sits in a #[cfg(test)] module or under tests/. Static recount: 157 unit tests, 61 of which create a temporary database, plus 11 of the 12 integration tests (one sets database = None): 72, as claimed.
Consistency: the plan link and the per-file-workflow anchor resolve; the plan's related artifacts exist; tempfile 3.27.0 is the version the workspace already locks, so Cargo.lock gains no package; no removed helper name survives anywhere in the tree; both frontmatters pass the validator's logic (permissive file-test-plan, strict issue); the only added word absent from the base tree is "misuse".
Hygiene: four Conventional subjects with [#2902], bodies match their diffs, author equals committer on each. Each commit carries an attribution footer and the description ends with a generated-with line; no rule in the tree forbids either. git diff --check is clean, the commit-id check prints nothing, and no closing keyword appears in the title, the description or the commits.
Findings: F1 (Minor) the plan's E1 row says 167 unit tests; F2 (Minor) the findings register's lead sentence still says none is fixed; F3 (Nit) T2b stays TODO; F4 (Nit) "This PR" loses its referent after merge. None blocks.
Checked, no finding: drop order in every changed test; #[must_use] and # Panics on the new public helpers; added Rust lines within max_width; nothing recreates the removed directory, so an early drop fails instead of leaking.
Checks
On the loop's compute node at this head, against the merge base a14a41ad4 (receipt server-gates-kranich-1119): the repository's pre-commit gate and lint roster exit 0 (452 s wall). This PR carries no audit record of its own, so the gate ran no validator for it. In a fresh per-PR target directory, cargo test --workspace passes 4205 tests with 0 failed and 5 ignored across 121 binaries (266 s wall), and cargo clippy --workspace --all-targets --all-features -- -D warnings is clean (44 s wall). cargo deny check exits 5 for the same license rejections and advisories as develop (RUSTSEC-2023-0071 for rsa, libsqlite3-sys, astral-tokio-tar and RUSTSEC-2026-0543 for chrono); the lockfile change is one line, tempfile added to the dependency list of torrust-tracker-core, with no new package, so this pull request changes nothing in that result. F1 checked against the bytes at posting: packages/tracker-core/src carries 157 test attributes at this head, and line 77 of the plan says 167 unit tests. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Package Coverage Regression: completed/success; Package Coverage (torrust-tracker-core): completed/success; Test (Docker) (release): in_progress/pending; Persistence Benchmark SQLite3: completed/success; Docker E2E: completed/skipped; Persistence Benchmark PostgreSQL: completed/success; Persistence Benchmark MySQL: completed/success; Unit (stable): in_progress/pending; Shipped Features: completed/success; Layer Boundary Bans: completed/success; Unit (nightly): in_progress/pending; Workspace Packaging: completed/success; Documented Clippy Allows: completed/success; Docs Lint: completed/success; Discover Package Coverage: completed/success; Generate Coverage Report: completed/success; Database Compatibility PostgreSQL (15): completed/success; Database Compatibility PostgreSQL (14): completed/success; Database Compatibility PostgreSQL (17): completed/success; Database Compatibility MySQL (8.0): completed/success; Database Compatibility MySQL (8.4): completed/success; Database Compatibility PostgreSQL (16): completed/success; Build on macos-latest (nightly): queued/pending; Build on macos-latest (stable): completed/success; Build on ubuntu-latest (nightly): completed/success; Build on ubuntu-latest (stable): completed/success; Build on windows-latest (nightly): completed/success; Build on windows-latest (stable): completed/success". At posting, develop is a14a41ad4.
|
ACK 35efb4a — every SQLite database a tracker-core test opens now lives in a temporary directory the test owns, with the 61 unit and 11 integration databases recounted at this head |
The package has 157 unit tests on this branch, as the results and the spec say; 167 was the count on the S1 branch (review finding F1 of torrust#2923). Co-Authored-By: Claude Opus 5.5 <[email protected]>
F5 is now fixed, so "none is fixed in this issue" contradicted its row (review finding F2 of torrust#2923). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The SQLite half of the checkpoint is recorded as approved, so the implementation plan row now says so (review finding F3 of torrust#2923). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…atabase split "This PR" lost its referent after the merge; the plan now names torrust#2923 and records that the SQLite part of torrust#2907 moves to a new torrust#2392 subissue (review finding F4 of torrust#2923). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rust#2923 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
ACK 35efb4a |
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at d0374dcc22d4e247f177e14dfd10d3ab7a0edf85. Recomputed from the bytes at this head, against the merge base a14a41ad4; git merge-tree against develop a14a41ad4 is clean and yields this head's own tree.
Process: since 35efb4af5 the branch moved by a fast-forward of five documentation commits, four fixes and the review audit record, held to process-pr-review. The Rust sources, the manifests and the lock file are unchanged since round 1.
The change against its claim: each fix does what its subject says. F1: the E1 row says 157 and the plan holds no "167". F2: the register's lead sentence now defers to each row's status. F3: T2b is IN_PROGRESS and links the plan as its approved SQLite half; the link and the anchor resolve. F4: the plan names #2923. The spec's own register finding F5 stays FIXED and still holds at this head.
Audit record: four rows, one per round 1 finding; severities equal the inline brackets, each reply sits on its own thread, every resolution reference is a subject on this branch and the log is chronological. The validator's logic, run offline against the capture, reports ok with 0 failures. Its account agrees with the capture: four replies between 18:34:42 and 18:34:49 UTC, all four threads resolved, and the bot overview review carries no inline comment. Its four current-tree checks reproduce.
Hygiene: Conventional subjects with [#2902], bodies match their diffs, author equals committer; each new commit carries the same attribution footer as in round 1, which no rule in the tree forbids. git diff --check is clean, the commit-id check prints nothing, no closing keyword appears in the description or the commits, and the description is unchanged since round 1.
Findings: F6 (Nit) the F4 fix names no subissue, and the spec and the description still say #2907 carries the shared fix. None blocks.
Checked, no finding: the record's sections match the recent audit records; no added word is absent from the base tree.
Checks
On the loop's compute node at this head, against the merge base a14a41ad4 (receipt server-gates-kranich-1127): the repository's pre-commit gate and lint roster exit 0 (445 s wall), and the audit validator passes the new record (4 rows, 2 log entries, 0 failures). No Rust source, manifest or lock file changed since 35efb4af5, where round 1's workspace run passed 4205 tests with 0 failed and clippy was clean, so those results still hold. F1's fix checked against the bytes at posting: the plan no longer contains "167". The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "". At posting, develop is a14a41ad4.
|
ACK d0374dc — round 1 findings F1 to F4 are fixed in place and the review audit record passes the validator's logic offline at this head |
…ite fix The plan and the spec named torrust#2907 or "a new torrust#2392 subissue" for the shared test-helpers fix; it is torrust#2924 (the guard) and torrust#2925 (the other packages, skipping tracker-core) (review finding F6 of torrust#2923). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rrust#2923 Co-Authored-By: Claude Opus 5.5 <[email protected]>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 597b3029d0d0a35d6c7bbb60b567a785b6d32efc. Recomputed from the bytes at this head, against the merge base a14a41ad4; git merge-tree against develop a14a41ad4 is clean and yields this head's own tree.
Process: since d0374dcc2 the branch moved by a fast-forward of two documentation commits, the F6 fix and the round 2 audit rows, held to process-pr-review. No Rust, manifest or lock byte moved since round 1.
The change against its claim: F6 is fixed. The plan names #2924 (the guard in test-helpers) and #2925 (the other packages, skipping tracker-core) and drops "the #2907 session"; the F5 and Q7 rows of the spec point at them; the description relates to #2924 and #2925 and hands the shared work to them. The timeline's #2926 adds both as EPIC #2392 orders 9 and 10. The 18:04 UTC log entry keeps its original wording, which the append-only log allows. F1 to F4 stay fixed.
Audit record: a fifth row and detail for F6; the severity equals the inline bracket, the reply sits on its own thread, the resolution reference is a subject on this branch, and the log stays chronological. The validator's logic, run offline against the capture, reports ok with 5 rows, 3 log entries and 0 failures. All five threads are resolved, and the record's two current-tree checks for F6 reproduce.
Hygiene: Conventional subjects with [#2902], the fix commit's body matches its diff, author equals committer, and each carries the same attribution footer as before, which no rule in the tree forbids. git diff --check is clean, the commit-id check prints nothing, no closing keyword appears in the description or the commits, and no added word is absent from the base tree.
Findings: F7 (Nit) the F5 row now gives the split a reason that postdates it. Optional; none blocks.
Checks
On the loop's compute node at this head, against the merge base a14a41ad4 (receipt server-gates-kranich-1133): the repository's pre-commit gate and lint roster exit 0 (69 s wall), and the audit validator passes the record (5 rows, 3 log entries, 0 failures). No Rust source, manifest or lock file changed since 35efb4af5, where round 1's workspace run passed 4205 tests with 0 failed and clippy was clean, so those results still hold. F6's fix checked against the bytes at posting: the plan now names #2924 and #2925. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "". At posting, develop is a14a41ad4.
|
ACK 597b302 — round 2 finding F6 is fixed in the plan, the spec and the description, and the review audit record passes the validator's logic offline at this head |
torrust#2924 and torrust#2925 were opened after the split; the reason was torrust#2907's plan, which they now carry out (review finding F7 of torrust#2923). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rust#2923 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
ACK c58f49c |
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
1 open issue
Review effort: Lite
…e configurations they return `public_tracker()`, `private_tracker()`, `private_tracker_with_keys_expiration_check_disabled()` and `listed_tracker()` return an `EphemeralTrackerConfiguration`, not a tracker. Their new names end in `_configuration`, so a call site shows that it holds a configuration whose guard must stay alive. The plan of the temporary-database fix uses the new names. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rrust#2923 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
ACK a94e922 |
… the SQLite drafts PR #2923 (#2902) removes the leaked test databases inside tracker-core with a wrapper struct that owns a TempDir. The two drafts skip that package and reuse its shape; the guard draft starts after it merges. Related to #2392 Co-Authored-By: Claude Fable 5.2 <[email protected]>
…as EPIC orders 9 and 10 9b602fb docs(pr-reviews): [#2392] audit review round 6 of PR 2926 (josecelano-bot) 1307c36 docs(issues): [#2392] exclude any leftover guard directory in #2925 and list the audit rounds (josecelano-bot) 0bea292 docs(pr-reviews): [#2392] audit review round 5 of PR 2926 (josecelano-bot) e0a68ba docs(issues): [#2392] name the leftover guard directory in #2925's AC1 and V2 (josecelano-bot) 8a359fd docs(pr-reviews): [#2392] audit review round 4 of PR 2926 (josecelano-bot) ffcedba docs(issues): [#2392] make #2925's goal depend on #2907 for an empty directory (josecelano-bot) d68ee92 docs(pr-reviews): [#2392] audit review round 3 of PR 2926 (josecelano-bot) 4d54604 docs(issues): [#2392] state #2924's AC3 as one invariant and name what V2 leaves (josecelano-bot) 358363d docs(pr-reviews): [#2392] audit review round 2 of PR 2926 (josecelano-bot) 57e90e0 docs(issues): [#2392] keep #2907's leak table in scope and reword the #2924 guard goal (josecelano-bot) 878d7f5 docs(pr-reviews): [#2392] audit review round 1 of PR 2926 (josecelano-bot) 165dc7b docs(issues): [#2392] align the order 7 title and widen #2925's SQLite leftover check (josecelano-bot) af819fe docs(issues): [#2392] add issue specifications for #2924 and #2925 (josecelano-bot) 2cd147c docs(issues): [#2392] account for the tracker-core fix of PR #2923 in the SQLite drafts (josecelano-bot) ba4593e docs(issues): [#2392] split #2907 and draft two SQLite test database issues (josecelano-bot) Pull request description: ## Summary Spec-only. No code changes. The design step (T2) of #2907 showed that removing the leaked test files is larger than one issue: about 100 tests need persistence, and about 278 call sites use the `ephemeral*()` test configurations. The maintainer split the work into focused subissues of EPIC #2392, and approved the two new specs before their issues were created. - **#2907, narrowed** (`docs/issues/open/2907-2392-remove-leaked-test-temporary-files/ISSUE.md`): keeps the `test_config_*.toml` and PEM files only. The plan is renumbered (the SQLite task left). Its title and body on GitHub are updated. - **#2924, new** (`docs/issues/open/2924-2392-sqlite-test-database-guard/ISSUE.md`): a guard that owns the SQLite test database's directory, and a factory that returns a configuration with its guard, next to the existing `ephemeral*()` functions. - **#2925, new** (`docs/issues/open/2925-2392-migrate-tests-to-guarded-sqlite-database/ISSUE.md`): moves the tests that need persistence to that factory, one pull request per package, then removes the database from `ephemeral*()`. It owns the check that a fresh `TMPDIR` is empty after the suite. Depends on #2924. - **`docs/issues/open/2392-test-isolation/EPIC.md`**: - Orders 9 and 10 for the two new issues; order 7's row is narrowed. - Two maintainer decisions of 2026-11-17: the split, and `ephemeral()` may default to no database with persistence opt-in through a factory that returns a guard. - AC2 now also waits on orders 9 and 10. - AC1 is TODO until the maintainer links #2924 and #2925 as sub-issues. PR #2923 (#2902) fixes the same SQLite leak inside `packages/tracker-core`. Both new specs skip that package and reuse its wrapper shape; #2924 starts after it merges. ## Validation - `linter all` passes, and the pre-commit hook passes on each of the branch's commits. Related to #2392 Related to #2907 Related to #2924 Related to #2925 🤖 Generated with [Claude Code](https://claude.com/claude-code) ACKs for top commit: josecelano: ACK 9b602fb da2ce7: ACK 9b602fb — the five changed documents recomputed against the tree at this head and develop, with the audit record validated offline and the commit-id, closing-keyword and whitespace checks clean Tree-SHA512: 0c9695bcdbaa47a41eb932fc200e6c46864ec5055ba9608dd2d74728e4868762fc5e20f31c21c8f2cdcda6c2d3f844cc2d2db63fb74d3a5b7ca79d07f1de4aa4
9363083 docs(pr-reviews): [#2392] audit review round 4 of PR 3045 (josecelano-bot) 7acac34 docs(pr-reviews): [#2392] restore the rewritten log entries of PR 3045 and name the right head (josecelano-bot) 91b41a7 docs(pr-reviews): [#2392] say the round 3 thread was already resolved (josecelano-bot) 7e81b3e docs(pr-reviews): [#2392] audit review rounds 2 and 3 of PR 3045 (josecelano-bot) f0e99af docs(issues): [#2392] log the attribution change as its own entry (josecelano-bot) d53c9f0 docs(issues): [#2392] say the six-file attribution follows from excluding the direct caller (josecelano-bot) 9d5e905 docs(pr-reviews): [#2392] correct the round 1 log of PR 3045 (josecelano-bot) 6f446d7 docs(issues): [#2392] record order 9 as done in the AC2 evidence (josecelano-bot) e1c4344 docs(pr-reviews): [#2392] audit review round 1 of PR 3045 (josecelano-bot) b27f66c docs(issues): [#2392] scope the recheck count of order 9 to http-core (josecelano-bot) 721d594 docs(issues): [#2392] mark order 9 (#2924) done (josecelano-bot) Pull request description: Syncs the EPIC #2392 spec (`docs/issues/open/2392-test-isolation/EPIC.md`) after #2924 closed. - Order 9 (#2924) is now DONE, with PRs #3011 (spec), #3029 (guard, factory and the `http-core` conversion) and #3035 (close-out). The row no longer says order 9 starts after #2923 merges. - Adds three progress-log entries and records in the AC2 evidence that order 9 is done. They record that the `http-core` recheck still counts 6 `data_*.db` files, which, by elimination of the one direct caller, come from `ephemeral*()` users that order 10 (#2925) moves (no per-test attribution), and that `tracker-core` keeps its own `EphemeralConfiguration` wrappers with no subissue owning their adoption of the shared type yet. - Bumps `last-updated-utc`. AC1 is unchanged: it waits for the maintainer to link #2924, #2925 and #2943 as sub-issues. ## Validation - `linter all` passes. - The pre-commit and pre-push hooks pass. Related to #2392 Related to #2924 🤖 Generated with [Claude Code](https://claude.com/claude-code) ACKs for top commit: josecelano: ACK 9363083 Tree-SHA512: badd1e5997af963bb759cf462392ca964aeb731351eda8eea63f5f6b4b7ff0197715adf7b117e5162ac915ef90d71d31ba3bfcc41fcd7d380028f445385c72a4
|
Post-merge note: this pull request requested a review from this account and was closed without one at its final head. A post-merge review will not be done: Its earlier heads were reviewed, and the only executable change after the last review renames test fixtures in test code, with no production behaviour. |

Related to #2902
Related to #2924
Related to #2925
Stops the
tracker-coretests from leaving SQLite files in the system temporary directory (finding F5 of #2902). Before, onecargo test -p torrust-tracker-core --all-featuresleft 72data_*.dbfiles of about 48 KB in/tmpand never removed them; after, it leaves 0 files and 0 temporary directories. Test code only: no production line changes.This was developed as the first part of slice S1 of #2902 and split into its own PR because #2907 (EPIC #2392, test isolation) planned the same fix for the shared
torrust_tracker_test_helpers::configuration::ephemeral_sqlite_databaseand every package. This PR coverstracker-coreonly and leaves the shared function unchanged. That SQLite work now belongs to #2924 (a guard-owned database intest-helpers) and #2925 (migrating the other packages, skippingtracker-core), which reuse this shape.Shape, approved by the maintainer at the design-review checkpoint of #2902:
test_helpers::tests::EphemeralConfiguration { pub config: Core, _database_directory: TempDir }fromephemeral_configuration()andephemeral_configuration_for_listed_tracker();EphemeralTrackerConfigurationfromephemeral_tracker_configuration(config)moves the database of a shared full configuration (ephemeral_public/private/listed()) into the directory. The integration fixture has its ownEphemeralConfiguration.&Coreor&Configuration, and the test keeps the guard alive. The database isdata.dbinside the directory, so a guard dropped too early makes SQLite fail to open it: a probe that dropped every guard at once failed 26 database tests withunable to open database fileinstead of leaking.tempfile = "3.27.0"as a dev-dependency, the version the workspace already uses.Commits: the shared unit-test fixtures and their callers; the integration fixture; the three private copies of the helper (SQLite driver, schema migrator, persisted key repository); the plan and spec updates (
docs/issues/open/2902-1347-add-tests-tracker-core/test-refactor-plans/test-support-ephemeral-database-tests.md).Validation (stable Rust 1.99.1; formatting with nightly):
cargo test -p torrust-tracker-core --all-features(157 unit, 12 integration, 18 other tests),cargo clippy -p torrust-tracker-core --all-targets --all-features,cargo +nightly fmt --all -- --check,cargo machete --with-metadataand the pre-commit gate pass. The leak count isfind /tmp -maxdepth 1 -name 'data_*.db' -newer <marker>around the test run.🤖 Generated with Claude Code