Skip to content

Fix multiple TAP tests [CI migration - mysql84-g1, mysql84-g2, mysql84-g3, mysql84-g4, mysql84-binlog-g1]#5469

Merged
renecannao merged 32 commits intov3.0from
v3.0-ci_84_mysql84
Apr 9, 2026
Merged

Fix multiple TAP tests [CI migration - mysql84-g1, mysql84-g2, mysql84-g3, mysql84-g4, mysql84-binlog-g1]#5469
renecannao merged 32 commits intov3.0from
v3.0-ci_84_mysql84

Conversation

@rahim-kanji
Copy link
Copy Markdown
Collaborator

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

mysql84-g1

  • 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
  • max_connections_ff-t
  • reg_test_3223-restapi_return_codes-t
  • reg_test_3625-sqlite3_session_client_error_limit-t

mysql84-g2

  • reg_test_3992_fast_forward_malformed_packet-t Removed from mysql84-g2. Requires mariadb user
  • reg_test_3992_fast_forward_malformed_packet-pymysql-t Removed from mysql84-g2. Requires mariadb user
  • reg_test_3992_fast_forward_malformed_packet-mysqlsh-t Removed from mysql84-g2. Requires mariadb user
  • set_character_set-t
  • set_testing-multi-t
  • set_testing-t
  • test_backend_conn_ping-t

mysql84-g3

  • fast_forward_grace_close_libmysql-t
  • test_binlog_reader-t
  • test_binlog_reader_uses_previous_hostgroup-t
  • test_client_limit_error-t
  • test_com_register_slave_enables_fast_forward-t
  • test_com_reset_connection_com_change_user-t
  • test_flush_logs-t
  • test_mysqlsh-t
  • test_noise_injection-t
  • test_prometheus_metrics-t
  • test_ps_logging-t

Summary by CodeRabbit

  • Tests

    • Broadened MySQL-version handling and error diagnostics; accept utf8/utf8mb3 equivalence and improved value comparisons.
    • Many tests now use configurable hostgroup values and respect infra-specific environment settings.
    • Protocol-specific noise can be toggled per-infra.
  • Chores

    • Test infra now conditionally sources per-infra environment files and derives infra type from group settings.
    • Added MySQL binlog infra and setup hooks for MySQL 8.4; updated test-group runner assignments.

…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
Copy Markdown

coderabbitai bot commented Mar 21, 2026

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

Walkthrough

Refactors TAP infra wiring: hardcoded hostgroup exports removed in favor of sourcing infra-specific .env; INFRA_TYPE can be derived from TAP_GROUP; adds a mysql-binlog infra with Docker/Orchestrator/ProxySQL setup; many tests updated to read hostgroup/infra envs and to treat utf8/utf8mb3 as equivalent.

Changes

Cohort / File(s) Summary
Control & env loaders
test/infra/control/env-isolated.bash, test/infra/control/run-tests-isolated.bash
Removed hardcoded TAP hostgroup export; conditionally source ${WORKSPACE}/test/infra/${INFRA_TYPE}/.env; derive/export INFRA_TYPE from TAP_GROUP when unset.
New infra: mysql84-binlog
test/infra/infra-mysql84-binlog/..., test/infra/infra-mysql84-binlog/docker-compose.yml
Adds a complete binlog infra: .env, docker-compose, post-start hooks, ProxySQL/orchestrator/proxysql config, MySQL configs, orchestration scripts, and init scripts.
Infra .env updates
test/infra/infra-mysql57/.env, test/infra/infra-mysql57-binlog/.env, test/infra/infra-mariadb10/.env, test/infra/infra-mysql84/.env, test/infra/infra-mysql84-binlog/.env
Move TAP hostgroup exports into infra .env files (add TAP_REG_TEST_..._MYSQL_SERVER_HOSTGROUP=${WHG} and TAP_MYSQL8_BACKEND_HG=${WHG} where applicable).
ProxySQL infra SQL
test/infra/infra-mysql84/conf/proxysql/infra-config.sql, test/infra/infra-mysql84-binlog/conf/proxysql/infra-config.sql
Extended user seeding and runtime/disk admin variable/debug settings; parameterized inserts/updates to use ${WHG}/${INFRA}.
Group configs & hooks
test/tap/groups/groups.json, test/tap/groups/mysql84/env.sh, test/tap/groups/mysql84/pre-proxysql.bash, test/tap/groups/mysql84/setup-infras.bash, test/tap/groups/mysql84-binlog/*
Adjusted runner lists; default infra/env changes (REGULAR_INFRA_DATADIR); made pre-proxysql a no-op; added setup-infras.bash; added mysql84-binlog group env/infras.lst.
TAP tests — hostgroup/infra driven
test/tap/tests/*, test/tap/tap/command_line.{h,cpp}, test/tap/tap/noise_utils.cpp
Replaced hardcoded hostgroup/infra values with env-driven variables (TAP_MYSQL8_BACKEND_HG, BINLOG_WHG/RHG, DEFAULT_MYSQL_INFRA, cl.host, cl.admin_host); added use_noise_mysql/pgsql gating and skipped-noise early returns.
TAP tests — charset/value equivalence
test/tap/tests/set_testing.h, set_character_set-t.cpp, set_testing*.cpp, test_sql*
Added values_equiv/charset_equiv logic to treat utf8 and utf8mb3 (and related collations) as equivalent; updated comparisons and error messages accordingly.
Docker image & build for binlog reader
test/infra/docker-mysql84-binlogreader/Dockerfile.reader, .../build.sh, .gitignore
Added reader Dockerfile, build script, and .gitignore to package/run proxysql mysqlbinlog reader image.
Small test adjustments
assorted test/tap/tests/*.env and C++ tests
Removed some hardcoded TAP envs from test .env files; updated tests to capture server error text/code and improved diagnostics.

Sequence Diagram(s)

sequenceDiagram
    participant Runner as Test Runner
    participant EnvLoader as env-isolated/run-tests
    participant InfraEnv as infra .env
    participant Compose as docker-compose-init
    participant ProxySQL as ProxySQL
    participant MySQL as MySQL Cluster
    participant Orchestrator as Orchestrator

    Runner->>EnvLoader: start tests (TAP_GROUP/TAP args)
    EnvLoader->>InfraEnv: if INFRA_TYPE set/derived, source ${WORKSPACE}/test/infra/${INFRA_TYPE}/.env
    EnvLoader-->>Runner: export envs (TAP_MYSQL8_BACKEND_HG, etc.)
    Runner->>Compose: invoke docker-compose-init.bash (uses infra .env)
    Compose->>MySQL: start mysql1/mysql2/mysql3 containers
    Compose->>Orchestrator: start orc1/orc2/orc3
    Compose->>ProxySQL: start proxysql
    ProxySQL->>MySQL: apply infra-config.sql (register servers/users/hostgroups)
    Orchestrator->>MySQL: discover/topology
    Runner->>ProxySQL: tests run using env-driven hostgroups/hosts
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • renecannao

"🐰
I hopped through envs and chased a dev cue,
Swapped hardcoded 1300 for something new.
UTF8 and friends now dance as one,
Tests read their world from where infra's spun.
A tiny hop, a tidy trail — hooray for config glue!"

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective: fixing multiple TAP tests as part of a CI migration for mysql84 test groups.

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

✨ Finishing Touches
🧪 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.

@gemini-code-assist
Copy link
Copy Markdown

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
Copy Markdown

@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);
Copy link
Copy Markdown

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);

Copy link
Copy Markdown

@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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
Contributor

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

@rahim-kanji rahim-kanji changed the base branch from v3.0 to private/multi-group-runner March 24, 2026 20:50
@rahim-kanji rahim-kanji changed the base branch from private/multi-group-runner to v3.0 March 25, 2026 09:44
…/'utf8mb3_general_ci' as equivalent. MySQL 8.4+ reports utf8mb3 where older versions report utf8. Function accepts json values directly to match the caller types.
…(MariaDB-specific users not available in mysql84).
@rahim-kanji rahim-kanji changed the title Fix multiple TAP tests [CI migration - mysql84-g1] Fix multiple TAP tests [CI migration - mysql84-g1, mysql84-g2] Mar 25, 2026
Copy link
Copy Markdown

@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: 3

♻️ Duplicate comments (1)
test/infra/control/run-tests-isolated.bash (1)

66-86: ⚠️ Potential issue | 🟠 Major

Derive INFRA_TYPE before using it as the no-list fallback.

The no-list path still assigns INFRAS_TO_CHECK="${INFRA_TYPE}" before the case block populates INFRA_TYPE, so groups without an infras.lst keep an empty infra list and skip the downstream default-selection/env wiring. The mapper also still misses mysql57*.

Suggested 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
+        mysql57*)  export INFRA_TYPE=infra-mysql57 ;;
         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
+
+# 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 66 - 86, The script
sets INFRAS_TO_CHECK from INFRA_TYPE before INFRA_TYPE is derived from
TAP_GROUP, causing empty fallback lists; move the "If no list found, use
INFRA_TYPE as single requirement" assignment (the
INFRAS_TO_CHECK="${INFRA_TYPE}" line) to after the case block that
derives/export INFRA_TYPE (or alternatively derive INFRA_TYPE first and then
perform the fallback), and update the case mapping in the TAP_GROUP ->
INFRA_TYPE switch (the case handling for TAP_GROUP) to include a mysql57*
pattern that exports INFRA_TYPE=infra-mysql57 so groups matching mysql57* get
the correct default.
🤖 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/env-isolated.bash`:
- Around line 111-114: The script currently only sources the per-infra .env when
INFRA_TYPE is set; change the logic to also attempt to source the selected MySQL
infra's .env using DEFAULT_MYSQL_INFRA when INFRA_TYPE is empty so TAP_MYSQLHOST
and hostgroup exports come from the chosen MySQL backend; update the conditional
around the source to check for either a non-empty INFRA_TYPE or a non-empty
DEFAULT_MYSQL_INFRA and pick the file at
"${WORKSPACE}/test/infra/${INFRA_TYPE:-$DEFAULT_MYSQL_INFRA}/.env", ensuring the
file exists before sourcing so exports like TAP_MYSQLHOST are loaded.

In `@test/tap/tests/set_testing-multi-t.cpp`:
- Around line 277-282: The conditional at the top of the if uses k.value() and
s.value() without first ensuring k and s are not end iterators; update the
compound condition so you first check the iterator-existence guards (e.g. k !=
end and s != end or the same existence checks used at lines 315–316) before any
use of k.value() or s.value(), and mirror the same guard ordering/pattern used
elsewhere in set_testing-multi-t.cpp so values_equiv(...) and
check_session_track_gtids(...) are only called when k and s are valid iterators.

In `@test/tap/tests/test_backend_conn_ping-t.cpp`:
- Around line 625-633: Treat an empty DEFAULT_MYSQL_INFRA as missing and use the
harness default "infra-mysql84" instead of "infra-mysql57": change the infra
initialization so it uses infra_env only when infra_env != nullptr and
infra_env[0] != '\0', otherwise set infra = "infra-mysql84"; also guard the
docker_mode usage (docker_mode should come from getenv and be treated as empty
when nullptr) before calling find; keep the hostname construction that assigns
s_server_test and m_server_test using "mysql1."+infra / "mysql2."+infra /
"mysql3."+infra.

---

Duplicate comments:
In `@test/infra/control/run-tests-isolated.bash`:
- Around line 66-86: The script sets INFRAS_TO_CHECK from INFRA_TYPE before
INFRA_TYPE is derived from TAP_GROUP, causing empty fallback lists; move the "If
no list found, use INFRA_TYPE as single requirement" assignment (the
INFRAS_TO_CHECK="${INFRA_TYPE}" line) to after the case block that
derives/export INFRA_TYPE (or alternatively derive INFRA_TYPE first and then
perform the fallback), and update the case mapping in the TAP_GROUP ->
INFRA_TYPE switch (the case handling for TAP_GROUP) to include a mysql57*
pattern that exports INFRA_TYPE=infra-mysql57 so groups matching mysql57* get
the correct default.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 169e0fcc-7dde-4017-86a5-b98958773dfe

📥 Commits

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

📒 Files selected for processing (16)
  • test/infra/control/ensure-infras.bash
  • test/infra/control/env-isolated.bash
  • test/infra/control/run-tests-isolated.bash
  • test/infra/infra-mysql84/.env
  • test/tap/groups/default/pre-proxysql.bash
  • test/tap/groups/groups.json
  • test/tap/groups/legacy/pre-proxysql.bash
  • test/tap/groups/mysql84/env.sh
  • test/tap/groups/mysql84/pre-proxysql.bash
  • test/tap/groups/mysql84/setup-infras.bash
  • test/tap/tests/reg_test_3317-lock_hostgroup_special_queries-t.cpp
  • test/tap/tests/set_character_set-t.cpp
  • test/tap/tests/set_testing-multi-t.cpp
  • test/tap/tests/set_testing-t.cpp
  • test/tap/tests/set_testing.h
  • test/tap/tests/test_backend_conn_ping-t.cpp
✅ Files skipped from review due to trivial changes (1)
  • test/tap/groups/mysql84/env.sh
🚧 Files skipped from review as they are similar to previous changes (4)
  • test/tap/groups/groups.json
  • test/infra/control/ensure-infras.bash
  • test/tap/tests/reg_test_3317-lock_hostgroup_special_queries-t.cpp
  • test/tap/groups/mysql84/setup-infras.bash
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{cpp,h,hpp}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{cpp,h,hpp}: Class names must use PascalCase with protocol prefixes (MySQL_, PgSQL_, ProxySQL_)
Member variables must use snake_case
Constants and macros must use UPPER_SNAKE_CASE
C++17 is required; use conditional compilation via #ifdef PROXYSQLGENAI, #ifdef PROXYSQL31, etc. for feature flags
Use pthread mutexes for synchronization and std::atomic<> for counters

Files:

  • test/tap/tests/set_character_set-t.cpp
  • test/tap/tests/set_testing.h
  • test/tap/tests/set_testing-multi-t.cpp
  • test/tap/tests/test_backend_conn_ping-t.cpp
  • test/tap/tests/set_testing-t.cpp
**/*.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

Use RAII for resource management and jemalloc for memory allocation

