diff --git a/.gitignore b/.gitignore index 2d0eef514..33787afec 100644 --- a/.gitignore +++ b/.gitignore @@ -201,3 +201,6 @@ database_discovery_report.md scripts/mcp/DiscoveryAgent/ClaudeCode_Headless/tmp/ test/tap/tests/test_cluster_sync_config/test_cluster_sync_nomonitor/cluster_sync_node_stderr.txt test/tap/tests/test_cluster_sync_config/test_cluster_sync_withmonitor/cluster_sync_node_stderr.txt + +# test-scripts runtime dependencies (created by run-tests-isolated.bash) +test-scripts/deps/ diff --git a/test-scripts/deps/mysqlbinlog b/test-scripts/deps/mysqlbinlog deleted file mode 120000 index 16b02387b..000000000 --- a/test-scripts/deps/mysqlbinlog +++ /dev/null @@ -1 +0,0 @@ -/home/rene/proxysql/test/deps/mysql-connector-c-8.4.0/mysql-8.4.0/runtime_output_directory/mysqlbinlog \ No newline at end of file diff --git a/test/infra/control/destroy-multi-group.bash b/test/infra/control/destroy-multi-group.bash index 2e49e3916..18512aed8 100755 --- a/test/infra/control/destroy-multi-group.bash +++ b/test/infra/control/destroy-multi-group.bash @@ -31,12 +31,12 @@ fi # Determine which groups to destroy if [ -n "${TAP_GROUPS}" ]; then # Use specified groups - read -ra GROUPS <<< "${TAP_GROUPS}" + read -ra TARGET_GROUPS <<< "${TAP_GROUPS}" MODE="specific" else # Auto-discover groups by finding matching directories MODE="auto" - GROUPS=() + TARGET_GROUPS=() # Look for log directories matching *-${RUN_ID} LOGS_PATH="${WORKSPACE}/ci_infra_logs" @@ -47,14 +47,14 @@ else if [[ "${dir_name}" == *"-${RUN_ID}" ]]; then # Extract group name from INFRA_ID group_name="${dir_name%-${RUN_ID}}" - GROUPS+=("${group_name}") + TARGET_GROUPS+=("${group_name}") fi fi done fi fi -TOTAL_GROUPS=${#GROUPS[@]} +TOTAL_GROUPS=${#TARGET_GROUPS[@]} if [ "${TOTAL_GROUPS}" -eq 0 ]; then echo "No groups found to destroy for RUN_ID: ${RUN_ID}" @@ -67,14 +67,14 @@ echo "Destroy Multiple TAP Groups" echo "==========================================" echo "RUN_ID: ${RUN_ID}" echo "MODE: ${MODE}" -echo "GROUPS: ${GROUPS[*]}" +echo "TARGET_GROUPS: ${TARGET_GROUPS[*]}" echo "==========================================" # Confirmation prompt (unless FORCE=1) if [ "${FORCE}" -eq 0 ]; then echo "" echo "This will destroy the following ${TOTAL_GROUPS} infrastructure(s):" - for group in "${GROUPS[@]}"; do + for group in "${TARGET_GROUPS[@]}"; do echo " - ${group}-${RUN_ID}" done echo "" @@ -92,7 +92,7 @@ SUCCESS_COUNT=0 FAIL_COUNT=0 # Destroy each group's infrastructure -for group in "${GROUPS[@]}"; do +for group in "${TARGET_GROUPS[@]}"; do infra_id="${group}-${RUN_ID}" echo "" echo ">>> Destroying: ${group} (INFRA_ID: ${infra_id})" diff --git a/test/infra/infra-mysql57-binlog/bin/docker-orchestrator-post.bash b/test/infra/infra-mysql57-binlog/bin/docker-orchestrator-post.bash index d4c105a7f..f77e515d5 100755 --- a/test/infra/infra-mysql57-binlog/bin/docker-orchestrator-post.bash +++ b/test/infra/infra-mysql57-binlog/bin/docker-orchestrator-post.bash @@ -1,25 +1,81 @@ #!/bin/bash +set -e +set -o pipefail +[ -f .env ] && . .env +# Ensure INFRA is set correctly +if [ -z "${INFRA}" ] || [ "${INFRA}" == "." ]; then + export INFRA=$(basename $(cd $(dirname $0)/.. && pwd)) +fi -#export ORCHESTRATOR_API="http://localhost:${ORC1_PORT}/api http://localhost:${ORC2_PORT}/api http://localhost:${ORC3_PORT}/api" -export ORCHESTRATOR_API="http://orc1.${INFRA}:3000/api http://orc2.${INFRA}:3000/api http://orc3.${INFRA}:3000/api" +PROXY_CONTAINER="proxysql.${INFRA_ID}" -echo -n "Configuring 'orchestrator' ..." -sleep 5 -orchestrator-client -c discover -i mysql1 >/dev/null -orchestrator-client -c discover -i mysql2 >/dev/null -orchestrator-client -c discover -i mysql3 >/dev/null -echo " done." +echo ">>> Configuring Orchestrator via ${PROXY_CONTAINER} (Infra: ${INFRA})" -#echo -n "Orchestrator discovering mysql1 ... got " -#orchestrator-client -c discover -i mysql1 -#echo -n "Orchestrator discovering mysql2 ... got " -#orchestrator-client -c discover -i mysql2 -#echo -n "Orchestrator discovering mysql3 ... got " -#orchestrator-client -c discover -i mysql3 +orc_exec() { + docker exec -e ORCHESTRATOR_API="http://orc1.${INFRA}:3000/api" "${PROXY_CONTAINER}" orchestrator-client "$@" +} -echo "Cluster topology:" -orchestrator-client -c topology -a $(orchestrator-client -c clusters) +echo -n "Waiting for Orchestrator API..." +MAX_WAIT=60 +COUNT=0 +while ! orc_exec -c clusters >/dev/null 2>&1; do + echo -n "." + sleep 2 + COUNT=$((COUNT+2)) + if [ $COUNT -gt $MAX_WAIT ]; then echo " FAILED"; exit 1; fi +done +echo " OK." -#echo -n "Cluster name: $(orchestrator-client -c clusters)" -#echo " done." +# Use -c discover and -i host:port +echo ">>> Triggering discovery of MySQL nodes..." +for i in 1 2 3; do + HOST="mysql${i}.${INFRA}" + orc_exec -c discover -i "${HOST}:3306" >/dev/null 2>&1 || true +done + +echo ">>> Waiting for topology to settle..." +MAX_WAIT=30 +COUNT=0 +CLUSTER_NAME="" +while [ -z "$CLUSTER_NAME" ]; do + # Try to find which cluster our primary belongs to + CLUSTER_NAME=$(orc_exec -c which-cluster -i "mysql1.${INFRA}:3306" 2>/dev/null | head -n 1) + + # Fallback: Just take any cluster name if which-cluster fails but clusters is not empty + if [ -z "$CLUSTER_NAME" ]; then + CLUSTER_NAME=$(orc_exec -c clusters 2>/dev/null | head -n 1) + fi + + if [ -n "$CLUSTER_NAME" ]; then break; fi + echo -n "." + sleep 2 + COUNT=$((COUNT+2)) + 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 ">>> Verifying Replication Topology for Cluster: ${CLUSTER_NAME}" + echo "--------------------------------------------------------------------------------" + # We use -c topology -i to get the text diagram + TOPOLOGY=$(orc_exec -c topology -i "${CLUSTER_NAME}") + echo "$TOPOLOGY" + echo "--------------------------------------------------------------------------------" + + # Check for replication issues (look for anything not [ok]) + # Note: Orchestrator topology output uses [ok] for healthy nodes + ISSUES=$(echo "$TOPOLOGY" | grep -E "\[.*\]" | grep -v "\[ok\]" || true) + if [ -n "$ISSUES" ]; then + echo "WARNING: Potential replication issues detected in topology!" + echo "$ISSUES" + else + echo "SUCCESS: Replication topology is healthy." + fi +else + echo "ERROR: Orchestrator failed to discover any cluster." + exit 1 +fi \ No newline at end of file diff --git a/test/infra/infra-mysql57-binlog/conf/proxysql/infra-config.sql b/test/infra/infra-mysql57-binlog/conf/proxysql/infra-config.sql index 620110611..887e21149 100644 --- a/test/infra/infra-mysql57-binlog/conf/proxysql/infra-config.sql +++ b/test/infra/infra-mysql57-binlog/conf/proxysql/infra-config.sql @@ -21,6 +21,7 @@ REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) va REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest8','sbtest8',1,${WHG},'${INFRA}'); REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('${INFRA}','${INFRA}',1,${WHG},'${INFRA}'); REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('root','${ROOT_PASSWORD}',1,${WHG},'${INFRA}'); +REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('testuser','testuser',1,${WHG},'${INFRA}'); LOAD MYSQL USERS TO RUNTIME; SAVE MYSQL USERS TO DISK; diff --git a/test/tap/tests/test_cluster_sync_config/test_cluster_sync_nomonitor/test_cluster_sync.cnf b/test/tap/tests/test_cluster_sync_config/test_cluster_sync_nomonitor/test_cluster_sync.cnf deleted file mode 100644 index 4b9a4d6ba..000000000 --- a/test/tap/tests/test_cluster_sync_config/test_cluster_sync_nomonitor/test_cluster_sync.cnf +++ /dev/null @@ -1,55 +0,0 @@ -datadir = "/data/rene/proxysql2/proxysql/test/tap/tests/test_cluster_sync_config/test_cluster_sync_nomonitor"; -admin_variables : -{ - admin_credentials = "admin:admin;radmin:radmin"; - mysql_ifaces = "0.0.0.0:96061"; - cluster_username = "radmin"; - cluster_password = "radmin"; - cluster_check_interval_ms = 200; - cluster_check_status_frequency = 100; - cluster_mysql_query_rules_save_to_disk = true; - cluster_mysql_servers_save_to_disk = true; - cluster_mysql_users_save_to_disk = true; - cluster_proxysql_servers_save_to_disk = true; - cluster_mysql_query_rules_diffs_before_sync = 3; - cluster_mysql_servers_diffs_before_sync = 3; - cluster_mysql_users_diffs_before_sync = 3; - cluster_admin_variables_diffs_before_sync = 3; - cluster_proxysql_servers_diffs_before_sync = 3; - cluster_mysql_servers_sync_algorithm = 3; - cluster_sync_interfaces = false; -}; -mysql_variables : -{ - threads = 8; - max_connections = 2048; - default_query_delay = 0; - default_query_timeout = 36000000; - have_compress = true; - poll_timeout = 2000; - interfaces = "0.0.0.0:6033"; - default_schema = "information_schema"; - stacksize = 1048576; - server_version = "5.5.30"; - connect_timeout_server = 3000; - monitor_username = "monitor"; - monitor_password = "monitor"; - monitor_history = 600000; - monitor_connect_interval = 10000; - monitor_connect_timeout = 1000; - monitor_ping_interval = 10000; - monitor_read_only_interval = 1500; - monitor_read_only_timeout = 500; - ping_interval_server_msec = 120000; - ping_timeout_server = 500; - commands_stats = true; - sessions_sort = true; - connect_retries_on_failure = 10; -}; -proxysql_servers = ( - { - hostname = "proxysql"; - port = 6032; - weight = 0; - comment = "proxysql130"; - } ); diff --git a/test/tap/tests/test_cluster_sync_config/test_cluster_sync_withmonitor/test_cluster_sync.cnf b/test/tap/tests/test_cluster_sync_config/test_cluster_sync_withmonitor/test_cluster_sync.cnf deleted file mode 100644 index d03b4decd..000000000 --- a/test/tap/tests/test_cluster_sync_config/test_cluster_sync_withmonitor/test_cluster_sync.cnf +++ /dev/null @@ -1,55 +0,0 @@ -datadir = "/data/rene/proxysql2/proxysql/test/tap/tests/test_cluster_sync_config/test_cluster_sync_withmonitor"; -admin_variables : -{ - admin_credentials = "admin:admin;radmin:radmin"; - mysql_ifaces = "0.0.0.0:96062"; - cluster_username = "radmin"; - cluster_password = "radmin"; - cluster_check_interval_ms = 200; - cluster_check_status_frequency = 100; - cluster_mysql_query_rules_save_to_disk = true; - cluster_mysql_servers_save_to_disk = true; - cluster_mysql_users_save_to_disk = true; - cluster_proxysql_servers_save_to_disk = true; - cluster_mysql_query_rules_diffs_before_sync = 3; - cluster_mysql_servers_diffs_before_sync = 3; - cluster_mysql_users_diffs_before_sync = 3; - cluster_admin_variables_diffs_before_sync = 3; - cluster_proxysql_servers_diffs_before_sync = 3; - cluster_mysql_servers_sync_algorithm = 3; - cluster_sync_interfaces = false; -}; -mysql_variables : -{ - threads = 8; - max_connections = 2048; - default_query_delay = 0; - default_query_timeout = 36000000; - have_compress = true; - poll_timeout = 2000; - interfaces = "0.0.0.0:6033"; - default_schema = "information_schema"; - stacksize = 1048576; - server_version = "5.5.30"; - connect_timeout_server = 3000; - monitor_username = "monitor"; - monitor_password = "monitor"; - monitor_history = 600000; - monitor_connect_interval = 10000; - monitor_connect_timeout = 1000; - monitor_ping_interval = 10000; - monitor_read_only_interval = 1500; - monitor_read_only_timeout = 500; - ping_interval_server_msec = 120000; - ping_timeout_server = 500; - commands_stats = true; - sessions_sort = true; - connect_retries_on_failure = 10; -}; -proxysql_servers = ( - { - hostname = "proxysql"; - port = 6032; - weight = 0; - comment = "proxysql130"; - } );