Skip to content

Add SKIP_PROXYSQL for infrastructure-free test groups (unit tests)#5520

Merged
renecannao merged 3 commits intov3.0from
unit-tests-skip-proxysql
Mar 22, 2026
Merged

Add SKIP_PROXYSQL for infrastructure-free test groups (unit tests)#5520
renecannao merged 3 commits intov3.0from
unit-tests-skip-proxysql

Conversation

@renecannao
Copy link
Contributor

@renecannao renecannao commented Mar 22, 2026

Summary

How it works

When a group's env.sh exports SKIP_PROXYSQL=1:

  • ensure-infras.bash: sources the group's env.sh early and exits immediately — no ProxySQL container, no backend containers, no hooks
  • run-tests-isolated.bash: sources the group's env.sh early, skips all ProxySQL/backend verification, and runs proxysql-tester.py directly on the host instead of inside a Docker container

Files changed

File Change
test/infra/control/ensure-infras.bash Source group env.sh early; early-exit on SKIP_PROXYSQL=1
test/infra/control/run-tests-isolated.bash Source group env.sh early; skip verification and Docker when SKIP_PROXYSQL=1
test/tap/groups/unit-tests/env.sh New — sets SKIP_PROXYSQL=1
test/tap/groups/groups.json Add 18 unit test binaries to unit-tests-g1
test/README.md Add unit-tests-g1 to group table; SKIP_PROXYSQL to env vars
test/infra/README.md Add SKIP_PROXYSQL to env vars; new section 6.1 for infrastructure-free groups

Test plan

  • Verify unit-tests-g1 runs successfully via multi-group runner
  • Verify existing groups (e.g., legacy-g1) are unaffected by the env.sh sourcing change
  • Verify ensure-infras.bash exits cleanly with SKIP_PROXYSQL=1

Summary by CodeRabbit

  • Documentation

    • Added guidance on infrastructure-free test groups, SKIP_PROXYSQL usage, group layout, and how to create/run such groups.
    • Expanded test-group catalog and mapping documentation to reflect new unit/AI/legacy groupings.
  • New Features

    • Unit tests can be executed directly on the host without ProxySQL or Docker when SKIP_PROXYSQL=1; test-run summaries are produced.

Copilot AI review requested due to automatic review settings March 22, 2026 14:42
@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 224219b1-54e7-4032-9f50-8b35f542926c

📥 Commits

Reviewing files that changed from the base of the PR and between 5519e54 and 3aab0c2.

📒 Files selected for processing (7)
  • test/README.md
  • test/infra/README.md
  • test/infra/control/ensure-infras.bash
  • test/infra/control/run-tests-isolated.bash
  • test/tap/groups/README.md
  • test/tap/groups/groups.json
  • test/tap/groups/unit-tests/env.sh

📝 Walkthrough

Walkthrough

Adds an infrastructure-free unit-test mode driven by SKIP_PROXYSQL=1 in group env.sh. Infra scripts now source group envs and early-exit when skipping ProxySQL/backends; the test runner can discover and execute unit test binaries directly on the host. Documentation and group mappings for unit-tests-g1 were added.

Changes

Cohort / File(s) Summary
Documentation
test/README.md, test/infra/README.md, test/tap/groups/README.md
Documented SKIP_PROXYSQL and "Infrastructure-Free Groups", added usage examples and described per-group layout and behavior for groups that skip ProxySQL/backends.
Infrastructure Control Scripts
test/infra/control/ensure-infras.bash, test/infra/control/run-tests-isolated.bash
Both scripts now source group-level env.sh (group or base). ensure-infras.bash exits early when SKIP_PROXYSQL=1. run-tests-isolated.bash bypasses Docker/ProxySQL/backend checks when SKIP_PROXYSQL=1 and runs/discovers unit test binaries on the host, aggregating results.
Group configs & mappings
test/tap/groups/unit-tests/env.sh, test/tap/groups/groups.json, test/tap/groups/...
Added unit-tests group env exporting SKIP_PROXYSQL=1. groups.json extensively reorganized and expanded test-to-group mappings, adding unit-tests-g1, no-infra-g1, new AI/legacy/unit suites, and many remapped entries.
Test docs (group mention)
test/README.md
Added unit-tests-g1 mention and SKIP_PROXYSQL usage note to test README.