Files:

  • test/tap/tests/set_character_set-t.cpp
  • test/tap/tests/set_testing-multi-t.cpp
  • test/tap/tests/test_backend_conn_ping-t.cpp
  • test/tap/tests/set_testing-t.cpp
test/tap/tests/{test_*,*-t}.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

Test files in test/tap/tests/ must follow the naming pattern test_*.cpp or *-t.cpp

Files:

  • test/tap/tests/set_character_set-t.cpp
  • test/tap/tests/set_testing-multi-t.cpp
  • test/tap/tests/test_backend_conn_ping-t.cpp
  • test/tap/tests/set_testing-t.cpp
🧠 Learnings (6)
📓 Common learnings
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:27.165Z
Learning: In ProxySQL test files (test/tap/tests/), resource leaks (such as not calling `mysql_close()` on early return paths) are not typically fixed because test processes are short-lived and the OS frees resources on process exit. This is a common pattern across the test suite.
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.093Z
Learning: Applies to test/tap/tests/unit/**/*.cpp : Unit tests in test/tap/tests/unit/ must use test_globals.h and test_init.h and link against libproxysql.a via the custom test harness
📚 Learning: 2026-01-20T07:40:34.938Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:24-28
Timestamp: 2026-01-20T07:40:34.938Z
Learning: In ProxySQL test files, calling `mysql_error(NULL)` after `mysql_init()` failure is safe because the MariaDB client library implementation returns an empty string for NULL handles (not undefined behavior).

Applied to files:

  • test/tap/tests/set_character_set-t.cpp
  • test/tap/tests/set_testing-t.cpp
  • test/tap/groups/mysql84/pre-proxysql.bash
📚 Learning: 2026-01-20T09:34:19.124Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:19.124Z
Learning: In ProxySQL's TAP test suite, resource leaks (e.g., not calling mysql_close() on early return paths) are commonly tolerated because test processes are short-lived and OS frees resources on exit. This pattern applies to all C++ test files under test/tap/tests. When reviewing, recognize this as a project-wide test convention and focus on test correctness and isolation rather than insisting on fixing such leaks in these test files.

Applied to files:

  • test/tap/tests/set_character_set-t.cpp
  • test/tap/tests/set_testing-multi-t.cpp
  • test/tap/tests/test_backend_conn_ping-t.cpp
  • test/tap/tests/set_testing-t.cpp
📚 Learning: 2026-03-22T14:38:16.093Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.093Z
Learning: Applies to test/tap/tests/unit/**/*.cpp : Unit tests in test/tap/tests/unit/ must use test_globals.h and test_init.h and link against libproxysql.a via the custom test harness

Applied to files:

  • test/tap/tests/test_backend_conn_ping-t.cpp
  • test/tap/tests/set_testing-t.cpp
  • test/tap/groups/mysql84/pre-proxysql.bash
  • test/infra/control/env-isolated.bash
  • test/infra/infra-mysql84/.env
  • test/tap/groups/default/pre-proxysql.bash
  • test/tap/groups/legacy/pre-proxysql.bash
📚 Learning: 2026-03-22T14:38:16.093Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.093Z
Learning: Applies to **/*.{cpp,h,hpp} : C++17 is required; use conditional compilation via `#ifdef` PROXYSQLGENAI, `#ifdef` PROXYSQL31, etc. for feature flags

Applied to files:

  • test/tap/tests/test_backend_conn_ping-t.cpp
  • test/tap/tests/set_testing-t.cpp
📚 Learning: 2026-01-20T09:34:27.165Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:27.165Z
Learning: In ProxySQL test files (test/tap/tests/), resource leaks (such as not calling `mysql_close()` on early return paths) are not typically fixed because test processes are short-lived and the OS frees resources on process exit. This is a common pattern across the test suite.

Applied to files:

  • test/tap/groups/mysql84/pre-proxysql.bash
  • test/tap/groups/default/pre-proxysql.bash
  • test/tap/groups/legacy/pre-proxysql.bash
🪛 dotenv-linter (4.0.0)
test/infra/infra-mysql84/.env

[warning] 12-12: [UnorderedKey] The TAP_MYSQL8_BACKEND_HG key should go before the TAP_REG_TEST_3549_AUTOCOMMIT_TRACKING___MYSQL_SERVER_HOSTGROUP key

(UnorderedKey)

🪛 Shellcheck (0.11.0)
test/tap/groups/mysql84/pre-proxysql.bash

[warning] 12-12: Declare and assign separately to avoid masking return values.

(SC2155)

test/infra/control/env-isolated.bash

[warning] 113-113: ShellCheck can't follow non-constant source. Use a directive to specify location.

(SC1090)

test/tap/groups/default/pre-proxysql.bash

[warning] 12-12: Declare and assign separately to avoid masking return values.

(SC2155)

test/tap/groups/legacy/pre-proxysql.bash

[warning] 12-12: Declare and assign separately to avoid masking return values.

(SC2155)

🔇 Additional comments (3)
test/tap/tests/set_testing.h (1)

140-153: values_equiv() change looks correct and targeted.

This helper cleanly handles utf8/utf8mb3 charset and collation aliases while keeping non-string JSON comparisons strict.

test/tap/tests/set_character_set-t.cpp (1)

98-99: Nice fix: charset assertions are now version-tolerant.

Accepting both utf8 and utf8mb3 here is the right compatibility adjustment for MySQL 8.4+ without breaking older expectations.

Also applies to: 101-107

test/tap/tests/set_testing-t.cpp (1)

318-319: values_equiv() integration is correct here.

Using equivalence-based comparison in this condition is a solid fix for utf8 vs utf8mb3 test portability.

Comment on lines +111 to +114
# Source infra-specific environment (exports WHG, RHG, and TAP test variables)
if [ -n "${INFRA_TYPE}" ] && [ -f "${WORKSPACE}/test/infra/${INFRA_TYPE}/.env" ]; then
source "${WORKSPACE}/test/infra/${INFRA_TYPE}/.env"
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Load the per-infra .env from the selected MySQL backend, not only INFRA_TYPE.

DEFAULT_MYSQL_INFRA is what the runner derives from infras.lst and what this script already uses for TAP_MYSQLHOST. When TAP_GROUP is something generic like default-*, INFRA_TYPE can still be empty even though a MySQL infra was selected, so this branch skips the hostgroup exports and affected TAP tests fall back to wrong defaults.

Suggested fix
 # Source infra-specific environment (exports WHG, RHG, and TAP test variables)
-if [ -n "${INFRA_TYPE}" ] && [ -f "${WORKSPACE}/test/infra/${INFRA_TYPE}/.env" ]; then
-    source "${WORKSPACE}/test/infra/${INFRA_TYPE}/.env"
+MYSQL_INFRA_ENV="${DEFAULT_MYSQL_INFRA:-${INFRA_TYPE}}"
+if [ -n "${MYSQL_INFRA_ENV}" ] && [ -f "${WORKSPACE}/test/infra/${MYSQL_INFRA_ENV}/.env" ]; then
+    source "${WORKSPACE}/test/infra/${MYSQL_INFRA_ENV}/.env"
 fi
📝 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
# Source infra-specific environment (exports WHG, RHG, and TAP test variables)
if [ -n "${INFRA_TYPE}" ] && [ -f "${WORKSPACE}/test/infra/${INFRA_TYPE}/.env" ]; then
source "${WORKSPACE}/test/infra/${INFRA_TYPE}/.env"
fi
# Source infra-specific environment (exports WHG, RHG, and TAP test variables)
MYSQL_INFRA_ENV="${DEFAULT_MYSQL_INFRA:-${INFRA_TYPE}}"
if [ -n "${MYSQL_INFRA_ENV}" ] && [ -f "${WORKSPACE}/test/infra/${MYSQL_INFRA_ENV}/.env" ]; then
source "${WORKSPACE}/test/infra/${MYSQL_INFRA_ENV}/.env"
fi
🧰 Tools
🪛 Shellcheck (0.11.0)

[warning] 113-113: ShellCheck can't follow non-constant source. Use a directive to specify location.

(SC1090)

🤖 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 111 - 114, The script
currently only sources the per-infra .env when INFRA_TYPE is set; change the
logic to also attempt to source the selected MySQL infra's .env using
DEFAULT_MYSQL_INFRA when INFRA_TYPE is empty so TAP_MYSQLHOST and hostgroup
exports come from the chosen MySQL backend; update the conditional around the
source to check for either a non-empty INFRA_TYPE or a non-empty
DEFAULT_MYSQL_INFRA and pick the file at
"${WORKSPACE}/test/infra/${INFRA_TYPE:-$DEFAULT_MYSQL_INFRA}/.env", ensuring the
file exists before sourcing so exports like TAP_MYSQLHOST are loaded.

Comment on lines 277 to 282
if (
(special_sqlmode == true && verified_special_sqlmode == false) ||
(special_sqlmode == false &&
(el.key() != "session_track_gtids" && (k.value() != el.value() || s.value() != el.value())) ||
(el.key() != "session_track_gtids" && (!values_equiv(k.value(), el.value()) || !values_equiv(s.value(), el.value()))) ||
(el.key() == "session_track_gtids" && !check_session_track_gtids(el.value(), s.value(), k.value()))
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== set_testing-multi-t.cpp condition block =="
rg -n -C4 'special_sqlmode == false|k\.value\(|s\.value\(|k == mysql_vars\.end\(\)|s == proxysql_vars\["conn"\]\.end\(\)' test/tap/tests/set_testing-multi-t.cpp

echo
echo "== set_testing-t.cpp corresponding guarded block =="
rg -n -C4 'special_sqlmode == false|k\.value\(|s\.value\(|k == mysql_vars\.end\(\)|s == proxysql_vars\["conn"\]\.end\(\)' test/tap/tests/set_testing-t.cpp

Repository: sysown/proxysql

Length of output: 4409


Add iterator-end guards before dereferencing k.value() and s.value() at line 280.

Line 280 can dereference end iterators when keys are missing, causing undefined behavior and potential crashes. The pattern in set_testing-t.cpp (lines 315-316) correctly guards against this before dereferencing. Apply the same guards to the condition at lines 277-282.

Fix
 		if (
 			(special_sqlmode == true && verified_special_sqlmode == false) ||
+			(k == mysql_vars.end()) ||
+			(s == proxysql_vars["conn"].end()) ||
 			(special_sqlmode == false &&
-				(el.key() != "session_track_gtids" && (!values_equiv(k.value(), el.value()) || !values_equiv(s.value(), el.value()))) ||
-				(el.key() == "session_track_gtids" && !check_session_track_gtids(el.value(), s.value(), k.value()))
+				(
+					(el.key() != "session_track_gtids" &&
+						(!values_equiv(k.value(), el.value()) || !values_equiv(s.value(), el.value()))) ||
+					(el.key() == "session_track_gtids" &&
+						!check_session_track_gtids(el.value(), s.value(), k.value()))
+				)
 			)
 		) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/tap/tests/set_testing-multi-t.cpp` around lines 277 - 282, The
conditional at the top of the if uses k.value() and s.value() without first
ensuring k and s are not end iterators; update the compound condition so you
first check the iterator-existence guards (e.g. k != end and s != end or the
same existence checks used at lines 315–316) before any use of k.value() or
s.value(), and mirror the same guard ordering/pattern used elsewhere in
set_testing-multi-t.cpp so values_equiv(...) and check_session_track_gtids(...)
are only called when k and s are valid iterators.

Comment on lines +625 to +633
const char* infra_env = getenv("DEFAULT_MYSQL_INFRA");
const string infra = infra_env ? infra_env : "infra-mysql57";
const string docker_mode = getenv("DOCKER_MODE");
if (docker_mode.find("dns") == docker_mode.size() - 3) {
s_server_test.assign({ { "mysql1.infra-mysql57", 3306 } });
s_server_test.assign({ { "mysql1." + infra, 3306 } });
m_server_test.assign({
{ "mysql1.infra-mysql57", 3306 },
{ "mysql2.infra-mysql57", 3306 },
{ "mysql3.infra-mysql57", 3306 }
{ "mysql1." + infra, 3306 },
{ "mysql2." + infra, 3306 },
{ "mysql3." + infra, 3306 }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Treat empty DEFAULT_MYSQL_INFRA as missing, and use the current harness default.

run-tests-isolated.bash always injects DEFAULT_MYSQL_INFRA into the container, so an unset upstream value arrives here as "", not nullptr. With the current check that builds mysql1. / mysql2. / mysql3. hostnames, and the hardcoded fallback is still the old infra-mysql57 instead of the isolated-harness default infra-mysql84.

Suggested fix
 const char* infra_env = getenv("DEFAULT_MYSQL_INFRA");
-const string infra = infra_env ? infra_env : "infra-mysql57";
+const string infra =
+	(infra_env != nullptr && infra_env[0] != '\0') ? infra_env : "infra-mysql84";
📝 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
const char* infra_env = getenv("DEFAULT_MYSQL_INFRA");
const string infra = infra_env ? infra_env : "infra-mysql57";
const string docker_mode = getenv("DOCKER_MODE");
if (docker_mode.find("dns") == docker_mode.size() - 3) {
s_server_test.assign({ { "mysql1.infra-mysql57", 3306 } });
s_server_test.assign({ { "mysql1." + infra, 3306 } });
m_server_test.assign({
{ "mysql1.infra-mysql57", 3306 },
{ "mysql2.infra-mysql57", 3306 },
{ "mysql3.infra-mysql57", 3306 }
{ "mysql1." + infra, 3306 },
{ "mysql2." + infra, 3306 },
{ "mysql3." + infra, 3306 }
const char* infra_env = getenv("DEFAULT_MYSQL_INFRA");
const string infra =
(infra_env != nullptr && infra_env[0] != '\0') ? infra_env : "infra-mysql84";
const string docker_mode = getenv("DOCKER_MODE");
if (docker_mode.find("dns") == docker_mode.size() - 3) {
s_server_test.assign({ { "mysql1." + infra, 3306 } });
m_server_test.assign({
{ "mysql1." + infra, 3306 },
{ "mysql2." + infra, 3306 },
{ "mysql3." + infra, 3306 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/tap/tests/test_backend_conn_ping-t.cpp` around lines 625 - 633, Treat an
empty DEFAULT_MYSQL_INFRA as missing and use the harness default "infra-mysql84"
instead of "infra-mysql57": change the infra initialization so it uses infra_env
only when infra_env != nullptr and infra_env[0] != '\0', otherwise set infra =
"infra-mysql84"; also guard the docker_mode usage (docker_mode should come from
getenv and be treated as empty when nullptr) before calling find; keep the
hostname construction that assigns s_server_test and m_server_test using
"mysql1."+infra / "mysql2."+infra / "mysql3."+infra.

- test_prometheus_metrics-t: Use TAP_MYSQL8_BACKEND_HG for dynamic hostgroup instead of hardcoded 0. Add protocol="mysql" label to Prometheus metric lookups.
- test_com_reset_connection_com_change_user-t: Replace hardcoded 127.0.0.1 with cl.host/cl.admin_host for Docker compatibility.
- Add use_noise_mysql and use_noise_pgsql flags to CommandLine, set based on DEFAULT_MYSQL_INFRA/DEFAULT_PGSQL_INFRA env vars.
- Add early-return guards in noise_utils.cpp for mysql_traffic, mysql_traffic_v2, pgsql_traffic, pgsql_traffic_v2.
- Update test_noise_injection-t to set protocol flags explicitly.
- Remove mysql84-g3 from test_clickhouse_server-*, test_clickhouse_server_libmysql-*
- Move to mysql84-g5: test_gtid_forwarding-t, test_cluster1-t, test_cluster_sync_mysql_servers-t, test_com_register_slave_enables_fast_forward-t, fast_forward_grace_close_libmysql-t
Copy link
Copy Markdown

@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

🤖 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/tap/groups/groups.json`:
- Around line 231-235: The tests remapped to the non-existent subgroup
"mysql84-g5" will fail scheduling; either add a TAP infra subgroup named
"mysql84-g5" following the pattern in test/infra/README.md, or change the test
group mappings in groups.json for the affected test keys ("test_cluster1-t",
"test_cluster_sync_mysql_servers-t",
"test_com_register_slave_enables_fast_forward-t" and the one at line 269) to an
existing subgroup such as "mysql84" or "mysql84-gr"; update the entries for
those keys to reference the chosen existing subgroup (or create the new
"mysql84-g5" infra definition) so the scheduler can find the target.

In `@test/tap/tests/test_prometheus_metrics-t.cpp`:
- Around line 46-48: The static WRITER_HG and WRITER_HG_S are initialized before
main() and before cl.getEnv() loads test env vars; move their initialization
into main() after calling cl.getEnv() so the values come from the loaded
environment, i.e., remove or defer the top-level static const int WRITER_HG /
WRITER_HG_S and instead assign them after cl.getEnv() (referencing WRITER_HG and
WRITER_HG_S where used); also add a test/tap/tests/test_prometheus_metrics-t.env
that exports TAP_MYSQL8_BACKEND_HG with the correct hostgroup values used by the
runners.
🪄 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

Run ID: 8d937309-c6fb-466e-b827-78552f9441b3

📥 Commits

Reviewing files that changed from the base of the PR and between 7014bd9 and 2d258ff.

📒 Files selected for processing (8)
  • test/tap/groups/groups.json
  • test/tap/groups/mysql84/env.sh
  • test/tap/tap/command_line.cpp
  • test/tap/tap/command_line.h
  • test/tap/tap/noise_utils.cpp
  • test/tap/tests/test_com_reset_connection_com_change_user-t.cpp
  • test/tap/tests/test_noise_injection-t.cpp
  • test/tap/tests/test_prometheus_metrics-t.cpp
✅ Files skipped from review due to trivial changes (1)
  • test/tap/tap/command_line.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/tap/groups/mysql84/env.sh
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: CI-builds / builds (ubuntu22,-tap)
  • GitHub Check: CI-builds / builds (ubuntu24,-tap-genai-gcov)
  • GitHub Check: CI-builds / builds (debian12,-dbg)
  • GitHub Check: claude-review
  • GitHub Check: run / trigger
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{cpp,h,hpp}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{cpp,h,hpp}: Class names must use PascalCase with protocol prefixes (MySQL_, PgSQL_, ProxySQL_)
Member variables must use snake_case
Constants and macros must use UPPER_SNAKE_CASE
C++17 is required; use conditional compilation via #ifdef PROXYSQLGENAI, #ifdef PROXYSQL31, etc. for feature flags
Use pthread mutexes for synchronization and std::atomic<> for counters

Files:

  • test/tap/tap/command_line.cpp
  • test/tap/tests/test_com_reset_connection_com_change_user-t.cpp
  • test/tap/tap/noise_utils.cpp
  • test/tap/tests/test_prometheus_metrics-t.cpp
  • test/tap/tests/test_noise_injection-t.cpp
**/*.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

