Repository navigation
test(tracker-core): [#2902] cover the statistics module - #2988
josecelano merged 40 commits into
Conversation
The merge of torrust#2903 has the same subject as the S0 commit, so the subject search found the merge commit first. Add --no-merges to the lookup in coverage-evidence.md and in the F8 and F18 verifications of the torrust#2903 review audit (review finding F20 of torrust#2903). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…orrust#2903 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ics repository plan Start S1: the shared file test plan guidance (T2) and the plan of the first ledger row, statistics/repository.rs, for the maintainer's approval. The plan proposes finding F6 (unused public gauge methods) and asks decision D1. The spec records S0 as merged and S1 in progress. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… and D1 Q2 after reading the code: the driver suites skip by design and db-compatibility.yaml runs them; S3 fixes the driver-test commands in the docs and a separate issue takes the visible skip and the published coverage. Q3 Docker-free S3, Q4 extract parse_valid_until in S2, Q5 quickcheck where natural, Q6 six slices, Q7 fix the temporary SQLite files in S1. F6 records the unused public gauge methods (D1: tested in S1). The statistics repository plan is approved. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ites and readers Ledger row 1 of S1. Add unit tests for the five write methods of statistics::repository::Repository (success, and the name collision the metric collection returns unchanged) and for a counter that is not in the collection reading as zero; one existing test asserts its three values as one tuple. The file goes from 86/140 to 277/277 lines (unit-only); all seven named mutations are killed. Plan and results in test-refactor-plans/statistics-repository-tests.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… in the S1 plans Co-Authored-By: Claude Opus 5.5 <[email protected]>
…atistics metrics `statistics/metrics.rs` only passes each call to its `MetricCollection`. The repository tests cover it 45 / 45 and kill all six hand-made mutants, so the maintainer approved no new test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s loader tests Co-Authored-By: Claude Opus 5.5 <[email protected]>
`load_persisted_metrics` had no unit test. Five tests with a mocked torrent-metrics store pin that a stored global total sets both the persistent and the persisted totals, that an empty store writes nothing, that a store failure is a database error, and that a refused write is a metrics error after the first total was already written (the load is not atomic). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…istics loader tests Co-Authored-By: Claude Opus 5.5 <[email protected]>
…stener tests Co-Authored-By: Claude Opus 5.5 <[email protected]>
`rustup update` moved stable from Rust 1.99.1 to 1.100.0, and `cargo-llvm-cov 0.6.16` then reported 0% for every file: it still read test binaries from `target/debug/deps/`, where Cargo 1.100.0 no longer writes them. With `cargo-llvm-cov 0.9.1` every figure of the issue is measured again at the same commits: the baseline at `5833cdae9` in five scopes and the unit-only runs after rows 1 and 3. The coverage evidence, the spec's baseline and ledger, the row records and the EPIC's torrust#2902 rows hold the new figures; the append-only logs keep the old ones. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er entry points The tests covered only the private dispatch loops. Four tests run the two `*_unspawned` functions the application supervises and the two spawn wrappers over a real event bus: send one event, cancel, await the listener within a 5-second deadline, and check the counted or persisted download and, for the unspawned functions, the `Cancelled` completion. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tener tests Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ndler tests Co-Authored-By: Claude Opus 5.5 <[email protected]>
…bal save failure of the statistics handlers Only `PeerAdded` stood for the events that must not count as a completed download, so counting `PeerRemoved` or `PeerUpdated` went unnoticed. Two table tests run all five such events through the in-memory and the persistent handler and replace the two `PeerAdded`-only tests. A third test pins that the persisted total does not move when the global downloads cannot be saved. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nt handler tests Co-Authored-By: Claude Opus 5.5 <[email protected]>
… repository tests Co-Authored-By: Claude Opus 5.5 <[email protected]>
…re incremented, not overwritten Every test increased a torrent's downloads once from nothing, so overwriting a stored total with 1 passed them all. Two tests on a temporary SQLite database increase the same torrent twice and the global total twice and expect 2. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…loads repository tests Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ests Co-Authored-By: Claude Opus 5.5 <[email protected]>
…atistics setting registers No test disabled usage statistics, so registering the in-session total regardless passed. One table test over the four combinations of usage and persisted statistics pins that the persistent total is always registered and the other two only with their setting, each at zero. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ule tests Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ment The S1 branch, rebased on `develop` `44ce734fe`, is measured in the four default scopes next to its base: unit-only lines 79.45% to 84.41%, aggregate 81.27% to 84.41%. The aggregate now equals unit-only, so the integration binary no longer reaches any `tracker-core` line the unit tests miss. The EPIC's torrust#2902 rows hold the latest values and row 14 is in progress. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… F20 follow-up Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rrust#2988 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
2 open issues
3 resolved since last review
Review effort: Lite
…bal downloads failure test The mock of `load_torrent_downloads` allowed any number of calls, so a redundant read went unnoticed. Like the other expectations of the test, it now expects exactly one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…features The `add-rust-dependency` skill prefers `default-features = false`. The statistics tests use neither default feature of `rstest` (`async-timeout`, `crate-name`), so they are off, as in `axum-rest-api-server`. The version stays 0.28.0, the latest stable release. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rust#2988 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
ACK 71c0a0f |
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 71c0a0f5ce6f9ea2e559327c55572c048de93d0b. Recomputed from the bytes at this head, against the merge base 44ce734fe; git merge-tree against develop 98fa27df2 writes a clean tree (develop's two new merges touch only other issues and their own audit records).
Process: this review covers the five commits since a05b5a02f. The record now holds 11 rows. Run offline over the capture, the validator's logic reports 11 rows, 4 log entries and no failure. All 11 root threads have a reply on their own thread and an audit row, and are resolved. That includes the two the automated reviewer opened at 10:03:41 UTC, after the previous head was pushed.
The change against its claim: 97e9699c5 adds .times(1) to expect_load_torrent_downloads (handler.rs:338-339). Production reads the torrent row once before saving it (persisted/downloads.rs:63), so the expectation holds. The test still fails for the reason its name states, the Err arm of increase_global_downloads; a redundant torrent read now fails it too. 31342ce9a turns off rstest's default features, as axum-rest-api-server does; the tests use no #[timeout] and no renamed crate. Cargo.lock rightly stays unchanged: it records no features, and the siblings that keep the defaults still pull the optional dependencies. 5ccaef5ae points the plan rows at their rstest cases, and F21 and F22 stay fixed.
Consistency: each new row's network-free verification prints what it says (handler.rs:338-339, Cargo.toml:50).
Hygiene: five Conventional subjects in the branch's form, and author equals committer. Each commit carries the same attribution footer as before; no rule in the tree forbids it. git diff --check is clean, the commit-id check prints nothing, and no closing keyword appears in the title, body or commits.
Findings: F25 Nit, the F23 row's severity departs from the record's own overview mapping. The record numbers the automated reviewer's two comments F23 and F24, so this review's finding is F25. It does not block.
Checked, no finding: F24 is recorded as FIXED for a declined version style plus a related change, which ten earlier rows in the tree also do; the 0.28.0 requirement matches three sibling packages; the round-3 log entry's reply times match the capture.
Checks
On the loop's compute node at this head, against the merge base 44ce734fe (receipt server-gates-kranich-1333): the repository's pre-commit gate and lint roster exit 0 (129 s wall), and the audit validator passes on this PR's record (11 rows, 4 log entries, 0 failures). In the per-PR target directory, with every workspace crate recompiled at this head, cargo test --workspace passes 4467 tests with 0 failed and 5 ignored across 131 binaries (87 s wall), and cargo clippy --workspace --all-targets --all-features -- -D warnings is clean. cargo deny check exits 5 with the same license rejections and advisories as recent runs on develop, plus one advisory published since then, RUSTSEC-2026-0592 against url 2.5.8; this PR does not change that entry of Cargo.lock, and develop at 98fa27df2 locks the same version. Checked against the bytes at posting: docs/pr-reviews/pr-2988-review/PR-REVIEW.md:67 records the F23 row as Nit (inferred), as F25 says, and packages/tracker-core/Cargo.toml:50 now reads rstest = { version = "0.28.0", default-features = false }. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Package Coverage (torrust-tracker-core): completed/success; Package Coverage (torrust-tracker): in_progress/pending; Docker E2E: completed/skipped; Documented Clippy Allows: completed/success; Workspace Packaging: completed/success; Unit (stable): in_progress/pending; Unit (nightly): in_progress/pending; Layer Boundary Bans: completed/success; Shipped Features: completed/success; Persistence Benchmark SQLite3: completed/success; Persistence Benchmark MySQL: completed/success; Persistence Benchmark PostgreSQL: completed/success; Database Compatibility MySQL (8.0): completed/success; Database Compatibility PostgreSQL (16): completed/success; Database Compatibility PostgreSQL (15): completed/success; Database Compatibility PostgreSQL (17): completed/success; Database Compatibility PostgreSQL (14): completed/success; Database Compatibility MySQL (8.4): completed/success; Discover Package Coverage: completed/success; Generate Coverage Report: in_progress/pending; Docs Lint: completed/success; Test (Docker) (release): in_progress/pending; Build on windows-latest (stable): completed/success; Build on macos-latest (nightly): 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 macos-latest (stable): completed/success". At posting, develop is 98fa27df2.
|
ACK 71c0a0f — the five commits since the round-2 head read against their messages, the one-read expectation and the rstest feature change checked against the code and lock file, and all eleven threads replied, recorded and resolved with the validator's logic passing at this head |
…t overview The overview of review `6011613619` marks F23 Medium, which the record maps to `Minor (inferred)` as it does for F5 and F6; the row said `Nit (inferred)`. The round 3 sentence now names both overview severities, as the round 1 sentence does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rrust#2988 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 🎉
2 resolved since last review
Review effort: Lite
|
ACK 5186511 |
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 51865117852673d00812bbaba7329b2773706dd1. Recomputed from the bytes at this head, against the merge base 44ce734fe; git merge-tree against develop 98fa27df2 writes a clean tree (develop has not moved since the last trial merge).
Process: this round reads the two commits since 71c0a0f5c. Both change only the pull request's own audit record; the path listing of merge-pull-request prints that one file. Run offline over the capture, the validator's logic reports 12 rows, 5 log entries and no failure. All 12 root threads have a reply on their own thread and an audit row, and are resolved. The automated reviewer's review of 71c0a0f5c (10:30:14 UTC, after this head's push) reports no open issue and adds no thread.
The change against its claim: 2da9871a5 does what it says. The F23 row reads Minor (inferred), following the overview's Medium as F5 and F6 do, and the round-3 sentence names both overview severities. 518651178 records round 4: the F25 row and its details, a round-4 sentence, and a 10:26 log entry whose reply time matches the capture. F25 is fixed. Every earlier finding (F1 to F7, F21 to F24) is unchanged, because no file of theirs moved.
Consistency: the F25 row's verification prints the F23 row with Minor (inferred), now at line 70. The F25 row's severity, Nit, matches its source bracket. The description is unchanged since the last review.
Hygiene: two Conventional subjects in the branch's form, and author equals committer. Each commit carries the same attribution footer as before; no rule in the tree forbids it. git diff --check is clean, the commit-id check prints nothing, and no closing keyword appears in the title, body or commits.
Findings: none.
Checked, no finding: the round-4 sentence names the reviewed head by its subject and gives the review's time as the capture has it; the log entries stay in time order; the new no-issue review needs no row.
Checks
On the loop's compute node at this head, against the merge base 44ce734fe (receipt server-gates-kranich-1339): the repository's pre-commit gate and lint roster exit 0 (48 s wall), and the audit validator passes on this PR's record (12 rows, 5 log entries, 0 failures). This head differs from 71c0a0f5c only in docs/pr-reviews/pr-2988-review/PR-REVIEW.md, so the package measurements made there (receipt server-gates-kranich-1333) hold: in the per-PR target directory, with every workspace crate recompiled, cargo test --workspace passes 4467 tests with 0 failed and 5 ignored across 131 binaries, cargo clippy --workspace --all-targets --all-features -- -D warnings is clean, and cargo deny check matches recent runs on develop plus the newly published RUSTSEC-2026-0592 against url 2.5.8, which develop locks too. Checked against the bytes at posting: PR-REVIEW.md:70 now records the F23 row as Minor (inferred), the fix for F25. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Package Coverage (torrust-tracker-core): in_progress/pending; Package Coverage (torrust-tracker): in_progress/pending; Test (Docker) (release): in_progress/pending; Docs Lint: in_progress/pending; Database Compatibility MySQL (8.0): completed/success; Database Compatibility PostgreSQL (14): completed/success; Database Compatibility MySQL (8.4): completed/success; Database Compatibility PostgreSQL (17): completed/success; Database Compatibility PostgreSQL (15): completed/success; Database Compatibility PostgreSQL (16): completed/success; Docker E2E: completed/skipped; Shipped Features: completed/success; Layer Boundary Bans: completed/success; Documented Clippy Allows: completed/success; Unit (stable): in_progress/pending; Unit (nightly): in_progress/pending; Workspace Packaging: completed/success; Discover Package Coverage: completed/success; Persistence Benchmark MySQL: completed/success; Persistence Benchmark PostgreSQL: completed/success; Generate Coverage Report: in_progress/pending; Persistence Benchmark SQLite3: completed/success; Build on ubuntu-latest (nightly): completed/success; Build on windows-latest (stable): in_progress/pending; Build on ubuntu-latest (stable): completed/success; Build on macos-latest (stable): completed/success; Build on macos-latest (nightly): completed/success; Build on windows-latest (nightly): in_progress/pending". At posting, develop is 98fa27df2.
|
ACK 5186511 — the two audit-only commits since the round-3 head read against their messages, F25 confirmed fixed, and all twelve threads replied, recorded and resolved with the validator's logic passing at this head |
|
ACK 5186511 |
torrust#2988 merged into `develop`, and the log of this change says so, but the slice table still showed S1 as in progress. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…view to the S1 test plans da2ae70 docs(pr-reviews): [#2902] say commit time, not push time, for the F18 fix (josecelano-bot) fe86c78 docs(pr-reviews): [#2902] give F20 its reply URL and log entry (josecelano-bot) 9765f36 docs(pr-reviews): [#2902] correct when the F18 fix was pushed and record the fifth review round of #3009 (josecelano-bot) 61f6b8f docs(issues): [#2902] add the missing Prose-First AAA Review to the S1 test plans (josecelano-bot) Pull request description: Related to #2902 Documentation only, follow-up to #2988 and #3009. The review of #3009 found that the test plans of slice S1 lack the Prose-First AAA Review that the per-file workflow requires before the completed-file review, and that one sentence of the #3009 audit record is wrong. This PR changes no code. - **Six S1 plans** (`statistics/persisted/mod.rs`, `persisted/downloads.rs`, `event/listener.rs`, `event/handler.rs`, `statistics/mod.rs` and the temporary-database fixture) get the section, written after the fact from each plan's Test Design and compared with the code, like the S2 plans in #3009. It is marked temporary prose for that reason. Smells found are recorded and none is fixed: the three older tests of `downloads.rs` have no AAA comments and read back inside the Act, and one handler test has mock expectations without call counts. The fixture plan adds no test, so its section says so. - **The audit record of #3009**: the F18 row said its fix "was already pushed when the review was written"; the commit landed 44 seconds after the review was submitted. The row and the round 4 log entry are corrected, and da2ce7's finding F16 on that sentence is recorded as F20 (his ID collides with an existing row). Validation: the pre-commit gate ran on both commits. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Documentation** * Expanded test plans with reviews of test setup, actions, expectations, and coverage observations. * Updated a pull request review record with a follow-up finding, corrected fix timing, and revised processing details. <!-- end of auto-generated comment: release notes by coderabbit.ai --> ACKs for top commit: josecelano: ACK da2ae70 Tree-SHA512: e5bf4d7301afb9cc1d7dfbd57e66dadf334c966f8f8cb30139540179591a831b592f1740e3698c20071ad5de5f08ebc453060f8b4bf9f839cff948ff18f574f4


Related to #2902
Slice S1 of #2902: focused unit tests for
packages/tracker-core/src/statistics/, the one area oftracker-corethat only the integration binary reached. Test code, documentation and one dev-dependency (rstest0.28.0, already in the lock file): no production line changes.Each file went through the spec's per-file workflow: a plan approved by the maintainer, the tests, hand-made named mutations, and a completed-file review. The plans and their results are in
docs/issues/open/2902-1347-add-tests-tracker-core/test-refactor-plans/.statistics/repository.rsstatistics/metrics.rsstatistics/persisted/mod.rsload_persisted_metricswith a mocked store, including that the load is not atomicstatistics/event/listener.rsstatistics/event/handler.rsrstesttables over every event that is not a completed download (replacing twoPeerAdded-only tests) and a test where the global downloads cannot be increasedstatistics/persisted/downloads.rsstatistics/mod.rs,statistics/event/mod.rsrstesttable of which totals each statistics setting registers;event/mod.rsdeclares modules onlyCoverage of
tracker-core(stable Rust 1.100.0,cargo-llvm-cov 0.9.1, against thedevelopbase44ce734fe): unit-only lines 79.45% to 84.41% (180 unit tests at the measured commit, 157 before), aggregate 81.27% to 84.41%. The aggregate now equals the unit-only figure line for line, so the integration binary no longer reaches any line the unit tests miss. Everystatistics/file runs all its lines; the regions left aretracinglog-level checks, one unreachable error arm and test code. Details:coverage-evidence.md, section "Slice Measurements".Also in this PR:
torrust-tracker-corepackage #2902 was measured again with Rust 1.100.0 andcargo-llvm-cov 0.9.1, at the maintainer's request: afterstablemoved from Rust 1.99.1,cargo-llvm-cov 0.6.16reported 0% for every file because it read test binaries from Cargo's oldtarget/debug/deps/layout. The baseline is now 79.32% unit-only lines (80.31% with the old toolchain). The append-only logs keep the old figures.tracker-corehold the latest values; row 14 is in progress.docs/pr-reviews/pr-2988-review/PR-REVIEW.md): the three loop tables became 14 namedrstestcases, which addsrstestas a dev-dependency of the package; the persistence cases expect no torrent row for any info-hash; a test name and plan text were corrected; the S1 log entry moved into the EPIC Progress Log, with a stray Overhaul Packages Testing: Add tests foraxum-rest-api-serverpackage #2637 entry.Validation at the head after review round 1:
cargo test -p torrust-tracker-core --all-features(191 unit test cases, 15 integration and 18 other tests),cargo clippy -p torrust-tracker-core --all-targets --all-features,cargo +nightly fmt --all -- --check, the pre-commit gate on every commit, and the repository's pre-push checks on push.🤖 Generated with Claude Code