Skip to content

refactor(axum-http-server): [#2724] gate the test environment behind the testing feature - #2729

Merged
josecelano merged 4 commits into
torrust:developfrom
josecelano-bot:2724-2482-gate-axum-http-server-test-environment
Nov 5, 2026
Merged

josecelano merged 4 commits into
torrust:developfrom
josecelano-bot:2724-2482-gate-axum-http-server-test-environment

Conversation

@josecelano-bot

Copy link
Copy Markdown
Contributor

Summary

Applies ADR rule A (docs/adrs/20261021190318_share_workspace_test_support_through_testing_features.md) to axum-http-server (row 5 of sub-EPIC #2482):

  • src/testing/ is compiled only with the new non-default testing feature.
  • torrust-clock, torrust-info-hash and torrust-tracker-swarm-coordination-registry become optional (direct normal dependencies: 26 to 23).
  • The package enables the feature through a path-only self dev-dependency (with the deny.toml self wrapper); axum-health-check-api-server enables it from its dev-dependencies.
  • New examples/http_only_public_tracker_production_style.rs starts the server the way the application does, without testing; the existing example is labelled as the testing-style one.

Evidence: docs/issues/open/2724-2482-gate-axum-http-server-test-environment/manual-verification-evidence.md (test counts unchanged, shipped features positive and negative, deny, machete, package, nightly check, container recipe with torrust-cargo-chef 0.1.79, shipped binary).

Spec PR: #2725.

Closes #2724

🤖 Generated with Claude Code

josecelano-bot and others added 3 commits November 5, 2026 07:41
…behind the testing feature

Compile src/testing/ only with the non-default `testing` feature (ADR
20261021190318, rule A). torrust-clock, torrust-info-hash and
torrust-tracker-swarm-coordination-registry become optional, used only by
that environment and the unit tests. The package enables the feature
through a path-only self dev-dependency (no version), the health check
package enables it from its dev-dependencies, and deny.toml lists the
crate as its own wrapper.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… and label the testing-style one

The new example composes the containers and starts the server like the
application does, without the testing module, with owned tokens and drop
guards, and separate absolute startup and shutdown deadlines. The existing
example is labelled as following the testing conventions; both headers
explain where they differ.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…k the inventory row resolved

Add manual-verification-evidence.md for the axum-http-server gating
(dependency count 26 to 23, unchanged test counts, shipped features
positive and negative, deny, nightly, package, container recipe, shipped
binary), mark the spec tasks and acceptance criteria done, and mark the
inventory row as resolved by torrust#2724.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
What changed in this PR

Gates axum-http-server’s test environment behind a new non-default testing feature (per ADR rule A) while updating examples and consumer dev-dependencies to opt in explicitly.

Changes:

  • Add testing feature and move select deps (torrust-clock, torrust-info-hash, torrust-tracker-swarm-coordination-registry) behind it as optional.
  • Gate pub mod testing behind #[cfg(feature = "testing")] and enable the feature via dev-dependencies (including a self dev-dependency).
  • Add a new “production-style” example and relabel/document the existing example as “testing-style”; update supporting docs and deny wrapper.
File Description
packages/​axum-http-server/​src/​testing/​mod.rs Updates module docs to reflect compilation behind the testing feature.
packages/​axum-http-server/​src/​lib.rs Gates testing module export behind cfg(feature = "testing").
packages/​axum-http-server/​examples/​http_only_public_tracker_production_style.rs Adds a production-style example that starts/stops the server similarly to the app.
packages/​axum-http-server/​examples/​http_only_public_tracker.rs Updates header docs to clarify this example uses the testing environment.
packages/​axum-http-server/​Cargo.toml Introduces testing feature, makes several deps optional, adds self dev-dep enabling testing.
packages/​axum-health-check-api-server/​Cargo.toml Enables testing feature on the dev-dependency for axum-http-server.
docs/​issues/​open/​2724-2482-gate-axum-http-server-test-environment/​manual-verification-evidence.md Adds manual verification transcript/evidence for the change.
docs/​issues/​open/​2724-2482-gate-axum-http-server-test-environment/​ISSUE.md Marks tasks/ACs as DONE and links new evidence/example.
docs/​issues/​open/​2482-1669-reorganize-shared-test-support/​test-support-inventory.md Updates inventory row to “Resolved by #2724”.
docs/​issues/​open/​2482-1669-reorganize-shared-test-support/​EPIC.md Adds progress log entry noting implementation ready for review.
deny.toml Adds axum-http-server to wrappers list to allow the self dev-dependency.

Review effort: Lite

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain to block approval.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@josecelano

Copy link
Copy Markdown
Member

ACK 2780bc6

@josecelano
josecelano merged commit de4a564 into torrust:develop Nov 5, 2026
23 checks passed
josecelano added a commit that referenced this pull request Nov 5, 2026
…/issues/closed

06aae71 chore(issues): archive closed issue #2724 spec to docs/issues/closed (josecelano-bot)

Pull request description:

  Archives the spec for issue #2724 (closed on GitHub) from `docs/issues/open/` to `docs/issues/closed/`.

  - Verified issue #2724 is `CLOSED` on GitHub (implementation PR #2729 merged)
  - Updated frontmatter (`status: done`, `spec-path`, `related-pr`, `last-updated-utc`) and workflow checkboxes
  - Repaired the links in the #2482 EPIC, the test-support inventory and the #1669 coupling report; marked row 5 of the #2482 EPIC `DONE`
  - Pre-commit hooks passed

  🤖 Generated with [Claude Code](https://claude.com/claude-code)

ACKs for top commit:
  josecelano:
    ACK 06aae71

Tree-SHA512: f406e224e9b6fdbd773a38572d33c8bb0d6fb14994477076a96accf4bf119e4fcfdf0ecaa9310bf36b26954ff63126e93c1b31720bdcfa384b99ff8aec0231c9

@da2ce7 da2ce7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a post-merge review of #2729 as it stands at e170b9620 on the default branch.

What still runs: pub mod testing compiles only with the non-default testing feature (packages/axum-http-server/src/lib.rs:306). torrust-clock, torrust-info-hash and torrust-tracker-swarm-coordination-registry are optional dependencies that only that feature enables (packages/axum-http-server/Cargo.toml:23). The package's own targets get the feature through the path-only self dev-dependency (packages/axum-http-server/Cargo.toml:64), with its self wrapper in deny.toml:42, and axum-health-check-api-server enables it from [dev-dependencies] only (packages/axum-health-check-api-server/Cargo.toml:49). Both examples are byte-identical to the merged head; the server API that the production-style example calls was reworked later, and the example still matches it.

[Minor] The production-style example cannot be built without the testing feature. It imports torrust_tracker_swarm_coordination_registry (packages/axum-http-server/examples/http_only_public_tracker_production_style.rs:66) and calls torrust_clock::initialize_static() (packages/axum-http-server/examples/http_only_public_tracker_production_style.rs:122), and the package reaches both crates only as optional dependencies behind testing. In the workspace the self dev-dependency turns the feature on for every target, so this goes unnoticed. cargo package strips that path-only entry, so in the packaged crate cargo run --example http_only_public_tracker_production_style fails with unresolved-crate errors unless --features testing is passed: the example offered as the one that does without testing needs it, and no build can catch it importing the testing module later, because every build of it has the module. Smallest fix: list both crates in [dev-dependencies] as well (torrust-clock = "3.0.0" and torrust-tracker-swarm-coordination-registry = { version = "0.1.0", path = "../swarm-coordination-registry" }). Versioned dev-dependencies survive packaging and neither crate depends back on this package, so the packaged example then builds without the feature; lines 11 to 13 of its header would then name those dev-dependencies instead of the feature.

[Nit] A database that cannot be opened makes the production-style example panic instead of reporting the error. packages/axum-http-server/examples/http_only_public_tracker_production_style.rs:219 calls .expect("the tracker core container requires persistence") on TrackerCoreContainer::initialize_from, which for this configuration fails only with Error::Persistence, when the SQLite file cannot be opened or migrated. With TMPDIR naming a missing or read-only directory, the example exits through a panic with status 101, and the message reads as though persistence were not configured. Every other startup failure in run prints a line and returns ExitCode::FAILURE, and the application returns the same error as Error::TrackerCoreComposition (src/container.rs:93). Smallest fix: return the Result from compose_container and handle Err beside the timeout arm at packages/axum-http-server/examples/http_only_public_tracker_production_style.rs:124.

[Nit] The module note claims more than the check it cites does. packages/axum-http-server/src/testing/mod.rs:9 says the Shipped Features check enforces that the feature is enabled from [dev-dependencies] entries only. That check (.github/workflows/testing.yaml:187) reads the normal and build edges of torrust-tracker alone and fails only when a testing feature reaches that tree, so a [dependencies] entry enabling torrust-tracker-axum-http-server/testing in a workspace member outside that tree passes it. Smallest fix: say that the check fails when the feature reaches the torrust-tracker build, and leave the dev-dependency rule to the manifest comment at packages/axum-http-server/Cargo.toml:22.

Checked and found sound: outside src/testing/, the three optional crates are used only in #[cfg(test)] modules (src/lib.rs, src/server.rs, the announce and scrape extractors and the scrape handler), which build with the feature on, and no crate-private item or doc link is left dangling without it; the direct normal dependencies drop from 26 to 23 required; testing is not in default, is absent from docs.rs metadata, and every optional crate behind it is publishable and versioned; no [dependencies] entry enables it, and the root crate names the three crates itself (Cargo.toml:123, Cargo.toml:126, Cargo.toml:133); the deny.toml self wrapper and the Cargo.lock self edge match the manifest; and the production-style example's startup deadline, server-then-listener stop order, drop-guard cancellation and signal handling agree with start_with_cancellation, which subscribes to no OS signal, and with src/bootstrap/jobs/http_tracker.rs at the tip.

This branch was previously deployed

1 inactive deployment
coverage — 2780bc6c Deployed Nov 5, 2026 by josecelano-bot via Generate Coverage Report #2927
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.

Gate the axum-http-server test environment behind a testing feature (#2482 subissue 5)

4 participants