Use RAII for resource management and jemalloc for memory allocation

Files:

  • test/tap/tap/command_line.cpp
  • test/tap/tests/test_com_reset_connection_com_change_user-t.cpp
  • test/tap/tap/noise_utils.cpp
  • test/tap/tests/test_prometheus_metrics-t.cpp
  • test/tap/tests/test_noise_injection-t.cpp
test/tap/tests/{test_*,*-t}.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

Test files in test/tap/tests/ must follow the naming pattern test_*.cpp or *-t.cpp

Files:

  • test/tap/tests/test_com_reset_connection_com_change_user-t.cpp
  • test/tap/tests/test_prometheus_metrics-t.cpp
  • test/tap/tests/test_noise_injection-t.cpp
🧠 Learnings (9)
📓 Common learnings
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:27.165Z
Learning: In ProxySQL test files (test/tap/tests/), resource leaks (such as not calling `mysql_close()` on early return paths) are not typically fixed because test processes are short-lived and the OS frees resources on process exit. This is a common pattern across the test suite.
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.093Z
Learning: Applies to test/tap/tests/unit/**/*.cpp : Unit tests in test/tap/tests/unit/ must use test_globals.h and test_init.h and link against libproxysql.a via the custom test harness
📚 Learning: 2026-03-22T14:38:16.093Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.093Z
Learning: Applies to test/tap/tests/unit/**/*.cpp : Unit tests in test/tap/tests/unit/ must use test_globals.h and test_init.h and link against libproxysql.a via the custom test harness

Applied to files:

  • test/tap/tap/command_line.cpp
  • test/tap/tests/test_com_reset_connection_com_change_user-t.cpp
  • test/tap/tap/noise_utils.cpp
  • test/tap/tests/test_prometheus_metrics-t.cpp
  • test/tap/tests/test_noise_injection-t.cpp
  • test/tap/groups/groups.json
📚 Learning: 2026-03-22T14:38:16.093Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.093Z
Learning: Applies to **/*.{cpp,h,hpp} : C++17 is required; use conditional compilation via `#ifdef` PROXYSQLGENAI, `#ifdef` PROXYSQL31, etc. for feature flags

Applied to files:

  • test/tap/tap/command_line.cpp
  • test/tap/tap/noise_utils.cpp
  • test/tap/tests/test_prometheus_metrics-t.cpp
  • test/tap/tests/test_noise_injection-t.cpp
📚 Learning: 2026-01-20T09:34:19.124Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:19.124Z
Learning: In ProxySQL's TAP test suite, resource leaks (e.g., not calling mysql_close() on early return paths) are commonly tolerated because test processes are short-lived and OS frees resources on exit. This pattern applies to all C++ test files under test/tap/tests. When reviewing, recognize this as a project-wide test convention and focus on test correctness and isolation rather than insisting on fixing such leaks in these test files.

Applied to files:

  • test/tap/tests/test_com_reset_connection_com_change_user-t.cpp
  • test/tap/tests/test_prometheus_metrics-t.cpp
  • test/tap/tests/test_noise_injection-t.cpp
📚 Learning: 2026-03-22T14:38:16.093Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.093Z
Learning: Applies to **/*.{cpp,h,hpp} : Class names must use PascalCase with protocol prefixes (MySQL_, PgSQL_, ProxySQL_)

Applied to files:

  • test/tap/tests/test_com_reset_connection_com_change_user-t.cpp
📚 Learning: 2026-02-13T09:29:39.713Z
Learnt from: wazir-ahmed
Repo: sysown/proxysql PR: 5372
File: test/tap/tap/mcp_client.cpp:355-385
Timestamp: 2026-02-13T09:29:39.713Z
Learning: In ProxySQL MCP implementation (test/tap/tap/mcp_client.cpp), the `check_server()` method uses the ping endpoint which is designed to work without authentication. The `ping` method at the `config` endpoint should not require the `Authorization: Bearer` header, unlike tool invocation endpoints which do require authentication when `auth_token_` is set.

Applied to files:

  • test/tap/tests/test_com_reset_connection_com_change_user-t.cpp
📚 Learning: 2026-01-20T07:40:34.938Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:24-28
Timestamp: 2026-01-20T07:40:34.938Z
Learning: In ProxySQL test files, calling `mysql_error(NULL)` after `mysql_init()` failure is safe because the MariaDB client library implementation returns an empty string for NULL handles (not undefined behavior).

Applied to files:

  • test/tap/tests/test_com_reset_connection_com_change_user-t.cpp
  • test/tap/tests/test_prometheus_metrics-t.cpp
📚 Learning: 2026-03-26T16:38:58.553Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5548
File: lib/mysql_connection.cpp:1837-1843
Timestamp: 2026-03-26T16:38:58.553Z
Learning: In ProxySQL's lib/mysql_connection.cpp, `SHOW WARNINGS` detection for both `update_warning_count_from_connection()` and the `add_eof()` call in `ASYNC_USE_RESULT_CONT` intentionally uses `myds->sess->CurrentQuery.QueryParserArgs.digest_text` (comment-stripped digest text). This means the fix/feature does not work when `mysql-query_digests_keep_comment=1` (digest_text contains comments) or `mysql-query_digests=0` (digest_text is unavailable) — these configurations are explicitly excluded from the regression test for `reg_test_5306-show_warnings_with_comment-t`. This design is consistent across the codebase and is an accepted, documented limitation.

Applied to files:

  • test/tap/groups/groups.json
📚 Learning: 2026-01-20T09:34:27.165Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:27.165Z
Learning: In ProxySQL test files (test/tap/tests/), resource leaks (such as not calling `mysql_close()` on early return paths) are not typically fixed because test processes are short-lived and the OS frees resources on process exit. This is a common pattern across the test suite.

Applied to files:

  • test/tap/groups/groups.json
🔇 Additional comments (5)
test/tap/groups/groups.json (1)

172-174: Targeted runner pruning here looks sensible.

These removals narrow the plain mysql84 runners out of suites that already keep alternate matrix entries.

Also applies to: 228-229

test/tap/tap/command_line.cpp (1)

390-396: Nice: the per-protocol noise flags now follow the available infra.

This keeps single-protocol runners from starting noise jobs they cannot satisfy.

test/tap/tests/test_com_reset_connection_com_change_user-t.cpp (1)

451-454: Using the TAP-configured hosts here is the right fix.

This removes the last loopback assumption from these connection paths and makes the test portable across non-local CI runners.

Also applies to: 1145-1158

test/tap/tests/test_noise_injection-t.cpp (1)

27-31: Good call recomputing the protocol flags after forcing use_noise.

Without this block, getEnv() would leave both flags false whenever TAP_USE_NOISE is unset, so the MySQL/PgSQL routines would immediately self-skip.

test/tap/tap/noise_utils.cpp (1)

287-287: These guards avoid false failures on single-protocol runners.

Skipping unsupported MySQL/PgSQL noise routines is cleaner than letting them fail as connection errors.

Also applies to: 638-638, 685-685, 729-729

Comment thread test/tap/groups/groups.json Outdated
Comment on lines +231 to +235
"test_cluster1-t" : [ "legacy-g3","mysql84-g5","mysql-auto_increment_delay_multiplex=0-g3","mysql-multiplexing=false-g3","mysql-query_digests=0-g3","mysql-query_digests_keep_comment=1-g3" ],
"test_cluster_sync-t" : [ "legacy-g5","mysql-auto_increment_delay_multiplex=0-g3","mysql-multiplexing=false-g3","mysql-query_digests=0-g3","mysql-query_digests_keep_comment=1-g3" ],
"test_cluster_sync_mysql_servers-t" : [ "legacy-g3","mysql-auto_increment_delay_multiplex=0-g3","mysql-multiplexing=false-g3","mysql-query_digests=0-g3","mysql-query_digests_keep_comment=1-g3" ],
"test_cluster_sync_mysql_servers-t" : [ "legacy-g3","mysql84-g5","mysql-auto_increment_delay_multiplex=0-g3","mysql-multiplexing=false-g3","mysql-query_digests=0-g3","mysql-query_digests_keep_comment=1-g3" ],
"test_com_binlog_dump_enables_fast_forward-t" : [ "legacy-binlog-g1" ],
"test_com_register_slave_enables_fast_forward-t" : [ "legacy-g3","mysql84-g3","mysql-auto_increment_delay_multiplex=0-g3","mysql-multiplexing=false-g3","mysql-query_digests=0-g3","mysql-query_digests_keep_comment=1-g3" ],
"test_com_register_slave_enables_fast_forward-t" : [ "legacy-g3","mysql84-g5","mysql-auto_increment_delay_multiplex=0-g3","mysql-multiplexing=false-g3","mysql-query_digests=0-g3","mysql-query_digests_keep_comment=1-g3" ],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'mysql84-g5 references:\n'
rg -n 'mysql84-g5' test/tap/groups test/infra test/tap || true

printf '\nAvailable TAP group definitions:\n'
fd 'infras\.lst$' test/tap/groups test/infra | sort

printf '\nResolution docs for custom subgroups:\n'
nl -ba test/infra/README.md | sed -n '163,171p'

Repository: sysown/proxysql

Length of output: 2995


🏁 Script executed:

#!/bin/bash

# Check if mysql84-g5 directory exists
printf 'Checking for mysql84-g5 directory:\n'
ls -la test/tap/groups/ | grep mysql84

printf '\n\nChecking if mysql84-g5/infras.lst exists:\n'
test -f test/tap/groups/mysql84-g5/infras.lst && echo "EXISTS" || echo "DOES NOT EXIST"

printf '\n\nSearching for any mysql84-g5 infrastructure definition:\n'
find test/tap/groups test/infra -name "*mysql84*" -type f 2>/dev/null | sort

Repository: sysown/proxysql

Length of output: 331


