Fix read_only test assuming default_hostgroup=0

The test configures mysql_servers with writer_hostgroup=0 and
reader_hostgroup=1, but the CI infrastructure sets users'
default_hostgroup to 1300. When the test opens a proxy connection and
runs BEGIN, ProxySQL routes to hostgroup 1300 which has no servers,
causing a 10s timeout. Fix by setting default_hostgroup=0 for the
test user at the start of each scenario.
v3.0-ci0405
Rene Cannao 3 weeks ago
parent 1261d18a95
commit 26c5a25724

@ -210,6 +210,14 @@ int test_scenario_1(MYSQL* proxy_admin, const CommandLine& cl) {
MYSQL_QUERY__(proxy_admin, "DELETE FROM mysql_replication_hostgroups");
MYSQL_QUERY__(proxy_admin, "LOAD MYSQL SERVERS TO RUNTIME");
// Set default_hostgroup=0 to match writer_hostgroup used in this test
{
std::string update_user;
string_format("UPDATE mysql_users SET default_hostgroup=0 WHERE username='%s'", update_user, cl.root_username);
MYSQL_QUERY__(proxy_admin, update_user.c_str());
MYSQL_QUERY__(proxy_admin, "LOAD MYSQL USERS TO RUNTIME");
}
MYSQL_QUERY__(proxy_admin, "SET mysql-monitor_read_only_interval=200"); // setting read_only variables
MYSQL_QUERY__(proxy_admin, "SET mysql-monitor_read_only_timeout=100");
MYSQL_QUERY__(proxy_admin, "SET mysql-monitor_enabled='true'"); // enabling monitor
@ -225,14 +233,14 @@ int test_scenario_1(MYSQL* proxy_admin, const CommandLine& cl) {
ok(read_only_val == 0, "MySQL Server '%s:%d' should function as a writer", cl.mysql_host, cl.mysql_port);
// Inserting new records into 'mysql_servers' and 'mysql_replication_hostgroups'.
// Inserting new records into 'mysql_servers' and 'mysql_replication_hostgroups'.
result = insert_mysql_servers_records(proxy_admin, insert_mysql_servers_values, insert_replication_hostgroups_values);
if (result != EXIT_SUCCESS) {
fprintf(stderr, "File %s, line %d, Error: `%s`\n", __FILE__, __LINE__, "Failed to insert records in mysql_servers table.");
goto cleanup;
}
std::string variable_val;
// get read_only interval variable value
@ -363,6 +371,14 @@ int test_scenario_2(MYSQL* proxy_admin, const CommandLine& cl) {
MYSQL_QUERY__(proxy_admin, "DELETE FROM mysql_replication_hostgroups");
MYSQL_QUERY__(proxy_admin, "LOAD MYSQL SERVERS TO RUNTIME");
// Set default_hostgroup=0 to match writer_hostgroup used in this test
{
std::string update_user;
string_format("UPDATE mysql_users SET default_hostgroup=0 WHERE username='%s'", update_user, cl.root_username);
MYSQL_QUERY__(proxy_admin, update_user.c_str());
MYSQL_QUERY__(proxy_admin, "LOAD MYSQL USERS TO RUNTIME");
}
MYSQL_QUERY__(proxy_admin, "SET mysql-monitor_read_only_interval=200"); // setting read_only variables
MYSQL_QUERY__(proxy_admin, "SET mysql-monitor_read_only_timeout=100");
MYSQL_QUERY__(proxy_admin, "SET mysql-monitor_writer_is_also_reader='false'");

Loading…
Cancel
Save