Skip to content

Commit

Permalink
more TAP test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mirostauder committed Oct 2, 2023
1 parent 0bbeef6 commit cfa5b66
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/tap/tests/test_binlog_fast_forward-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,18 @@ int setup_replication(int server_id, bool frontend_ssl, bool backend_ssl, std::v

std::vector<std::string> 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();
Expand Down
19 changes: 19 additions & 0 deletions test/tap/tests/test_binlog_reader_uses_previous_hostgroup-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>& out_stats) {
MYSQL_RES* my_stats_res = NULL;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit cfa5b66

Please sign in to comment.