These test remaps to mysql84-g5 will fail scheduling—the infrastructure is not wired.

Verification confirms mysql84-g5 does not exist in the codebase. Only mysql84 and mysql84-gr infrastructure definitions are present. The four tests now referencing mysql84-g5 (lines 231, 233, 235, and 269) will fail to schedule until this custom subgroup is properly defined in the TAP infrastructure.

Either define the mysql84-g5 infrastructure following the pattern in test/infra/README.md, or revert these test mappings to use an existing group like mysql84 or mysql84-gr.

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

In `@test/tap/groups/groups.json` around lines 231 - 235, The tests remapped to
the non-existent subgroup "mysql84-g5" will fail scheduling; either add a TAP
infra subgroup named "mysql84-g5" following the pattern in test/infra/README.md,
or change the test group mappings in groups.json for the affected test keys
("test_cluster1-t", "test_cluster_sync_mysql_servers-t",
"test_com_register_slave_enables_fast_forward-t" and the one at line 269) to an
existing subgroup such as "mysql84" or "mysql84-gr"; update the entries for
those keys to reference the chosen existing subgroup (or create the new
"mysql84-g5" infra definition) so the scheduler can find the target.

Comment on lines +46 to +48
// Writer hostgroup: read from TAP_MYSQL8_BACKEND_HG, fallback to 0 for legacy
static const int WRITER_HG = get_env_int("TAP_MYSQL8_BACKEND_HG", 0);
static const string WRITER_HG_S = std::to_string(WRITER_HG);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Static env read vs. cl.getEnv():\n'
nl -ba test/tap/tests/test_prometheus_metrics-t.cpp | sed -n '44,50p'
printf '\n'
nl -ba test/tap/tests/test_prometheus_metrics-t.cpp | sed -n '1178,1184p'

printf '\nHostgroup env exports across infra files:\n'
rg -n --glob 'test/infra/**/.env' 'TAP_MYSQL8_BACKEND_HG|TAP_REG_TEST_3549_AUTOCOMMIT_TRACKING___MYSQL_SERVER_HOSTGROUP'

printf '\nRunners still executing test_prometheus_metrics-t:\n'
rg -n '"test_prometheus_metrics-t"' test/tap/groups/groups.json

Repository: sysown/proxysql

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Static env read vs. cl.getEnv():\n'
sed -n '44,50p' test/tap/tests/test_prometheus_metrics-t.cpp | cat -n
printf '\n'
sed -n '1178,1184p' test/tap/tests/test_prometheus_metrics-t.cpp | cat -n

printf '\nHostgroup env exports across infra files:\n'
rg -n 'TAP_MYSQL8_BACKEND_HG' test/infra/ 2>/dev/null || printf '(no TAP_MYSQL8_BACKEND_HG found)\n'

printf '\nRunners still executing test_prometheus_metrics-t:\n'
rg -n '"test_prometheus_metrics-t"' test/tap/groups/groups.json || printf '(no match found)\n'

Repository: sysown/proxysql

Length of output: 902


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Searching for TAP_MYSQL8_BACKEND_HG anywhere in codebase:\n'
rg -i 'TAP_MYSQL8_BACKEND_HG' . 2>/dev/null || printf '(no matches found)\n'

printf '\n.env files in test/infra:\n'
find test/infra -name '.env' -type f 2>/dev/null | head -20

printf '\nContent of mysql84 .env if it exists:\n'
if [ -f test/infra/infra-mysql84/.env ]; then
  cat test/infra/infra-mysql84/.env | head -70
else
  printf '(file not found)\n'
fi

printf '\nSearching for references to hostgroup assignment or writer_hg:\n'
rg -i 'WRITER_HG|writer.*hg|backend.*hg' test/tap/tests/test_prometheus_metrics-t.cpp | head -20

Repository: sysown/proxysql

Length of output: 4091


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Check for test_prometheus_metrics-t.env:\n'
ls -la test/tap/tests/test_prometheus_metrics-t.env 2>/dev/null || printf '(file does not exist)\n'

