Repository navigation
ci(tracker-core): add DB compatibility matrix coverage for issue #1703 - #1705
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands persistence/driver CI coverage by adding a dedicated database-compatibility job (MySQL matrix) and adds regression coverage for large scrape counters, while updating the related issue spec documentation.
Changes:
- Add UDP scrape counter saturation guard (u32 → i32::MAX) plus a regression unit test.
- Add MySQL image-tag injection for tracker-core MySQL driver tests and gate those tests behind a new
db-compatibility-testsfeature used by CI. - Add a
database-compatibilityGitHub Actions job (MySQL 8.0 / 8.4 matrix) and update issue-spec docs to match the implemented workflow.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/udp-tracker-server/src/handlers/scrape.rs | Saturating conversion helper for UDP i32 counters + regression test. |
| packages/tracker-core/src/databases/driver/mysql.rs | Feature-gate MySQL container tests and allow overriding MySQL image tag via env var. |
| packages/tracker-core/Cargo.toml | Add db-compatibility-tests feature flag for compatibility suite gating. |
| packages/http-protocol/src/v1/responses/scrape.rs | Add regression test ensuring very large downloaded values are encoded. |
| .github/workflows/testing.yaml | Add database-compatibility CI job with MySQL version matrix; e2e now depends on it. |
| docs/issues/1703-1525-01-persistence-test-coverage.md | Update spec to reflect workflow-based matrix approach. |
| docs/issues/1525-overhaul-persistence.md | Point the EPIC step to the updated spec filename. |
Comments suppressed due to low confidence (1)
packages/tracker-core/src/databases/driver/mysql.rs:360
- The inline test instructions below still say the MySQL driver tests are executed with just
TORRUST_TRACKER_CORE_RUN_MYSQL_DRIVER_TEST=true cargo test, but the module is now gated behindfeature = "db-compatibility-tests". Update the instructions to include enabling that feature (so developers can still run these tests locally).
#[cfg(all(test, feature = "db-compatibility-tests"))]
mod tests {
use std::sync::Arc;
use testcontainers::core::IntoContainerPort;
/*
We run a MySQL container and run all the tests against the same container and database.
Test for this driver are executed with:
`TORRUST_TRACKER_CORE_RUN_MYSQL_DRIVER_TEST=true cargo test`
The `Database` trait is very simple and we only have one driver that needs
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1705 +/- ##
===========================================
+ Coverage 86.43% 86.44% +0.01%
===========================================
Files 288 288
Lines 22672 22693 +21
Branches 22672 22693 +21
===========================================
+ Hits 19596 19617 +21
- Misses 2838 2842 +4
+ Partials 238 234 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ust#1703 - Renamed docs/issues/1525-01-persistence-test-coverage.md to docs/issues/1703-1525-01-persistence-test-coverage.md to align the file name with the tracked GitHub issue number - Updated the spec title to include the issue number (torrust#1703) and added a link to torrust#1703 - Updated the spec file reference in docs/issues/1525-overhaul-persistence.md to point to the renamed file
73aa385 to
6342067
Compare
|
ACK f523745 |
da2ce7
left a comment
There was a problem hiding this comment.
This is a post-merge review of #1705 as it stands at e170b9620 on the default branch.
What still runs: the MySQL driver suite that #1705 moved into a job of its own now runs as database-compatibility-mysql (MySQL 8.0 and 8.4) in .github/workflows/db-compatibility.yaml. 517b42e moved it there and took it out of the E2E job's dependencies. It is selected by the db-compatibility-tests feature (packages/tracker-core/Cargo.toml:21, packages/tracker-core/src/databases/driver/mysql/mod.rs:77) and by the image tag variable read at mysql/mod.rs:115. The UDP clamp that #1705 put in place of the wrapping as i32 casts is now saturating_wire_i32 (packages/udp-server/src/handlers/mod.rs:38, since b4d1a75), shared by scrape (packages/udp-server/src/handlers/scrape.rs:107-109) and announce. The pull request's description lists this among the tests, but it changes what the server sends for any counter above i32::MAX. The HTTP test should_encode_large_download_counts_as_i64 (packages/http-protocol/src/v1/responses/scrape/encoding.rs:134) pins the lossless i64 encoding; HTTP does not clamp, so it is not a saturation test. Before #1705 the UDP scrape answer followed the scrape map rather than the request order; dc3c85f has since fixed that.
[Minor] .github/workflows/db-compatibility.yaml:15 and :20: since 35d03b3 the workflow triggers only on changes under packages/tracker-core/** and the workflow's own files. The MySQL suite also depends on inputs outside those paths: the sqlx, testcontainers and TLS versions resolved in the root Cargo.lock; the connection URL that Database::connection_url() builds in packages/configuration/src/v3_0_0/database.rs:66, which the test connects with (mysql/mod.rs:193-198 and :242-249); and NumberOfDownloads from packages/primitives. For example, a scheduled cargo update moves sqlx within 0.8 and changes only Cargo.lock. Neither the pull request nor the push after merge starts the MySQL 8.0 and 8.4 jobs. The Testing unit job's --all-features run does compile run_mysql_driver_tests, but the test returns Ok without starting a container because TORRUST_TRACKER_CORE_RUN_MYSQL_DRIVER_TEST is unset (mysql/mod.rs:205-208), so it reports ok. The legacy bootstrap, bigint column and above-i32::MAX save-and-load checks (mysql/mod.rs:225-315) then stay unrun until the next tracker-core change, which inherits the failure. The comment at lines 7-11 says broader dependency closure is not required, but these inputs show that it is. Smallest fix: add Cargo.lock, Cargo.toml, packages/configuration/** and packages/primitives/** to both paths lists. The PostgreSQL job shares the trigger and gains the same coverage.
[Nit] packages/tracker-core/src/databases/driver/mysql/mod.rs:201-202: the comment added by #1705 says the test is invoked by .github/workflows/testing.yaml in the database-compatibility job. Since 517b42e it is the database-compatibility-mysql job in .github/workflows/db-compatibility.yaml, and testing.yaml no longer has such a job. The same sentence was copied to packages/tracker-core/src/databases/driver/postgres/mod.rs:182-183. A reader who follows it to find out how the suite runs lands on the wrong file. Smallest fix: name the current file and job in both comments.
[Nit] .github/workflows/db-compatibility.yaml:25: the workflow declares no permissions:, so on push events its jobs run with the repository's default token scope, although they only read the checkout and run tests. The repository's workflow guidelines ask for least-privilege permissions. The Testing workflow has the same omission, so this is an existing pattern rather than something #1705 introduced. Smallest fix: add a top-level permissions: with contents: read before env:.
Checked and found sound: the clamp at packages/udp-server/src/handlers/mod.rs:38-40 and its tests at lines 656-678 (i32::MAX kept, i32::MAX + 1 and u32::MAX clamped, small values unchanged); the lossless i64::from encoding at packages/http-protocol/src/v1/responses/scrape/encoding.rs:62-64 and its test; the cfg on the feature at mysql/mod.rs:77 together with the Testing unit job's --all-features run (the suite compiles, and skips without the variable); the fallback to tag 8.0 when the variable is unset (mysql/mod.rs:115); the matrix values and test filter at .github/workflows/db-compatibility.yaml:35 and :61; action references that match the rest of the repository; and no real credentials in the workflow or the test (the container password is a fixed throwaway value).
Summary
database-compatibilityjob between unit and e2e with a MySQL 8.0/8.4 matrixdocs/issues/1703-1525-01-persistence-test-coverage.mdto match the implemented workflowCloses #1703