diff --git a/test/tap/groups/mysql84/env.sh b/test/tap/groups/mysql84/env.sh index 66301acc3..d35f807c9 100755 --- a/test/tap/groups/mysql84/env.sh +++ b/test/tap/groups/mysql84/env.sh @@ -1,8 +1,14 @@ -# Legacy Test Group Environment -# Defines the primary targets for tests that expect a generic MySQL or PGSQL backend. +# 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" + [ -f "${_INFRA_ENV}" ] && . "${_INFRA_ENV}" +fi + # Path to RESTAPI test scripts inside ProxySQL container # The setup-infras.bash hook copies scripts to the ProxySQL data directory export REGULAR_INFRA_DATADIR="/var/lib/proxysql" diff --git a/test/tap/tests/reg_test_4935-caching_sha2-t.env b/test/tap/tests/reg_test_4935-caching_sha2-t.env index 4036e7d02..99f515318 100644 --- a/test/tap/tests/reg_test_4935-caching_sha2-t.env +++ b/test/tap/tests/reg_test_4935-caching_sha2-t.env @@ -1,2 +1 @@ -TAP_MYSQL8_BACKEND_HG=30 TAP_NUM_CLIENT_THREADS=4 diff --git a/test/tap/tests/test_auth_methods-t.env b/test/tap/tests/test_auth_methods-t.env index 73c1bdfe4..7cd8c3bd8 100644 --- a/test/tap/tests/test_auth_methods-t.env +++ b/test/tap/tests/test_auth_methods-t.env @@ -1,4 +1,3 @@ TAP_MYSQLUSERNAME=root -TAP_MYSQL8_BACKEND_HG=30 TAP_NUM_CLIENT_THREADS=4 diff --git a/test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp b/test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp index 5f0762d6e..3d7862320 100644 --- a/test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp +++ b/test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp @@ -29,6 +29,19 @@ using std::pair; const uint32_t SYNC_TIMEOUT = 10; +// Writer and reader hostgroups — read from TAP_MYSQL8_BACKEND_HG env var. +// Defaults to 0/1 for backward compatibility with legacy infra. +static int WHG = 0; +static int RHG = 1; + +static void init_hostgroups() { + const char* hg_env = getenv("TAP_MYSQL8_BACKEND_HG"); + if (hg_env) { + WHG = atoi(hg_env); + RHG = WHG + 1; + } +} + using mysql_server_tuple = std::tuple; using replication_hostgroups_tuple = std::tuple; @@ -198,11 +211,11 @@ int test_scenario_1(MYSQL* proxy_admin, const CommandLine& cl) { MYSQL* dummy_mysqldb = NULL; const std::vector insert_mysql_servers_values { - std::make_tuple(0, cl.mysql_host, cl.mysql_port, 12, "ONLINE", 1, 1, 1000, 300, 1, 200, "") // this server has read_only value 0 (writer) + std::make_tuple(WHG, cl.mysql_host, cl.mysql_port, 12, "ONLINE", 1, 1, 1000, 300, 1, 200, "") // this server has read_only value 0 (writer) }; const std::vector insert_replication_hostgroups_values { - std::make_tuple(0, 1, "read_only") + std::make_tuple(WHG, RHG, "read_only") }; // cleaning old records @@ -351,11 +364,11 @@ int test_scenario_2(MYSQL* proxy_admin, const CommandLine& cl) { MYSQL* dummy_mysqldb = NULL; const std::vector insert_mysql_servers_values { - std::make_tuple(1, cl.mysql_host, cl.mysql_port, 12, "ONLINE", 1, 1, 1000, 300, 1, 200, "") // this server has read_only value 0 (writer) + std::make_tuple(RHG, cl.mysql_host, cl.mysql_port, 12, "ONLINE", 1, 1, 1000, 300, 1, 200, "") // this server has read_only value 0 (writer) }; const std::vector insert_replication_hostgroups_values { - std::make_tuple(0, 1, "read_only") + std::make_tuple(WHG, RHG, "read_only") }; // cleaning old records @@ -587,6 +600,9 @@ int main(int, char**) { return EXIT_FAILURE; } + init_hostgroups(); + diag("Using hostgroups: WHG=%d, RHG=%d", WHG, RHG); + plan(9+9); MYSQL* proxy_admin = mysql_init(NULL); diff --git a/test/tap/tests/test_sqlite3_pass_exts-t.env b/test/tap/tests/test_sqlite3_pass_exts-t.env index ed9226ab2..42defa00f 100644 --- a/test/tap/tests/test_sqlite3_pass_exts-t.env +++ b/test/tap/tests/test_sqlite3_pass_exts-t.env @@ -1,2 +1 @@ TAP_MYSQLUSERNAME=root -TAP_MYSQL8_BACKEND_HG=30