PMM-7 Add metrics test for QAN#5446
Conversation
|
@copilot review |
There was a problem hiding this comment.
Pull request overview
This PR adds ClickHouse-backed integration tests for QAN metrics and aligns the database helper code under the models package, along with Makefile improvements for standing up a local ClickHouse test environment.
Changes:
- Added integration tests for
Metricsmethods (Get,SelectQueryExamples,SchemaByQueryID,ExplainFingerprintByQueryID) against ClickHouse fixtures. - Moved QAN DB helpers from
package maintopackage modelsand updatedmain.gocall sites accordingly. - Improved
qan-api2/Makefiletest environment targets (container startup + readiness wait + clearer help).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| qan-api2/models/metrics_test.go | New ClickHouse integration tests for QAN metrics APIs. |
| qan-api2/models/db.go | Switched package to models (exported DB helpers used by main.go). |
| qan-api2/models/db_test.go | Refactored ClickHouse partition/db-creation tests (docker exec + migrations/fixtures). |
| qan-api2/Makefile | Updated help/default goal and improved test container startup flow. |
| qan-api2/main.go | Updated references to DB helpers now living in models. |
Comments suppressed due to low confidence (3)
qan-api2/models/db.go:17
- The package-level doc comment still says
Package main., but the file now declarespackage models. That makes generated docs misleading and breaks the Go convention that the doc comment must match the package name and sit immediately above thepackageclause (no blank line in between).
qan-api2/models/db_test.go:125 TestCreateDbIfNotExistscreatespmm_created_dbbut never cleans it up, and it also runs in parallel despite using the shared ClickHouse Docker container. This can leave state behind and/or race with other tests that drop/create databases in the same container.
qan-api2/models/db_test.go:83t.Parallel()here can race with other ClickHouse-integration tests because this test uses a shared Docker container and fixed database names (pmm_test_parts,pmm_created_db). In particular, the cleanup dropspmm_created_db, which can collide withTestCreateDbIfNotExistsif they run in parallel. Run this test serially or use per-test unique database names.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3 #5446 +/- ##
==========================================
- Coverage 43.17% 42.54% -0.64%
==========================================
Files 413 413
Lines 42325 42325
==========================================
- Hits 18275 18006 -269
- Misses 22179 22476 +297
+ Partials 1871 1843 -28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
|
Ticket number: PMM-7
Percona-Lab/pmm-submodules#4387