printf '\nCompare .env patterns for similar tests:\n'
ls -la test/tap/tests/*prometheus* 2>/dev/null || printf '(no matches)\n'
ls -la test/tap/tests/*auth* 2>/dev/null | grep '\.env'

printf '\nCheck infra-mysql57 and other non-mysql84 infra .env files:\n'
for env_file in test/infra/infra-mysql57/.env test/infra/infra-mariadb10/.env; do
  if [ -f "$env_file" ]; then
    printf "\n=== $env_file ===\n"
    cat "$env_file" | grep -i 'hg\|hostgroup\|WHG\|RHG' || printf '(no hostgroup vars found)\n'
  fi
done

printf '\nSearching for writer hostgroup defaults in non-mysql84 context:\n'
rg -i 'writer.*hg|default.*hostgroup|legacy.*hostgroup' test/tap/tests/test_prometheus_metrics-t.cpp | head -10

Repository: sysown/proxysql

Length of output: 1825


Move WRITER_HG initialization after cl.getEnv() and add test_prometheus_metrics-t.env.

The static initialization at lines 46-48 runs before main(), before cl.getEnv() loads environment variables. Additionally, unlike other tests that use TAP_MYSQL8_BACKEND_HG (e.g., test_auth_methods-t.env, reg_test_4935-caching_sha2-t.env), test_prometheus_metrics-t lacks a .env file to export this variable.

This test runs on 6 runners (legacy-g3, mysql84-g3, and 4 mysql variants) but only mysql84-g3 exports TAP_MYSQL8_BACKEND_HG. On the other 5 runners, the fallback to 0 is incorrect: infra-mysql57 defines WHG=1300, not 0. The hardcoded fallback will cause the metric and connection tests to target the wrong hostgroup.

Suggested changes
  1. Create test/tap/tests/test_prometheus_metrics-t.env with appropriate hostgroup exports (matching the test infrastructure).
  2. Move WRITER_HG initialization to after cl.getEnv() in main():
-static const int WRITER_HG = get_env_int("TAP_MYSQL8_BACKEND_HG", 0);
-static const string WRITER_HG_S = std::to_string(WRITER_HG);
+static int WRITER_HG = 0;
+static string WRITER_HG_S = "0";

Then add after cl.getEnv():

+WRITER_HG = get_env_int("TAP_MYSQL8_BACKEND_HG", 0);
+WRITER_HG_S = std::to_string(WRITER_HG);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/tap/tests/test_prometheus_metrics-t.cpp` around lines 46 - 48, The
static WRITER_HG and WRITER_HG_S are initialized before main() and before
cl.getEnv() loads test env vars; move their initialization into main() after
calling cl.getEnv() so the values come from the loaded environment, i.e., remove
or defer the top-level static const int WRITER_HG / WRITER_HG_S and instead
assign them after cl.getEnv() (referencing WRITER_HG and WRITER_HG_S where
used); also add a test/tap/tests/test_prometheus_metrics-t.env that exports
TAP_MYSQL8_BACKEND_HG with the correct hostgroup values used by the runners.

@rahim-kanji rahim-kanji changed the title Fix multiple TAP tests [CI migration - mysql84-g1, mysql84-g2] Fix multiple TAP tests [CI migration - mysql84-g1, mysql84-g2, mysql84-g3] Mar 26, 2026
Add infra-mysql84-binlog Docker Compose environment with 3 MySQL 8.4 servers, 3 proxysql_binlog_reader v2.3 sidecars (with SHOW BINARY LOG STATUS patch for 8.4 compatibility), and 3 Percona Orchestrator nodes.

Key adaptations from legacy mysql57-binlog:
  - MySQL 8.4 config (log-replica-updates, innodb_redo_log_capacity)
  - MySQL 8.4 replication syntax (CHANGE REPLICATION SOURCE TO, RESET
    BINARY LOGS AND GTIDS)
  - Plain mysql:8.4 image + separate reader containers using
    proxysql-mysqlbinlog v2.3
  - SSL auto-generated by MySQL 8.4 (mysql_ssl_rsa_setup removed)
  - Percona Orchestrator with MySQLTopologySSLSkipVerify

Create mysql84-binlog test group (PREFIX=14, hostgroups 1400-1403) and make test_binlog_reader-t hostgroups configurable via WHG/RHG environment variables for multi-infra support.
Add missing users (root, testuser, sbtest2-8, ssluser) needed by various TAP tests. Enable event logging, audit logging, Prometheus RESTAPI, debug filters, and SSL keylog to match the test expectations that were previously only configured for the legacy infra.
MySQL 8.4 reports 'utf8mb3' where older versions report 'utf8'. Add charset_equiv() to treat both names and their collations (e.g. utf8_general_ci vs utf8mb3_general_ci) as equivalent so the test passes on both MySQL 5.7 and 8.4 backends.
Add test_binlog_fast_forward-t to mysql84-binlog-g2 (failing, need to investigate)
Tests were using hardcoded hostgroup 0/1 or 30 instead of the mysql84 infra hostgroups (WHG=2900, RHG=2901), causing timeouts and failures.
  - test_read_only_actions_offline_hard_servers: read WHG/RHG from
    TAP_MYSQL8_BACKEND_HG env var instead of hardcoding 0/1
  - Remove hardcoded TAP_MYSQL8_BACKEND_HG=30 from per-test .env files
    (test_sqlite3_pass_exts, test_auth_methods, reg_test_4935) so the
    value comes from the infra .env
  - Source infra .env from mysql84/env.sh using WORKSPACE to export
    TAP test variables into the proxysql-tester.py subprocess (sh-safe,
    no BASH_SOURCE dependency)
MySQL 8.4 defaults local_infile to OFF. Tests using LOAD DATA LOCAL INFILE (test_unsupported_queries) fail without it.
@rahim-kanji rahim-kanji changed the title Fix multiple TAP tests [CI migration - mysql84-g1, mysql84-g2, mysql84-g3] Fix multiple TAP tests [CI migration - mysql84-g1, mysql84-g2, mysql84-g3, mysql84-g4, mysql84-binlog-g1] Mar 31, 2026
Copy link
Copy Markdown

@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: 9

🧹 Nitpick comments (11)
test/tap/tests/test_set_collation-t.cpp (1)

82-90: Consider consolidating utf8/utf8mb3 equivalence logic.

This function duplicates the equivalence logic from values_equiv() in set_testing.h (lines 142-153). Both handle the same utf8↔utf8mb3 and collation prefix matching. Consider extracting a shared string-based helper function (e.g., charset_str_equiv(const std::string&, const std::string&)) in a common header to avoid maintaining identical logic in multiple places.

That said, the current implementation is correct and works well for this test file.

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

In `@test/tap/tests/test_set_collation-t.cpp` around lines 82 - 90, The
charset_equiv function duplicates utf8↔utf8mb3 and collation-prefix logic
already implemented in values_equiv; extract that logic into a shared helper
like charset_str_equiv(const std::string&, const std::string&) in a common
header, replace the body of charset_equiv to call charset_str_equiv (converting
const char* to std::string) and update values_equiv to call the same helper so
both tests reuse the single implementation.
test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp (1)

37-43: Consider using std::stoul for consistency and safer parsing.

The atoi() function silently returns 0 on invalid input, which could mask configuration errors. The sibling test test_binlog_reader-t.cpp uses std::stoul() for the same purpose.

💡 Optional: Use std::stoul for consistency
 static void init_hostgroups() {
 	const char* hg_env = getenv("TAP_MYSQL8_BACKEND_HG");
 	if (hg_env) {
-		WHG = atoi(hg_env);
+		WHG = static_cast<int>(std::stoul(hg_env));
 		RHG = WHG + 1;
 	}
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp` around
lines 37 - 43, Replace the unsafe atoi usage in init_hostgroups with std::stoul
to parse the TAP_MYSQL8_BACKEND_HG env var: read the getenv result into a
std::string (or check for nullptr), call std::stoul to convert to an unsigned
long for WHG, set RHG = WHG + 1, and wrap the conversion in try/catch
(std::invalid_argument/std::out_of_range) to handle bad input and preserve
detectable failure behavior rather than silently returning 0; reference
init_hostgroups(), WHG, and RHG when locating the change.
test/infra/docker-mysql84-binlogreader/Dockerfile.reader (2)

1-12: Optional: Consider adding a non-root user for defense-in-depth.

The Trivy DS-0002 warning about running as root is valid in general, but for CI test infrastructure with ephemeral containers, the risk is limited. Consider adding a non-root user if this image might be used in broader contexts.

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

In `@test/infra/docker-mysql84-binlogreader/Dockerfile.reader` around lines 1 -
12, Add a non-root user and switch to it to address the Trivy DS-0002 warning:
create a dedicated user (e.g., "binlog") and group during the image build (in
the same Dockerfile context that creates /var/log/mysqlbinlog and installs
proxysql-mysqlbinlog), chown the log directory and any runtime files to that
user, and add a USER instruction before the CMD so proxysql_binlog_reader runs
as the non-root user; ensure the CMD/container still has access to environment
variables (no changes to proxysql_binlog_reader args needed).

5-6: Add --no-install-recommends to reduce image size.

The apt-get -f install fallback may pull in unnecessary recommended packages.

📦 Proposed fix
-RUN dpkg -i /tmp/proxysql-mysqlbinlog_*.deb || apt-get -f install -y && \
+RUN dpkg -i /tmp/proxysql-mysqlbinlog_*.deb || apt-get -f install -y --no-install-recommends && \
     rm -f /tmp/proxysql-mysqlbinlog_*.deb
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/infra/docker-mysql84-binlogreader/Dockerfile.reader` around lines 5 - 6,
Update the RUN command that falls back to apt-get by adding
--no-install-recommends to the apt-get invocation so the fallback apt-get -f
install step becomes apt-get -f install -y --no-install-recommends (the RUN line
containing "dpkg -i /tmp/proxysql-mysqlbinlog_*.deb || apt-get -f install -y &&
rm -f /tmp/proxysql-mysqlbinlog_*.deb"); this reduces pulled recommended
packages and image size while preserving the existing dpkg fallback and
subsequent rm -f cleanup.
test/tap/groups/mysql84-binlog/env.sh (1)

1-4: Consider adding a shell directive for static analysis tools.

This sourced environment file correctly exports the infra type for the mysql84-binlog group. While the script works as intended, adding a shell directive would silence the ShellCheck warning and clarify the expected shell.

💡 Optional: Add shell directive
+# shellcheck shell=bash
 # Environment settings for mysql84-binlog group
 # This group uses infra-mysql84-binlog which has GTID and binlog reader support
 export INFRA_TYPE="infra-mysql84-binlog"
 export DEFAULT_MYSQL_INFRA="infra-mysql84-binlog"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/tap/groups/mysql84-binlog/env.sh` around lines 1 - 4, Add a shell
directive comment at the top of env.sh to satisfy static analysis (ShellCheck)
and clarify the expected shell; for example add a line like "# shellcheck
shell=bash" (or "# shellcheck shell=sh" if POSIX sh is intended) above the
exports of INFRA_TYPE and DEFAULT_MYSQL_INFRA so linters know the target shell
for the environment file.
test/tap/groups/mysql84/env.sh (1)

7-10: Optional: Add ShellCheck directive to suppress SC1090.

The dynamic source path is intentional and safe (file existence is checked). A directive would document this intent.

💡 Optional: Add ShellCheck directive
+# shellcheck shell=bash
 # MySQL 8.4 Test Group Environment
 
 export DEFAULT_MYSQL_INFRA="infra-mysql84"
 
 # Source infra .env to export TAP test variables (TAP_MYSQL8_BACKEND_HG, etc.)
 # Uses WORKSPACE (always set in CI) to avoid shell-specific BASH_SOURCE
 if [ -n "${WORKSPACE}" ]; then
     _INFRA_ENV="${WORKSPACE}/test/infra/${DEFAULT_MYSQL_INFRA}/.env"
+    # shellcheck source=/dev/null
     [ -f "${_INFRA_ENV}" ] && . "${_INFRA_ENV}"
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/tap/groups/mysql84/env.sh` around lines 7 - 10, Add a ShellCheck
directive to suppress SC1090 for the dynamic sourcing around the _INFRA_ENV
sourcing block: above the line that checks and sources _INFRA_ENV (the
conditional that uses WORKSPACE and DEFAULT_MYSQL_INFRA and does [ -f
"${_INFRA_ENV}" ] && . "${_INFRA_ENV}"), add a comment like a ShellCheck disable
for SC1090 (e.g., "# shellcheck disable=SC1090" or "# shellcheck
source=/dev/null") to document the intentional dynamic source and silence the
linter.
test/infra/infra-mysql84-binlog/docker-compose.yml (1)

136-136: Minor: Orchestrator log path uses /var/logs/ instead of conventional /var/log/.

The orchestrator containers mount logs to /var/logs/orchestrator/ (plural "logs"), while the standard Linux convention is /var/log/. This is likely fine if the orchestrator image expects this path, but worth verifying consistency.

Also applies to: 155-155, 174-174

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

In `@test/infra/infra-mysql84-binlog/docker-compose.yml` at line 136, The
docker-compose volume mappings for the orchestrator services use the nonstandard
path "/var/logs/orchestrator/" (e.g. the volume mapping
"${INFRA_LOGS_PATH}/${COMPOSE_PROJECT}/orc1:/var/logs/orchestrator/"); update
those mappings to the conventional "/var/log/orchestrator/" (and verify the
orchestrator image expects that path) for consistency—apply the same change to
the other occurrences referenced (the mappings at the other two identical
lines).
test/infra/infra-mysql84-binlog/conf/proxysql/infra-config.sql (1)

19-25: Consider using INSERT OR IGNORE for user idempotency.

Using REPLACE INTO for users will overwrite existing rows including passwords. If a root user exists with a different password (e.g., from a prior configuration), this will change it. While likely fine for CI, the pattern in infra-mysql84/conf/proxysql/infra-config.sql uses INSERT OR IGNORE + UPDATE which is more explicit about intent.

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

In `@test/infra/infra-mysql84-binlog/conf/proxysql/infra-config.sql` around lines
19 - 25, The SQL uses REPLACE INTO on the mysql_users table (lines inserting
'sbtest7','sbtest8','${INFRA}','root') which will overwrite existing rows
(including passwords); change the pattern to an idempotent INSERT OR IGNORE for
mysql_users followed by an explicit UPDATE for fields you intend to change
(e.g., for username 'root' with '${ROOT_PASSWORD}') so existing users are
preserved unless you explicitly update their password; locate the statements
using REPLACE INTO mysql_users and replace them with INSERT OR IGNORE ... and
subsequent UPDATE ... WHERE username = ... for each user you need to enforce.
test/infra/infra-mysql84-binlog/docker-compose-init.bash (2)

87-92: In-place sed modification of orchestrator configs may leave artifacts on failure.

If the script fails after patching orchestrator.conf.json but before successful startup, subsequent runs may encounter already-patched files with stale values. Consider:

  1. Operating on copies, or
  2. Adding idempotency by checking if substitution is needed

For CI this is likely acceptable since the teardown would clean up, but worth noting.

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

In `@test/infra/infra-mysql84-binlog/docker-compose-init.bash` around lines 87 -
92, The sed edits on orchestrator.conf.json can leave partially-modified files
if the script fails; modify the patching to be idempotent or operate on copies:
detect whether "MySQLTopologyPassword" already equals "${ROOT_PASSWORD}" or
whether placeholders like "${INFRA}" remain before running sed, or copy
./conf/orchestrator to a temp directory and perform substitutions there (then
atomically move into place) so use checks against orchestrator.conf.json, the
"MySQLTopologyPassword" key, and the "${INFRA}" placeholder to avoid
double-patching or stale values.

71-74: Eval usage is safe here but add a comment for clarity.

The eval "ACTUAL_PATH=${RAW_PATH}" expands shell variables in paths extracted from docker-compose.yml. While this is safe because RAW_PATH comes from controlled input (the compose file), adding a comment would help future maintainers understand the safety boundary.

Suggested comment
     # Expand variables like ${INFRA_LOGS_PATH} and ${COMPOSE_PROJECT}
+    # Safe: RAW_PATH is extracted from docker-compose.yml, not user input
     eval "ACTUAL_PATH=${RAW_PATH}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/infra/infra-mysql84-binlog/docker-compose-init.bash` around lines 71 -
74, Add a brief inline comment above the eval usage explaining why eval
"ACTUAL_PATH=${RAW_PATH}" is safe: note that RAW_PATH is sourced from the
repository-controlled docker-compose.yml (not user input) and that eval is only
used to expand legitimate shell variables like
${INFRA_LOGS_PATH}/${COMPOSE_PROJECT}; reference the eval invocation and the
ACTUAL_PATH and RAW_PATH variables so future maintainers know the safety
boundary and purpose of this expansion.
test/infra/infra-mysql84-binlog/bin/docker-mysql-post.bash (1)

86-88: Consider using a dedicated replication user instead of root.

Using root for SOURCE_USER works but grants the replica unnecessary privileges. A dedicated repl user with only REPLICATION SLAVE privilege would be more secure.

For CI this is acceptable, but if this pattern propagates to production docs/examples, it could encourage insecure practices.

Alternative approach (optional)

On master (line 60 area):

CREATE USER IF NOT EXISTS 'repl'@'%' IDENTIFIED WITH 'mysql_native_password' BY '${ROOT_PASSWORD}';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';

On replica:

-CHANGE REPLICATION SOURCE TO SOURCE_HOST='mysql1.${INFRA}', SOURCE_USER='root', SOURCE_PASSWORD='${ROOT_PASSWORD}', SOURCE_AUTO_POSITION=1;
+CHANGE REPLICATION SOURCE TO SOURCE_HOST='mysql1.${INFRA}', SOURCE_USER='repl', SOURCE_PASSWORD='${ROOT_PASSWORD}', SOURCE_AUTO_POSITION=1;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/infra/infra-mysql84-binlog/bin/docker-mysql-post.bash` around lines 86 -
88, Replace using root as the replication user in the replication setup: create
a dedicated replication user (e.g., 'repl') on the primary using CREATE USER and
grant it only the REPLICATION SLAVE privilege via GRANT REPLICATION SLAVE ON *.*
TO 'repl'@'%'; then change the replica configuration to use SOURCE_USER='repl'
and SOURCE_PASSWORD set to that user's password instead of SOURCE_USER='root' so
the SOURCE_USER/SOURCE_PASSWORD in the CHANGE REPLICATION SOURCE command and the
START REPLICA call use the least-privileged account.
🤖 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/docker-mysql84-binlogreader/Dockerfile.reader`:
- Line 12: The CMD line launching proxysql_binlog_reader uses inconsistent
parameter expansion for MYSQL_USER (\"${MYSQL_USER:=root}\") which assigns the
default instead of just substituting; update the invocation in the CMD (the
proxysql_binlog_reader command) to use \"${MYSQL_USER:-root}\" to match the
other variables (MYSQL_HOST, MYSQL_PASSWORD, MYSQL_PORT, LISTEN_PORT) so no
environment variables are modified by the script and behavior stays consistent.

In `@test/infra/infra-mysql84-binlog/bin/docker-orchestrator-post.bash`:
- Around line 54-59: The script prints " OK." unconditionally after the loop,
which is misleading when discovery timed out; update the post-loop logic so that
the echo " OK." is only printed when CLUSTER_NAME is non-empty (i.e. discovery
succeeded) and print a clear failure message when COUNT > MAX_WAIT or
CLUSTER_NAME is empty; modify the block that follows the while loop (references:
COUNT, MAX_WAIT, CLUSTER_NAME and the echo " OK.") to conditionally echo success
on non-empty CLUSTER_NAME and echo a timeout/failure message otherwise.
- Around line 7-11: The script uses unquoted command substitutions and
references INFRA_ID which may be unset; fix by quoting all substitutions when
setting INFRA (use command substitutions wrapped in double quotes for
basename/cd/dirname and wrap variable expansions in quotes) and ensure INFRA_ID
has a sensible fallback (e.g., set INFRA_ID to "${INFRA_ID:-$INFRA}" or derive
it from INFRA) before building PROXY_CONTAINER (PROXY_CONTAINER should remain
quoted as "proxysql.${INFRA_ID}").

In `@test/infra/infra-mysql84-binlog/bin/docker-proxy-post.bash`:
- Line 23: The conditional that checks the previous exit code (if [ $? -eq 0 ];
then ... else ... fi) is unreachable because the script enables set -e at the
top; either remove this redundant check and rely on set -e to fail fast, or wrap
the command that may fail (the docker exec/ProxySQL registration invocation)
with a temporary disable of set -e (trap errexit) so you can inspect its exit
status and call processLogger-style echo on failure; update the block that
contains the conditional accordingly (the conditional around ProxySQL
registration) to use one of these two approaches.

In `@test/infra/infra-mysql84-binlog/docker-compose-init.bash`:
- Around line 3-5: The INFRA_ID derivation uses unquoted command substitutions
causing word-splitting for paths with spaces; update the assignment of INFRA_ID
so all command substitutions and their arguments are quoted (e.g., quote the
outputs of pwd, dirname and basename and the whole right-hand side) and keep the
sed transformation, e.g. change the export INFRA_ID line that references
INFRA_ID, basename, dirname and $(pwd) to use quoted substitutions to prevent
SC2046/SC2155 issues.
- Around line 46-48: The export of ROOT_PASSWORD is done inline with command
substitution which hides pipeline failures (SC2155); change to first compute
ROOT_PASSWORD by running sha256sum on INFRA_ID and capture its exit status, fail
early if the command fails, then export ROOT_PASSWORD separately. Locate the
block using INFRA_ID and the assignment to ROOT_PASSWORD (the sha256sum | head
-c 10 pipeline) and replace it with a two-step: assign to a local/temporary
variable, check its exit code and non-empty result, then export ROOT_PASSWORD.

In `@test/infra/infra-mysql84-binlog/docker-compose.yml`:
- Around line 83-85: The docker-compose network aliases currently make reader
containers share the same alias as MySQL (e.g., reader1.${INFRA} and
mysql1.${INFRA}), which causes DNS ambiguity; update the reader container alias
names to distinct identifiers (for example change reader1.${INFRA} →
binlog-reader1.${INFRA}, reader2.${INFRA} → binlog-reader2.${INFRA},
reader3.${INFRA} → binlog-reader3.${INFRA}) and ensure any references that
expect to contact the reader or the MySQL instance use the new names (check env
keys like MYSQL_HOST and reader service definitions); alternatively, if the
shared-alias behavior is intended, add a short comment next to the aliases
explaining why the overlap is required and noting the non-deterministic DNS
behavior.

In `@test/tap/tests/test_binlog_reader-t.cpp`:
- Around line 241-244: The lines assigning hg_whg_sync_queries and
hg_rhg_sync_queries have stray double semicolons causing a warning; remove the
extra semicolons so the assignments use a single terminating semicolon (fix the
statements assigning hg_whg_sync_queries = hg_stats.at(WHG).second; and
hg_rhg_sync_queries = hg_stats.at(RHG).second;).
- Around line 200-204: The two variable declarations hg_whg_sync_queries and
hg_rhg_sync_queries contain accidental double semicolons (;;); edit their
statements to remove the extra semicolon so each declaration ends with a single
semicolon (e.g., fix the lines that set hg_whg_sync_queries =
hg_stats.at(WHG).second and hg_rhg_sync_queries = hg_stats.at(RHG).second).

---

Nitpick comments:
In `@test/infra/docker-mysql84-binlogreader/Dockerfile.reader`:
- Around line 1-12: Add a non-root user and switch to it to address the Trivy
DS-0002 warning: create a dedicated user (e.g., "binlog") and group during the
image build (in the same Dockerfile context that creates /var/log/mysqlbinlog
and installs proxysql-mysqlbinlog), chown the log directory and any runtime
files to that user, and add a USER instruction before the CMD so
proxysql_binlog_reader runs as the non-root user; ensure the CMD/container still
has access to environment variables (no changes to proxysql_binlog_reader args
needed).
- Around line 5-6: Update the RUN command that falls back to apt-get by adding
--no-install-recommends to the apt-get invocation so the fallback apt-get -f
install step becomes apt-get -f install -y --no-install-recommends (the RUN line
containing "dpkg -i /tmp/proxysql-mysqlbinlog_*.deb || apt-get -f install -y &&
rm -f /tmp/proxysql-mysqlbinlog_*.deb"); this reduces pulled recommended
packages and image size while preserving the existing dpkg fallback and
subsequent rm -f cleanup.

In `@test/infra/infra-mysql84-binlog/bin/docker-mysql-post.bash`:
- Around line 86-88: Replace using root as the replication user in the
replication setup: create a dedicated replication user (e.g., 'repl') on the
primary using CREATE USER and grant it only the REPLICATION SLAVE privilege via
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%'; then change the replica
configuration to use SOURCE_USER='repl' and SOURCE_PASSWORD set to that user's
password instead of SOURCE_USER='root' so the SOURCE_USER/SOURCE_PASSWORD in the
CHANGE REPLICATION SOURCE command and the START REPLICA call use the
least-privileged account.

In `@test/infra/infra-mysql84-binlog/conf/proxysql/infra-config.sql`:
- Around line 19-25: The SQL uses REPLACE INTO on the mysql_users table (lines
inserting 'sbtest7','sbtest8','${INFRA}','root') which will overwrite existing
rows (including passwords); change the pattern to an idempotent INSERT OR IGNORE
for mysql_users followed by an explicit UPDATE for fields you intend to change
(e.g., for username 'root' with '${ROOT_PASSWORD}') so existing users are
preserved unless you explicitly update their password; locate the statements
using REPLACE INTO mysql_users and replace them with INSERT OR IGNORE ... and
subsequent UPDATE ... WHERE username = ... for each user you need to enforce.

In `@test/infra/infra-mysql84-binlog/docker-compose-init.bash`:
- Around line 87-92: The sed edits on orchestrator.conf.json can leave
partially-modified files if the script fails; modify the patching to be
idempotent or operate on copies: detect whether "MySQLTopologyPassword" already
equals "${ROOT_PASSWORD}" or whether placeholders like "${INFRA}" remain before
running sed, or copy ./conf/orchestrator to a temp directory and perform
substitutions there (then atomically move into place) so use checks against
orchestrator.conf.json, the "MySQLTopologyPassword" key, and the "${INFRA}"
placeholder to avoid double-patching or stale values.
- Around line 71-74: Add a brief inline comment above the eval usage explaining
why eval "ACTUAL_PATH=${RAW_PATH}" is safe: note that RAW_PATH is sourced from
the repository-controlled docker-compose.yml (not user input) and that eval is
only used to expand legitimate shell variables like
${INFRA_LOGS_PATH}/${COMPOSE_PROJECT}; reference the eval invocation and the
ACTUAL_PATH and RAW_PATH variables so future maintainers know the safety
boundary and purpose of this expansion.

In `@test/infra/infra-mysql84-binlog/docker-compose.yml`:
- Line 136: The docker-compose volume mappings for the orchestrator services use
the nonstandard path "/var/logs/orchestrator/" (e.g. the volume mapping
"${INFRA_LOGS_PATH}/${COMPOSE_PROJECT}/orc1:/var/logs/orchestrator/"); update
those mappings to the conventional "/var/log/orchestrator/" (and verify the
orchestrator image expects that path) for consistency—apply the same change to
the other occurrences referenced (the mappings at the other two identical
lines).

In `@test/tap/groups/mysql84-binlog/env.sh`:
- Around line 1-4: Add a shell directive comment at the top of env.sh to satisfy
static analysis (ShellCheck) and clarify the expected shell; for example add a
line like "# shellcheck shell=bash" (or "# shellcheck shell=sh" if POSIX sh is
intended) above the exports of INFRA_TYPE and DEFAULT_MYSQL_INFRA so linters
know the target shell for the environment file.

In `@test/tap/groups/mysql84/env.sh`:
- Around line 7-10: Add a ShellCheck directive to suppress SC1090 for the
dynamic sourcing around the _INFRA_ENV sourcing block: above the line that
checks and sources _INFRA_ENV (the conditional that uses WORKSPACE and
DEFAULT_MYSQL_INFRA and does [ -f "${_INFRA_ENV}" ] && . "${_INFRA_ENV}"), add a
comment like a ShellCheck disable for SC1090 (e.g., "# shellcheck
disable=SC1090" or "# shellcheck source=/dev/null") to document the intentional
dynamic source and silence the linter.

In `@test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp`:
- Around line 37-43: Replace the unsafe atoi usage in init_hostgroups with
std::stoul to parse the TAP_MYSQL8_BACKEND_HG env var: read the getenv result
into a std::string (or check for nullptr), call std::stoul to convert to an
unsigned long for WHG, set RHG = WHG + 1, and wrap the conversion in try/catch
(std::invalid_argument/std::out_of_range) to handle bad input and preserve
detectable failure behavior rather than silently returning 0; reference
init_hostgroups(), WHG, and RHG when locating the change.

In `@test/tap/tests/test_set_collation-t.cpp`:
- Around line 82-90: The charset_equiv function duplicates utf8↔utf8mb3 and
collation-prefix logic already implemented in values_equiv; extract that logic
into a shared helper like charset_str_equiv(const std::string&, const
std::string&) in a common header, replace the body of charset_equiv to call
charset_str_equiv (converting const char* to std::string) and update
values_equiv to call the same helper so both tests reuse the single
implementation.
🪄 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

Run ID: 27bf1298-5881-49ba-b6c1-5a934505e0cf

📥 Commits

Reviewing files that changed from the base of the PR and between 2d258ff and d3b88c5.

📒 Files selected for processing (32)
  • test/infra/docker-mysql84-binlogreader/.gitignore
  • test/infra/docker-mysql84-binlogreader/Dockerfile.reader
  • test/infra/docker-mysql84-binlogreader/build.sh
  • test/infra/infra-mysql84-binlog/.env
  • test/infra/infra-mysql84-binlog/bin/docker-mysql-post.bash
  • test/infra/infra-mysql84-binlog/bin/docker-orchestrator-post.bash
  • test/infra/infra-mysql84-binlog/bin/docker-proxy-post.bash
  • test/infra/infra-mysql84-binlog/conf/mysql/mysql1/my.cnf
  • test/infra/infra-mysql84-binlog/conf/mysql/mysql2/my.cnf
  • test/infra/infra-mysql84-binlog/conf/mysql/mysql3/my.cnf
  • test/infra/infra-mysql84-binlog/conf/mysql/ssl/configure_ssl.sh
  • test/infra/infra-mysql84-binlog/conf/orchestrator/orc1/orchestrator.conf.json
  • test/infra/infra-mysql84-binlog/conf/orchestrator/orc2/orchestrator.conf.json
  • test/infra/infra-mysql84-binlog/conf/orchestrator/orc3/orchestrator.conf.json
  • test/infra/infra-mysql84-binlog/conf/orchestrator/remove-proxysql-host.bash
  • test/infra/infra-mysql84-binlog/conf/proxysql/infra-config.sql
  • test/infra/infra-mysql84-binlog/docker-compose-init.bash
  • test/infra/infra-mysql84-binlog/docker-compose.yml
  • test/infra/infra-mysql84/conf/mysql/mysql1/my.cnf
  • test/infra/infra-mysql84/conf/mysql/mysql2/my.cnf
  • test/infra/infra-mysql84/conf/mysql/mysql3/my.cnf
  • test/infra/infra-mysql84/conf/proxysql/infra-config.sql
  • test/tap/groups/groups.json
  • test/tap/groups/mysql84-binlog/env.sh
  • test/tap/groups/mysql84-binlog/infras.lst
  • test/tap/groups/mysql84/env.sh
  • test/tap/tests/reg_test_4935-caching_sha2-t.env
  • test/tap/tests/test_auth_methods-t.env
  • test/tap/tests/test_binlog_reader-t.cpp
  • test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp
  • test/tap/tests/test_set_collation-t.cpp
  • test/tap/tests/test_sqlite3_pass_exts-t.env
💤 Files with no reviewable changes (3)
  • test/tap/tests/test_sqlite3_pass_exts-t.env
  • test/tap/tests/test_auth_methods-t.env
  • test/tap/tests/reg_test_4935-caching_sha2-t.env
✅ Files skipped from review due to trivial changes (11)
  • test/infra/docker-mysql84-binlogreader/.gitignore
  • test/tap/groups/mysql84-binlog/infras.lst
  • test/infra/infra-mysql84/conf/mysql/mysql1/my.cnf
  • test/infra/infra-mysql84/conf/mysql/mysql2/my.cnf
  • test/infra/infra-mysql84/conf/mysql/mysql3/my.cnf
  • test/infra/infra-mysql84-binlog/conf/mysql/mysql3/my.cnf
  • test/infra/infra-mysql84-binlog/conf/mysql/ssl/configure_ssl.sh
  • test/infra/infra-mysql84-binlog/conf/orchestrator/orc2/orchestrator.conf.json
  • test/infra/infra-mysql84-binlog/conf/mysql/mysql1/my.cnf
  • test/infra/infra-mysql84-binlog/conf/mysql/mysql2/my.cnf
  • test/infra/infra-mysql84-binlog/conf/orchestrator/orc1/orchestrator.conf.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/tap/groups/groups.json
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: CI-builds / builds (debian12,-dbg)
  • GitHub Check: CI-builds / builds (ubuntu22,-tap)
  • GitHub Check: CI-builds / builds (ubuntu24,-tap-genai-gcov)
  • GitHub Check: run / trigger
  • GitHub Check: claude-review
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{cpp,h,hpp}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{cpp,h,hpp}: Class names must use PascalCase with protocol prefixes (MySQL_, PgSQL_, ProxySQL_)
Member variables must use snake_case
Constants and macros must use UPPER_SNAKE_CASE
C++17 is required; use conditional compilation via #ifdef PROXYSQLGENAI, #ifdef PROXYSQL31, etc. for feature flags
Use pthread mutexes for synchronization and std::atomic<> for counters

Files:

  • test/tap/tests/test_set_collation-t.cpp
  • test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp
  • test/tap/tests/test_binlog_reader-t.cpp
**/*.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

