Skip to content

Fix multiple TAP tests [CI migration - mysql84-g1]#5469

Open
rahim-kanji wants to merge 3 commits intov3.0from
v3.0-ci_84_mysql84
Open

Fix multiple TAP tests [CI migration - mysql84-g1]#5469
rahim-kanji wants to merge 3 commits intov3.0from
v3.0-ci_84_mysql84

Conversation

@rahim-kanji
Copy link
Collaborator

@rahim-kanji rahim-kanji commented Mar 21, 2026

  • mysql-sql_log_bin-error-t
  • mysql_query_logging_memory-t
  • reg_test_3247-mycli_support-t
  • reg_test_3317-lock_hostgroup_special_queries-t
  • reg_test_3504-change_user-t
  • reg_test_3549-autocommit_tracking-t

Summary by CodeRabbit

  • Chores

    • Refactored test infrastructure configuration to use environment-specific configuration files instead of hardcoded values for improved flexibility.
    • Added automatic infrastructure type detection based on test group configuration.
  • Tests

    • Improved error message capture and handling in MySQL query logging tests with better version-specific error code validation.

…stent schema.

MySQL 8.4+ returns 1049 (Unknown database) for the same scenario.
Accept both error codes for compatibility across versions.
Add TAP_REG_TEST_3549_AUTOCOMMIT_TRACKING___MYSQL_SERVER_HOSTGROUP export to infra .env files and source them in env-isolated.bash. Add INFRA_TYPE derivation from TAP_GROUP to ensure correct hostgroup (2900 for mysql84, 1300 for mysql57, etc.) is used for each infrastructure type.
@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

📝 Walkthrough

Walkthrough

This PR migrates test infrastructure configuration from a single hardcoded hostgroup value to a decentralized, infra-specific approach. It auto-derives the infrastructure type from test group names, conditionally sources per-infra environment files containing hostgroup settings, adds the hostgroup variable to multiple infra configurations, updates a ProxySQL user entry, and improves error message handling in a test.

Changes

Cohort / File(s) Summary
Control Scripts
test/infra/control/env-isolated.bash, test/infra/control/run-tests-isolated.bash
Replaced hardcoded hostgroup export with conditional sourcing of infra-specific .env files; added logic to auto-derive INFRA_TYPE from TAP_GROUP using pattern matching when INFRA_TYPE is unset.
Infrastructure Environment Files
test/infra/infra-mariadb10/.env, test/infra/infra-mysql57-binlog/.env, test/infra/infra-mysql57/.env, test/infra/infra-mysql84/.env
Added TAP_REG_TEST_3549_AUTOCOMMIT_TRACKING___MYSQL_SERVER_HOSTGROUP environment variable set to ${WHG} in each infra configuration.
ProxySQL Configuration
test/infra/infra-mysql84/conf/proxysql/infra-config.sql
Added INSERT OR IGNORE statement to create a sbtest1 user record with default hostgroup set to ${WHG}.
Test Error Handling
test/tap/tests/mysql_query_logging_memory-t.cpp
Refactored error code validation from inline expression to named boolean; updated error message logging to capture actual server error via mysql_error() and reflect version-specific error codes (1044 for 5.7/8.0, 1049 for 8.4+).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • renecannao

Poem

🐰 From hardcoded values, we break free,
Each infra now knows what it shall be,
Patterns matched, environments sourced with care,
Configurations dance through the air!
Hostgroups distributed, no longer alone,
The test infra finds its rightful home. ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fix multiple TAP tests [CI migration - mysql84-g1]' is partially related to the changeset. It mentions fixing TAP tests and CI migration context, which aligns with the PR's goal, but it is overly broad and generic. The title does not highlight the primary technical changes: environment-based hostgroup configuration, INFRA_TYPE derivation, or MySQL version-specific error handling. Consider a more specific title that captures the main technical changes, such as 'Support environment-based hostgroup configuration for TAP tests in isolated CI' or 'Auto-derive INFRA_TYPE and environment configuration for TAP test compatibility'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v3.0-ci_84_mysql84

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Tip

You can customize the tone of the review comments and chat replies.

Configure the tone_instructions setting to customize the tone of the review comments and chat replies. For example, you can set the tone to Act like a strict teacher, Act like a pirate and more.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses several failing TAP tests, primarily in the context of a CI migration to a MySQL 8.4 environment. The changes focus on enhancing the test infrastructure's adaptability by dynamically configuring environment variables and hostgroups based on the specific test group. Additionally, it improves test robustness by accommodating varying error behaviors across different MySQL versions, ensuring tests pass consistently in the new CI setup.

