Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions test/infra/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,18 @@ docker network inspect ${INFRA_ID}_backend

### Issue: "GTID: failed to connect to ProxySQL binlog reader on port 6020"

**Cause:** Reader containers not running or gtid_port misconfigured.
**Cause:** Binlog reader on the mysqlN containers is not listening on 6020, or `gtid_port` is misconfigured.

**Solution:**
1. Verify reader containers are running:
```bash
docker ps | grep reader
```
2. Check mysql_servers has gtid_port set:
1. Check mysql_servers has gtid_port set:
```bash
docker exec proxysql.${INFRA_ID} mysql -uradmin -pradmin -h127.0.0.1 -P6032 \
-e "SELECT hostname, gtid_port FROM mysql_servers;"
```
2. Verify the mysqlN container is listening on 6020:
```bash
docker exec ${INFRA}-${INFRA_ID}-mysql1-1 bash -lc 'timeout 3 bash -lc "</dev/tcp/127.0.0.1/6020" && echo OPEN || echo CLOSED'
```
Comment thread
wazir-ahmed marked this conversation as resolved.

### Issue: Test runs but no queries executed (act_queries: 0)

Expand Down Expand Up @@ -194,7 +194,7 @@ zcat ci_infra_logs/${INFRA_ID}/tests/proxysql-tester.py/tests/test_name-t.log.gz
docker exec -it proxysql.${INFRA_ID} bash
mysql -h mysql1.infra-mysql57-binlog -P 3306 -u root -p