Use RAII for resource management and jemalloc for memory allocation

Files:

  • test/tap/tests/test_set_collation-t.cpp
  • test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp
  • test/tap/tests/test_binlog_reader-t.cpp
test/tap/tests/{test_*,*-t}.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

Test files in test/tap/tests/ must follow the naming pattern test_*.cpp or *-t.cpp

Files:

  • test/tap/tests/test_set_collation-t.cpp
  • test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp
  • test/tap/tests/test_binlog_reader-t.cpp
🧠 Learnings (8)
📓 Common learnings
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:27.165Z
Learning: In ProxySQL test files (test/tap/tests/), resource leaks (such as not calling `mysql_close()` on early return paths) are not typically fixed because test processes are short-lived and the OS frees resources on process exit. This is a common pattern across the test suite.
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.093Z
Learning: Applies to test/tap/tests/unit/**/*.cpp : Unit tests in test/tap/tests/unit/ must use test_globals.h and test_init.h and link against libproxysql.a via the custom test harness
📚 Learning: 2026-01-20T09:34:27.165Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:27.165Z
Learning: In ProxySQL test files (test/tap/tests/), resource leaks (such as not calling `mysql_close()` on early return paths) are not typically fixed because test processes are short-lived and the OS frees resources on process exit. This is a common pattern across the test suite.

Applied to files:

  • test/infra/infra-mysql84-binlog/conf/orchestrator/remove-proxysql-host.bash
  • test/infra/infra-mysql84-binlog/bin/docker-proxy-post.bash
  • test/tap/groups/mysql84/env.sh
📚 Learning: 2026-01-20T07:40:34.938Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:24-28
Timestamp: 2026-01-20T07:40:34.938Z
Learning: In ProxySQL test files, calling `mysql_error(NULL)` after `mysql_init()` failure is safe because the MariaDB client library implementation returns an empty string for NULL handles (not undefined behavior).

Applied to files:

  • test/infra/infra-mysql84-binlog/conf/orchestrator/remove-proxysql-host.bash
  • test/tap/tests/test_set_collation-t.cpp
  • test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp
  • test/infra/infra-mysql84-binlog/bin/docker-proxy-post.bash
📚 Learning: 2026-03-26T16:38:58.553Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5548
File: lib/mysql_connection.cpp:1837-1843
Timestamp: 2026-03-26T16:38:58.553Z
Learning: In ProxySQL's lib/mysql_connection.cpp, `SHOW WARNINGS` detection for both `update_warning_count_from_connection()` and the `add_eof()` call in `ASYNC_USE_RESULT_CONT` intentionally uses `myds->sess->CurrentQuery.QueryParserArgs.digest_text` (comment-stripped digest text). This means the fix/feature does not work when `mysql-query_digests_keep_comment=1` (digest_text contains comments) or `mysql-query_digests=0` (digest_text is unavailable) — these configurations are explicitly excluded from the regression test for `reg_test_5306-show_warnings_with_comment-t`. This design is consistent across the codebase and is an accepted, documented limitation.

Applied to files:

  • test/tap/tests/test_set_collation-t.cpp
📚 Learning: 2026-01-20T09:34:19.124Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:19.124Z
Learning: In ProxySQL's TAP test suite, resource leaks (e.g., not calling mysql_close() on early return paths) are commonly tolerated because test processes are short-lived and OS frees resources on exit. This pattern applies to all C++ test files under test/tap/tests. When reviewing, recognize this as a project-wide test convention and focus on test correctness and isolation rather than insisting on fixing such leaks in these test files.

Applied to files:

  • test/tap/tests/test_set_collation-t.cpp
  • test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp
  • test/tap/tests/test_binlog_reader-t.cpp
📚 Learning: 2026-03-22T14:38:16.093Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.093Z
Learning: Applies to test/tap/tests/unit/**/*.cpp : Unit tests in test/tap/tests/unit/ must use test_globals.h and test_init.h and link against libproxysql.a via the custom test harness

Applied to files:

  • test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp
  • test/tap/tests/test_binlog_reader-t.cpp
  • test/infra/infra-mysql84-binlog/.env
  • test/tap/groups/mysql84/env.sh