Sequence Diagram

sequenceDiagram
    participant User
    participant Ensure as "ensure-infras.bash"
    participant Runner as "run-tests-isolated.bash"
    participant Tester as "Test binaries (host)"

    User->>Ensure: start test execution
    Ensure->>Ensure: source group env.sh
    alt SKIP_PROXYSQL == "1"
        Ensure-->>User: log "Skipping ProxySQL/backends" and exit 0
    else
        Ensure->>Ensure: ensure ProxySQL & backends up
    end

    User->>Runner: invoke test run
    Runner->>Runner: source group env.sh
    alt SKIP_PROXYSQL == "1"
        Runner->>Tester: discover & execute unit test binaries on host
        Tester-->>Runner: return aggregated results
    else
        Runner->>Runner: verify Docker containers & infra
        Runner->>Tester: run tests inside test container
        Tester-->>Runner: return aggregated results
    end

    Runner-->>User: return aggregated exit status
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hop where tests run light and free,
SKIP_PROXYSQL set, I dance with glee.
No ProxySQL chase, just host-side fun,
Unit hops complete — one by one.
🌿✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: introducing SKIP_PROXYSQL environment variable support to enable infrastructure-free test groups, specifically for unit tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch unit-tests-skip-proxysql

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

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 introduces a mechanism to skip the requirement for ProxySQL and backend infrastructure for specific test groups, primarily targeting unit tests. By setting the SKIP_PROXYSQL environment variable, the test infrastructure setup is bypassed, and tests are executed directly on the host, leading to faster test cycles for unit tests and other infrastructure-independent tests. The changes include modifications to the test execution scripts and documentation, as well as the creation of a new test group for unit tests.

Highlights

  • Infrastructure-Free Testing: Introduces the ability to run test groups without requiring ProxySQL or any backend infrastructure by setting SKIP_PROXYSQL=1 in the group's env.sh.
  • Unit Test Group: Creates a new unit-tests group containing 18 unit test binaries, enabling faster and more isolated unit testing.
  • Simplified Testing: Modifies ensure-infras.bash and run-tests-isolated.bash to streamline the testing process when SKIP_PROXYSQL=1, skipping infrastructure setup and running tests directly on the host.

🧠 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.

Unit tests run standalone against libproxysql.a with stubs and need
no ProxySQL instance or backend databases. This adds a SKIP_PROXYSQL
flag that test groups can set in their env.sh to bypass all Docker
infrastructure setup and run tests directly on the host.

Changes:
- ensure-infras.bash: source group env.sh early; exit immediately
  when SKIP_PROXYSQL=1
- run-tests-isolated.bash: source group env.sh early; skip ProxySQL
  and backend verification; run proxysql-tester.py directly on host
  instead of inside a Docker container
- New test/tap/groups/unit-tests/env.sh with SKIP_PROXYSQL=1
- groups.json: add 18 unit test binaries to unit-tests-g1 group
- Documentation: SKIP_PROXYSQL in env var tables and new section
  for infrastructure-free groups in test/infra/README.md
@renecannao renecannao force-pushed the unit-tests-skip-proxysql branch from 5519e54 to 4c4736c Compare March 22, 2026 14:45
Copy link

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

Choose a reason for hiding this comment

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

Code Review

This pull request introduces SKIP_PROXYSQL support, which is a great feature for running unit tests without backend infrastructure. The implementation is solid and the documentation updates are clear and comprehensive. I've identified a couple of areas for improvement related to code duplication and structure in the bash scripts, which I've detailed in my comments. These changes would enhance the maintainability of the test infrastructure.

