Skip to content

PMM-7 Add metrics test for QAN#5446

Merged
maxkondr merged 18 commits into
v3from
PMM-7-qan-metrics-test
Jun 3, 2026
Merged

PMM-7 Add metrics test for QAN#5446
maxkondr merged 18 commits into
v3from
PMM-7-qan-metrics-test

Conversation

@maxkondr
Copy link
Copy Markdown
Contributor

@maxkondr maxkondr commented Jun 2, 2026

@maxkondr
Copy link
Copy Markdown
Contributor Author

maxkondr commented Jun 2, 2026

@copilot review

@maxkondr maxkondr marked this pull request as ready for review June 2, 2026 11:18
@maxkondr maxkondr requested a review from a team as a code owner June 2, 2026 11:18
@maxkondr maxkondr requested review from JiriCtvrtka, ademidoff and Copilot and removed request for a team June 2, 2026 11:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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 Metrics methods (Get, SelectQueryExamples, SchemaByQueryID, ExplainFingerprintByQueryID) against ClickHouse fixtures.
  • Moved QAN DB helpers from package main to package models and updated main.go call sites accordingly.
  • Improved qan-api2/Makefile test 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 declares package models. That makes generated docs misleading and breaks the Go convention that the doc comment must match the package name and sit immediately above the package clause (no blank line in between).
    qan-api2/models/db_test.go:125
  • TestCreateDbIfNotExists creates pmm_created_db but 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:83
  • t.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 drops pmm_created_db, which can collide with TestCreateDbIfNotExists if 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.

Comment thread qan-api2/models/metrics_test.go
Comment thread qan-api2/models/metrics_test.go Outdated
Comment thread qan-api2/models/metrics_test.go Outdated
Comment thread qan-api2/Makefile Outdated
Comment thread qan-api2/Makefile Outdated
Comment thread qan-api2/Makefile Outdated
maxkondr and others added 5 commits June 2, 2026 14:32
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>
Comment thread qan-api2/Makefile Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.54%. Comparing base (e72363c) to head (4e36fea).
⚠️ Report is 1 commits behind head on v3.

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     
Flag Coverage Δ
admin 34.69% <ø> (ø)
agent 46.53% <ø> (-2.61%) ⬇️
managed 42.32% <ø> (-0.01%) ⬇️
vmproxy 72.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maxkondr maxkondr requested review from ademidoff and Copilot June 3, 2026 09:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Comment thread qan-api2/Makefile
Comment thread qan-api2/Makefile
Comment thread qan-api2/Makefile
Comment thread qan-api2/db_test.go
Comment thread qan-api2/db_test.go Outdated
Comment thread qan-api2/models/metrics_test.go
maxkondr and others added 3 commits June 3, 2026 12:20
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>
@it-percona-cla
Copy link
Copy Markdown
Contributor

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ maxkondr
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Comment thread qan-api2/models/metrics_test.go
Comment thread qan-api2/db_test.go Outdated
Comment thread qan-api2/Makefile
Comment thread qan-api2/Makefile
Comment thread qan-api2/db_test.go
Comment thread qan-api2/Makefile
@maxkondr maxkondr merged commit 7f6ab28 into v3 Jun 3, 2026
27 of 30 checks passed
@maxkondr maxkondr deleted the PMM-7-qan-metrics-test branch June 3, 2026 10:15
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.

6 participants