Highlights

  • Infrastructure Environment Loading: The test infrastructure now dynamically sources environment variables specific to the detected INFRA_TYPE, replacing a hardcoded hostgroup configuration.
  • Dynamic INFRA_TYPE Derivation: The INFRA_TYPE is now automatically derived from the TAP_GROUP variable, improving flexibility for CI environments.
  • MySQL Error Code Compatibility: The mysql_query_logging_memory-t test was updated to accept both MySQL error codes 1044 (Access denied) and 1049 (Unknown database) for non-existent schema queries, ensuring compatibility across different MySQL versions (5.7/8.0 vs 8.4+).
  • Hostgroup Configuration for autocommit_tracking test: The TAP_REG_TEST_3549_AUTOCOMMIT_TRACKING___MYSQL_SERVER_HOSTGROUP variable is now explicitly exported in several .env files for various MySQL/MariaDB infrastructures.
  • New User for MySQL 8.4 Infrastructure: A new sbtest1 user was added to the ProxySQL configuration for the infra-mysql84 environment.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses multiple TAP test failures for the mysql84-g1 CI migration. The changes primarily involve making the test environment setup more dynamic by sourcing infrastructure-specific configurations and deriving the infrastructure type from the TAP_GROUP. Additionally, a C++ test file is updated to accommodate different error codes across MySQL versions. The changes are logical and well-implemented. I have one suggestion to improve code clarity by using symbolic constants for error codes instead of magic numbers.

// MySQL 5.7/8.0 returns 1044 (Access denied) when connecting to non-existent schema.
// MySQL 8.4+ returns 1049 (Unknown database) for the same scenario.
// Accept both error codes for compatibility across versions.
bool is_expected_error = (error_code == 1044 || error_code == 1049);

Choose a reason for hiding this comment

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

medium

To improve readability and maintainability, it's better to use the symbolic constants for MySQL error codes instead of magic numbers. The header mysqld_error.h is already included in this file, so you can use ER_DBACCESS_DENIED_ERROR for 1044 and ER_BAD_DB_ERROR for 1049.

Suggested change
bool is_expected_error = (error_code == 1044 || error_code == 1049);
bool is_expected_error = (error_code == ER_DBACCESS_DENIED_ERROR || error_code == ER_BAD_DB_ERROR);

@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
test/infra/control/env-isolated.bash (1)

105-108: Optional: add ShellCheck suppression for dynamic source.

This is intentional dynamic sourcing, but SC1090 will keep warning unless explicitly suppressed.

Proposed lint-only tweak
 # Source infra-specific environment (exports WHG, RHG, and TAP test variables)
 if [ -n "${INFRA_TYPE}" ] && [ -f "${WORKSPACE}/test/infra/${INFRA_TYPE}/.env" ]; then
+    # shellcheck disable=SC1090
     source "${WORKSPACE}/test/infra/${INFRA_TYPE}/.env"
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/infra/control/env-isolated.bash` around lines 105 - 108, Add a
ShellCheck suppression for the intentional dynamic source to silence SC1090:
update the dynamic sourcing block (the line that does source
"${WORKSPACE}/test/infra/${INFRA_TYPE}/.env") to include a shellcheck directive
(e.g., a preceding comment like "shellcheck disable=SC1090" or "shellcheck
source=/dev/null") so the linter knows this dynamic source is intentional while
leaving the runtime logic in place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/infra/control/run-tests-isolated.bash`:
- Around line 39-54: INFRAS_TO_CHECK is populated from INFRA_TYPE before
INFRA_TYPE is derived from TAP_GROUP, which can leave INFRAS_TO_CHECK empty;
move the population of INFRAS_TO_CHECK to after the INFRA_TYPE derivation block
(the section referencing TAP_GROUP and export INFRA_TYPE) so the fallback path
gets the derived value, and add a case for TAP_GROUP patterns matching mysql57*
that maps to infra-mysql57 (referencing INFRA_TYPE, INFRAS_TO_CHECK, and
TAP_GROUP to locate the logic).

In `@test/infra/infra-mariadb10/.env`:
- Line 14: Remove the extra blank line flagged by dotenv-linter (ExtraBlankLine)
in test/infra/infra-mariadb10/.env so there are no consecutive empty lines;
simply delete the blank line at the reported location (line 14) to satisfy the
linter.

---

Nitpick comments:
In `@test/infra/control/env-isolated.bash`:
- Around line 105-108: Add a ShellCheck suppression for the intentional dynamic
source to silence SC1090: update the dynamic sourcing block (the line that does
source "${WORKSPACE}/test/infra/${INFRA_TYPE}/.env") to include a shellcheck
directive (e.g., a preceding comment like "shellcheck disable=SC1090" or
"shellcheck source=/dev/null") so the linter knows this dynamic source is
intentional while leaving the runtime logic in place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7b4ea004-f055-452b-84b6-ce3919b86ffb

📥 Commits

Reviewing files that changed from the base of the PR and between 0e955cd and 11b398e.