Comment on lines +31 to +35
if [ -f "${WORKSPACE}/test/tap/groups/${TAP_GROUP}/env.sh" ]; then
source "${WORKSPACE}/test/tap/groups/${TAP_GROUP}/env.sh"
elif [ -f "${WORKSPACE}/test/tap/groups/${BASE_GROUP}/env.sh" ]; then
source "${WORKSPACE}/test/tap/groups/${BASE_GROUP}/env.sh"
fi

Choose a reason for hiding this comment

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

medium

This block for sourcing the group's env.sh is duplicated in test/infra/control/run-tests-isolated.bash (lines 59-63). To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, consider extracting this logic into a common script that can be sourced by both files.

For example, you could create test/infra/common/source-group-env.bash with the following content:

# This script is meant to be sourced.
# It sources the environment file for a given TAP_GROUP.

if [ -z "${TAP_GROUP}" ] || [ -z "${WORKSPACE}" ]; then
    echo "ERROR: TAP_GROUP and WORKSPACE must be set before sourcing." >&2
    return 1
fi

BASE_GROUP=$(echo "${TAP_GROUP}" | sed -E "s/[-_]g[0-9]+.*//")

if [ -f "${WORKSPACE}/test/tap/groups/${TAP_GROUP}/env.sh" ]; then
    source "${WORKSPACE}/test/tap/groups/${TAP_GROUP}/env.sh"
elif [ -f "${WORKSPACE}/test/tap/groups/${BASE_GROUP}/env.sh" ]; then
    source "${WORKSPACE}/test/tap/groups/${BASE_GROUP}/env.sh"
fi

Then, you could replace the duplicated block in both scripts with:

source "${SCRIPT_DIR}/../common/source-group-env.bash"

Comment on lines +100 to +149
if [ "${SKIP_PROXYSQL}" = "1" ]; then
echo ">>> SKIP_PROXYSQL=1: Skipping ProxySQL and backend verification for group '${TAP_GROUP}'."
echo ">>> Running unit tests directly (no infrastructure needed)."
else
# VERIFICATION: Verify ProxySQL is running
PROXY_CONTAINER="proxysql.${INFRA_ID}"
echo ">>> Verifying ProxySQL container: ${PROXY_CONTAINER}"
if ! docker ps --format '{{.Names}}' | grep -q "^${PROXY_CONTAINER}$"; then
echo "ERROR: ProxySQL container ${PROXY_CONTAINER} is NOT running!"
exit 1
fi

