Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 10
CI: MySQL version matrix (5.7-9.6) and named channels tests#85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
8436ee5f2d2a0ffa4267975fe695File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -13,7 +13,7 @@ pass() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fail() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo " ❌ FAIL: $1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ -n "$2" ] && echo " $2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ -n "${2:-}" ] && echo " $2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ((FAIL_COUNT++)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| @@ -33,7 +33,7 @@ summary() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| test_endpoint() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| local NAME="$1" URL="$2" EXPECT="$3" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| local CODE | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| CODE=$(curl -s -o /dev/null -w "%{http_code}" "$URL" 2>&1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| CODE=$(curl -s --max-time 10 -o /dev/null -w "%{http_code}" "$URL" 2>&1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$CODE" = "$EXPECT" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass "$NAME (HTTP $CODE)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| @@ -45,7 +45,7 @@ test_endpoint() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| test_body_contains() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| local NAME="$1" URL="$2" EXPECT="$3" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| local BODY | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| BODY=$(curl -s "$URL" 2>&1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| BODY=$(curl -s --max-time 10 "$URL" 2>&1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if echo "$BODY" | grep -q "$EXPECT"; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| pass "$NAME" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| @@ -57,7 +57,7 @@ test_body_contains() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| wait_for_orchestrator() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Waiting for orchestrator to be ready..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| for i in $(seq 1 30); do | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if curl -s -o /dev/null "$ORC_URL/api/clusters" 2>/dev/null; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if curl -s --max-time 5 -o /dev/null "$ORC_URL/api/clusters" 2>/dev/null; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Orchestrator ready after ${i}s" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| @@ -73,35 +73,92 @@ CLUSTER_NAME="" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| discover_topology() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| local MASTER_HOST="$1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Seeding discovery with $MASTER_HOST..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -s "$ORC_URL/api/discover/$MASTER_HOST/3306" > /dev/null | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -s --max-time 10 "$ORC_URL/api/discover/$MASTER_HOST/3306" > /dev/null | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Also seed replicas directly | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -s "$ORC_URL/api/discover/mysql2/3306" > /dev/null 2>&1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -s "$ORC_URL/api/discover/mysql3/3306" > /dev/null 2>&1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -s --max-time 10 "$ORC_URL/api/discover/mysql2/3306" > /dev/null 2>&1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -s --max-time 10 "$ORC_URL/api/discover/mysql3/3306" > /dev/null 2>&1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Waiting for topology discovery..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| for i in $(seq 1 60); do | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Get the cluster name dynamically | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| CLUSTER_NAME=$(curl -s "$ORC_URL/api/clusters" 2>/dev/null | python3 -c "import json,sys; c=json.load(sys.stdin); print(c[0] if c else '')" 2>/dev/null || echo "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| CLUSTER_NAME=$(curl -s --max-time 5 "$ORC_URL/api/clusters" 2>/dev/null | python3 -c "import json,sys; c=json.load(sys.stdin); print(c[0] if c else '')" 2>/dev/null || echo "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -n "$CLUSTER_NAME" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| local COUNT | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| COUNT=$(curl -s "$ORC_URL/api/cluster/$CLUSTER_NAME" 2>/dev/null | python3 -c "import json,sys; print(len(json.load(sys.stdin)))" 2>/dev/null || echo "0") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| COUNT=$(curl -s --max-time 5 "$ORC_URL/api/cluster/$CLUSTER_NAME" 2>/dev/null | python3 -c "import json,sys; print(len(json.load(sys.stdin)))" 2>/dev/null || echo "0") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$COUNT" -ge 3 ] 2>/dev/null; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Full topology discovered (${COUNT} instances, cluster=$CLUSTER_NAME) after ${i}s" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Re-seed replicas periodically | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$((i % 10))" = "0" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -s "$ORC_URL/api/discover/mysql2/3306" > /dev/null 2>&1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -s "$ORC_URL/api/discover/mysql3/3306" > /dev/null 2>&1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -s --max-time 10 "$ORC_URL/api/discover/mysql2/3306" > /dev/null 2>&1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -s --max-time 10 "$ORC_URL/api/discover/mysql3/3306" > /dev/null 2>&1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| sleep 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "WARNING: Cluster=$CLUSTER_NAME, instances=${COUNT:-0} after 60s" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Detect MySQL major version (e.g., "5.7", "8.0", "8.4", "9.0") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Caches result in MYSQL_MAJOR_VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| MYSQL_MAJOR_VERSION="" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql_version() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -n "$MYSQL_MAJOR_VERSION" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "$MYSQL_MAJOR_VERSION" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| local FULL | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| FULL=$(docker compose -f tests/functional/docker-compose.yml exec -T mysql1 \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql -uroot -ptestpass -Nse "SELECT VERSION()" 2>/dev/null | tr -d '[:space:]') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| MYSQL_MAJOR_VERSION=$(echo "$FULL" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "$MYSQL_MAJOR_VERSION" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Check if MySQL version is 5.7 (returns 0 for 5.7, 1 otherwise) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql_is_57() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ "$(mysql_version)" = "5.7" ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Return the correct CHANGE REPLICATION SOURCE / CHANGE MASTER command | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Arguments: HOST PORT USER PASSWORD | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql_change_source_sql() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| local HOST="$1" PORT="$2" USER="$3" PASS="$4" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if mysql_is_57; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "CHANGE MASTER TO MASTER_HOST='${HOST}', MASTER_PORT=${PORT}, MASTER_USER='${USER}', MASTER_PASSWORD='${PASS}', MASTER_AUTO_POSITION=1;" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "CHANGE REPLICATION SOURCE TO SOURCE_HOST='${HOST}', SOURCE_PORT=${PORT}, SOURCE_USER='${USER}', SOURCE_PASSWORD='${PASS}', SOURCE_AUTO_POSITION=1, GET_SOURCE_PUBLIC_KEY=1;" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Return the correct CHANGE REPLICATION SOURCE / CHANGE MASTER command with FOR CHANNEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Arguments: HOST PORT USER PASSWORD CHANNEL | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql_change_source_channel_sql() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| local HOST="$1" PORT="$2" USER="$3" PASS="$4" CHANNEL="$5" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if mysql_is_57; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "CHANGE MASTER TO MASTER_HOST='${HOST}', MASTER_PORT=${PORT}, MASTER_USER='${USER}', MASTER_PASSWORD='${PASS}', MASTER_AUTO_POSITION=1 FOR CHANNEL '${CHANNEL}';" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "CHANGE REPLICATION SOURCE TO SOURCE_HOST='${HOST}', SOURCE_PORT=${PORT}, SOURCE_USER='${USER}', SOURCE_PASSWORD='${PASS}', SOURCE_AUTO_POSITION=1, GET_SOURCE_PUBLIC_KEY=1 FOR CHANNEL '${CHANNEL}';" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Return the correct START REPLICA / START SLAVE command | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql_start_replica_sql() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if mysql_is_57; then echo "START SLAVE;"; else echo "START REPLICA;"; fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Return the correct STOP REPLICA / STOP SLAVE command | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql_stop_replica_sql() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if mysql_is_57; then echo "STOP SLAVE;"; else echo "STOP REPLICA;"; fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Return the correct RESET REPLICA ALL / RESET SLAVE ALL command | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql_reset_replica_all_sql() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if mysql_is_57; then echo "RESET SLAVE ALL;"; else echo "RESET REPLICA ALL;"; fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Get ProxySQL servers for a hostgroup | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| proxysql_servers() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| local HG="$1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| @@ -120,6 +177,11 @@ mysql_read_only() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Get MySQL replication source | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql_source_host() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| local CONTAINER="$1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| docker compose -f tests/functional/docker-compose.yml exec -T "$CONTAINER" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql -uroot -ptestpass -Nse "SHOW REPLICA STATUS\G" 2>/dev/null | grep "Source_Host" | awk '{print $2}' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if mysql_is_57; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| docker compose -f tests/functional/docker-compose.yml exec -T "$CONTAINER" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql -uroot -ptestpass -Nse "SHOW SLAVE STATUS\G" 2>/dev/null | grep "Master_Host" | awk '{print $2}' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| docker compose -f tests/functional/docker-compose.yml exec -T "$CONTAINER" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql -uroot -ptestpass -Nse "SHOW REPLICA STATUS\G" 2>/dev/null | grep "Source_Host" | awk '{print $2}' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
178
to
187
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mysql_source_host()still assumes single-source replication.On a multi-channel replica,
SHOW SLAVE/REPLICA STATUS\Greturns one block per channel. This helper will therefore emit everyMaster_Host/Source_Hostit finds, so callers get a concatenated value as soon asmysql3has both its default channel andextra. Please make this helper channel-aware, or fail fast when multiple channels are present.🐛 Proposed fix
mysql_source_host() { - local CONTAINER="$1"+ local CONTAINER="$1" CHANNEL="${2:-}" if mysql_is_57; then + local STATUS_SQL="SHOW SLAVE STATUS\\G"+ [ -n "$CHANNEL" ] && STATUS_SQL="SHOW SLAVE STATUS FOR CHANNEL '${CHANNEL}'\\G" docker compose -f tests/functional/docker-compose.yml exec -T "$CONTAINER" \ - mysql -uroot -ptestpass -Nse "SHOW SLAVE STATUS\G" 2>/dev/null | grep "Master_Host" | awk '{print $2}'+ mysql -uroot -ptestpass -Nse "$STATUS_SQL" 2>/dev/null |+ awk -F': ' '$1 == "Master_Host" { print $2; exit }' else + local STATUS_SQL="SHOW REPLICA STATUS\\G"+ [ -n "$CHANNEL" ] && STATUS_SQL="SHOW REPLICA STATUS FOR CHANNEL '${CHANNEL}'\\G" docker compose -f tests/functional/docker-compose.yml exec -T "$CONTAINER" \ - mysql -uroot -ptestpass -Nse "SHOW REPLICA STATUS\G" 2>/dev/null | grep "Source_Host" | awk '{print $2}'+ mysql -uroot -ptestpass -Nse "$STATUS_SQL" 2>/dev/null |+ awk -F': ' '$1 == "Source_Host" { print $2; exit }' fi }🤖 Prompt for AI Agents