-
Notifications
You must be signed in to change notification settings - Fork 14
PMM-15284 Add MySQL RTA QA coverage #1128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
theTibi
wants to merge
10
commits into
main
Choose a base branch
from
PMM-15284
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
575e80d
PMM-15284 Add MySQL RTA QA coverage
theTibi 9d667af
PMM-15284 Address review: exit codes, mock fidelity, fast teardown
theTibi 9f38979
Improve long-running query simulation in MySQLHelper for better RTA v…
theTibi b66dd1b
Enhance RTA filters to support text input with lazy matching and upda…
theTibi bc1072d
PMM-15284 Follow RTA overview default-column changes
theTibi 4ee1208
Merge branch 'main' into PMM-15284
theTibi 8a9c399
PMM-15284 Make showColumns enforce column visibility
theTibi 2533279
PMM-15284 Follow RTA elapsed-time precision change
theTibi 6331426
PMM-15284 Cover RTA technology, pinning and toggle changes
theTibi 9e13a13
PMM-15284 Follow the one-technology-per-view change
theTibi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import mysql, { Connection, Pool } from 'mysql2/promise'; | ||
| import { Timeouts } from './timeouts'; | ||
|
|
||
| interface MySqlConfig { | ||
| host?: string; | ||
| port: number; | ||
| username: string; | ||
| password: string; | ||
| database?: string; | ||
| } | ||
|
|
||
| export default class MySQLHelper { | ||
| private closed = false; | ||
| private config: mysql.PoolOptions; | ||
| // Connections running intentionally long queries; destroyed on close() so | ||
| // fixture teardown does not wait for SLEEP() statements to finish. | ||
| private longRunningConnections: Connection[] = []; | ||
| private pool: Pool; | ||
|
|
||
| constructor(config: MySqlConfig) { | ||
| this.config = { | ||
| connectTimeout: Timeouts.THIRTY_SECONDS, | ||
| database: config.database, | ||
| host: config.host || '127.0.0.1', | ||
| password: config.password, | ||
| port: config.port, | ||
| user: config.username, | ||
| }; | ||
| this.pool = mysql.createPool(this.config); | ||
| } | ||
|
|
||
| close = async () => { | ||
| this.closed = true; | ||
|
|
||
| // destroy() drops the socket immediately instead of draining, so teardown | ||
| // is not blocked by long-running SLEEP() queries. | ||
| for (const connection of this.longRunningConnections) { | ||
| connection.destroy(); | ||
| } | ||
|
|
||
| this.longRunningConnections = []; | ||
|
|
||
| await this.pool.end(); | ||
| }; | ||
|
|
||
| runQuery = async (sql: string) => await this.pool.query(sql); | ||
|
|
||
| /** | ||
| * Simulates a long-running query visible in sys.x$processlist (and therefore in RTA). | ||
| * SLEEP() keeps the statement in the processlist for the whole delay while consuming | ||
| * nothing; the label is embedded as a string literal so the RTA query text can be | ||
| * filtered by it (comments could be stripped by intermediaries, literals cannot). | ||
| * | ||
| * Runs on a dedicated connection that close() destroys, so tests do not have to | ||
| * wait for the full delay. Errors caused by that teardown are suppressed; anything | ||
| * else is rethrown so a query that could not run still fails the test. | ||
| * | ||
| * @param options.queryLabel - string selected by the query; use it to find this query in RTA | ||
| * @returns Resolves when the statement finishes or the helper is closed | ||
| */ | ||
| 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)); | ||
| const connection = await mysql.createConnection(this.config); | ||
|
|
||
| this.longRunningConnections.push(connection); | ||
|
|
||
| try { | ||
| return await connection.query(`SELECT '${escapedLabel}', SLEEP(${delaySeconds})`); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| } catch (error) { | ||
| if (this.closed) { | ||
| return null; | ||
| } | ||
|
|
||
| throw error; | ||
| } | ||
| }; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.