Skip to content

feat(test-helpers): [#2924] add a guard-owned SQLite test database - #3029

Merged
josecelano merged 2 commits into
torrust:developfrom
josecelano-bot:2924-2392-sqlite-test-database-guard
Nov 24, 2026
Merged

josecelano merged 2 commits into
torrust:developfrom
josecelano-bot:2924-2392-sqlite-test-database-guard

Conversation

@josecelano-bot

Copy link
Copy Markdown
Contributor

Closes #2924. Part of EPIC #2392.

Summary

Adds a guard-owned SQLite test database to torrust-tracker-test-helpers and converts the one direct caller outside tracker-core.

  • SqliteDatabaseGuard owns a temporary directory for a test's SQLite file and deletes it on drop, even when the test panics. It is independent of any test environment, so a restart test can share one guard between two environments. The doc comment explains why the type is called a "guard" (RAII guard idiom).
  • ephemeral_with_sqlite_database() -> (Configuration, SqliteDatabaseGuard) returns a configuration pointing at the guard's database file.
  • ephemeral() and the other ephemeral*() functions are unchanged. ephemeral_sqlite_database() stays until Move tests to the guard-owned SQLite database and default to no database #2925. tracker-core keeps its own wrappers.
  • The http-core test it_should_panic_when_the_configured_database_cannot_be_initialized now builds its never-created path inside a guard directory.

Files and packages

  • packages/test-helpers: src/configuration.rs (guard, factory, 6 unit tests) and Cargo.toml (tempfile).
  • packages/http-core/src/container.rs: the converted test.
  • docs/issues/open/2924-2392-sqlite-test-database-guard/: spec progress (T3 to T5, V2) and manual-verification-evidence.md (T3 red check, design approval, V2).

Validation

  • cargo test -p torrust-tracker-test-helpers: 8 tests pass. Red check by mutation: pointing the factory at ephemeral_sqlite_database() made the two factory tests fail.
  • cargo test -p torrust-tracker-http-core: the converted test passes.
  • V2: the same steps as V1 (fresh TMPDIR, cargo +stable test -p torrust-tracker-http-core --all-targets --all-features, count data_*.db) still count 6 files. This is expected: T2 found the converted caller never created a file, and the 6 files come from the ephemeral*() configurations, which are out of scope (Move tests to the guard-owned SQLite database and default to no database #2925). The cleanup behaviour is covered by the guard's unit tests.
  • Pre-commit gate (including linter all) passes.

🤖 Generated with Claude Code

josecelano-bot and others added 2 commits November 24, 2026 13:37
…its factory

SqliteDatabaseGuard owns a temporary directory for a test's SQLite file and
removes it on drop, even when the test panics.
ephemeral_with_sqlite_database() returns a configuration pointing at that
file together with the guard. ephemeral() and the other ephemeral*()
functions are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…e a guard directory

The only direct caller of ephemeral_sqlite_database() outside tracker-core now
derives its never-created path from a SqliteDatabaseGuard directory. V2 recheck
and the T3 design approval are recorded in the spec evidence.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c2fd21c7-7336-4536-81cd-e8fdfbf78740
Commits

Reviewing files that changed from the base of the PR and between afe4862 and b6b4fc4.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 5

  • docs/issues/open/2924-2392-sqlite-test-database-guard/ISSUE.md
  • docs/issues/open/2924-2392-sqlite-test-database-guard/manual-verification-evidence.md
  • packages/http-core/src/container.rs
  • packages/test-helpers/Cargo.toml
  • packages/test-helpers/src/configuration.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@josecelano

Copy link
Copy Markdown
Member

ACK b6b4fc4

@josecelano
josecelano merged commit aea341d into torrust:develop Nov 24, 2026
25 checks passed
josecelano pushed a commit that referenced this pull request Nov 24, 2026
Issue #2924 is closed on GitHub (PR #3029 merged). Moves its spec folder to
docs/issues/closed/, marks it done, ticks the checkpoints and acceptance
criteria with their evidence, and repairs the live links to it in EPIC #2392
(links only) and in the #2907 and #2925 specs.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
josecelano added a commit that referenced this pull request Nov 25, 2026
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
@da2ce7

da2ce7 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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: All 119 executable lines it added are tests, benchmarks or test support with no production behaviour, and 119 of them are still present.

This branch was previously deployed

1 inactive deployment
coverage — b6b4fc46 Deployed Nov 24, 2026 by josecelano-bot via Generate Coverage Report #3455
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a guard-owned SQLite test database

3 participants