Skip to content

PMM-15284 Add MySQL RTA QA coverage - #1128

Open
theTibi wants to merge 8 commits into
mainfrom
PMM-15284
Open

PMM-15284 Add MySQL RTA QA coverage#1128
theTibi wants to merge 8 commits into
mainfrom
PMM-15284

Conversation

@theTibi

@theTibi theTibi commented Aug 2, 2026

Copy link
Copy Markdown

Real-Time Analytics now supports MySQL (PMM-15283, percona/pmm#5509); add QA automation verified against the PR-4417-11f4346 feature build:

  • MySQLHelper workload generator (labeled SELECT SLEEP() statements visible in sys.x$processlist) with a mySqlDbHelper fixture; defaults match the QA framework ps setup, overridable via MYSQL_* env vars.
  • mysql.test.ts (@RTA, 6 tests): overview shows a running MySQL query with host/database/user; details pane shows MySQL attributes and the raw processlist row; Hide-COMMIT toggle; Database/User faceted multi-select filters; MongoDB and MySQL rows side by side with payload-specific details; CSV export contains the MySQL columns. Mocked search responses use the snake_case wire format.
  • CLI: add/change/remove flow for rta-mysql-agent in the percona-server suite, gated on pmm-client >= 3.9.0.
  • RealTimeAnalyticsPage: update position-based column locators for the new layout (Database 3, User 4, Operation ID 5, Elapsed time 6 pinned right) and add locators for the new controls; fix the T2252 export filename assertion (mongodb_rta_export_ -> rta_export_).
  • CI: the @RTA feature-build job also provisions ps=8.4.
  • Add mysql2 dependency.

Summary by CodeRabbit

  • New Features

    • Added end-to-end coverage for MySQL Real-Time Analytics, including live queries, query details, database and user filtering, column visibility, COMMIT visibility, mixed database results, and CSV exports.
    • Added MySQL service support to automated test environments.
    • Added lifecycle coverage for configuring, updating, monitoring, and removing the Real-Time Analytics agent.
  • Bug Fixes

    • Updated CSV export validation to match the rta_export_YYYYMMDD_HHMMSS.csv filename format.

Real-Time Analytics now supports MySQL (PMM-15283, percona/pmm#5509);
add QA automation verified against the PR-4417-11f4346 feature build:

- MySQLHelper workload generator (labeled SELECT SLEEP() statements
  visible in sys.x$processlist) with a mySqlDbHelper fixture; defaults
  match the QA framework ps setup, overridable via MYSQL_* env vars.
- mysql.test.ts (@RTA, 6 tests): overview shows a running MySQL query
  with host/database/user; details pane shows MySQL attributes and the
  raw processlist row; Hide-COMMIT toggle; Database/User faceted
  multi-select filters; MongoDB and MySQL rows side by side with
  payload-specific details; CSV export contains the MySQL columns.
  Mocked search responses use the snake_case wire format.
- CLI: add/change/remove flow for rta-mysql-agent in the
  percona-server suite, gated on pmm-client >= 3.9.0.
- RealTimeAnalyticsPage: update position-based column locators for the
  new layout (Database 3, User 4, Operation ID 5, Elapsed time 6
  pinned right) and add locators for the new controls; fix the T2252
  export filename assertion (mongodb_rta_export_ -> rta_export_).
- CI: the @RTA feature-build job also provisions ps=8.4.
- Add mysql2 dependency.
@theTibi
theTibi removed the request for review from peterSirotnak August 2, 2026 10:29
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The change adds MySQL provisioning and helpers, CLI RTA lifecycle coverage, and Playwright coverage for MySQL RTA display, filtering, details, COMMIT visibility, mixed engines, elapsed time, and CSV export.

Changes

MySQL RTA coverage

Layer / File(s) Summary
MySQL test infrastructure
.github/workflows/fb-e2e-suite.yml, e2e_tests/helpers/mysql.helper.ts, e2e_tests/fixtures/pmmTest.ts, e2e_tests/package.json
The E2E environment provisions Percona Server for MySQL 8.4. The test suite adds mysql2, MySQLHelper, and a Playwright fixture with environment-variable configuration and teardown.
CLI RTA agent lifecycle
cli/tests/perconaMySqlServer.spec.ts
A version-gated test covers MySQL RTA agent creation, readiness polling, configuration updates, and cleanup.
MySQL RTA UI coverage
e2e_tests/pages/qan/rta/realTimeAnalytics.page.ts, e2e_tests/tests/qan/rta/mysql.test.ts, e2e_tests/tests/qan/rta/overview.test.ts
The page model supports Database and User columns, details fields, filters, elapsed-time parsing, and the Hide COMMIT control. Tests cover MySQL queries, mixed-engine details, filtering, column visibility, compact elapsed time, CSV export, and the updated export filename.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the pull request's main change: adding QA coverage for MySQL RTA.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
e2e_tests/helpers/mysql.helper.ts (1)

42-53: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Use a parameterized query instead of manual string escaping.

simulateLongRunningQuery builds the query with manual escaping (escapedLabel) instead of a placeholder. Static analysis flags this pattern as a SQL injection risk (CWE-89). queryLabel is only ever a literal from test code today, but rolling manual escaping is fragile and unnecessary when mysql2 supports ? placeholders natively.

Use a parameterized query to eliminate the manual escaping and the static-analysis finding.

🔒️ Proposed fix using a parameterized query
   simulateLongRunningQuery = async (
     options: {
       delayMs?: number;
       queryLabel?: string;
     } = {},
   ) => {
     const { delayMs = Timeouts.TEN_SECONDS, queryLabel = 'rta-simulated-query' } = options;
-    const escapedLabel = queryLabel.replace(/\\/g, '\\\\').replace(/'/g, "''");
     const delaySeconds = Math.max(1, Math.ceil(delayMs / 1_000));

-    return this.pool.query(`SELECT '${escapedLabel}', SLEEP(${delaySeconds})`);
+    return this.pool.query('SELECT ?, SLEEP(?)', [queryLabel, delaySeconds]);
   };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e_tests/helpers/mysql.helper.ts` around lines 42 - 53, Update
simulateLongRunningQuery to use a mysql2 parameterized query with a ?
placeholder for queryLabel and pass the label through the query parameters,
removing the escapedLabel manual escaping. Preserve the existing delaySeconds
calculation and SLEEP behavior.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cli/tests/perconaMySqlServer.spec.ts`:
- Around line 248-250: Update the affected test steps around the MySQL RTA agent
operations to call output.assertSuccess() after each cli.exec() and before or
alongside outContains(), matching the existing pattern near lines 241-242; apply
this consistently to the steps at the referenced ranges while preserving their
current output assertions.
- Line 235: Update the version gate in the perconaMySqlServer test to compare
the full pmm-client major and minor version against 3.9.0, rather than relying
on the minor value returned by getPmmAdminMinorVersion. Ensure 4.0.0 is accepted
and 2.10.0 is skipped while preserving the existing test.skip behavior.

In `@e2e_tests/tests/qan/rta/mysql.test.ts`:
- Around line 71-80: Update both tests’ “Simulate long running MySQL query”
steps to retain the promise returned by mySqlDbHelper.simulateLongRunningQuery,
attach error handling that preserves failures, and await or cancel it before
fixture teardown. Ensure the query does not remain floating after the
rowByQueryText assertion, avoiding delayed pool.end() cleanup while still
propagating query errors.
- Around line 10-34: Add the required string state field to the object returned
by buildMySqlQuery, using a representative value such as “executing” so the mock
conforms to the wire contract while preserving the existing query fields.

---

Nitpick comments:
In `@e2e_tests/helpers/mysql.helper.ts`:
- Around line 42-53: Update simulateLongRunningQuery to use a mysql2
parameterized query with a ? placeholder for queryLabel and pass the label
through the query parameters, removing the escapedLabel manual escaping.
Preserve the existing delaySeconds calculation and SLEEP behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3063f4b8-cbca-4f49-858a-02a795577c2a

📥 Commits

Reviewing files that changed from the base of the PR and between 15bc85a and 575e80d.

⛔ Files ignored due to path filters (1)
  • e2e_tests/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • .github/workflows/fb-e2e-suite.yml
  • cli/tests/perconaMySqlServer.spec.ts
  • e2e_tests/fixtures/pmmTest.ts
  • e2e_tests/helpers/mysql.helper.ts
  • e2e_tests/package.json
  • e2e_tests/pages/qan/rta/realTimeAnalytics.page.ts
  • e2e_tests/tests/qan/rta/mysql.test.ts
  • e2e_tests/tests/qan/rta/overview.test.ts

Comment thread cli/tests/perconaMySqlServer.spec.ts
Comment thread cli/tests/perconaMySqlServer.spec.ts
Comment thread e2e_tests/tests/qan/rta/mysql.test.ts
Comment thread e2e_tests/tests/qan/rta/mysql.test.ts
- CLI: assert the exit code alongside the output message in the RTA
  agent add/change/remove steps.
- e2e: add the state field to the mocked MySQL payload to match the
  wire contract.
- MySQLHelper: run long queries on dedicated tracked connections and
  destroy them on close(), so fixture teardown no longer waits out
  SLEEP() statements (the two live tests drop from ~31s to ~4s each);
  teardown-induced aborts are suppressed while real query failures
  still surface.

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e_tests/helpers/mysql.helper.ts`:
- Around line 70-75: Create the MySQL connection within the try block in the
long-running query method, then check the helper’s closed state immediately
after creation and destroy and return without tracking it if shutdown has begun.
Track active connections only after that check, and add finally cleanup to
remove the connection from longRunningConnections and destroy it after the query
completes or fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: de6dac9d-0012-40b9-8a35-08baf08a68fa

📥 Commits

Reviewing files that changed from the base of the PR and between 575e80d and 9d667af.

📒 Files selected for processing (3)
  • cli/tests/perconaMySqlServer.spec.ts
  • e2e_tests/helpers/mysql.helper.ts
  • e2e_tests/tests/qan/rta/mysql.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • e2e_tests/tests/qan/rta/mysql.test.ts

Comment thread e2e_tests/helpers/mysql.helper.ts Outdated
theTibi added 4 commits August 2, 2026 12:59
The RTA overview now hides Database and User by default (percona/pmm#5509),
so the QA coverage is updated to match:

- cells are addressed by their query-<id>-<name>-cell test id instead of by
  column position, which is no longer stable when columns are hidden;
- elapsed time is parsed from the compact form ('1.5s', '42s') the overview
  renders, where splitting on a space returned NaN;
- showColumns() reveals Database and User through the Show/Hide columns menu
  for the tests that assert or filter on them;
- new tests cover the hidden-by-default columns and the compact elapsed time
  format.

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
e2e_tests/pages/qan/rta/realTimeAnalytics.page.ts (1)

21-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a stable locator for the MongoDB code block.

code.language-mongodb is a CSS-class selector. We must not make a syntax-highlighting class part of the Grafana test contract. Use a data-testid or an accessible locator. If the UI has no stable locator, add one before using this page object. Make it so.

As per coding guidelines, use data-testid locators where available and do not use CSS class selectors for Grafana elements.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e_tests/pages/qan/rta/realTimeAnalytics.page.ts` around lines 21 - 24,
Update detailsPaneCodeByText to remove the syntax-highlighting selector
code.language-mongodb and use the MongoDB code block’s stable data-testid or
accessible locator instead. If no stable locator exists in the UI, add one there
first, then reference it from this page object while preserving the queryText
filter.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e_tests/pages/qan/rta/realTimeAnalytics.page.ts`:
- Around line 203-205: Update the checkbox interaction in showColumns to call
check() instead of click(), ensuring repeated calls enforce column visibility
without hiding already visible columns.

---

Nitpick comments:
In `@e2e_tests/pages/qan/rta/realTimeAnalytics.page.ts`:
- Around line 21-24: Update detailsPaneCodeByText to remove the
syntax-highlighting selector code.language-mongodb and use the MongoDB code
block’s stable data-testid or accessible locator instead. If no stable locator
exists in the UI, add one there first, then reference it from this page object
while preserving the queryText filter.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f7dc2ea8-3e66-42e1-b8f8-bc024606e081

📥 Commits

Reviewing files that changed from the base of the PR and between b66dd1b and bc1072d.

📒 Files selected for processing (2)
  • e2e_tests/pages/qan/rta/realTimeAnalytics.page.ts
  • e2e_tests/tests/qan/rta/mysql.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • percona/pmm-qa (manual)
  • percona/pmm (manual) → reviewed against open PR #5509 rta-mysql-test instead of the default branch

Comment thread e2e_tests/pages/qan/rta/realTimeAnalytics.page.ts
theTibi added 2 commits August 4, 2026 22:41
check() leaves an already visible column visible, where click() toggled it
back off. No test hits that today - each caller runs in its own test, where
the columns start hidden - but the helper is now safe to call more than once
and if a column ever becomes visible by default.
The overview keeps three decimals below ten seconds (percona/pmm#5509), so the
mocked two-second query now renders as '2.000s'.
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.

1 participant