# VERIFICATION: Verify all required backend containers are running
for INFRA_NAME in ${INFRAS_TO_CHECK}; do
echo ">>> Verifying Backend: ${INFRA_NAME}"
# Extract container names from the infra's docker-compose.yml
if [ -f "${WORKSPACE}/test/infra/${INFRA_NAME}/docker-compose.yml" ]; then
# Project name used by init script
COMPOSE_PROJECT="${INFRA_NAME}-${INFRA_ID}"
# Get all services for this project
RUNNING_CONTAINERS=$(docker ps --filter "label=com.docker.compose.project=${COMPOSE_PROJECT}" --format '{{.Names}}')
if [ -z "${RUNNING_CONTAINERS}" ]; then
if [ -f "${WORKSPACE}/test/tap/groups/${TAP_GROUP}/infras.lst" ]; then LST_PATH="${WORKSPACE}/test/tap/groups/${TAP_GROUP}/infras.lst"; else LST_PATH="${WORKSPACE}/test/tap/groups/${BASE_GROUP}/infras.lst"; fi
echo "ERROR: Required infrastructure '${INFRA_NAME}' is NOT running."
if [ -f "${LST_PATH}" ]; then
echo "According to '${LST_PATH}', this infrastructure is mandatory for the '${TAP_GROUP}' group."
# VERIFICATION: Verify all required backend containers are running
for INFRA_NAME in ${INFRAS_TO_CHECK}; do
echo ">>> Verifying Backend: ${INFRA_NAME}"
# Extract container names from the infra's docker-compose.yml
if [ -f "${WORKSPACE}/test/infra/${INFRA_NAME}/docker-compose.yml" ]; then
# Project name used by init script
COMPOSE_PROJECT="${INFRA_NAME}-${INFRA_ID}"
# Get all services for this project
RUNNING_CONTAINERS=$(docker ps --filter "label=com.docker.compose.project=${COMPOSE_PROJECT}" --format '{{.Names}}')
if [ -z "${RUNNING_CONTAINERS}" ]; then
if [ -f "${WORKSPACE}/test/tap/groups/${TAP_GROUP}/infras.lst" ]; then LST_PATH="${WORKSPACE}/test/tap/groups/${TAP_GROUP}/infras.lst"; else LST_PATH="${WORKSPACE}/test/tap/groups/${BASE_GROUP}/infras.lst"; fi
echo "ERROR: Required infrastructure '${INFRA_NAME}' is NOT running."
if [ -f "${LST_PATH}" ]; then
echo "According to '${LST_PATH}', this infrastructure is mandatory for the '${TAP_GROUP}' group."
fi
echo "Please run initialization for '${INFRA_NAME}' first (e.g. cd test/infra/${INFRA_NAME} && ./docker-compose-init.bash)."
exit 1
fi
echo "Please run initialization for '${INFRA_NAME}' first (e.g. cd test/infra/${INFRA_NAME} && ./docker-compose-init.bash)."
echo "Found running containers: ${RUNNING_CONTAINERS//$'\n'/ }"
else
echo "ERROR: Infrastructure directory ${INFRA_NAME} not found!"
exit 1
fi
echo "Found running containers: ${RUNNING_CONTAINERS//$'\n'/ }"
else
echo "ERROR: Infrastructure directory ${INFRA_NAME} not found!"
exit 1
fi
done
done

echo ">>> INFRASTRUCTURE VERIFIED. LAUNCHING TEST RUNNER..."
fi

echo ">>> INFRASTRUCTURE VERIFIED. LAUNCHING TEST RUNNER..."
# SKIP_PROXYSQL path: run unit tests directly on the host, no Docker needed
if [ "${SKIP_PROXYSQL}" = "1" ]; then
echo ">>> Running unit tests directly (no Docker container)..."

# Execute the Python tester directly on the host
export WORKSPACE
export TAP_GROUP
python3 "${WORKSPACE}/test/scripts/bin/proxysql-tester.py"
exit $?
fi

Choose a reason for hiding this comment

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

medium

The logic for handling SKIP_PROXYSQL=1 is currently split across two if statements. This can be simplified by using an 'early exit' pattern. This would make the script's control flow easier to follow.

You can place all the logic for the SKIP_PROXYSQL case at the beginning of this section and have it exit. The rest of the script would then represent the default execution path, without needing to be wrapped in an else block.

if [ "${SKIP_PROXYSQL}" = "1" ]; then
    echo ">>> SKIP_PROXYSQL=1: Skipping ProxySQL and backend verification for group '${TAP_GROUP}'."
    echo ">>> Running unit tests directly (no infrastructure needed)."
    echo ">>> Running unit tests directly (no Docker container)..."

    # Execute the Python tester directly on the host
    export WORKSPACE
    export TAP_GROUP
    python3 "${WORKSPACE}/test/scripts/bin/proxysql-tester.py"
    exit $?
fi

# VERIFICATION: Verify ProxySQL is running
PROXY_CONTAINER="proxysql.${INFRA_ID}"
echo ">>> Verifying ProxySQL container: ${PROXY_CONTAINER}"
if ! docker ps --format '{{.Names}}' | grep -q "^${PROXY_CONTAINER}$" ; then
    echo "ERROR: ProxySQL container ${PROXY_CONTAINER} is NOT running!"
    exit 1