📚 Learning: 2026-03-22T14:38:16.093Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.093Z
Learning: Applies to **/*.{cpp,h,hpp} : C++17 is required; use conditional compilation via `#ifdef` PROXYSQLGENAI, `#ifdef` PROXYSQL31, etc. for feature flags

Applied to files:

  • test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp
📚 Learning: 2026-03-22T14:38:16.093Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.093Z
Learning: Admin interface uses SQLite3 backend for SQL-based configuration and schema versions are tracked in ProxySQL_Admin_Tables_Definitions.h

Applied to files:

  • test/infra/infra-mysql84/conf/proxysql/infra-config.sql
  • test/infra/infra-mysql84-binlog/conf/proxysql/infra-config.sql
🪛 dotenv-linter (4.0.0)
test/infra/infra-mysql84-binlog/.env

[warning] 6-6: [UnorderedKey] The RHG key should go before the WHG key

(UnorderedKey)


[warning] 7-7: [UnorderedKey] The BHG key should go before the RHG key

(UnorderedKey)


[warning] 8-8: [UnorderedKey] The OHG key should go before the RHG key

(UnorderedKey)


[warning] 11-11: [UnorderedKey] The BINLOG_RHG key should go before the BINLOG_WHG key

(UnorderedKey)


[warning] 25-25: [SubstitutionKey] The INFRA key is not assigned properly

(SubstitutionKey)


[warning] 29-29: [UnorderedKey] The TAP_MYSQL8_BACKEND_HG key should go before the TAP_REG_TEST_3549_AUTOCOMMIT_TRACKING___MYSQL_SERVER_HOSTGROUP key

(UnorderedKey)

🪛 Shellcheck (0.11.0)
test/infra/infra-mysql84-binlog/bin/docker-orchestrator-post.bash

[warning] 8-8: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 8-8: Quote this to prevent word splitting.

(SC2046)


[warning] 8-8: Quote this to prevent word splitting.

(SC2046)

test/infra/infra-mysql84-binlog/docker-compose-init.bash

[warning] 4-4: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 4-4: Quote this to prevent word splitting.

(SC2046)


[warning] 4-4: Quote this to prevent word splitting.

(SC2046)


[warning] 24-24: Quote this to prevent word splitting.

(SC2046)


[warning] 24-24: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 27-27: Quote this to prevent word splitting.

(SC2046)


[warning] 48-48: Declare and assign separately to avoid masking return values.

(SC2155)

test/tap/groups/mysql84-binlog/env.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)

test/tap/groups/mysql84/env.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)


[warning] 9-9: ShellCheck can't follow non-constant source. Use a directive to specify location.

(SC1090)

🪛 Trivy (0.69.3)
test/infra/docker-mysql84-binlogreader/Dockerfile.reader

[error] 1-1: Image user should not be 'root'

Specify at least 1 USER command in Dockerfile with non-root user as argument

Rule: DS-0002

Learn more

(IaC/Dockerfile)


[error] 5-6: 'apt-get' missing '--no-install-recommends'

'--no-install-recommends' flag is missed: 'dpkg -i /tmp/proxysql-mysqlbinlog_.deb || apt-get -f install -y && rm -f /tmp/proxysql-mysqlbinlog_.deb'

Rule: DS-0029

Learn more

(IaC/Dockerfile)

🔇 Additional comments (20)
test/tap/tests/test_set_collation-t.cpp (1)

92-104: LGTM - equivalence check correctly handles utf8/utf8mb3 differences.

The update to use charset_equiv() instead of direct strcmp() properly accommodates MySQL version differences in charset naming (utf8 vs utf8mb3). The diagnostic output in the ok() calls showing both expected and actual values is helpful for debugging test failures.

Minor note: row[1] is passed directly to charset_equiv() without a NULL check. Since these session variables should always have values, this is acceptable, but be aware that a NULL result would cause undefined behavior in strcmp().

test/infra/infra-mysql84-binlog/conf/orchestrator/remove-proxysql-host.bash (1)

1-4: LGTM — consistent with existing infra pattern.

The script mirrors the sibling implementation in test/infra/infra-mysql57/conf/orchestrator/remove-proxysql-host.bash. The misleading name (suggests removal but only logs) is an existing pattern across the codebase.

test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp (2)

213-222: Good: Dynamic hostgroup values now used in test assertions.

The test scenarios correctly use the resolved WHG/RHG values instead of hardcoded hostgroup IDs, enabling the test to run across different infrastructure configurations.


603-606: LGTM — proper initialization and diagnostic output.

The init_hostgroups() call and diagnostic output provide clear visibility into which hostgroups the test is using, aiding in debugging CI failures.

test/tap/groups/mysql84/env.sh (1)

1-14: Well-structured environment configuration.

The conditional sourcing pattern with WORKSPACE check is robust and matches the established pattern in test/tap/groups/legacy/env.sh. The fallback behavior when WORKSPACE is not set ensures local development still works.

test/infra/docker-mysql84-binlogreader/build.sh (1)

1-24: Well-designed build script with good developer UX.

The pre-flight check with clear error messages and build instructions is excellent. The script fails fast when prerequisites are missing.

test/infra/infra-mysql84-binlog/conf/orchestrator/orc3/orchestrator.conf.json (1)

1-38: LGTM — Orchestrator config follows the established pattern.

The configuration correctly mirrors the orc1/orc2 configs with the appropriate RaftBind hostname for orc3. The hardcoded password is acceptable for CI test infrastructure where credentials are injected via docker-compose-init.bash.

test/tap/tests/test_binlog_reader-t.cpp (2)

101-104: Good: Environment-driven hostgroup configuration.

Using static file-scope variables with environment overrides enables the same test to run against different infrastructure configurations without code changes.


288-292: LGTM — Safe environment parsing with std::stoul.

Using std::stoul is better than atoi as it will throw std::invalid_argument or std::out_of_range on malformed input, making configuration errors visible rather than silently defaulting.

test/infra/infra-mysql84/conf/proxysql/infra-config.sql (2)

28-38: LGTM - User seeding expanded for test coverage.

The INSERT OR IGNORE + UPDATE pattern for the root user ensures idempotent configuration regardless of whether the user pre-exists. The additional test users (sbtest1-8, ssluser, testuser) align with the TAP test requirements mentioned in the PR objectives.


53-116: LGTM - Extended ProxySQL configuration for CI observability.

The additions enable:

  • Query/audit logging for test verification
  • REST API on fixed port 6070 for Prometheus metrics
  • Debug filtering to reduce log noise from high-frequency monitor/handler calls
  • SSL keylog capture for debugging encrypted connections

This configuration supports the expanded TAP test coverage for mysql84-g1/g2/g3 groups.

test/infra/infra-mysql84-binlog/bin/docker-proxy-post.bash (1)

1-21: LGTM - ProxySQL post-setup hook for binlog infra.

The script correctly:

  • Sources environment from the infra .env
  • Uses the established eval pattern for SQL variable expansion
  • Synchronizes monitor credentials for binlog reader health checks
test/infra/infra-mysql84-binlog/docker-compose.yml (1)

1-187: LGTM - Well-structured Docker Compose for MySQL 8.4 binlog CI environment.

The compose file correctly:

  • Establishes MySQL replication topology (mysql1 as primary, mysql2/3 as replicas)
  • Deploys binlog readers with appropriate GTID configuration
  • Sets up Percona Orchestrator Raft cluster for HA
  • Uses external network for ProxySQL connectivity
  • Configures appropriate resource limits (nofile ulimits)
test/infra/infra-mysql84-binlog/bin/docker-orchestrator-post.bash (1)

15-77: LGTM - Orchestrator discovery and health verification logic.

The script properly:

  • Polls for API readiness with timeout
  • Triggers discovery for all 3 MySQL nodes
  • Verifies cluster topology formation
  • Detects replication issues via [ok] pattern matching
test/infra/infra-mysql84-binlog/conf/proxysql/infra-config.sql (2)

8-10: LGTM - MySQL servers configured with GTID port for binlog readers.

The gtid_port=6020 configuration correctly points to the binlog reader sidecar containers, enabling ProxySQL's GTID-consistent read routing. This aligns with the GTID_PORT=6020 environment variable in docker-compose.yml.


28-34: LGTM - Query rules with GTID-aware read routing.

The rules correctly implement:

  • SELECT ... FOR UPDATE → writer hostgroup (no GTID tracking needed, acquires lock)
  • Plain SELECT → reader hostgroup with gtid_from_hostgroup=${WHG} (ensures read-your-writes consistency)
  • Catch-all .* → writer hostgroup

This is the standard pattern for GTID-based read/write splitting.

test/infra/infra-mysql84-binlog/.env (1)

1-29: LGTM - Well-structured environment configuration for mysql84-binlog infra.

The file correctly:

  • Uses PREFIX-based derivation for unique hostgroup IDs (1400, 1401, etc.) avoiding collision with other infras
  • Exports BINLOG_WHG/BINLOG_RHG for binlog-specific tests
  • Provides TAP test environment variables (TAP_MYSQL8_BACKEND_HG, TAP_REG_TEST_3549_AUTOCOMMIT_TRACKING___MYSQL_SERVER_HOSTGROUP)
  • Uses standard shell default syntax for INFRA fallback

The static analysis warnings about key ordering are false positives - the grouping by purpose (hostgroups, MySQL ports, binlog ports, orchestrator ports) is more maintainable than alphabetical ordering.

test/infra/infra-mysql84-binlog/bin/docker-mysql-post.bash (2)

14-37: LGTM - Robust authentication probing with fallback.

The three-tier password probing (dynamic → default "root" → empty) handles various MySQL container initialization states gracefully. The 120s timeout is appropriate for cold-start scenarios.


39-79: LGTM - Master configuration with appropriate user grants.

The master setup correctly:

  • Creates users with mysql_native_password for compatibility
  • Grants REPLICATION CLIENT, REPLICATION SLAVE to binlog user
  • Creates test databases and per-database grants for sbtest users
  • Aligns monitor user credentials with ProxySQL config (as shown in context snippet from docker-proxy-post.bash)
test/infra/infra-mysql84-binlog/docker-compose-init.bash (1)

1-136: LGTM - Comprehensive CI bootstrap script for mysql84-binlog infra.

The script properly orchestrates:

  • Environment derivation with fallbacks
  • Volume preparation with safety checks (non-empty directory rejection)
  • Dynamic config injection for Orchestrator
  • Docker Compose lifecycle with health verification
  • Network connectivity for containerized runners
  • Post-start hook execution sequence


EXPOSE 6020

CMD ["bash", "-c", "while true; do sleep 5; proxysql_binlog_reader -h \"${MYSQL_HOST:-127.0.0.1}\" -u \"${MYSQL_USER:=root}\" -p \"${MYSQL_PASSWORD:-root}\" -P \"${MYSQL_PORT:-3306}\" -l \"${LISTEN_PORT:-6020}\" -f 2>&1 | tee -a /var/log/mysqlbinlog/error.log; done"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Inconsistent parameter expansion: MYSQL_USER uses := while others use :-.

The := operator assigns the default to the variable (modifying it), while :- only substitutes without assignment. All other variables use :-. This inconsistency could cause unexpected behavior if the script is extended.

🔧 Proposed fix for consistency
-CMD ["bash", "-c", "while true; do sleep 5; proxysql_binlog_reader -h \"${MYSQL_HOST:-127.0.0.1}\" -u \"${MYSQL_USER:=root}\" -p \"${MYSQL_PASSWORD:-root}\" -P \"${MYSQL_PORT:-3306}\" -l \"${LISTEN_PORT:-6020}\" -f 2>&1 | tee -a /var/log/mysqlbinlog/error.log; done"]
+CMD ["bash", "-c", "while true; do sleep 5; proxysql_binlog_reader -h \"${MYSQL_HOST:-127.0.0.1}\" -u \"${MYSQL_USER:-root}\" -p \"${MYSQL_PASSWORD:-root}\" -P \"${MYSQL_PORT:-3306}\" -l \"${LISTEN_PORT:-6020}\" -f 2>&1 | tee -a /var/log/mysqlbinlog/error.log; done"]
📝 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
CMD ["bash", "-c", "while true; do sleep 5; proxysql_binlog_reader -h \"${MYSQL_HOST:-127.0.0.1}\" -u \"${MYSQL_USER:=root}\" -p \"${MYSQL_PASSWORD:-root}\" -P \"${MYSQL_PORT:-3306}\" -l \"${LISTEN_PORT:-6020}\" -f 2>&1 | tee -a /var/log/mysqlbinlog/error.log; done"]
CMD ["bash", "-c", "while true; do sleep 5; proxysql_binlog_reader -h \"${MYSQL_HOST:-127.0.0.1}\" -u \"${MYSQL_USER:-root}\" -p \"${MYSQL_PASSWORD:-root}\" -P \"${MYSQL_PORT:-3306}\" -l \"${LISTEN_PORT:-6020}\" -f 2>&1 | tee -a /var/log/mysqlbinlog/error.log; done"]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/infra/docker-mysql84-binlogreader/Dockerfile.reader` at line 12, The CMD
line launching proxysql_binlog_reader uses inconsistent parameter expansion for
MYSQL_USER (\"${MYSQL_USER:=root}\") which assigns the default instead of just
substituting; update the invocation in the CMD (the proxysql_binlog_reader
command) to use \"${MYSQL_USER:-root}\" to match the other variables
(MYSQL_HOST, MYSQL_PASSWORD, MYSQL_PORT, LISTEN_PORT) so no environment
variables are modified by the script and behavior stays consistent.

Comment on lines +7 to +11
if [ -z "${INFRA}" ] || [ "${INFRA}" == "." ]; then
export INFRA=$(basename $(cd $(dirname $0)/.. && pwd))
fi

PROXY_CONTAINER="proxysql.${INFRA_ID}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix shell quoting and INFRA_ID dependency.

  1. Line 8 has unquoted command substitutions that can cause word splitting issues (SC2046/SC2155).
  2. Line 11 uses ${INFRA_ID} but the fallback on line 8 only sets INFRA, leaving INFRA_ID potentially unset from .env.
Proposed fix
 # Ensure INFRA is set correctly
 if [ -z "${INFRA}" ] || [ "${INFRA}" == "." ]; then
-    export INFRA=$(basename $(cd $(dirname $0)/.. && pwd))
+    SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+    export INFRA="$(basename "$(cd "${SCRIPT_DIR}/.." && pwd)")"
 fi
 
+# INFRA_ID should come from .env; fail early if missing
+if [ -z "${INFRA_ID}" ]; then
+    echo "ERROR: INFRA_ID is not set. Ensure .env is sourced correctly."
+    exit 1
+fi
+
 PROXY_CONTAINER="proxysql.${INFRA_ID}"
🧰 Tools
🪛 Shellcheck (0.11.0)

[warning] 8-8: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 8-8: Quote this to prevent word splitting.

(SC2046)


[warning] 8-8: Quote this to prevent word splitting.

(SC2046)

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

In `@test/infra/infra-mysql84-binlog/bin/docker-orchestrator-post.bash` around
lines 7 - 11, The script uses unquoted command substitutions and references
INFRA_ID which may be unset; fix by quoting all substitutions when setting INFRA
(use command substitutions wrapped in double quotes for basename/cd/dirname and
wrap variable expansions in quotes) and ensure INFRA_ID has a sensible fallback
(e.g., set INFRA_ID to "${INFRA_ID:-$INFRA}" or derive it from INFRA) before
building PROXY_CONTAINER (PROXY_CONTAINER should remain quoted as
"proxysql.${INFRA_ID}").

Comment on lines +54 to +59
if [ $COUNT -gt $MAX_WAIT ]; then
echo " WARNING: Still waiting for cluster discovery after ${MAX_WAIT}s"
break
fi
done
echo " OK."
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

"OK" printed even when cluster discovery times out.

When the while loop exits due to COUNT > MAX_WAIT, CLUSTER_NAME may still be empty, but line 59 unconditionally prints " OK.". The subsequent if [ -n "$CLUSTER_NAME" ] handles this, but the output is misleading.

Proposed fix
     if [ $COUNT -gt $MAX_WAIT ]; then
         echo " WARNING: Still waiting for cluster discovery after ${MAX_WAIT}s"
         break
     fi
 done
-echo " OK."
+if [ -n "$CLUSTER_NAME" ]; then
+    echo " OK."
+fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/infra/infra-mysql84-binlog/bin/docker-orchestrator-post.bash` around
lines 54 - 59, The script prints " OK." unconditionally after the loop, which is
misleading when discovery timed out; update the post-loop logic so that the echo
" OK." is only printed when CLUSTER_NAME is non-empty (i.e. discovery succeeded)
and print a clear failure message when COUNT > MAX_WAIT or CLUSTER_NAME is
empty; modify the block that follows the while loop (references: COUNT,
MAX_WAIT, CLUSTER_NAME and the echo " OK.") to conditionally echo success on
non-empty CLUSTER_NAME and echo a timeout/failure message otherwise.

SAVE MYSQL VARIABLES TO DISK;
SQL

if [ $? -eq 0 ]; then echo "Cluster ${INFRA} registered in ProxySQL."; else echo "ERROR: ProxySQL configuration FAILED for ${INFRA}"; exit 1; fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Unreachable error handling due to set -e.

With set -e enabled on line 2, if the docker exec command fails, the script will exit immediately before reaching this conditional check. The success path message works, but the error path is dead code.

Proposed fix

Either remove the redundant check (relying on set -e behavior):

-if [ $? -eq 0 ]; then echo "Cluster ${INFRA} registered in ProxySQL."; else echo "ERROR: ProxySQL configuration FAILED for ${INFRA}"; exit 1; fi
+echo "Cluster ${INFRA} registered in ProxySQL."

Or temporarily disable set -e to handle the error explicitly:

+set +e
 docker exec -i "${PROXY_CONTAINER}" mysql -uradmin -pradmin -h127.0.0.1 -P6032 <<SQL
 ...
 SQL
+set -e

 if [ $? -eq 0 ]; then echo "Cluster ${INFRA} registered in ProxySQL."; else echo "ERROR: ProxySQL configuration FAILED for ${INFRA}"; exit 1; fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/infra/infra-mysql84-binlog/bin/docker-proxy-post.bash` at line 23, The
conditional that checks the previous exit code (if [ $? -eq 0 ]; then ... else
... fi) is unreachable because the script enables set -e at the top; either
remove this redundant check and rely on set -e to fail fast, or wrap the command
that may fail (the docker exec/ProxySQL registration invocation) with a
temporary disable of set -e (trap errexit) so you can inspect its exit status
and call processLogger-style echo on failure; update the block that contains the
conditional accordingly (the conditional around ProxySQL registration) to use
one of these two approaches.

Comment on lines +3 to +5
if [ -z "${INFRA_ID}" ]; then
export INFRA_ID=$(basename $(dirname $(pwd)) | sed 's/infra-//; s/docker-//')
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Shell quoting issues in INFRA_ID derivation.

The nested command substitutions lack quoting, which can cause word splitting with directory names containing spaces (SC2046/SC2155).

Proposed fix
 # RELIABLY CAPTURE INFRA_ID FROM ENVIRONMENT OR DIRECTORY NAME
 if [ -z "${INFRA_ID}" ]; then
-    export INFRA_ID=$(basename $(dirname $(pwd)) | sed 's/infra-//; s/docker-//')
+    PARENT_DIR="$(dirname "$(pwd)")"
+    export INFRA_ID="$(basename "${PARENT_DIR}" | sed 's/infra-//; s/docker-//')"
 fi
🧰 Tools
🪛 Shellcheck (0.11.0)

[warning] 4-4: Declare and assign separately to avoid masking return values.

(SC2155)


[warning] 4-4: Quote this to prevent word splitting.

(SC2046)


[warning] 4-4: Quote this to prevent word splitting.

(SC2046)

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

In `@test/infra/infra-mysql84-binlog/docker-compose-init.bash` around lines 3 - 5,
The INFRA_ID derivation uses unquoted command substitutions causing
word-splitting for paths with spaces; update the assignment of INFRA_ID so all
command substitutions and their arguments are quoted (e.g., quote the outputs of
pwd, dirname and basename and the whole right-hand side) and keep the sed
transformation, e.g. change the export INFRA_ID line that references INFRA_ID,
basename, dirname and $(pwd) to use quoted substitutions to prevent
SC2046/SC2155 issues.

Comment on lines +46 to +48
if [ -z "${INFRA_ID}" ]; then echo "Error: INFRA_ID must be set"; exit 1; fi

export ROOT_PASSWORD=$(echo -n "${INFRA_ID}" | sha256sum | head -c 10)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Separate declaration and assignment for ROOT_PASSWORD.

Combining export with command substitution masks the return value of the pipeline (SC2155). If sha256sum fails, the error would be silently ignored.

Proposed fix
 if [ -z "${INFRA_ID}" ]; then echo "Error: INFRA_ID must be set"; exit 1; fi

-export ROOT_PASSWORD=$(echo -n "${INFRA_ID}" | sha256sum | head -c 10)
+ROOT_PASSWORD="$(echo -n "${INFRA_ID}" | sha256sum | head -c 10)"
+export ROOT_PASSWORD
 export INFRA=${PWD##*/}
