Skip to content

ci(tracker-core): add DB compatibility matrix coverage for issue #1703 - #1705

Merged
josecelano merged 4 commits into
torrust:developfrom
josecelano:1703-1525-01-db-compatibility-matrix
Apr 22, 2026
Merged

josecelano merged 4 commits into
torrust:developfrom
josecelano:1703-1525-01-db-compatibility-matrix

Conversation

@josecelano

Copy link
Copy Markdown
Member

Summary

  • add saturation regression tests for large download counters in HTTP and UDP scrape responses
  • add MySQL image-tag injection for tracker-core DB driver tests
  • add a dedicated database-compatibility job between unit and e2e with a MySQL 8.0/8.4 matrix
  • run compatibility tests via Rust test command with explicit env vars and feature-gated compatibility suite
  • update issue spec docs/issues/1703-1525-01-persistence-test-coverage.md to match the implemented workflow

Closes #1703

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.

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-tests feature used by CI.
  • Add a database-compatibility GitHub 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 behind feature = "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

codecov Bot commented Apr 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.10345% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.44%. Comparing base (d51ef29) to head (f523745).
⚠️ Report is 5 commits behind head on develop.

Files with missing lines Patch % Lines
...ackages/tracker-core/src/databases/driver/mysql.rs 0.00% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…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
@josecelano
josecelano force-pushed the 1703-1525-01-db-compatibility-matrix branch from 73aa385 to 6342067 Compare April 22, 2026 10:54
@josecelano

Copy link
Copy Markdown
Member Author

ACK f523745

@josecelano
josecelano merged commit c1ebdc7 into torrust:develop Apr 22, 2026
23 checks passed
@josecelano
josecelano deleted the 1703-1525-01-db-compatibility-matrix branch April 22, 2026 13:03

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

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

This branch was previously deployed

1 inactive deployment
coverage — f5237451 Deployed Apr 22, 2026 by josecelano via Generate Coverage Report #1112
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.

feat(persistence): add DB compatibility matrix (#1525-01)

3 participants