fi

# VERIFICATION: Verify all required backend containers are running
for INFRA_NAME in ${INFRAS_TO_CHECK}; do
    echo ">>> Verifying Backend: ${INFRA_NAME}"
    # Extract container names from the infra's docker-compose.yml
    if [ -f "${WORKSPACE}/test/infra/${INFRA_NAME}/docker-compose.yml" ]; then
        # Project name used by init script
        COMPOSE_PROJECT="${INFRA_NAME}-${INFRA_ID}"
        # Get all services for this project
        RUNNING_CONTAINERS=$(docker ps --filter "label=com.docker.compose.project=${COMPOSE_PROJECT}" --format '{{.Names}}')
        if [ -z "${RUNNING_CONTAINERS}" ]; then
            if [ -f "${WORKSPACE}/test/tap/groups/${TAP_GROUP}/infras.lst" ]; then LST_PATH="${WORKSPACE}/test/tap/groups/${TAP_GROUP}/infras.lst"; else LST_PATH="${WORKSPACE}/test/tap/groups/${BASE_GROUP}/infras.lst"; fi
            echo "ERROR: Required infrastructure '${INFRA_NAME}' is NOT running."
            if [ -f "${LST_PATH}" ]; then
                echo "According to '${LST_PATH}', this infrastructure is mandatory for the '${TAP_GROUP}' group."
            fi
            echo "Please run initialization for '${INFRA_NAME}' first (e.g. cd test/infra/${INFRA_NAME} && ./docker-compose-init.bash)."
            exit 1
        fi
        echo "Found running containers: ${RUNNING_CONTAINERS//$'
'/ }"
    else
        echo "ERROR: Infrastructure directory ${INFRA_NAME} not found!"
        exit 1
    fi
done

echo ">>> INFRASTRUCTURE VERIFIED. LAUNCHING TEST RUNNER..."

Documents groups.json format (one entry per line, compact arrays),
group naming conventions, directory structure, and infrastructure-free
groups.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new “infrastructure-free” execution mode intended to let the TAP orchestration run the unit-test group without starting ProxySQL/backends, by introducing SKIP_PROXYSQL=1 semantics in the infra control scripts and defining a new unit-tests group.

Changes:

  • Add early env.sh sourcing + SKIP_PROXYSQL=1 short-circuit behavior to ensure-infras.bash and run-tests-isolated.bash.
  • Introduce test/tap/groups/unit-tests/env.sh and register unit test binaries in test/tap/groups/groups.json under unit-tests-g1.
  • Document SKIP_PROXYSQL and the unit-tests group in test/README.md and test/infra/README.md.

Reviewed changes

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

Show a summary per file
File Description
test/infra/control/ensure-infras.bash Sources group env early and exits immediately when SKIP_PROXYSQL=1.
test/infra/control/run-tests-isolated.bash Sources group env early; skips infra verification and attempts host-side test execution when SKIP_PROXYSQL=1.
test/tap/groups/unit-tests/env.sh New group env enabling SKIP_PROXYSQL=1.
test/tap/groups/groups.json Adds unit-tests-g1 membership for unit test binaries (plus existing unit strip-schema test).
test/infra/README.md Documents SKIP_PROXYSQL and adds a section describing infrastructure-free groups.
test/README.md Adds unit-tests-g1 and documents SKIP_PROXYSQL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +144 to +148
# Execute the Python tester directly on the host
export WORKSPACE
export TAP_GROUP
python3 "${WORKSPACE}/test/scripts/bin/proxysql-tester.py"
exit $?
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