📝 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
if [ -z "${INFRA_ID}" ]; then echo "Error: INFRA_ID must be set"; exit 1; fi
export ROOT_PASSWORD=$(echo -n "${INFRA_ID}" | sha256sum | head -c 10)
if [ -z "${INFRA_ID}" ]; then echo "Error: INFRA_ID must be set"; exit 1; fi
ROOT_PASSWORD="$(echo -n "${INFRA_ID}" | sha256sum | head -c 10)"
export ROOT_PASSWORD
🧰 Tools
🪛 Shellcheck (0.11.0)

[warning] 48-48: Declare and assign separately to avoid masking return values.

(SC2155)

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

In `@test/infra/infra-mysql84-binlog/docker-compose-init.bash` around lines 46 -
48, The export of ROOT_PASSWORD is done inline with command substitution which
hides pipeline failures (SC2155); change to first compute ROOT_PASSWORD by
running sha256sum on INFRA_ID and capture its exit status, fail early if the
command fails, then export ROOT_PASSWORD separately. Locate the block using
INFRA_ID and the assignment to ROOT_PASSWORD (the sha256sum | head -c 10
pipeline) and replace it with a two-step: assign to a local/temporary variable,
check its exit code and non-empty result, then export ROOT_PASSWORD.

Comment on lines +83 to +85
aliases:
- reader1.${INFRA}
- mysql1.${INFRA}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if similar alias patterns exist in other infra compose files
rg -n 'aliases:' -A3 test/infra/*/docker-compose.yml | grep -E 'mysql[0-9]+\.\$' || echo "No overlapping mysql alias patterns found"

Repository: sysown/proxysql

Length of output: 1496


🏁 Script executed:

# Read the entire docker-compose.yml to understand the structure
cat -n test/infra/infra-mysql84-binlog/docker-compose.yml | head -130

Repository: sysown/proxysql

Length of output: 4215


Network alias overlap between MySQL and binlog reader containers causes DNS ambiguity.

Both mysql1 container and reader1 container declare the network alias mysql1.${INFRA} (and similarly for mysql2/reader2, mysql3/reader3). When two containers share an identical alias on the same network, Docker's DNS resolver exhibits non-deterministic behavior—connections to mysql1.${INFRA} may resolve to either the MySQL or reader container depending on Docker version and internal state.

This appears intentional (binlog readers are configured to connect to their corresponding MySQL servers via MYSQL_HOST=mysql[1-3].${INFRA}), but the shared alias creates instability: services expecting to reach MySQL directly could be routed to the binlog reader instead, causing test inconsistencies.

Either document the rationale for this design in a comment within the compose file, or use distinct aliases for readers (e.g., binlog-reader1.${INFRA}) to avoid DNS ambiguity.

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

In `@test/infra/infra-mysql84-binlog/docker-compose.yml` around lines 83 - 85, The
docker-compose network aliases currently make reader containers share the same
alias as MySQL (e.g., reader1.${INFRA} and mysql1.${INFRA}), which causes DNS
ambiguity; update the reader container alias names to distinct identifiers (for
example change reader1.${INFRA} → binlog-reader1.${INFRA}, reader2.${INFRA} →
binlog-reader2.${INFRA}, reader3.${INFRA} → binlog-reader3.${INFRA}) and ensure
any references that expect to contact the reader or the MySQL instance use the
new names (check env keys like MYSQL_HOST and reader service definitions);
alternatively, if the shared-alias behavior is intended, add a short comment
next to the aliases explaining why the overlap is required and noting the
non-deterministic DNS behavior.

Comment on lines +200 to 204
uint32_t hg_whg_queries = hg_stats.at(WHG).first;
uint32_t hg_whg_sync_queries = hg_stats.at(WHG).second;;
uint32_t hg_rhg_queries = hg_stats.at(RHG).first;
uint32_t hg_rhg_sync_queries = hg_stats.at(RHG).second;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor: Double semicolons at end of statements.

Lines 201, 203 have trailing ;; which, while valid C++, appear to be copy-paste artifacts.

🔧 Fix the double semicolons
 	uint32_t hg_whg_queries = hg_stats.at(WHG).first;
-	uint32_t hg_whg_sync_queries = hg_stats.at(WHG).second;;
+	uint32_t hg_whg_sync_queries = hg_stats.at(WHG).second;
 	uint32_t hg_rhg_queries = hg_stats.at(RHG).first;
-	uint32_t hg_rhg_sync_queries = hg_stats.at(RHG).second;;
+	uint32_t hg_rhg_sync_queries = hg_stats.at(RHG).second;
📝 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
uint32_t hg_whg_queries = hg_stats.at(WHG).first;
uint32_t hg_whg_sync_queries = hg_stats.at(WHG).second;;
uint32_t hg_rhg_queries = hg_stats.at(RHG).first;
uint32_t hg_rhg_sync_queries = hg_stats.at(RHG).second;;
uint32_t hg_whg_queries = hg_stats.at(WHG).first;
uint32_t hg_whg_sync_queries = hg_stats.at(WHG).second;
uint32_t hg_rhg_queries = hg_stats.at(RHG).first;
uint32_t hg_rhg_sync_queries = hg_stats.at(RHG).second;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/tap/tests/test_binlog_reader-t.cpp` around lines 200 - 204, The two
variable declarations hg_whg_sync_queries and hg_rhg_sync_queries contain
accidental double semicolons (;;); edit their statements to remove the extra
semicolon so each declaration ends with a single semicolon (e.g., fix the lines
that set hg_whg_sync_queries = hg_stats.at(WHG).second and hg_rhg_sync_queries =
hg_stats.at(RHG).second).

Comment on lines +241 to +244
hg_whg_queries = hg_stats.at(WHG).first;
hg_whg_sync_queries = hg_stats.at(WHG).second;;
hg_rhg_queries = hg_stats.at(RHG).first;
hg_rhg_sync_queries = hg_stats.at(RHG).second;;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Same double-semicolon issue here.

🔧 Fix the double semicolons
 	hg_whg_queries = hg_stats.at(WHG).first;
-	hg_whg_sync_queries = hg_stats.at(WHG).second;;
+	hg_whg_sync_queries = hg_stats.at(WHG).second;
 	hg_rhg_queries = hg_stats.at(RHG).first;
-	hg_rhg_sync_queries = hg_stats.at(RHG).second;;
+	hg_rhg_sync_queries = hg_stats.at(RHG).second;
📝 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
hg_whg_queries = hg_stats.at(WHG).first;
hg_whg_sync_queries = hg_stats.at(WHG).second;;
hg_rhg_queries = hg_stats.at(RHG).first;
hg_rhg_sync_queries = hg_stats.at(RHG).second;;
hg_whg_queries = hg_stats.at(WHG).first;
hg_whg_sync_queries = hg_stats.at(WHG).second;
hg_rhg_queries = hg_stats.at(RHG).first;
hg_rhg_sync_queries = hg_stats.at(RHG).second;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/tap/tests/test_binlog_reader-t.cpp` around lines 241 - 244, The lines
assigning hg_whg_sync_queries and hg_rhg_sync_queries have stray double
semicolons causing a warning; remove the extra semicolons so the assignments use
a single terminating semicolon (fix the statements assigning hg_whg_sync_queries
= hg_stats.at(WHG).second; and hg_rhg_sync_queries = hg_stats.at(RHG).second;).

rahim-kanji and others added 4 commits April 1, 2026 12:20
Move test_cluster1-t, test_cluster_sync_mysql_servers-t, and test_gtid_forwarding-t to legacy-g5
Signed-off-by: René Cannaò <rene@proxysql.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 9, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
E Reliability Rating on New Code (required ≥ A)
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@renecannao renecannao merged commit bd83f9b into v3.0 Apr 9, 2026
6 of 9 checks passed
@renecannao renecannao deleted the v3.0-ci_84_mysql84 branch April 17, 2026 17:54
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