Skip to content

Commit

Permalink
Make 'test_cluster_sync_mysql_servers' exit gracefully in clusterless…
Browse files Browse the repository at this point in the history
… env

Current GitHub actions testing environment lacks of a ProxySQL cluster.
This change allows the test to gracefully exit when the env conditions
for it are not met.
  • Loading branch information
JavierJF committed Jan 11, 2024
1 parent 83cf46d commit 9b00eb3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/tap/tests/test_cluster_sync_mysql_servers-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
#include "command_line.h"
#include "utils.h"

using std::string;

#define MYSQL_QUERY__(mysql, query) \
do { \
if (mysql_query(mysql, query)) { \
Expand Down Expand Up @@ -863,6 +865,28 @@ int main(int, char**) {
std::vector<mysql_res_row> core_nodes { extract_mysql_rows(my_res) };
mysql_free_result(my_res);

// 2.1 If core nodes are not reachable, assume no cluster is running; make test gracefully exit
if (core_nodes.size()) {
const string host { core_nodes[0][0] };
const int port = std::stol(core_nodes[0][1]);
MYSQL* c_node_admin = mysql_init(NULL);

if (!mysql_real_connect(c_node_admin, host.c_str(), cl.admin_username, cl.admin_password, NULL, port, NULL, 0)) {
int myerrno = mysql_errno(c_node_admin);

if (myerrno == 2002) {
diag("Unable to connect to cluster Core nodes; required environment not met, gracefully exiting...");
plan(0);
return exit_status();
} else {
fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxy_admin));
return EXIT_FAILURE;
}
}

mysql_close(c_node_admin);
}

// 3. Wait for all Core nodes to sync (confirm primary out of core nodes)
std::string check_no_primary_query {};
string_format(
Expand Down

0 comments on commit 9b00eb3

Please sign in to comment.