In the SKIP_PROXYSQL=1 path, this script executes test/scripts/bin/proxysql-tester.py directly on the host, but that runner currently requires a ProxySQL admin connection and several environment variables that are normally set inside the Docker test-runner (e.g. TESTS_LOGS_PATH, TAP_ADMIN*). With SKIP_PROXYSQL=1 there is no ProxySQL to connect to, so proxysql-tester.py will fail immediately (it opens the admin connection unconditionally during initialization). Consider either (a) adding an explicit “unit-tests / no-proxysql” mode to proxysql-tester.py that skips admin-dependent setup/dumps and only runs test/tap/tests/unit/*-t, while also setting the minimal required env vars for logging, or (b) bypassing proxysql-tester.py here and directly execute the unit test binaries for unit-tests-g1 with TAP-style reporting.

Suggested change
# Execute the Python tester directly on the host
export WORKSPACE
export TAP_GROUP
python3 "${WORKSPACE}/test/scripts/bin/proxysql-tester.py"
exit $?
# Prepare logs path for unit tests when skipping ProxySQL
TESTS_LOGS_PATH_HOST="${INFRA_LOGS_PATH:-${WORKSPACE}/ci_infra_logs}/${INFRA_ID}/tests"
mkdir -p "${TESTS_LOGS_PATH_HOST}"
chmod 777 "${TESTS_LOGS_PATH_HOST}" || true
# Discover unit test binaries
UNIT_TEST_DIR="${WORKSPACE}/test/tap/tests/unit"
if [ ! -d "${UNIT_TEST_DIR}" ]; then
echo "ERROR: Unit test directory not found: ${UNIT_TEST_DIR}"
exit 1
fi
# Collect all unit test binaries matching *-t
shopt -s nullglob
UNIT_TEST_BINARIES=( "${UNIT_TEST_DIR}"/*-t )
shopt -u nullglob
if [ ${#UNIT_TEST_BINARIES[@]} -eq 0 ]; then
echo "ERROR: No unit test binaries found in ${UNIT_TEST_DIR} (pattern '*-t')."
exit 1
fi
# Run unit tests with simple TAP-style reporting
TOTAL_TESTS=${#UNIT_TEST_BINARIES[@]}
echo "1..${TOTAL_TESTS}"
EXIT_CODE=0
INDEX=0
for TEST_BIN in "${UNIT_TEST_BINARIES[@]}"; do
INDEX=$((INDEX + 1))
TEST_NAME="$(basename "${TEST_BIN}")"
if "${TEST_BIN}"; then
echo "ok ${INDEX} - ${TEST_NAME}"
else
echo "not ok ${INDEX} - ${TEST_NAME}"
EXIT_CODE=1
fi
done
exit ${EXIT_CODE}

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +35
# Source group env.sh to pick up SKIP_PROXYSQL and other group-level settings
if [ -f "${WORKSPACE}/test/tap/groups/${TAP_GROUP}/env.sh" ]; then
source "${WORKSPACE}/test/tap/groups/${TAP_GROUP}/env.sh"
elif [ -f "${WORKSPACE}/test/tap/groups/${BASE_GROUP}/env.sh" ]; then
source "${WORKSPACE}/test/tap/groups/${BASE_GROUP}/env.sh"
fi
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

source ".../${TAP_GROUP}/env.sh" executes code from a path derived directly from TAP_GROUP/BASE_GROUP without validating that the group name is a simple, safe identifier (no /, .., whitespace, etc.). Previously these variables were used only for file reads, but sourcing turns this into code execution if someone can influence TAP_GROUP (e.g., in CI env). Suggest validating TAP_GROUP/BASE_GROUP against a strict allowlist regex (and rejecting/escaping anything else) before constructing paths and sourcing.

Copilot uses AI. Check for mistakes.
Comment on lines +58 to +63
# Source group env.sh to pick up SKIP_PROXYSQL and other group-level settings
if [ -f "${WORKSPACE}/test/tap/groups/${TAP_GROUP}/env.sh" ]; then
source "${WORKSPACE}/test/tap/groups/${TAP_GROUP}/env.sh"
elif [ -f "${WORKSPACE}/test/tap/groups/${BASE_GROUP}/env.sh" ]; then
source "${WORKSPACE}/test/tap/groups/${BASE_GROUP}/env.sh"
fi
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

Same concern as in ensure-infras.bash: this script sources env.sh from a path derived from TAP_GROUP/BASE_GROUP without validating the group name. Since source executes the file, please add a strict allowlist validation (e.g., only [A-Za-z0-9._=-] and no path separators) before sourcing, to avoid accidental or malicious code execution when TAP_GROUP is user/CI-provided.

Copilot uses AI. Check for mistakes.
Comment on lines +180 to +185
Some test groups do not require ProxySQL or any backend infrastructure. These groups set `SKIP_PROXYSQL=1` in their `env.sh`, which causes:

- `ensure-infras.bash` to exit immediately (no Docker containers started)
- `run-tests-isolated.bash` to run tests directly on the host (no Docker test runner)

The `unit-tests` group is the primary example. Unit tests link against `libproxysql.a` with stub globals and run as standalone binaries.
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

This section states that with SKIP_PROXYSQL=1, run-tests-isolated.bash will run tests directly on the host with “no infrastructure needed”. With the current implementation, the SKIP path still invokes proxysql-tester.py, which requires ProxySQL admin connectivity and Docker-provisioned env vars, so this documentation will be incorrect unless the runner is updated accordingly (or the SKIP path is changed to execute unit test binaries directly).

Copilot uses AI. Check for mistakes.
# No ProxySQL or backend infrastructure required.
# Unit tests link against libproxysql.a with stubs and run standalone.

export SKIP_PROXYSQL=1
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

This group’s unit test binaries live under test/tap/tests/unit/, but env.sh only sets SKIP_PROXYSQL=1 and doesn’t override TAP_WORKDIR/TAP_WORKDIRS to include that unit-test directory. With the current test runner (proxysql-tester.py), discovery is driven by TAP_WORKDIRS, so unit-tests-g1 will end up running 0 tests (it will ignore the regular TAP tests due to groups.json membership filtering, and won’t find the unit binaries). Recommend exporting TAP_WORKDIRS (and TAP_WORKDIR) to point at ${WORKSPACE}/test/tap/tests/unit/ for this group (or adjusting the SKIP runner to execute unit binaries directly without relying on TAP_WORKDIRS).

Suggested change
export SKIP_PROXYSQL=1
export SKIP_PROXYSQL=1
# Point the TAP runner at the unit test binaries for this group.
export TAP_WORKDIR="${WORKSPACE}/test/tap/tests/unit"
export TAP_WORKDIRS="${TAP_WORKDIR}"

Copilot uses AI. Check for mistakes.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 140-148: The SKIP_PROXYSQL branch in run-tests-isolated.bash runs
proxysql-tester.py before the tester environment (e.g., TESTS_LOGS_PATH_HOST and
variables from env-isolated.bash) is created; update that branch to perform the
same bootstrap used later: source the existing env-isolated.bash (or call the
shared bootstrap helper if you extract one) and ensure TESTS_LOGS_PATH_HOST and
TAP_WORKDIR*/TAP_*PORT variables are exported before invoking python3
"${WORKSPACE}/test/scripts/bin/proxysql-tester.py" so the script (which reads
TESTS_LOGS_PATH, TAP_WORKDIR*, TAP_*PORT) always sees the expected environment.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eb37a4ca-6326-4fc5-9790-a23684c76443