📒 Files selected for processing (8)
  • test/infra/control/env-isolated.bash
  • test/infra/control/run-tests-isolated.bash
  • test/infra/infra-mariadb10/.env
  • test/infra/infra-mysql57-binlog/.env
  • test/infra/infra-mysql57/.env
  • test/infra/infra-mysql84/.env
  • test/infra/infra-mysql84/conf/proxysql/infra-config.sql
  • test/tap/tests/mysql_query_logging_memory-t.cpp

Comment on lines +39 to +54
# Derive INFRA_TYPE from TAP_GROUP if not set
# This is simple and deterministic - matches group naming convention
if [ -z "${INFRA_TYPE}" ]; then
case "${TAP_GROUP}" in
mysql84*) export INFRA_TYPE=infra-mysql84 ;;
mysql90*) export INFRA_TYPE=infra-mysql90 ;;
mysql91*) export INFRA_TYPE=infra-mysql91 ;;
mysql92*) export INFRA_TYPE=infra-mysql92 ;;
mysql93*) export INFRA_TYPE=infra-mysql93 ;;
mariadb*) export INFRA_TYPE=infra-mariadb10 ;;
legacy*) export INFRA_TYPE=infra-mysql57 ;;
esac
if [ -n "${INFRA_TYPE}" ]; then
echo ">>> Derived INFRA_TYPE from TAP_GROUP: ${INFRA_TYPE}"
fi
fi
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Derivation order leaves INFRAS_TO_CHECK empty in the no-list path.

Line 35 populates INFRAS_TO_CHECK from INFRA_TYPE before INFRA_TYPE is derived at Line 41. In the fallback path, infra verification/default selection can be skipped unintentionally. Also, mysql57* is not mapped.

Proposed fix
-# If no list found, use INFRA_TYPE as single requirement
-if [ -z "${INFRAS_TO_CHECK}" ]; then
-    INFRAS_TO_CHECK="${INFRA_TYPE}"
-fi
-
 # Derive INFRA_TYPE from TAP_GROUP if not set
 # This is simple and deterministic - matches group naming convention
 if [ -z "${INFRA_TYPE}" ]; then
     case "${TAP_GROUP}" in
         mysql84*)  export INFRA_TYPE=infra-mysql84 ;;
+        mysql57*)  export INFRA_TYPE=infra-mysql57 ;;
         mysql90*)  export INFRA_TYPE=infra-mysql90 ;;
         mysql91*)  export INFRA_TYPE=infra-mysql91 ;;
         mysql92*)  export INFRA_TYPE=infra-mysql92 ;;
         mysql93*)  export INFRA_TYPE=infra-mysql93 ;;
         mariadb*)  export INFRA_TYPE=infra-mariadb10 ;;
         legacy*)   export INFRA_TYPE=infra-mysql57 ;;
     esac
     if [ -n "${INFRA_TYPE}" ]; then
         echo ">>> Derived INFRA_TYPE from TAP_GROUP: ${INFRA_TYPE}"
     fi
 fi
+
+# If no list found, use INFRA_TYPE as single requirement
+if [ -z "${INFRAS_TO_CHECK}" ]; then
+    INFRAS_TO_CHECK="${INFRA_TYPE}"
+fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/infra/control/run-tests-isolated.bash` around lines 39 - 54,
INFRAS_TO_CHECK is populated from INFRA_TYPE before INFRA_TYPE is derived from
TAP_GROUP, which can leave INFRAS_TO_CHECK empty; move the population of
INFRAS_TO_CHECK to after the INFRA_TYPE derivation block (the section
referencing TAP_GROUP and export INFRA_TYPE) so the fallback path gets the
derived value, and add a case for TAP_GROUP patterns matching mysql57* that maps
to infra-mysql57 (referencing INFRA_TYPE, INFRAS_TO_CHECK, and TAP_GROUP to
locate the logic).

MARIADB2_PORT=${PREFIX}307
MARIADB3_PORT=${PREFIX}308


Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove extra blank line to satisfy dotenv-linter.

Line 14 triggers the ExtraBlankLine warning.

Proposed fix
-
 # Export hostgroup for TAP tests that need it
 export TAP_REG_TEST_3549_AUTOCOMMIT_TRACKING___MYSQL_SERVER_HOSTGROUP=${WHG}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Export hostgroup for TAP tests that need it
export TAP_REG_TEST_3549_AUTOCOMMIT_TRACKING___MYSQL_SERVER_HOSTGROUP=${WHG}
🧰 Tools
🪛 dotenv-linter (4.0.0)

[warning] 14-14: [ExtraBlankLine] Extra blank line detected

(ExtraBlankLine)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/infra/infra-mariadb10/.env` at line 14, Remove the extra blank line
flagged by dotenv-linter (ExtraBlankLine) in test/infra/infra-mariadb10/.env so
there are no consecutive empty lines; simply delete the blank line at the
reported location (line 14) to satisfy the linter.

@renecannao
Copy link
Contributor

@rahim-kanji : maybe we should try to merge this into private/multi-group-runner (PR #5470) that already has a lot of enhancements

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.

2 participants