Repository navigation
test(tracker-core): [#2902] cover the constructors of the MySQL and PostgreSQL drivers - #3036
Conversation
…L and PostgreSQL drivers A malformed URL gives a connection error of the driver's own kind, and a well-formed one builds a lazy pool without connecting. Unreachable-endpoint tests are not added: the pool takes 30 s to give up, measured on 2026-11-24. The other server-driver files stay with db-compatibility.yaml. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…in the driver-test commands Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ment Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Warning Review limit reachedYou'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 12 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
[Low impact] The PR appears safe to merge. SummaryAdds six constructor tests for the MySQL and PostgreSQL drivers without changing production code.
No actionable issues were found in the latest changes or the full-PR rules check. Reviews (2) · Last reviewed commit: "docs(issues): [#2902] record the S3 pull..." · Reviewed by Greptile |
|
ACK 8fb5e11 |
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 8fb5e1181dc6a07642931cc1509ac1dc1410e2ef. Recomputed from the bytes at this head, against the merge base b81e4512e; git merge-tree against develop d89ab84bd writes a clean tree with no conflict, and no file this change touches has moved on develop since the merge base.
Process. A test-coverage slice, governed by write-unit-test, the issue's per-file workflow and plan guidance (ISSUE.md, test-refactor-plans/README.md), commit-changes and open-pull-request. The plan has every required section; ledger, slice row, measurement, EPIC rows and logs are updated; the description uses Related to, as the slice rules require. Gaps: F1, F2.
The change against its claim. Both constructors map a from_str failure through (e, DRIVER), which databases/error.rs turns into ConnectionError for Configuration; both inputs fail in the URL parser, and connect_lazy_with does no I/O but spawns a maintenance task, hence #[tokio::test]. Production code is unchanged, so the mutants are the guard: by reading, each test fails under its named mutation. The new commands match db-compatibility.yaml, and the skip-passes sentence matches the early return Ok(()) of both suites. Every percentage and delta in the evidence table, the EPIC rows and the plan recomputes; the setup.rs 119-128 reference and the percent-encoding claim hold.
Consistency. All 126 relative links, anchors and frontmatter paths in the six changed Markdown files resolve; nothing is moved; the dictionary is unchanged and every added word already occurs in the tree. Two records lag: the S2 row (F3) and the comments by the new modules (F4).
Hygiene. Four commits with Conventional subjects in the [#2902] form the slice rules give; the one body matches its diff; author equals committer. Each commit carries an attribution footer, which no rule in the tree forbids (the provenance discussion has no Outcome, and a discussion is not a rule). git diff --check is clean, the commit-id check prints nothing, and the closing-keyword pattern matches nothing in the title, description or folded messages.
Findings. Minor: F1 plan register row, F2 unrecorded per-file deviation, F3 stale S2 row. Nit: F4 wrong workflow in comments, F5 README sentence. None blocks.
Checked, no finding. The Driver import (as in stored_key_tests); the missing // Arrange (recorded in the plan); no audit record is due, as no comment asks for a reply.
Checks
On the loop's compute node at this head, against the merge base b81e4512e (receipt server-gates-kranich-1419): the repository's pre-commit gate and lint roster exit 0 (314 s wall). This pull request has no review audit record, so there was nothing for the audit validator to check. In the per-PR target directory, with every workspace crate recompiled at this head, cargo test --workspace passes 4678 tests with 0 failed and 5 ignored across 136 binaries (566 s wall), cargo clippy --workspace --all-targets --all-features -- -D warnings is clean (30 s wall), and cargo deny check exits 5 with no error outside the set develop already has (464 errors; the base's lockfile replaced torrust-located-error with source-location-check, which removes one license rejection). Checked against the bytes at posting: the Plans table in docs/issues/open/2902-1347-add-tests-tracker-core/test-refactor-plans/README.md ends at row 17 (line 44) and line 46 says "Add a row when a plan is created", while the new plan databases-server-drivers-tests.md has no row, as F1 says. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Publish (Development): completed/skipped; Publish (Release): completed/skipped; Context: completed/success; Package Coverage Regression: completed/success; Package Coverage (torrust-tracker-http-core): completed/success; Package Coverage (torrust-tracker-core): completed/success; Package Coverage (torrust-tracker-test-helpers): completed/success; Database Compatibility PostgreSQL (15): completed/success; Database Compatibility PostgreSQL (16): completed/success; Database Compatibility PostgreSQL (17): completed/success; Database Compatibility PostgreSQL (14): completed/success; Database Compatibility MySQL (8.4): completed/success; Database Compatibility MySQL (8.0): completed/success; Docker E2E: completed/skipped; Docs Lint: completed/success; Workspace Packaging: completed/success; Shipped Features: completed/success; Unit (stable): completed/success; Documented Clippy Allows: completed/success; Layer Boundary Bans: completed/success; Unit (nightly): completed/success; Source Locations: completed/success; Test (Docker) (release): completed/success; Build on windows-latest (nightly): completed/success; Build on ubuntu-latest (stable): completed/success; Build on windows-latest (stable): completed/success; Build on ubuntu-latest (nightly): completed/success; Build on macos-latest (nightly): completed/success; Build on macos-latest (stable): completed/success; Generate Coverage Report: completed/success; Discover Package Coverage: completed/success; Persistence Benchmark SQLite3: completed/success; Persistence Benchmark MySQL: completed/success; Persistence Benchmark PostgreSQL: completed/success; CodeRabbit: completed/neutral; Greptile Review: completed/success". At posting, develop is d89ab84bd.
|
|
||
| # Server Database Drivers Test Plan | ||
|
|
||
| Follow the shared [guidance](README.md). This plan covers ledger rows 18 to 27, slice S3: the MySQL |
There was a problem hiding this comment.
[Minor][F1] The new plan has no row in the plan register of test-refactor-plans/README.md.
The guidance this line links says "Add a row when a plan is created", and its Plans table stops at sequence 17 (databases-driver-mod-and-traits-no-change.md) at this head; its Reconciliation section also asks for every plan state to be reconciled before final verification. Suggest adding row 18 for this plan, with its approval and result in the table's own form.
|
|
||
| ## Test Design | ||
|
|
||
| One test module per driver, always compiled (`#[cfg(test)]`, no feature), next to the existing gated one. |
There was a problem hiding this comment.
[Minor][F2] The slice departs from the issue's per-file rules without saying so.
ISSUE.md Commit Points gives T3 one commit per completed file and says "Never mix two source files", and Per-File Workflow gives each file one decision record, shared only by no-change rows. Here one record covers two test-producing files (mysql/mod.rs, postgres/mod.rs), and 9e965091d changes both. The two modules are identical, so nothing is hidden at this head, but a reader of the spec cannot tell whether the rule was waived. Suggest one sentence here or in the spec recording why the two drivers share a record and a commit.
| | S1 | T2, then `statistics/`: `repository.rs`, `metrics.rs`, `persisted/mod.rs`, `persisted/downloads.rs`, `event/listener.rs`, `event/handler.rs`, `mod.rs` (the only area reached just by the integration binary) | 1-7 | `2902-1347-add-tests-tracker-core-statistics` | #2988 | DONE | | ||
| | S2 | The SQLite persistence boundary: `sqlite/{auth_key_store,torrent_metrics_store,whitelist_store,mod,schema_migrator}.rs`, `databases/{error,setup}.rs`, `error.rs`, the extraction of `parse_valid_until` and the row mapping (Q4, F2), plus the `databases/traits` and `driver/mod.rs` no-change decisions | 8-17 | `2902-1347-add-tests-tracker-core-sqlite` | #3009 | IN_PROGRESS | | ||
| | S3 | MySQL and PostgreSQL drivers: Docker-free error-path tests if non-flaky, otherwise no-change rows with the `db-compatibility` workflow as owner (Q3); the README and `packages/AGENTS.md` driver-test commands (Q2) | 18-27 | `2902-1347-add-tests-tracker-core-server-drivers` | TBD | TODO | | ||
| | S3 | MySQL and PostgreSQL drivers: Docker-free error-path tests if non-flaky, otherwise no-change rows with the `db-compatibility` workflow as owner (Q3); the README and `packages/AGENTS.md` driver-test commands (Q2) | 18-27 | `2902-1347-add-tests-tracker-core-server-drivers` | #3036 | IN_PROGRESS | |
There was a problem hiding this comment.
[Minor][F3] The row above this one (line 301, outside the diff) still shows S2 as IN_PROGRESS.
The merge of its pull request #3009 is an ancestor of the merge base, and the Rules under this table say each PR updates the slice table. The previous slice made the same correction for S1 in docs(issues): [#2902] mark slice S1 done in the slice table. Suggest setting S2 to DONE in this change.
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod constructor_tests { |
There was a problem hiding this comment.
[Nit][F4] Outside the diff, the comment above the gated suite (lines 201-202 here, and lines 182-183 of postgres/mod.rs) says it is invoked by the database-compatibility job of .github/workflows/testing.yaml.
That workflow has no such job at this head; db-compatibility.yaml runs both suites, as the README and the plan now say. The comment predates this change, but it sits beside the new module, and the slice's Q2 fix is about naming the right runner.
| ## Testing | ||
|
|
||
| Run tests including tests for MySQL driver: | ||
| Run tests including the tests of the MySQL driver (each driver suite needs the `db-compatibility-tests` feature, a container and its variable): |
There was a problem hiding this comment.
[Nit][F5] This sentence still reads "Run tests including the tests of" the driver, but the command below it is now filtered to run_mysql_driver_tests, so it runs that one suite and none of the package's other tests.
Suggest wording it as running that driver's suite, as line 29 does for the other driver.
|
ACK 8fb5e11 — the six driver-constructor tests, the corrected driver-suite commands and the recomputed S3 coverage records were checked against the bytes at this head |
|
ACK 8fb5e11 |
Related to #2902
Slice S3 of #2902: the MySQL and PostgreSQL drivers of
packages/tracker-core. It adds six unit tests, fixes two documentation commands and records why almost nothing else can be tested without a server. No production code changes.Scope decision (Q8). I measured an unreachable endpoint first:
Mysql::new("mysql://u:[email protected]:1/db")builds a lazy pool, and the first store call fails withConnectionError { source: PoolTimedOut }after 30.0 s, the fixedsqlxacquire timeout of the pool options the drivers use. Q3 keeps Docker-free tests only if they are fast and not flaky, and a shorter timeout needs a production change, so the maintainer chose instant tests only. A malformed URL fails at once, and a well-formed one builds the pool without connecting.mysql/mod.rs,postgres/mod.rsdb-compatibility.yamlowns themThe
setup.rsarms for the two drivers also stay untested here: the URL is built from typed fields and percent-encoded, so a configuration cannot produce one that fails to parse, and the arms can only fail after the 30 s timeout.A first draft of the constructor tests had a case "a URL of another driver"; it was wrong (the MySQL parser accepts a
postgresql://URL and the PostgreSQL parser amysql://one), so it became "a port that is not a number". The plan records this.Documentation (Q2). The README of
tracker-coreandpackages/AGENTS.mdgaveTORRUST_TRACKER_CORE_RUN_MYSQL_DRIVER_TEST=true cargo test ..., which omits--features db-compatibility-tests(without it the gated module is not compiled and nothing runs) and names only MySQL. Both now give the commands of thedb-compatibilityworkflow for both drivers; the README also says that a run without the variable reports the suites as passed. The visible skip and the driver coverage in the published report stay with the separate issue of Q2.Coverage of
tracker-core(stable Rust 1.100.0,cargo-llvm-cov 0.9.1, against thedevelopbaseb81e4512e): unit-only lines 87.13% to 87.36% (287 unit tests, 281 on the base), aggregate 87.13% to 87.38%. The aggregate counts five more lines than the unit-only run in each of the two files with identical regions and functions; this is recorded and was not investigated further. Details:coverage-evidence.md, section "Slice Measurements".Validation:
cargo test -p torrust-tracker-core --all-features(287 unit, 15 integration and 18 other tests),cargo clippy -p torrust-tracker-core --all-targets --all-features,cargo +nightly fmt --all -- --check,cargo machete --with-metadata, the pre-commit gate on every commit and the repository's pre-push checks on push. The six mutants (three per driver) are each killed; the plan has the table.🤖 Generated with Claude Code
Summary by CodeRabbit