Skip to content

refactor(test-helpers): [#2628] move the protocol helpers to the root tests - #2636

Merged
josecelano merged 11 commits into
torrust:developfrom
josecelano:2628-2482-move-test-helpers-protocol-helpers
Oct 24, 2026
Merged

josecelano merged 11 commits into
torrust:developfrom
josecelano:2628-2482-move-test-helpers-protocol-helpers

Conversation

@josecelano

Copy link
Copy Markdown
Member

Closes #2628

Row 2 of sub-EPIC #2482. torrust-tracker-test-helpers becomes a generic leaf crate (configuration, logging, random) by moving its http and udp helpers into the only crate that uses them, the root crate's tests/common/ (rule B of the test support ADR). The move is behaviour-preserving: the root tests call the same names through common::, and the helper code is copied without redesign.

Summary of changes

  • The http helpers (http_announce, http_complete_download, http_scrape) and the udp helpers (udp_announce, udp_scrape, udp_complete_download and the three send_invalid_connection_id* helpers) move to tests/common/http_requests.rs and tests/common/udp_requests.rs with git mv, so their history follows. Each file carries a module-level #![allow(dead_code, reason = ...)], because each integration-test binary compiles the module and uses only some helpers.
  • The root crate gains the dev-dependencies the moved code needs (client-lib, http-protocol, udp-protocol, torrust-info-hash, torrust-peer-id) and test-helpers drops its direct dependencies on client-lib, http-protocol, udp-protocol, primitives, torrust-info-hash, torrust-peer-id and url. It now depends directly only on rand, configuration, tracing and tracing-subscriber.
  • deny.toml: test-helpers leaves the wrappers of http-protocol and udp-protocol, the root joins the udp-protocol wrappers, and new ban entries for client-lib, tracker-core, swarm-coordination-registry and events (the maintainer's scope decision on the spec PR) list their dependents and never test-helpers.
  • The descriptions that called test-helpers "mock servers" (AGENTS.md, docs/packages.md, packages/AGENTS.md, docs/testing.md) now describe it as test configurations, logging and random data, and inventory pattern B is marked resolved.
  • The issue folder gains manual-verification-evidence.md and implementation-retrospective.md, and the spec records the tasks, acceptance criteria and completion review.

Files and packages touched

tests/common/ (root crate), packages/test-helpers, the root Cargo.toml and Cargo.lock, deny.toml, four documentation files, and the #2482 inventory and the #2628 issue folder under docs/issues/open/.

Validation performed

  • cargo test -p torrust-tracker --tests: the same 15 test binaries and 194 passing tests before and after, with identical per-binary results (evidence V2).
  • cargo tree -p torrust-tracker-test-helpers -e normal --depth 1: 11 direct dependencies before, 4 after (evidence V1). primitives stays reachable through configuration, which rule B.1 allows.
  • cargo deny check bans passes; adding a dependency on each of the four newly banned crates to test-helpers makes it fail (evidence V3). The only warning left is the unmatched wrapper that was already on develop.
  • cargo machete --with-metadata, the pre-commit gate on every commit, and ./contrib/dev-tools/git/hooks/pre-push.sh (including the packaging check and the full stable test suite) pass.
  • No temporary local-only patch is part of this branch; the negative test of the bans edited one manifest in the working tree and restored it.

Notes for reviewers

The spec planned the dependency pruning and the deny.toml changes for a later task, but the pre-commit gate (cargo machete, cargo deny check bans) fails each move commit without the changes it makes necessary, so each move commit carries them and the deny.toml commit holds the four new entries; the retrospective explains this and two other findings. The published torrust-tracker-test-helpers 3.0.0 exports only configuration and random, so the move does not change its published API; #2583 decides any version bump.

josecelano and others added 5 commits October 24, 2026 20:39
…oot tests

The three http helpers have one consumer, the root crate's tests/common/mod.rs. They now live in tests/common/http_requests.rs; the root crate gains the dev-dependencies they need and test-helpers drops the ones only they used.

Co-authored-by: Copilot <[email protected]>
…ot tests

The udp helpers have one consumer, the root crate's tests/common/mod.rs. They now live in tests/common/udp_requests.rs. test-helpers drops the dependencies they used and the protocol crates' deny wrappers no longer name it; the root joins the udp-protocol wrappers.

Co-authored-by: Copilot <[email protected]>
…nd on

Add ban entries for client-lib, tracker-core, swarm-coordination-registry and events (ADR rule B.1), each listing today's dependents and never test-helpers.

Co-authored-by: Copilot <[email protected]>
…nd mark inventory pattern B resolved

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 24, 2026 19:41

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

2 open issues
What changed in this PR

Refactors workspace test support by moving HTTP/UDP protocol helpers out of torrust-tracker-test-helpers into the root crate’s tests/common/, keeping test-helpers as a generic leaf crate and updating docs + cargo-deny bans accordingly.

Changes:

  • Move protocol request helpers to tests/common/ and re-export them from tests/common/mod.rs.
  • Prune packages/test-helpers dependencies; add required dev-dependencies to the root crate.
  • Update deny.toml wrappers/bans and align documentation + issue/spec artifacts with the new structure.
File Description
tests/​common/​mod.rs Switches re-exports from test-helpers to tests/common/*_requests modules.
packages/​test-helpers/​src/​lib.rs Stops exporting http/udp modules to keep crate generic.
packages/​test-helpers/​src/​http.rs Adds module-level allow(dead_code) (but module no longer exported).
packages/​test-helpers/​src/​udp.rs Adds module-level allow(dead_code) (but module no longer exported).
packages/​test-helpers/​Cargo.toml Removes protocol/domain dependencies per ADR rule B.
Cargo.toml Adds dev-deps needed by moved helper code to root crate.
deny.toml Updates wrappers and introduces bans ensuring test-helpers can’t depend on forbidden crates.
AGENTS.md Updates test-helpers description (workspace overview).
packages/​AGENTS.md Updates test-helpers guidance to generic utilities + ADR rule B pointer.
docs/​testing.md Updates guidance about what belongs in test-helpers.
docs/​packages.md Updates package catalog description for test-helpers.
docs/​issues/​open/​2628-.../​manual-verification-evidence.md Adds manual verification evidence artifact.
docs/​issues/​open/​2628-.../​implementation-retrospective.md Adds retrospective artifact.
docs/​issues/​open/​2628-.../​ISSUE.md Updates spec status/progress, evidence links, and acceptance verification.
docs/​issues/​open/​2482-.../​test-support-inventory.md Marks inventory row resolved by #2628.

Review effort: Lite

da2ce7
da2ce7 previously approved these changes Oct 24, 2026

@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.

Reviewed at 70c96acf5d8c1bed7de446cf1ccc0fa26ef6ea13. Recomputed from the bytes at this head, against the merge base abce11ec8; git merge-tree against develop abce11ec8 writes a clean tree (a5f4e14ce), the head's own tree.

Verdict: approve. The move is a copy, the manifests and bans match the code, and the records agree with the bytes. Two non-blocking findings are inline.

  • The move. http.rs becomes tests/common/http_requests.rs (96 % similar) and udp.rs becomes udp_requests.rs (98 %). The only added lines in each are the five-line #![allow(dead_code, reason = ...)]. tests/common/mod.rs re-exports the same nine names, so no test file changes. No reference to test_helpers::http or test_helpers::udp remains, and lib.rs keeps configuration, logging and random.
  • Manifests. Every crate path the moved files use is a root dev-dependency (torrust_tracker_client is the lib name of client-lib). test-helpers keeps rand, configuration, tracing and tracing-subscriber, and its sources use exactly these: 4 direct, as claimed. Cargo.lock moves the same edges (root +5, test-helpers -7). The statement about the published 3.0.0 API cannot be checked offline, and I take no position on it.
  • deny.toml. Each new wrapper list equals the in-graph dependents of its crate. The console client and persistence-benchmark sit outside the graph rooted at the root crate, as the new comment says. test-helpers appears only on the two comment lines (98 and 101), as the AC3 row says. The root's http-protocol wrapper becomes real, which leaves the self-wrapper at line 35 as the one unmatched warning, as V3 says. The scope decision the description cites is recorded in the spec's scope paragraph and its 16:23 log entry, not in a thread on the spec PR.
  • Commit points. Each move commit carries the manifest and wrapper changes its own pre-commit gate needs. The departure is recorded in the T2 and T3 rows, in the Commit Points note and in the retrospective.
  • Records. V1 to V3 match the retrospective and the spec rows. The evidence baseline 0599fbd05 is 23 commits behind abce11ec8, and those commits touch only docs/, .github/skills/ and project-words.txt, so the counts hold at the merge base. The head branch matches branch:, every stamp precedes its commit, and the links resolve.
  • Hygiene. Six Conventional subjects, each tagged [#2628]. git diff --check is clean for each commit, the commit-id check prints nothing, and there is one closing keyword (Closes #2628).
  • Bot. It had started work at 19:42:06Z and had posted nothing when I captured.

Gate I expect.

  • Pre-commit and the three lints: green.
  • Frontmatter validator: the same diagnostics at head and base.
  • cargo test -p torrust-tracker --tests: 15 binaries and 194 tests at both.
  • test-helpers tests and clippy: green, because the allow covers the per-binary dead code.
  • cargo tree ... --depth 1: 11 dependencies before and 4 after.
  • cargo deny check bans: ok at both, with two unmatched-wrapper warnings at the base and one at the head.

Checks

On the loop's compute hub at this head, against the merge base abce11ec8, the #2630 merge, which is develop (receipt server-gates-sojka-447): pre-commit profile gate exit 0 (96 s); linter markdown, linter cspell, linter lychee exit 0; frontmatter-validator --all: 16 errors / 4 warnings at this head and 16 / 4 at the base re-measured, the same 20 diagnostics by path and category, none in the files this PR touches. cargo test -p torrust-tracker --tests: 194 passed, 0 failed in 15 suites at this head (64 s) and the same at the base (28 s); cargo test -p torrust-tracker-test-helpers exit 0 (no tests); cargo clippy -p torrust-tracker -p torrust-tracker-test-helpers --all-targets --all-features -- -D warnings exit 0; cargo tree -p torrust-tracker-test-helpers -e normal --depth 1: 4 direct dependencies at this head (rand, torrust-tracker-configuration, tracing, tracing-subscriber), 11 at the base; cargo deny check bans exit 0 at both, with one unused-wrapper warning at this head against two at the base (the rest are duplicate-version warnings); cargo machete --with-metadata finds no unused dependency. GitHub checks at this head at posting time: "Package Coverage Regression: completed/success; Package Coverage (torrust-tracker-test-helpers): completed/success; Package Coverage (torrust-tracker): completed/success; Docker E2E: completed/skipped; Unit (stable): completed/success; Unit (nightly): completed/success; Workspace Packaging: completed/success; Documented Clippy Allows: completed/success; Layer Boundary Bans: completed/success; Test (Docker) (release): in_progress/pending; Build on windows-latest (stable): completed/success; Build on ubuntu-latest (nightly): completed/success; Build on windows-latest (nightly): completed/success; Build on macos-latest (nightly): completed/success; Build on ubuntu-latest (stable): completed/success; Build on macos-latest (stable): completed/success; Discover Package Coverage: completed/success; Generate Coverage Report: completed/success; Docs Lint: completed/success". At posting, develop is abce11ec8.

Comment thread packages/AGENTS.md Resolved
Comment thread tests/common/http_requests.rs Resolved
@da2ce7

da2ce7 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

ACK 70c96ac — the protocol helpers move unchanged into the root tests, the manifests and bans match the code, and the records agree with the bytes; F1 and F2 do not block.

@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.

Reviewed at 9e5c380052a65b93a0453027c596102e310c4fca. Recomputed from the bytes at this head, against the merge base abce11ec8; git merge-tree against develop d09a45f0a writes a clean tree (100082e79), whose Cargo.lock is develop's plus this PR's delta.

Verdict: approve. The four fixes do what was asked, and each reply describes its commit. Two non-blocking findings are inline.

The four fixes.

  • 162a81e9d: AC1 now says "no direct dependency", which is what V1's cargo tree --depth 1 and the AC1 verification row show, and the 20:02 log entry records the change.
  • 1b7c0ee7b: the template's two-line blockquote is dropped. Of the tree's 40 retrospectives, 39 carry none.
  • 60f44ceca: cites the #2238 rule with its path and states the reason. Recomputed: the two files hold 16 functions (5 and 11), and 7 of the 10 binaries that compile tests/common leave one module wholly unused. The banning and udp_error binaries call no http helper, the completed-downloads test calls no udp helper, and scaffold calls neither. Each module therefore meets the #2238 module-level case for some binary, so my round-1 premise was stronger than the facts. The record as written is accurate.
  • 61f0208b6: the line I proposed. It matches lib.rs (configuration, logging, random), and the reply's grep holds: outside issue specs, audits and ADRs, the only other "mock server" is a generic effort row in create-refactor-plan.

Knock-on effects. Only these three files and the audit record changed since 70c96acf5. The retrospective keeps the template's eight sections, but item 5 now lags AC1 (F6). The spec stamp (20:02) precedes its commit, and the 132 relative links in the 10 changed Markdown files resolve.

develop moved. It gained #2634 (smallvec 1.16.3 to 1.16.4, its only Cargo.lock change) and #2635 (two other specs). The two lockfile deltas touch disjoint packages, and the merged lockfile keeps the root's five added dependencies and the seven test-helpers removals.

Hygiene.

  • Five Conventional subjects, each tagged [#2628].
  • Each body is one attribution footer naming the review bot's account, and no rule in the tree governs that footer.
  • Author equals committer, git diff --check is clean, and the commit-id check prints nothing.
  • The description is unchanged and closes #2628 only.

The audit record. Its four rows match the threads, reviewers, severities as raised, replies and subject references, and "Reviewer finding ID" maps my F1 and F2 to its F3 and F4. The validator passes offline. The heads of the two reviews are misstated (F5).

The review bot. I agree with both of its threads, and the commits that answer them resolve both. Its overview's rows for packages/test-helpers/src/http.rs and udp.rs describe the move as an in-place edit, but nothing there is actionable.

Findings: F5 (Minor) and F6 (Nit), inline.

Checked, no finding: the reply quotes, the commit-subject uniqueness, the frontmatter of the touched records, the timeline states (the round-1 approval was dismissed by the 20:10:46Z push), and thread resolution (4 of 4).

Checks

On the loop's compute hub at this head, against the merge base abce11ec8, the #2630 merge (receipt server-gates-sojka-449): pre-commit profile gate exit 0 (90 s); linter markdown, linter cspell, linter lychee exit 0; frontmatter-validator --all: 16 errors / 4 warnings at this head and 16 / 4 at the base re-measured, the same 20 diagnostics by path and category, none in the files this PR touches; the audit validator over docs/pr-reviews/pr-2636-review/PR-REVIEW.md with the captured review comments: ok, 4 rows, 1 log entry, 0 failures. cargo test -p torrust-tracker --tests: 194 passed, 0 failed in 15 suites at this head and the same at the base; cargo test -p torrust-tracker-test-helpers exit 0; cargo clippy -p torrust-tracker -p torrust-tracker-test-helpers --all-targets --all-features -- -D warnings exit 0; cargo tree -p torrust-tracker-test-helpers -e normal --depth 1: 4 direct dependencies at this head, 11 at the base; cargo deny check bans exit 0 at both; cargo machete --with-metadata finds no unused dependency. develop moved to d09a45f0a, the #2634 merge, which also changes Cargo.lock: the merge of this head into it is clean, cargo metadata --locked exits 0 on the merged tree, and cargo test --locked -p torrust-tracker --tests passes there with 194 tests in 15 suites. GitHub checks at this head at posting time: "Package Coverage (torrust-tracker): in_progress/pending; Package Coverage (torrust-tracker-test-helpers): completed/success; Docker E2E: completed/skipped; Layer Boundary Bans: completed/success; Workspace Packaging: completed/success; Documented Clippy Allows: completed/success; Unit (stable): in_progress/pending; Unit (nightly): in_progress/pending; Test (Docker) (release): queued/pending; Generate Coverage Report: in_progress/pending; Discover Package Coverage: completed/success; Build on windows-latest (nightly): completed/success; Build on macos-latest (stable): completed/success; Build on ubuntu-latest (nightly): completed/success; Build on ubuntu-latest (stable): completed/success; Docs Lint: completed/success; Build on windows-latest (stable): completed/success; Build on macos-latest (nightly): completed/success". At posting, develop is d09a45f0a.


## Findings

Round 1: Copilot's review 5639728582 (COMMENTED, submitted 2026-10-24T19:58:25Z, on the opening head after the spec-record commit) opens two inline threads, F1 and F2; its overview warns that the agentic review timed out and its file table calls the moved helper files "module no longer exported", which describes the rename and raises no actionable assertion. da2ce7's review 5639731135 (APPROVED, submitted 2026-10-24T19:59:04Z, same head, dismissed by the 2026-10-24T20:10:46Z push of the fix commits) opens two inline threads, F3 and F4, which he labelled F1 and F2, next to an ACK of that head. Severities are the labels of the source comments; the Copilot severity "Medium" is recorded as Minor (inferred).

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.

[Minor][F5] This paragraph says that review 5639731135 was on the "same head" as the review bot's review, and the Processing Log entry (line 106) says that both "reviewed the opening head".

The captured review and comment records show otherwise:

  • The bot's review 5639728582 and its two threads are on the PR's opening head, whose subject is docs(issues): [#2628] record the implementation evidence, retrospective and completion.
  • Review 5639731135 and its two threads are on the next head, docs(issues): [#2628] record the implementation pull request in the spec.

A reader mapping F1 and F2 against F3 and F4 would place them on one tree. To repair it, name both heads by subject here and append a correction entry to the Processing Log rather than rewriting line 106 (docs/templates/PR-REVIEW-TEMPLATE.md:112-113).

4. **`develop` moved under the spec.** #2623 added `http_complete_download` after the spec was
refreshed; the reviewer found it in the spec PR. No code was affected, because the move carries
whatever the module holds.
5. **AC1 reads as stronger than it is.** "No dependency on `primitives`" is true for direct

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.

[Nit][F6] Item 5 still says "AC1 reads as stronger than it is". Since docs(issues): [#2628] say that AC1 means no direct dependency, AC1 (ISSUE.md:162) says "no direct dependency", so the item describes a wording that no longer exists.

Past tense and one clause would keep it true, for example: "AC1 read as stronger than it was ...; it now says "no direct dependency"." Root Cause and Improvement 3 already read correctly.

@da2ce7

da2ce7 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

ACK 9e5c380 — the four fixes answer their threads, the merge into develop d09a45f is clean with a consistent lockfile, and the audit record matches the captures apart from the non-blocking F5.

@josecelano

Copy link
Copy Markdown
Member Author

ACK 9e5c380

@josecelano
josecelano merged commit 722f2b5 into torrust:develop Oct 24, 2026
22 checks passed
josecelano added a commit that referenced this pull request Oct 25, 2026
…ssues/closed

0af1e95 chore(issues): archive closed issue #2628 spec to docs/issues/closed (Jose Celano)

Pull request description:

  Related to #2628

  Archives the specification of the closed issue #2628 (row 2 of sub-EPIC #2482), as the maintainer asked after PR #2636 merged. No code changes.

  ## Summary of changes

  - The #2628 spec folder (`ISSUE.md`, `manual-verification-evidence.md`, `implementation-retrospective.md`) moves from `docs/issues/open/` to `docs/issues/closed/`; `ISSUE.md` gets `status: done`, the new `spec-path`, a ticked "Issue closed and spec moved" checkpoint and a Progress Log entry, and the other two files get their new paths and stamps.
  - The #2482 EPIC marks row 2 DONE with the new spec path and a Progress Log entry, and its Subissues paragraph now says that subissues 1 and 2 are GitHub issues. No EPIC acceptance criterion or checkpoint became true with this row alone (AC4, AC6, AC7 and AC8 stay open, and the per-subissue checkpoints cover every subissue), so none is ticked.
  - The two live links to the old path (the test support inventory and the 2026-10-06 coupling report) point to the new location. A search for the folder name finds no other stale reference.

  ## Files and packages touched

  Only `docs/issues/`: the moved #2628 folder, the #2482 EPIC, the test support inventory and the workspace coupling report.

  ## Validation performed

  The pre-commit gate passed (`linter all`, which includes the local link check), `git diff --cached --check` was clean, and the commit-id check printed nothing.

ACKs for top commit:
  josecelano:
    ACK 0af1e95

Tree-SHA512: 22241caf5099c9e1d34bf5208572e896027e3f84558c5a9194f5257a4f941e76fb94ab986af8ebe10d7536cb87107930e73d1a6ca3992311f35f1c7bc71722e1

This branch was previously deployed

1 inactive deployment
coverage — 9e5c3800 Deployed Oct 24, 2026 by josecelano via Generate Coverage Report #2786
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.

Move the test-helpers protocol helpers to their consumer (#2482 subissue 2)

3 participants