From cfa5b6654c62351dd456d86b190e88821acef8f5 Mon Sep 17 00:00:00 2001 From: Miro Stauder Date: Sun, 1 Oct 2023 16:17:22 +0000 Subject: [PATCH] more TAP test fixes --- test/tap/tests/test_binlog_fast_forward-t.cpp | 9 +++++---- ...inlog_reader_uses_previous_hostgroup-t.cpp | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/test/tap/tests/test_binlog_fast_forward-t.cpp b/test/tap/tests/test_binlog_fast_forward-t.cpp index 12d0d15dc9..24ad73a8d0 100644 --- a/test/tap/tests/test_binlog_fast_forward-t.cpp +++ b/test/tap/tests/test_binlog_fast_forward-t.cpp @@ -105,17 +105,18 @@ int setup_replication(int server_id, bool frontend_ssl, bool backend_ssl, std::v std::vector admin_queries = {}; admin_queries.push_back(std::string("SET mysql-have_ssl='") + std::string(frontend_ssl ? "true" : "false") + "'"); - admin_queries.push_back(std::string("UPDATE mysql_users SET use_ssl=") + std::string(frontend_ssl ? "1" : "0") + " WHERE username = 'root'"); admin_queries.push_back("LOAD MYSQL VARIABLES TO RUNTIME"); + admin_queries.push_back(std::string("UPDATE mysql_users SET use_ssl=") + std::string(frontend_ssl ? "1" : "0") + " WHERE username = 'root'"); + admin_queries.push_back("LOAD MYSQL USERS TO RUNTIME"); admin_queries.push_back(std::string("UPDATE mysql_servers SET use_ssl=") + std::string(backend_ssl ? "1" : "0")); admin_queries.push_back("LOAD MYSQL SERVERS TO RUNTIME"); + sleep(3); + MYSQL * mysql = mysql_init(NULL); diag("Connecting: cl.root_username='%s' frontend_ssl=%d", cl.root_username, frontend_ssl); - if (frontend_ssl || backend_ssl) { + if (frontend_ssl) mysql_ssl_set(mysql, NULL, NULL, NULL, NULL, NULL); - diag(">>> 'mysql_ssl_set(mysql, NULL, NULL, NULL, NULL, NULL);' <<<"); - } if (!mysql_real_connect(mysql, cl.host, cl.root_username, cl.root_password, NULL, cl.root_port, NULL, 0)) { fprintf(stderr, "Failed to connect to database: Error: %s\n", mysql_error(mysql)); return exit_status(); diff --git a/test/tap/tests/test_binlog_reader_uses_previous_hostgroup-t.cpp b/test/tap/tests/test_binlog_reader_uses_previous_hostgroup-t.cpp index 3e911d2c10..083c02d19d 100644 --- a/test/tap/tests/test_binlog_reader_uses_previous_hostgroup-t.cpp +++ b/test/tap/tests/test_binlog_reader_uses_previous_hostgroup-t.cpp @@ -26,6 +26,24 @@ const char* QUERY_CONN_CLOSED { "SELECT ConnOk - ConnFree FROM stats.stats_mysql_connection_pool WHERE hostgroup=%d" }; + +void * work(void *arg) { + sleep(30); + diag("Timeout! - exiting..."); + exit(EXIT_FAILURE); + return NULL; +} + +int run_funct_timeout(void *(*start_routine)(void *), int timeout) { + // we run the test on a separate thread because we have a built-in timeout + pthread_t thread_id; + if (pthread_create(&thread_id, NULL, start_routine, NULL)) { + fprintf(stderr, "Error calling pthread_create()"); + return EXIT_FAILURE; + } + return 0; +} + int conn_pool_hg_stat_conn_closed(MYSQL* proxy_admin, int hg_id, vector& out_stats) { MYSQL_RES* my_stats_res = NULL; @@ -77,6 +95,7 @@ int main(int argc, char** argv) { } plan(2 + 1); + run_funct_timeout(work, 30); const int destination_hostgroup = 2; string query;