📥 Commits

Reviewing files that changed from the base of the PR and between 1652944 and 5519e54.

📒 Files selected for processing (6)
  • test/README.md
  • test/infra/README.md
  • test/infra/control/ensure-infras.bash
  • test/infra/control/run-tests-isolated.bash
  • test/tap/groups/groups.json
  • test/tap/groups/unit-tests/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: Agent
  • GitHub Check: CI-builds / builds (ubuntu22,-tap)
  • GitHub Check: CI-builds / builds (debian12,-dbg)
  • GitHub Check: run / trigger
  • GitHub Check: claude-review
🧰 Additional context used
🧠 Learnings (7)
📓 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: 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).
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.082Z
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
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.082Z
Learning: Feature tiers are controlled by build flags: PROXYSQL31=1 for v3.1.x, PROXYSQLGENAI=1 for v4.0.x; PROXYSQLGENAI=1 implies PROXYSQL31=1
📚 Learning: 2026-03-22T14:38:16.082Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.082Z
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/groups/unit-tests/env.sh
  • test/README.md
  • test/infra/control/run-tests-isolated.bash
  • test/infra/README.md
📚 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/unit-tests/env.sh
  • test/README.md
  • test/infra/control/run-tests-isolated.bash
  • test/infra/README.md
📚 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/groups/unit-tests/env.sh
📚 Learning: 2026-03-22T14:38:16.082Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.082Z
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/groups/unit-tests/env.sh
📚 Learning: 2026-03-22T14:38:16.082Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.082Z
Learning: Feature tiers are controlled by build flags: PROXYSQL31=1 for v3.1.x, PROXYSQLGENAI=1 for v4.0.x; PROXYSQLGENAI=1 implies PROXYSQL31=1

