Repository navigation
test(http-core): [#1349] pin the event contract and the container composition with unit tests - #2593
Merged
josecelano merged 7 commits intoOct 21, 2026
Conversation
Mark slice S3 done after the merge of torrust#2586, point the specification at the S4 branch, and log that the baseline for S4 is the final S3 measurement because packages/http-core did not change on develop after the S3 head. Update the EPIC row. Related to torrust#1349 Co-authored-by: Copilot <[email protected]>
…ection context Refactor the 7 tests of event.rs into 27 cases in 10 test functions with an in-file builder, AAA markers and it_should_* names. Add whole label-set tables, the public URL and instance id accessors, and pin the four accessors that have no caller as public API. Remove the dead announce_events_match helper and make the test module private. event.rs goes from 157/187 to 135/135 lines. Mutations L1-L4 and six extra probes are killed. The S4 baseline is re-measured because the S3 merge brought torrust#2414 into the listener. Add the file plan, its results and the coverage evidence. Co-authored-by: Copilot <[email protected]>
…TP services Add 20 unit tests for container.rs, which had none: the always-enabled event bus and its sender, the collaborators the container exposes, the instance id, public URL, reverse proxy and IP-override policy that reach the announce and scrape services, the tracker-core authentication, whitelist and torrent repository they use, and the initialize entry point over a real SQLite file. The tracker-core container is built by hand, so no test calls a production container factory. All 73 production lines are covered. Mutations M1-M7 and eight extra probes are killed; one survives, the swarm registry's usage-statistics flag, which this package cannot observe. Add the file plan, its results and the coverage evidence. Co-authored-by: Copilot <[email protected]>
Add an HTTPS case on port 443 and a case with a server bound to an IPv4-mapped IPv6 address to the event label table, which kills three surviving label mutants. Replace a match that computed an expected value with a case parameter, split the tests that had several reasons to fail or a split Act, and take the missing database directory of the panic test from a random name. Record the review report and the final S4 figures: 140 unit tests, lines 97.90%, regions 98.26% and functions 98.14%, with the EPIC rows. Co-authored-by: Copilot <[email protected]>
…ication Record the S4 pull request, its branch state and the pre-push result in the slice table, the frontmatter and the progress log. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The always-enabled event-publication contract still needs a test with usage statistics disabled.
1 open issue
What changed in this PR
Adds S4 test coverage for HTTP core event contracts and service composition under #1349, without changing production code.
Changes:
- Expands event tests to 29 cases covering labels, accessors, and equality.
- Adds 23 container tests covering wiring, configuration, and initialization.
- Records coverage, mutation evidence, and review outcomes.
| File | Description |
|---|---|
packages/http-core/src/event.rs |
Refactors and expands event contract tests. |
packages/http-core/src/container.rs |
Adds service composition and initialization tests. |
docs/issues/open/1349-1347-add-tests-http-core/test-refactor-plans/README.md |
Registers completed file plans. |
docs/issues/open/1349-1347-add-tests-http-core/test-refactor-plans/event-tests.md |
Documents event tests and mutation evidence. |
docs/issues/open/1349-1347-add-tests-http-core/test-refactor-plans/container-tests.md |
Documents composition tests and coverage boundaries. |
docs/issues/open/1349-1347-add-tests-http-core/ISSUE.md |
Updates slice progress and implementation ledger. |
docs/issues/open/1349-1347-add-tests-http-core/coverage-evidence.md |
Records refreshed baseline and S4 coverage. |
docs/issues/open/1349-1347-add-tests-http-core/agent-review-reports.md |
Records independent review and follow-up fixes. |
docs/issues/open/1347-overhaul-packages-testing/EPIC.md |
Updates package progress and coverage tables. |
Review effort: Balanced
…atistics disabled The delivery test of the HTTP core services ran with the default core configuration, whose usage statistics are enabled, so a bus gated on that policy would have passed it. Turn it and the three container publication tests into tables over the usage-statistics policy of the tracker core and of the HTTP tracker, each with an enabled and a disabled case. Three new mutations that gate the bus or a service sender on the policy are killed only by the disabled cases. Record the round and the figures: 27 container tests, 144 unit tests, lines 97.84%, regions 98.19%, functions 98.10%. Co-authored-by: Copilot <[email protected]>
Record Copilot's finding on the event-delivery test, its fix and the resolved thread. Co-authored-by: Copilot <[email protected]>
Member
Author
|
ACK 580b592 |
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 1,015 executable lines it added are tests, benchmarks or test support with no production behaviour, and 1,013 of them are still present. |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Slice S4 of #1349 (tests for the
torrust-tracker-http-corepackage, EPIC #1347): the unit tests for the HTTP core events and for the container that composes the services. It changes test code and documentation only. Production code is unchanged: everything before the#[cfg(test)]module ofevent.rsis byte-identical todevelop,container.rsonly gains an appended test module, and there is no manifest change. The remaining files follow in the slices S5-S6 of the specification, each starting after the previous one merges.Related to #1349
Parent EPIC: #1347
What this slice adds
event.rs. The 7 existing tests are refactored onto small in-file builders andrstesttables, and the approved plan adds the rest: 29 cases in 10 test functions. They pin the full metric label set of a connection context as literal strings (IPv4, IPv6, an IPv4-mapped client, a configured public URL, an HTTPS server on another port and a server bound to an IPv4-mapped address), the client IP family and type derived from the client and not the server binding, the public URL and instance id accessors, equality over every part of a context, and the four public accessors that have no caller in the repository, which are pinned as public API by maintainer decision. The deadannounce_events_matchhelper is removed and the publictestmodule becomes a privatetestsmodule.container.rs. The file had no tests. It now has 27: the always-enabled statistics event bus and its sender (with usage statistics enabled and disabled), the collaborators the container exposes, the instance id, public URL, reverse-proxy policy and query-string IP policy that reach the announce and scrape services, thetracker-coreauthentication, whitelist and torrent repository those services use, howinitialize_from_tracker_coreexposes its own event bus, andinitializeover a real SQLite file in the temp directory, including its documented panic. Thetracker-corecontainer is built by hand, so no test calls a production container factory.Evidence
cargo-llvm-cov 0.6.16, stable Rust 1.99.0, clean unit-only runs). The S3 merge brought Drain listener queues on shutdown #2414 intostatistics/event/listener.rs, so the baseline was measured again at the S3 merge: lines 2,040 / 2,197 (92.85%), regions 93.64%, functions 93.85%, 95 unit tests. Now: lines 2,536 / 2,592 (97.84%), regions 3,264 / 3,324 (98.19%), functions 309 / 315 (98.10%), and 144 unit tests.event.rsgoes from 83.96% to 100% of lines, and every production line ofcontainer.rs(73) is covered; the uncovered regions are failure branches ofmatches!assertions in the test module. The totals include the test modules, and llvm-cov does not count the body lines of a test that is both anrstesttable and a#[tokio::test], so the counted totals fell by 80 lines when four tests became tables; no production line lost coverage. The mutation results below are the stronger signal.initialize, the key store, the whitelist and the statistics repository were killed too. The independent review then found two label mutants that survived (the protocol and address-type labels hard-coded) and an unvaried port; an HTTPS case on port 443 and a case with a server bound to an IPv4-mapped address now kill them. Copilot's review of this pull request found a mutant nobody had hunted: a bus gated on the usage-statistics policy passed the delivery test, because the default configuration enables usage statistics. Four tests are now tables over the policy and three new mutations are killed only by the disabled cases. One mutation survives by design:initializealways creating the swarm registry with usage statistics disabled, which nothing in this package can observe because the container does not expose the registry. The plan records it with its owner.event.rson a maintainer review before the new tests. R1 and R2 were coded together and the maintainer approved the completed file; the plan and the specification log say so. The specification log also carries a correction: the S4 start entry claimed thathttp-coredid not change after S3, which was wrong because of Drain listener queues on shutdown #2414. Three mutation forms did not compile under the workspace lints and were redone in a compiling form before they counted.Review guidance
The production diff is empty, so review the tests, not the behavior. Each plan lists every test with the Arrange, Act and Assert it was written from, the mutation that proves it, and the maintainer's approvals. The commits are the S3 merge record, one commit per file, and the fixes from the independent Task Reviewer, kept as separate steps.
Files
packages/http-core/src/event.rs(test module only)packages/http-core/src/container.rs(test module appended)docs/issues/open/1349-1347-add-tests-http-core/(ISSUE.md,coverage-evidence.md,agent-review-reports.md,test-refactor-plans/README.md,test-refactor-plans/event-tests.md(new),test-refactor-plans/container-tests.md(new))docs/issues/open/1347-overhaul-packages-testing/EPIC.mddocs/pr-reviews/pr-2593-review/PR-REVIEW.md(new)Validation
cargo test -p torrust-tracker-http-core: 144 unit tests and the doc tests pass.cargo +nightly fmt --all -- --check,cargo clippy -p torrust-tracker-http-core --all-targets --all-features -- -D warnings,cargo machete --with-metadata,git diff --check,linter markdownandlinter cspellpass../contrib/dev-tools/git/hooks/pre-commit.sh) passed for every commit../contrib/dev-tools/git/hooks/pre-push.sh: nightly Rust format, check and docs, then the stable Rust 1.99.0 test suite) passed on the final head.LOWfindings and no required change; all four are fixed, and the report is inagent-review-reports.md.open-pull-requestskill prints nothing (no branch commit ids cited).develop: it changed only documentation outsidepackages/http-coresince this branch was cut, andgit merge-treeagainst it reports no conflict.