diff --git a/test/tap/tests/set_testing-240-t.cpp b/test/tap/tests/set_testing-240-t.cpp index e08bf5753d..f69b59cfda 100644 --- a/test/tap/tests/set_testing-240-t.cpp +++ b/test/tap/tests/set_testing-240-t.cpp @@ -456,6 +456,11 @@ void * my_conn_thread(void *arg) { } __sync_fetch_and_add(&query_phase_completed,1); + // close all connections + for (i=0; i rows_res { extract_mysql_rows(result) }; + mysql_free_result(result); + + for (const auto& act_row : rows_res) { + diag("Found hostgroup: %s '%s'", act_row[0].c_str(), act_row[1].c_str()); + } //queries = 3000; //queries = testCases.size(); + queries = queries / rows_res.size(); // keep test duration constant unsigned int p = queries * num_threads; - p *= 2; // number of algorithms + p *= 2; // number of algorithms + p *= rows_res.size(); // number of host groups plan(p); - if (strcmp(host,"localhost")==0) { - local = 1; - } - if (uniquequeries == 0) { - if (queries) uniquequeries=queries; - } - if (uniquequeries) { - uniquequeries=(int)sqrt(uniquequeries); - } + for (const auto& act_row : rows_res) { + diag("Using hostgroup: %s '%s'", act_row[0].c_str(), act_row[1].c_str()); - for (int algo = 1; algo <= 2; algo++ ) { - connect_phase_completed = 0; - query_phase_completed = 0; - std::string qu = "SET mysql-set_parser_algorithm=" + std::to_string(algo); - diag("Setting: %s", qu.c_str()); - MYSQL_QUERY(proxysql_admin, qu.c_str()); - MYSQL_QUERY(proxysql_admin, "LOAD MYSQL VARIABLES TO RUNTIME"); - pthread_t *thi=(pthread_t *)malloc(sizeof(pthread_t)*num_threads); - if (thi==NULL) + diag("Creating new hostgroup 101: DELETE FROM mysql_servers WHERE hostgroup_id = 101"); + MYSQL_QUERY(proxysql_admin, "DELETE FROM mysql_servers WHERE hostgroup_id = 101"); + + const std::string insert = "INSERT INTO mysql_servers (hostgroup_id, hostname, port, max_connections, max_replication_lag, comment) SELECT DISTINCT 101, hostname, port, 100, 0, comment FROM mysql_servers WHERE hostgroup_id = '" + act_row[0] + "'"; + diag("Creating new hostgroup 101: %s" , insert.c_str()); + MYSQL_QUERY(proxysql_admin, insert.c_str()); + MYSQL_QUERY(proxysql_admin, "LOAD MYSQL SERVERS TO RUNTIME"); + + const std::string update = "UPDATE mysql_query_rules SET destination_hostgroup=101 WHERE destination_hostgroup=" + act_row[0]; + diag("Changing read traffic to hostgroup 101: %s", update.c_str()); + MYSQL_QUERY(proxysql_admin, update.c_str()); + MYSQL_QUERY(proxysql_admin, "LOAD MYSQL QUERY RULES TO RUNTIME"); + + if (detect_version(cl, is_mariadb) != 0) { + diag("Cannot detect MySQL version"); return exit_status(); + } - for (unsigned int i=0; i::iterator it = vars_counters.begin(); it!=vars_counters.end(); it++) { - diag("Unknown variable %s:\t Count: %d , unknown: %d", it->first.c_str(), it->second.count, it->second.unknown); + if (uniquequeries) { + uniquequeries=(int)sqrt(uniquequeries); + } + + for (int algo = 1; algo <= 2; algo++ ) { + connect_phase_completed = 0; + query_phase_completed = 0; + std::string qu = "SET mysql-set_parser_algorithm=" + std::to_string(algo); + diag("Setting %s", qu.c_str()); + MYSQL_QUERY(proxysql_admin, qu.c_str()); + MYSQL_QUERY(proxysql_admin, "LOAD MYSQL VARIABLES TO RUNTIME"); + pthread_t *thi=(pthread_t *)malloc(sizeof(pthread_t)*num_threads); + if (thi==NULL) + return exit_status(); + + for (unsigned int i=0; i::iterator it = vars_counters.begin(); it!=vars_counters.end(); it++) { + diag("Unknown variable %s:\t Count: %d , unknown: %d", it->first.c_str(), it->second.count, it->second.unknown); + } + sleep(10); + } return exit_status(); }