Applied to files:

  • test/tap/groups/unit-tests/env.sh
  • test/README.md
📚 Learning: 2026-03-22T14:38:16.082Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-22T14:38:16.082Z
Learning: Applies to test/tap/tests/{test_*,*-t}.cpp : Test files in test/tap/tests/ must follow the naming pattern test_*.cpp or *-t.cpp

Applied to files:

  • test/README.md
  • test/infra/README.md
🪛 Shellcheck (0.11.0)
test/tap/groups/unit-tests/env.sh

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

(SC2148)

test/infra/control/ensure-infras.bash

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

(SC1090)


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

(SC1090)

test/infra/control/run-tests-isolated.bash

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

(SC1090)


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

(SC1090)

🔇 Additional comments (6)
test/README.md (1)

39-39: Top-level docs expose the new mode clearly.

Adding unit-tests-g1 to the table and documenting SKIP_PROXYSQL here makes the infrastructure-free flow easy to discover from the main test README.

Also applies to: 53-53

test/tap/groups/unit-tests/env.sh (1)

1-5: Nice minimal base-group env toggle.

Keeping this as a tiny unit-tests/env.sh file lines up with the BASE_GROUP fallback in the control scripts and avoids hard-coding special cases elsewhere.

test/infra/control/ensure-infras.bash (1)

30-42: Early skip path is in the right place.

Sourcing group env before infra resolution and exiting before any Docker or hook work keeps infrastructure-free groups from touching containers at all.

test/infra/README.md (1)

119-119: The infrastructure-free section reads clearly.

The env-var reference plus Section 6.1 make the unit-tests-g1 flow easy to follow and clearly explain why these groups do not need an infras.lst.

Also applies to: 178-209

test/infra/control/run-tests-isolated.bash (2)

58-63: Base-group env fallback looks good.

Loading ${TAP_GROUP}/env.sh first and then ${BASE_GROUP}/env.sh keeps unit-tests-g1 aligned with test/tap/groups/unit-tests/env.sh without adding a one-off path.


100-138: Good: infra-backed groups keep the existing guardrails.

Keeping the ProxySQL/backend verification under the non-skip branch limits the behavior change to SKIP_PROXYSQL=1 groups.

…l-tester.py

proxysql-tester.py requires a ProxySQL admin connection and Docker-specific
env vars (TESTS_LOGS_PATH, TAP_ADMINPORT, TAP_WORKDIR, etc.) that don't
exist when SKIP_PROXYSQL=1. Instead, discover test binaries from groups.json
and execute them directly on the host with a simple pass/fail summary.

Addresses review feedback from CodeRabbit, Copilot, and Gemini on PR #5520.
@sonarqubecloud
Copy link

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

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