# Test reader connection
# Test binlog reader connection
telnet mysql1.infra-mysql57-binlog 6020
```

Expand Down
23 changes: 23 additions & 0 deletions test/infra/control/docker-fs-helper.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# docker_fs_exec <command> <path>
# Run a command against a host path through a temporary container.
# Use this for host-mounted files/directories whose ownership was set by container users and
# cannot be reliably modified from the host user context.
# Example: docker_fs_exec "rm -f proxysql/proxysql.db" "${INFRA_LOGS_PATH}/${INFRA_ID}"
docker_fs_exec() {
local fs_command="$1"
local target_path="$2"

if [ -z "${fs_command}" ] || [ -z "${target_path}" ]; then
echo "docker_fs_exec requires a command and a path" >&2
return 1
fi

# Work around host-mounted paths owned by container users different from the host user.
# Alpine/busybox would also work here, but proxysql-ci-base:latest is already pulled in this workflow.
docker run --rm \
-v "${target_path}:/target" \
proxysql-ci-base:latest \
/bin/sh -ec "cd /target && ${fs_command}"
}
2 changes: 1 addition & 1 deletion test/infra/control/ensure-infras.bash
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ if [ -f "${SETUP_HOOK}" ]; then
"${SETUP_HOOK}"
fi

# ensure-infras.bash completed successfully
# ensure-infras.bash completed successfully
3 changes: 0 additions & 3 deletions test/infra/control/run-tests-isolated.bash
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ chmod 777 "${TESTS_LOGS_PATH_HOST}"

# Find binaries
MYSQL_BINLOG_BIN=$(find "${WORKSPACE}" -path "${WORKSPACE}/ci_infra_logs" -prune -o -path "${WORKSPACE}/.git" -prune -o -name "mysqlbinlog" -type f -executable -print | head -n 1)
BINLOG_READER_BIN=$(find "${WORKSPACE}" -path "${WORKSPACE}/ci_infra_logs" -prune -o -path "${WORKSPACE}/.git" -prune -o -name "test_binlog_reader-t" -type f -executable -print | head -n 1)

# Execution: run the container
docker run \
Expand All @@ -295,7 +294,6 @@ docker run \
-e COVERAGE_REPORT_DIR="${COVERAGE_REPORT_DIR}" \
-e SCRIPT_DIR="${SCRIPT_DIR}" \
-e MYSQL_BINLOG_BIN="${MYSQL_BINLOG_BIN}" \
-e BINLOG_READER_BIN="${BINLOG_READER_BIN}" \
-e TAP_USE_NOISE="${TAP_USE_NOISE:-0}" \
-e TAP_PGSQL_SYNC_REPLICA_PORT="${TAP_PGSQL_SYNC_REPLICA_PORT:-}" \
-e MULTI_GROUP="${MULTI_GROUP:-0}" \
Expand Down Expand Up @@ -394,7 +392,6 @@ docker run \

mkdir -p \"${WORKSPACE}/test-scripts/deps\"
[ -n \"${MYSQL_BINLOG_BIN}\" ] && ln -sf \"${MYSQL_BINLOG_BIN}\" \"${WORKSPACE}/test-scripts/deps/mysqlbinlog\"
[ -n \"${BINLOG_READER_BIN}\" ] && ln -sf \"${BINLOG_READER_BIN}\" \"${WORKSPACE}/test-scripts/deps/test_binlog_reader-t\"

# Source group environment first (sets TEST_PY_* flags etc.)
if [ -n \"${TAP_GROUP}\" ]; then
Expand Down
12 changes: 5 additions & 7 deletions test/infra/control/start-proxysql-isolated.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
set -e
set -o pipefail

# SUDO helper: empty if root
SUDO=""
if [ "$(id -u)" != "0" ]; then SUDO="sudo"; fi

# Derive Workspace relative to script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
export WORKSPACE="${REPO_ROOT}"

source "${SCRIPT_DIR}/docker-fs-helper.bash"

if [ -z "${INFRA_ID}" ]; then echo "Error: INFRA_ID is not set."; exit 1; fi

export ROOT_PASSWORD=$(echo -n "${INFRA_ID}" | sha256sum | head -c 10)
Expand All @@ -35,9 +33,9 @@ echo ">>> Setting up isolated network: ${NETWORK_NAME}"
docker network inspect ${NETWORK_NAME} >/dev/null 2>&1 || docker network create ${NETWORK_NAME}

echo ">>> Preparing ProxySQL data directory: ${PROXY_DATA_DIR}"
$SUDO mkdir -p "${PROXY_DATA_DIR}"
$SUDO chmod -R 777 "${INFRA_LOGS_PATH}/${INFRA_ID}"
$SUDO rm -f "${PROXY_DATA_DIR}/proxysql.db" "${PROXY_DATA_DIR}"/*.pem
mkdir -p "${PROXY_DATA_DIR}"
docker_fs_exec "chmod -R 777 ." "${INFRA_LOGS_PATH}/${INFRA_ID}"
docker_fs_exec "rm -f proxysql/proxysql.db proxysql/*.pem" "${INFRA_LOGS_PATH}/${INFRA_ID}"

docker rm -f "${PROXY_CONTAINER}" >/dev/null 2>&1 || true

Expand Down
5 changes: 4 additions & 1 deletion test/infra/control/stop-proxysql-isolated.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
export WORKSPACE="${REPO_ROOT}"

source "${SCRIPT_DIR}/docker-fs-helper.bash"

# Default INFRA_ID if not provided
export INFRA_ID="${INFRA_ID:-dev-$USER}"

Expand Down Expand Up @@ -34,5 +36,6 @@ done
echo ">>> Log permissions cleanup"
INFRA_LOGS_PATH="${WORKSPACE}/ci_infra_logs"
if [ -d "${INFRA_LOGS_PATH}/${INFRA_ID}" ]; then
sudo chmod -R 777 "${INFRA_LOGS_PATH}/${INFRA_ID}" 2>/dev/null || true
chmod -R 777 "${INFRA_LOGS_PATH}/${INFRA_ID}" 2>/dev/null || \
docker_fs_exec "chmod -R 777 ." "${INFRA_LOGS_PATH}/${INFRA_ID}" >/dev/null 2>&1 || true
fi
4 changes: 2 additions & 2 deletions test/infra/infra-mysql57-binlog/bin/docker-mysql-post.bash
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ SQL
else
echo "Configuring slave (mysql${i})..."
docker exec -i "${CONTAINER}" mysql -h127.0.0.1 -uroot ${PASS_OPT} <<SQL || { echo "ERROR: Failed slave configuration on ${CONTAINER}"; exit 1; }
SET SQL_LOG_BIN=0;
STOP SLAVE;
SET GLOBAL READ_ONLY=1;
RESET MASTER;

Expand All @@ -88,8 +90,6 @@ RESET MASTER;
-- Configure replication
CHANGE MASTER TO MASTER_HOST='mysql1.${INFRA}', MASTER_USER='root', MASTER_PASSWORD='${ROOT_PASSWORD}', MASTER_AUTO_POSITION=1;
START SLAVE;

FLUSH PRIVILEGES;
SQL
fi
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ LOAD ADMIN VARIABLES TO RUNTIME;
SAVE ADMIN VARIABLES TO DISK;

DELETE FROM mysql_servers WHERE comment LIKE '%${INFRA}';
-- MySQL servers with gtid_port pointing to proxysql_mysqlbinlog readers
-- Note: reader1/2/3 hostnames resolve to the reader containers via Docker network aliases
-- In *-binlog infra, binlog readers are embedded into all mysqlN containers and serve gtid_port 6020.
INSERT INTO mysql_servers (hostgroup_id,hostname,gtid_port,port,max_replication_lag,comment) VALUES (${WHG},'mysql1.${INFRA}',6020,3306,10,'mysql1.${INFRA}');
INSERT INTO mysql_servers (hostgroup_id,hostname,gtid_port,port,max_replication_lag,comment) VALUES (${RHG},'mysql2.${INFRA}',6020,3306,10,'mysql2.${INFRA}');
INSERT INTO mysql_servers (hostgroup_id,hostname,gtid_port,port,max_replication_lag,comment) VALUES (${RHG},'mysql3.${INFRA}',6020,3306,10,'mysql3.${INFRA}');
Expand Down
65 changes: 0 additions & 65 deletions test/infra/infra-mysql57-binlog/docker-compose-destroy.bash

This file was deleted.

38 changes: 32 additions & 6 deletions test/infra/infra-mysql57-binlog/docker-compose-init.bash
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
export WORKSPACE="${REPO_ROOT}"

source "${REPO_ROOT}/test/infra/control/docker-fs-helper.bash"

set -e
set -o pipefail

# SUDO helper: empty if root
SUDO=""
if [ "$(id -u)" != "0" ]; then SUDO="sudo"; fi

# relaunch self with timeout
[[ $(ps -o command= $(ps -o ppid= $$)) =~ timeout ]] || exec timeout -v -s 9 ${TIMEOUT:-600} "${BASH_SOURCE}" "$@"

Expand Down Expand Up @@ -80,8 +78,8 @@ for RAW_PATH in ${MOUNTED_PATHS}; do
fi

echo "Preparing directory: ${ACTUAL_PATH}"
$SUDO mkdir -p "${ACTUAL_PATH}"
$SUDO chmod -R 777 "${ACTUAL_PATH}"
mkdir -p "${ACTUAL_PATH}"
docker_fs_exec "chmod -R 777 ." "${ACTUAL_PATH}"
done

# 3. Inject dynamic variables into Orchestrator configs
Expand Down Expand Up @@ -128,6 +126,34 @@ fi
# 7. Run post-scripts if they exist
sleep 2 # wait a bit for engines to start
[ -f ./bin/docker-mysql-post.bash ] && ./bin/docker-mysql-post.bash

if [[ "${INFRA}" == *-binlog ]]; then
echo ">>> Waiting for binlog readers on port 6020..."
for i in 1 2 3; do
MYSQL_CONTAINER="${COMPOSE_PROJECT}-mysql${i}-1"
READER_CONTAINER="${COMPOSE_PROJECT}-reader${i}-1"
echo -n "Waiting for mysql${i} binlog reader ..."
MAX_WAIT=60
COUNT=0
while ! docker exec "${MYSQL_CONTAINER}" bash -lc 'exec 3<>/dev/tcp/127.0.0.1/6020; exec 3>&-; exec 3<&-' >/dev/null 2>&1; do
echo -n "."
sleep 2
COUNT=$((COUNT+2))
if [ ${COUNT} -ge ${MAX_WAIT} ]; then
echo " FAILED"
echo ">>> ${MYSQL_CONTAINER} logs:"
docker logs "${MYSQL_CONTAINER}" | tail -n 50 || true
if docker inspect "${READER_CONTAINER}" >/dev/null 2>&1; then
echo ">>> ${READER_CONTAINER} logs:"
docker logs "${READER_CONTAINER}" | tail -n 50 || true
fi
exit 1
fi
done
echo " OK."
done
fi

[ -f ./bin/docker-orchestrator-post.bash ] && ./bin/docker-orchestrator-post.bash
[ -f ./bin/docker-proxy-post.bash ] && ./bin/docker-proxy-post.bash "$1"

Expand Down
Loading
Loading