Fix hardcoded hostgroups in TAP tests for mysql84

Tests were using hardcoded hostgroup 0/1 or 30 instead of the mysql84 infra hostgroups (WHG=2900, RHG=2901), causing timeouts and failures.
  - test_read_only_actions_offline_hard_servers: read WHG/RHG from
    TAP_MYSQL8_BACKEND_HG env var instead of hardcoding 0/1
  - Remove hardcoded TAP_MYSQL8_BACKEND_HG=30 from per-test .env files
    (test_sqlite3_pass_exts, test_auth_methods, reg_test_4935) so the
    value comes from the infra .env
  - Source infra .env from mysql84/env.sh using WORKSPACE to export
    TAP test variables into the proxysql-tester.py subprocess (sh-safe,
    no BASH_SOURCE dependency)
pull/5469/head
Rahim Kanji 3 months ago
parent 8a811ab6a1
commit 4f9ab49e7a

@ -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"

@ -1,2 +1 @@
TAP_MYSQL8_BACKEND_HG=30
TAP_NUM_CLIENT_THREADS=4

@ -1,4 +1,3 @@
TAP_MYSQLUSERNAME=root
TAP_MYSQL8_BACKEND_HG=30
TAP_NUM_CLIENT_THREADS=4

@ -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<int,std::string,int,int,std::string,int,int,int,int,int,int,std::string>;
using replication_hostgroups_tuple = std::tuple<int,int,std::string>;
@ -198,11 +211,11 @@ int test_scenario_1(MYSQL* proxy_admin, const CommandLine& cl) {
MYSQL* dummy_mysqldb = NULL;
const std::vector<mysql_server_tuple> 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<replication_hostgroups_tuple> 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<mysql_server_tuple> 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<replication_hostgroups_tuple> 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);

@ -1,2 +1 @@
TAP_MYSQLUSERNAME=root
TAP_MYSQL8_BACKEND_HG=30

Loading…
Cancel
Save