Repository navigation
Description
Parent EPIC: #2392
Goal
A test that needs persistence gets its SQLite database from a factory that also returns a guard. The guard owns the database's directory and removes it on drop, on success, failure and drop paths. This issue adds the guard and the factory next to the existing ephemeral*() functions of torrust-tracker-test-helpers. It is the foundation for the migration issue, #2925.
Background
torrust_tracker_test_helpers::configuration::ephemeral_sqlite_database() only builds a path, <temp dir>/data_<random>.db. The tracker creates the file when it first opens the database, and nothing removes it. One full test run left 301 such files in a fresh TMPDIR (#2907, #2394 finding F2).
The fix was first part of #2907. Its design step showed it is larger than one issue: about 100 tests need persistence and about 278 call sites use the ephemeral*() configurations. The maintainer split it into this issue and #2925.
PR #2923 (#2902) fixes the same leak inside packages/tracker-core with a wrapper struct that keeps the configuration and its TempDir together. This issue reuses that shape for the shared helpers and starts after that PR merges.
Approach
- Add a guard type that owns a
tempfile::TempDirholding the database file, and a factory that returns a configuration with SQLite persistence together with its guard. The test keeps the guard for its whole body. - The guard is independent of the test environment, because some tests start a second environment on the same database to simulate a restart.
- Convert the helpers outside
tracker-corethat callephemeral_sqlite_database()directly. - Leave the existing
ephemeral*()functions unchanged; the migration issue moves their callers.
Tasks
- Decide the names and the return shape with the maintainer.
- Add the guard type and the factory, with unit tests that prove the directory is removed on drop.
- Convert the direct users outside
tracker-core. - Recheck: the converted helpers leave no
data_*.dbfile.
The full specification is added to docs/issues/open/ by a spec-only pull request.
Activity
docs(issues): [torrust#2902] name the issues that take the shared SQL…
docs(issues): [torrust#2902] give the F5 split its original reason
docs(issues): [torrust#2392] keep torrust#2907's leak table in scope …
docs(issues): [torrust#2392] state torrust#2924's AC3 as one invarian…
Merge #2923: test(tracker-core): [#2902] keep each test database in a…
docs(issues): [#2392] add issue specifications for #2924 and #2925
Merge #2926: docs(issues): [#2392] split #2907 and add #2924 and #2925 …
Merge #2938: test(configuration, axum-server): [#2907] remove the TOM…
chore(issues): archive closed issue #2907 spec to docs/issues/closed
Merge #2947: chore(issues): [#2907] archive the spec and mark order 7…
docs(issues): [torrust#2924] rerun V1 with stamped steps and address …
docs(issues): [torrust#2924] embed the V1 script in the evidence file
docs(issues): [torrust#2924] export TMPDIR in the V1 row and create .…
docs(issues): [#2924] record the T1 design decision and the V1 reprod…
Merge #3011: docs(issues): [#2924] record the T1 design decision and …
1 remaining item
test(http-core): [torrust#2924] build the missing database path insid…
feat(test-helpers): [torrust#2924] add the SQLite database guard and …
test(http-core): [torrust#2924] build the missing database path insid…
docs(pr-reviews): [torrust#2924] record the audit of review round 1 o…
docs(issues): [torrust#2924] record the completion review decision in…
docs(pr-reviews): [torrust#2924] record the audit of review round 2 o…
chore(issues): archive closed issue #2924 spec to docs/issues/closed
Merge #3035: chore(issues): archive closed issue #2924 spec to docs/i…
Merge torrust#3029: feat(test-helpers): [torrust#2924] add a guard-ow…
docs(issues): [#2392] mark order 9 (#2924) done
Merge #3045: docs(issues): [#2392] mark order 9 (#2924) done
Merge #3066: docs(issues): [#2392] mark AC1 done
Merge #3067: docs(issues): [#2925] record the T1 reproduction and cla…