From e1fc0b87340b7926c40c2d4b674123441cbd667a Mon Sep 17 00:00:00 2001 From: Timofey Turenko Date: Mon, 16 Dec 2019 15:41:52 +0200 Subject: [PATCH 1/2] Squashed commit of the following: commit 48a0b902b67da46f1eed4afa687bdcb56b59d02f Author: Timofey Turenko Date: Mon Dec 16 15:35:07 2019 +0200 Increase timouts in the mxs173_trottle_filter test commit 81d8083a89421a8004b8024d480ae0f35d715b86 Author: Timofey Turenko Date: Mon Dec 16 14:19:39 2019 +0200 Increase timeouts in max1071_maxrow test commit e1039c6132f0e9274b8801165f3f905ede7c9421 Author: Timofey Turenko Date: Mon Dec 16 00:06:53 2019 +0200 Remove hardcoded 'home/vagrant/' from all maxscale.cnf in system tests commit 28c8029e060afdcf5159bf802b13dcd5e484d9f1 Author: Timofey Turenko Date: Sun Dec 15 21:31:34 2019 +0200 Use private IP for Galera congiguration in maxscale-system-tests commit 66dc36cbf43a5fb92465df31e1295e82865be1fc Author: Timofey Turenko Date: Sun Dec 15 09:06:28 2019 +0200 Fix typos in fwf_*.cpp commit 44c7a4384ddf39596c0254c955aeb6c008a00a35 Author: Timofey Turenko Date: Sun Dec 15 09:05:26 2019 +0200 Fix typos in fwf_*.cpp commit 2649017611908a8b0d27090f49722947ac31c4f4 Author: Timofey Turenko Date: Sun Dec 15 09:03:41 2019 +0200 Fix typos in fwf_*.cpp commit 5cc87658523e8496eaab17700be8a821af5b0cde Author: Timofey Turenko Date: Sat Dec 14 23:54:53 2019 +0200 Fix typo in fwf_copy_rules.cpp commit fb1accc36cb9d79691469f63cb4535f3bc38dedd Author: Timofey Turenko Date: Sat Dec 14 23:52:51 2019 +0200 More hardcoded 'vagrant' removals commit 77e49d474b4abe767629ff87b01f08137773d761 Author: Timofey Turenko Date: Sat Dec 14 23:35:09 2019 +0200 Fix hardcoded 'vagrant' user in fwf* tests Several firewall filter tests has hardcoded 'vagrant' as a user name for access user on the VM. Changed to node->access_user. commit ed5ab1487f37822db6a7478f76c0f3652776c389 Author: Timofey Turenko Date: Sat Dec 14 22:50:35 2019 +0200 Fix IP vs IP_private Many tests use IP instead of IP_private which makes them failed in the AWS or GCloud environment. The same applies to get_conn_num() etc functions. commit 0558aac23d303a675dc12d05b1766e698753b444 Author: Timofey Turenko Date: Thu Aug 15 12:02:01 2019 +0300 fix IP -> IP_private for some mysqlmon* testst commit 5d9c70970d970eb995c8774d0088bd1c54ab76fe Author: Timofey Turenko Date: Sat Dec 14 20:20:51 2019 +0200 Replace IP to IP_private in the maxscale-system-tests commit b06cf3329af59ff100748691991213fe639f29e6 Author: Timofey Turenko Date: Tue Nov 19 11:52:33 2019 +0200 Remove spaces from value which were read from *_network_config MDBCI can put spaces around values in the *_network_config file which can cause ssh connection failures in the tests. To fix it removing all spaces from all values which were read from *_network_config commit b3904f019847ef1db9d4ec9714ad9ef869fa0b01 Author: Timofey Turenko Date: Thu Dec 12 23:36:31 2019 +0200 Increate default timeout for all system tests --- maxscale-system-test/bug529.cpp | 28 +++++++++---------- ...axscale.cnf.template.masking_auto_firewall | 2 +- .../cnf/maxscale.cnf.template.mxs1719 | 2 +- ...cale.cnf.template.mxs2057_systemd_watchdog | 2 +- maxscale-system-test/config_operations.cpp | 2 +- maxscale-system-test/fw_copy_rules.cpp | 10 +++++++ maxscale-system-test/fwf.cpp | 8 ------ maxscale-system-test/fwf_com_ping.cpp | 7 ++--- maxscale-system-test/fwf_duplicate_rules.cpp | 7 ++--- maxscale-system-test/fwf_prepared_stmt.cpp | 16 +++++++---- maxscale-system-test/keepalived_func.cpp | 1 + maxscale-system-test/mariadb_func.cpp | 2 +- maxscale-system-test/mariadb_nodes.cpp | 10 +++---- .../masking_auto_firewall.cpp | 2 +- maxscale-system-test/mxs1071_maxrows.cpp | 4 +-- maxscale-system-test/mxs1110_16mb.cpp | 7 ----- maxscale-system-test/mxs1509.cpp | 2 +- maxscale-system-test/mxs1719.cpp | 3 +- .../mxs173_throttle_filter.cpp | 12 ++++---- .../mxs2057_systemd_watchdog.cpp | 2 +- maxscale-system-test/mxs922_bad_server.cpp | 4 +-- maxscale-system-test/mxs922_server.cpp | 2 +- .../mysqlmon_detect_standalone_master.cpp | 2 +- maxscale-system-test/mysqlmon_multimaster.cpp | 2 +- maxscale-system-test/mysqlmon_rejoin_bad.cpp | 2 +- maxscale-system-test/mysqlmon_rejoin_bad2.cpp | 2 +- .../mysqlmon_rejoin_manual.cpp | 4 +-- .../mysqlmon_rejoin_manual2.cpp | 2 +- maxscale-system-test/nodes.cpp | 5 ++-- maxscale-system-test/testconnections.cpp | 22 +++++++-------- maxscale-system-test/utilities.cmake | 2 +- 31 files changed, 88 insertions(+), 90 deletions(-) diff --git a/maxscale-system-test/bug529.cpp b/maxscale-system-test/bug529.cpp index 0728015bb..254f5c50c 100644 --- a/maxscale-system-test/bug529.cpp +++ b/maxscale-system-test/bug529.cpp @@ -183,10 +183,10 @@ int main(int argc, char* argv[]) Test->set_timeout(60); num_conn = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], + Test->maxscales->IP_private[0], Test->maxscales->hostname[0], (char*) "test"); - Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); + Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP_private[i], num_conn); if ((i == 0) && (num_conn > 2 * conn_N)) { Test->add_result(1, "too many connections to master\n"); @@ -205,10 +205,10 @@ int main(int argc, char* argv[]) Test->set_timeout(60); num_conn = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], + Test->maxscales->IP_private[0], Test->maxscales->hostname[0], (char*) "test"); - printf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); + printf("Connections to node %d (%s): %d\n", i, Test->repl->IP_private[i], num_conn); if ((i == 0) && (num_conn > 2 * conn_N)) { Test->add_result(1, "too many connections to master\n"); @@ -223,10 +223,10 @@ int main(int argc, char* argv[]) { num_conn = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], + Test->maxscales->IP_private[0], Test->maxscales->hostname[0], (char*) "test"); - printf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); + printf("Connections to node %d (%s): %d\n", i, Test->repl->IP_private[i], num_conn); if ((i == 0) && (num_conn > 2 * conn_N)) { Test->add_result(1, "too many connections to master\n"); @@ -242,10 +242,10 @@ int main(int argc, char* argv[]) Test->set_timeout(60); num_conn = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], + Test->maxscales->IP_private[0], Test->maxscales->hostname[0], (char*) "test"); - printf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); + printf("Connections to node %d (%s): %d\n", i, Test->repl->IP_private[i], num_conn); if ((i == 0) && (num_conn != 0)) { Test->add_result(1, "there are still connections to master\n"); @@ -263,10 +263,10 @@ int main(int argc, char* argv[]) Test->set_timeout(60); num_conn = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], + Test->maxscales->IP_private[0], Test->maxscales->hostname[0], (char*) "test"); - Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); + Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP_private[i], num_conn); if ((i == 0) && (num_conn != 0)) { Test->add_result(1, "there are still connections to master\n"); @@ -288,10 +288,10 @@ int main(int argc, char* argv[]) Test->set_timeout(60); num_conn = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], + Test->maxscales->IP_private[0], Test->maxscales->hostname[0], (char*) "test"); - Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); + Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP_private[i], num_conn); if ((i == 0) && (num_conn != 0)) { Test->add_result(1, "there are still connections to master\n"); @@ -311,10 +311,10 @@ int main(int argc, char* argv[]) Test->set_timeout(60); num_conn = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], + Test->maxscales->IP_private[0], Test->maxscales->hostname[0], (char*) "test"); - Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); + Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP_private[i], num_conn); if ((i == 0) && (num_conn != 0)) { Test->add_result(1, "there are still connections to master\n"); diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.masking_auto_firewall b/maxscale-system-test/cnf/maxscale.cnf.template.masking_auto_firewall index 7943dc83c..8e3812035 100644 --- a/maxscale-system-test/cnf/maxscale.cnf.template.masking_auto_firewall +++ b/maxscale-system-test/cnf/maxscale.cnf.template.masking_auto_firewall @@ -20,7 +20,7 @@ monitor_interval=1000 [Masking] type=filter module=masking -rules=/home/vagrant/masking_auto_firewall.json +rules=/###access_homedir###/masking_auto_firewall.json warn_type_mismatch=always large_payload=ignore treat_string_arg_as_field=false diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.mxs1719 b/maxscale-system-test/cnf/maxscale.cnf.template.mxs1719 index b1c88cf33..bc26db29e 100644 --- a/maxscale-system-test/cnf/maxscale.cnf.template.mxs1719 +++ b/maxscale-system-test/cnf/maxscale.cnf.template.mxs1719 @@ -20,7 +20,7 @@ monitor_interval=1000 [Masking] type=filter module=masking -rules=/home/vagrant/mxs1719.json +rules=/###access_homedir###/mxs1719.json warn_type_mismatch=always large_payload=ignore require_fully_parsed=false diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.mxs2057_systemd_watchdog b/maxscale-system-test/cnf/maxscale.cnf.template.mxs2057_systemd_watchdog index 2ef4a6f33..18e1f3fb9 100644 --- a/maxscale-system-test/cnf/maxscale.cnf.template.mxs2057_systemd_watchdog +++ b/maxscale-system-test/cnf/maxscale.cnf.template.mxs2057_systemd_watchdog @@ -27,7 +27,7 @@ port = 4006 [lua] type = filter module = luafilter -session_script=/home/vagrant/infinite_loop.lua +session_script=/###access_homedir###/infinite_loop.lua [MaxAdmin-Service] type = service diff --git a/maxscale-system-test/config_operations.cpp b/maxscale-system-test/config_operations.cpp index f15b160a5..52c71732d 100644 --- a/maxscale-system-test/config_operations.cpp +++ b/maxscale-system-test/config_operations.cpp @@ -83,7 +83,7 @@ void Config::create_server(int num) true, "maxadmin create server server%d %s %d", num, - test_->repl->IP[num], + test_->repl->IP_private[num], test_->repl->port[num]); created_servers_.insert(num); test_->stop_timeout(); diff --git a/maxscale-system-test/fw_copy_rules.cpp b/maxscale-system-test/fw_copy_rules.cpp index 3216ba2bb..ccc237e93 100644 --- a/maxscale-system-test/fw_copy_rules.cpp +++ b/maxscale-system-test/fw_copy_rules.cpp @@ -6,6 +6,16 @@ void copy_rules(TestConnections* Test, const char* rules_name, const char* rules std::stringstream src; std::stringstream dest; + Test->maxscales->ssh_node_f(0, + true, + "cd %s;" + "rm -rf rules;" + "mkdir rules;" + "chown %s:%s rules", + Test->maxscales->access_homedir[0], + Test->maxscales->access_user[0], + Test->maxscales->access_user[0]); + src << rules_dir << "/" << rules_name; dest << Test->maxscales->access_homedir[0] << "/rules/rules.txt"; diff --git a/maxscale-system-test/fwf.cpp b/maxscale-system-test/fwf.cpp index c20618d4b..5f5267840 100644 --- a/maxscale-system-test/fwf.cpp +++ b/maxscale-system-test/fwf.cpp @@ -35,14 +35,6 @@ int main(int argc, char* argv[]) char rules_dir[4096]; FILE* file; - Test->maxscales->ssh_node_f(0, - true, - "cd %s;" - "rm -rf rules;" - "mkdir rules;" - "chown vagrant:vagrant rules", - Test->maxscales->access_homedir[0]); - sprintf(rules_dir, "%s/fw/", test_dir); int N = 19; int i; diff --git a/maxscale-system-test/fwf_com_ping.cpp b/maxscale-system-test/fwf_com_ping.cpp index 9f9158b8a..b5b3857c0 100644 --- a/maxscale-system-test/fwf_com_ping.cpp +++ b/maxscale-system-test/fwf_com_ping.cpp @@ -5,6 +5,7 @@ */ #include "testconnections.h" +#include "fw_copy_rules.h" const char* rules = "rule test1 deny regex '.*'\n" "users %@% match any rules test1\n"; @@ -19,11 +20,7 @@ int main(int argc, char** argv) TestConnections::skip_maxscale_start(true); TestConnections test(argc, argv); - test.maxscales->ssh_node(0, - "mkdir -p /home/vagrant/rules/; chown -R vagrant:vagrant /home/vagrant/rules/", - true); - test.maxscales->copy_to_node_legacy((char*)"rules.txt", (char*)"~/rules/rules.txt", 0); - test.maxscales->ssh_node(0, "chmod a+r /home/vagrant/rules/rules.txt;", true); + copy_rules(&test, (char*) "rules.txt", (char*) "."); test.maxscales->restart_maxscale(0); test.maxscales->connect_maxscale(0); diff --git a/maxscale-system-test/fwf_duplicate_rules.cpp b/maxscale-system-test/fwf_duplicate_rules.cpp index f6cc45c83..57a7dfa67 100644 --- a/maxscale-system-test/fwf_duplicate_rules.cpp +++ b/maxscale-system-test/fwf_duplicate_rules.cpp @@ -5,6 +5,7 @@ */ #include "testconnections.h" +#include "fw_copy_rules.h" const char* rules = "rule test1 deny no_where_clause\n" "rule test1 deny columns a b c\n" @@ -20,11 +21,7 @@ int main(int argc, char** argv) TestConnections::skip_maxscale_start(true); TestConnections test(argc, argv); - test.maxscales->ssh_node(0, - "mkdir -p /home/vagrant/rules/; chown -R vagrant:vagrant /home/vagrant/rules/", - true); - test.maxscales->copy_to_node_legacy((char*)"rules.txt", (char*)"~/rules/rules.txt", 0); - test.maxscales->ssh_node(0, "chmod a+r /home/vagrant/rules/rules.txt;", true); + copy_rules(&test, (char*) "rules.txt", (char*) "."); int rc = 0; diff --git a/maxscale-system-test/fwf_prepared_stmt.cpp b/maxscale-system-test/fwf_prepared_stmt.cpp index 71102cd3d..5c45f6292 100644 --- a/maxscale-system-test/fwf_prepared_stmt.cpp +++ b/maxscale-system-test/fwf_prepared_stmt.cpp @@ -6,17 +6,21 @@ */ #include "testconnections.h" +#include "fw_copy_rules.h" + +const char* rules = "rule test1 deny columns c on_queries select\n" + "users %@% match any rules test1\n"; int main(int argc, char** argv) { + FILE* file = fopen("rules.txt", "w"); + fwrite(rules, 1, strlen(rules), file); + fclose(file); + TestConnections::skip_maxscale_start(true); TestConnections test(argc, argv); - test.maxscales->ssh_node_f(0, - true, - "mkdir -p /home/vagrant/rules/;" - "echo 'rule test1 deny columns c on_queries select' > /home/vagrant/rules/rules.txt;" - "echo 'users %%@%% match any rules test1' >> /home/vagrant/rules/rules.txt;" - "chmod a+r /home/vagrant/rules/rules.txt;"); + + copy_rules(&test, (char*) "rules.txt", (char*) "."); test.add_result(test.maxscales->restart_maxscale(0), "Restarting MaxScale failed"); diff --git a/maxscale-system-test/keepalived_func.cpp b/maxscale-system-test/keepalived_func.cpp index 7252f4bb1..7b15d7394 100644 --- a/maxscale-system-test/keepalived_func.cpp +++ b/maxscale-system-test/keepalived_func.cpp @@ -71,5 +71,6 @@ void stop_keepalived(TestConnections* Test) for (int i = 0; i < Test->maxscales->N; i++) { Test->maxscales->ssh_node(i, "sudo service keepalived stop", true); + Test->maxscales->ssh_node(i, "killall -9 keepalived", true); } } diff --git a/maxscale-system-test/mariadb_func.cpp b/maxscale-system-test/mariadb_func.cpp index b814347d2..3c97c14bb 100644 --- a/maxscale-system-test/mariadb_func.cpp +++ b/maxscale-system-test/mariadb_func.cpp @@ -462,7 +462,7 @@ int get_conn_num(MYSQL* conn, std::string ip, std::string hostname, std::string row = mysql_fetch_row(res); if ((row[2] != NULL ) && (row[3] != NULL)) { - if (strstr(row[2], ip.c_str()) && strstr(row[3], db.c_str())) + if ((strcmp(strtok(row[2], ":"), ip.c_str()) == 0) && strstr(row[3], db.c_str())) { conn_num++; } diff --git a/maxscale-system-test/mariadb_nodes.cpp b/maxscale-system-test/mariadb_nodes.cpp index 3d100eebd..66af629a5 100644 --- a/maxscale-system-test/mariadb_nodes.cpp +++ b/maxscale-system-test/mariadb_nodes.cpp @@ -229,7 +229,7 @@ int Mariadb_nodes::find_master() i = 0; while ((found == 0) && (i < N)) { - if (strcmp(IP[i], master_IP) == 0) + if (strcmp(IP_private[i], master_IP) == 0) { found = 1; master_node = i; @@ -267,7 +267,7 @@ void Mariadb_nodes::change_master(int NewMaster, int OldMaster) if (i != NewMaster && mysql_ping(nodes[i]) == 0) { char str[1024]; - sprintf(str, setup_slave, IP[NewMaster], log_file, log_pos, port[NewMaster]); + sprintf(str, setup_slave, IP_private[NewMaster], log_file, log_pos, port[NewMaster]); execute_query(nodes[i], "%s", str); } } @@ -438,7 +438,7 @@ int Galera_nodes::start_galera() true, "sed -i 's/###NODE-ADDRESS###/%s/' /etc/my.cnf.d/* /etc/mysql/my.cnf.d/*;" "sed -i \"s|###GALERA-LIB-PATH###|$(ls /usr/lib*/galera/*.so)|g\" /etc/my.cnf.d/* /etc/mysql/my.cnf.d/*", - IP[i]); + IP_private[i]); } printf("Starting new Galera cluster\n"); @@ -1437,7 +1437,7 @@ int Mariadb_nodes::prepare_servers() void Mariadb_nodes::replicate_from(int slave, int master, const char* type) { std::stringstream change_master; - change_master << "CHANGE MASTER TO MASTER_HOST = '" << IP[master] + change_master << "CHANGE MASTER TO MASTER_HOST = '" << IP_private[master] << "', MASTER_PORT = " << port[master] << ", MASTER_USE_GTID = " << type << ", " "MASTER_USER='repl', MASTER_PASSWORD='repl';"; @@ -1473,7 +1473,7 @@ std::string Mariadb_nodes::cnf_servers() cnf_server_name + std::to_string(i + 1) + std::string("]\\ntype=server\\naddress=") + - std::string(IP[i]) + + std::string(IP_private[i]) + std::string("\\nport=") + std::to_string(port[i]) + std::string("\\nprotocol=MySQLBackend\\n"); diff --git a/maxscale-system-test/masking_auto_firewall.cpp b/maxscale-system-test/masking_auto_firewall.cpp index af7919e54..73b0a93f7 100644 --- a/maxscale-system-test/masking_auto_firewall.cpp +++ b/maxscale-system-test/masking_auto_firewall.cpp @@ -173,7 +173,7 @@ int main(int argc, char* argv[]) std::string json_file("/masking_auto_firewall.json"); std::string from = test_dir + json_file; - std::string to = "/home/vagrant" + json_file; + std::string to = std::string(test.maxscales->access_homedir[0]) + json_file; if (test.maxscales->copy_to_node(0, from.c_str(), to.c_str()) == 0) { diff --git a/maxscale-system-test/mxs1071_maxrows.cpp b/maxscale-system-test/mxs1071_maxrows.cpp index 6c5c2130d..b37877d00 100644 --- a/maxscale-system-test/mxs1071_maxrows.cpp +++ b/maxscale-system-test/mxs1071_maxrows.cpp @@ -207,7 +207,7 @@ int compare_expected(TestConnections* Test, const char* sql, my_ulonglong exp_i, my_ulonglong* rows = new my_ulonglong[30]; my_ulonglong i; - Test->set_timeout(30); + Test->set_timeout(90); execute_query_num_of_rows(Test->maxscales->conn_rwsplit[0], sql, rows, &i); Test->tprintf("Result sets number is %llu\n", i); @@ -252,7 +252,7 @@ int compare_stmt_expected(TestConnections* Test, my_ulonglong* rows = new my_ulonglong[30]; my_ulonglong i; - Test->set_timeout(30); + Test->set_timeout(90); execute_stmt_num_of_rows(stmt, rows, &i); Test->tprintf("Result sets number is %llu\n", i); diff --git a/maxscale-system-test/mxs1110_16mb.cpp b/maxscale-system-test/mxs1110_16mb.cpp index a5f3b1fc9..47a5886b4 100644 --- a/maxscale-system-test/mxs1110_16mb.cpp +++ b/maxscale-system-test/mxs1110_16mb.cpp @@ -27,13 +27,6 @@ int main(int argc, char* argv[]) Test->maxscales->copy_to_node_legacy(cache_rules.c_str(), "~/", 0); - Test->maxscales->ssh_node_f(0, - true, - "cd %s;" - "rm -rf rules;" - "mkdir rules;" - "chown vagrant:vagrant rules", - Test->maxscales->access_homedir[0]); copy_rules(Test, "rules2", fw_rules.c_str()); Test->maxscales->start_maxscale(0); diff --git a/maxscale-system-test/mxs1509.cpp b/maxscale-system-test/mxs1509.cpp index 716efd735..c9198c10e 100644 --- a/maxscale-system-test/mxs1509.cpp +++ b/maxscale-system-test/mxs1509.cpp @@ -24,7 +24,7 @@ void change_master(TestConnections& test, int slave, int master, const char* nam "CHANGE MASTER %s TO master_host='%s', master_port=3306, master_user='%s', master_password='%s', master_use_gtid=slave_pos;" "START ALL SLAVES", source.c_str(), - test.repl->IP[master], + test.repl->IP_private[master], test.repl->user_name, test.repl->password); } diff --git a/maxscale-system-test/mxs1719.cpp b/maxscale-system-test/mxs1719.cpp index 4b71cabfa..8d79ee8e4 100644 --- a/maxscale-system-test/mxs1719.cpp +++ b/maxscale-system-test/mxs1719.cpp @@ -78,8 +78,9 @@ int main(int argc, char* argv[]) TestConnections test(argc, argv); std::string src = test_dir; src += "/mxs1719.json"; + std::string dst = std::string(test.maxscales->access_homedir[0]) + "/mxs1719.json"; - if (test.maxscales->copy_to_node(0, src.c_str(), "/home/vagrant/mxs1719.json") == 0) + if (test.maxscales->copy_to_node(0, src.c_str(), dst.c_str()) == 0) { if (test.maxscales->start() == 0) { diff --git a/maxscale-system-test/mxs173_throttle_filter.cpp b/maxscale-system-test/mxs173_throttle_filter.cpp index 6215b0be7..e9366fca9 100644 --- a/maxscale-system-test/mxs173_throttle_filter.cpp +++ b/maxscale-system-test/mxs173_throttle_filter.cpp @@ -13,6 +13,8 @@ DEFINE_EXCEPTION(Whoopsy); +#define TIMEOUT 300 + // TODO these should be read from maxscale.cnf. Maybe the test-lib should replace // any "###ENV_VAR###", with environment variables so that code and conf can share. constexpr int max_qps = 500; @@ -196,26 +198,26 @@ int main(int argc, char* argv[]) test.maxscales->connect_maxscale(0); std::cout << "Create table\n"; - test.set_timeout(120); + test.set_timeout(TIMEOUT); create_table(test.maxscales->conn_master[0]); std::cout << "Insert rows\n"; - test.set_timeout(120); + test.set_timeout(TIMEOUT); insert_rows(test.maxscales->conn_master[0]); - test.set_timeout(120); + test.set_timeout(TIMEOUT); gauge_raw_speed(test); test.stop_timeout(); test.repl->sync_slaves(); - test.set_timeout(120); + test.set_timeout(TIMEOUT); verify_throttling_performace(test); test.maxscales->close_maxscale_connections(0); test.maxscales->connect_maxscale(0); - test.set_timeout(120); + test.set_timeout(TIMEOUT); verify_throttling_disconnect(test); std::cout << "\n\n"; diff --git a/maxscale-system-test/mxs2057_systemd_watchdog.cpp b/maxscale-system-test/mxs2057_systemd_watchdog.cpp index 50910a41a..4b47c5ce0 100644 --- a/maxscale-system-test/mxs2057_systemd_watchdog.cpp +++ b/maxscale-system-test/mxs2057_systemd_watchdog.cpp @@ -78,7 +78,7 @@ int main(int argc, char* argv[]) std::string lua_file("/infinite_loop.lua"); std::string from = test_dir + lua_file; - std::string to = "/home/vagrant" + lua_file; + std::string to = std::string(test.maxscales->access_homedir[0]) + lua_file; test.maxscales->copy_to_node(0, from.c_str(), to.c_str()); test.maxscales->start(); diff --git a/maxscale-system-test/mxs922_bad_server.cpp b/maxscale-system-test/mxs922_bad_server.cpp index 852c564a3..236880841 100644 --- a/maxscale-system-test/mxs922_bad_server.cpp +++ b/maxscale-system-test/mxs922_bad_server.cpp @@ -77,7 +77,7 @@ int main(int argc, char* argv[]) true, "maxadmin create server server%d 3306 %s", i + 1, - test->repl->IP[i]); + test->repl->IP_private[i]); } /** Add the servers to the monitor and service */ @@ -96,7 +96,7 @@ int main(int argc, char* argv[]) true, "maxadmin create server server%d %s %d", i + 1, - test->repl->IP[i], + test->repl->IP_private[i], test->repl->port[i]); } diff --git a/maxscale-system-test/mxs922_server.cpp b/maxscale-system-test/mxs922_server.cpp index 83e266110..6eab15827 100644 --- a/maxscale-system-test/mxs922_server.cpp +++ b/maxscale-system-test/mxs922_server.cpp @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) config.create_server(1); config.add_server(1); - config.alter_server(1, "address", test->repl->IP[1]); + config.alter_server(1, "address", test->repl->IP_private[1]); sleep(1); test->check_maxscale_alive(0); config.alter_server(1, "address", "This-is-not-the-address-you-are-looking-for"); diff --git a/maxscale-system-test/mysqlmon_detect_standalone_master.cpp b/maxscale-system-test/mysqlmon_detect_standalone_master.cpp index ab75b4373..d1bab8b91 100644 --- a/maxscale-system-test/mysqlmon_detect_standalone_master.cpp +++ b/maxscale-system-test/mysqlmon_detect_standalone_master.cpp @@ -32,7 +32,7 @@ void check_maxscale(TestConnections& test) void replicate_from(TestConnections& test, int server_ind, int target_ind) { stringstream change_master; - change_master << "CHANGE MASTER TO MASTER_HOST = '" << test.repl->IP[target_ind] + change_master << "CHANGE MASTER TO MASTER_HOST = '" << test.repl->IP_private[target_ind] << "', MASTER_PORT = " << test.repl->port[target_ind] << ", MASTER_USE_GTID = current_pos, " "MASTER_USER='repl', MASTER_PASSWORD='repl';"; cout << "Server " << server_ind + 1 << " starting to replicate from server " << target_ind + 1 << endl; diff --git a/maxscale-system-test/mysqlmon_multimaster.cpp b/maxscale-system-test/mysqlmon_multimaster.cpp index 7423c16e3..17ded46bc 100644 --- a/maxscale-system-test/mysqlmon_multimaster.cpp +++ b/maxscale-system-test/mysqlmon_multimaster.cpp @@ -172,7 +172,7 @@ void change_master(TestConnections& test ,int slave, int master, const string& c "master_user='repl', master_password='repl', master_delay=%d; " "START SLAVE '%s';"; test.try_query(test.repl->nodes[slave], query, conn_name.c_str(), - test.repl->IP[master], test.repl->port[master], + test.repl->IP_private[master], test.repl->port[master], replication_delay, conn_name.c_str()); } diff --git a/maxscale-system-test/mysqlmon_rejoin_bad.cpp b/maxscale-system-test/mysqlmon_rejoin_bad.cpp index 8b5e4e8c9..2807f7484 100644 --- a/maxscale-system-test/mysqlmon_rejoin_bad.cpp +++ b/maxscale-system-test/mysqlmon_rejoin_bad.cpp @@ -120,7 +120,7 @@ int main(int argc, char** argv) const char CHANGE_CMD_FMT[] = "CHANGE MASTER TO MASTER_HOST = '%s', MASTER_PORT = %d, " "MASTER_USE_GTID = current_pos, MASTER_USER='repl', MASTER_PASSWORD = 'repl';"; char change_cmd[256]; - snprintf(change_cmd, sizeof(change_cmd), CHANGE_CMD_FMT, test.repl->IP[3], test.repl->port[3]); + snprintf(change_cmd, sizeof(change_cmd), CHANGE_CMD_FMT, test.repl->IP_private[3], test.repl->port[3]); test.try_query(nodes[0], "%s", change_cmd); test.try_query(nodes[0], "START SLAVE;"); test.maxscales->wait_for_monitor(2); diff --git a/maxscale-system-test/mysqlmon_rejoin_bad2.cpp b/maxscale-system-test/mysqlmon_rejoin_bad2.cpp index 01f0749c4..a57dda96e 100644 --- a/maxscale-system-test/mysqlmon_rejoin_bad2.cpp +++ b/maxscale-system-test/mysqlmon_rejoin_bad2.cpp @@ -138,7 +138,7 @@ int main(int argc, char** argv) "MASTER_USER='repl', MASTER_PASSWORD = 'repl';"; char cmd[256]; int ind = master_id_new - 1; - snprintf(cmd, sizeof(cmd), CHANGE_CMD_FMT, test.repl->IP[0], test.repl->port[0]); + snprintf(cmd, sizeof(cmd), CHANGE_CMD_FMT, test.repl->IP_private[0], test.repl->port[0]); MYSQL** nodes = test.repl->nodes; mysql_query(nodes[ind], cmd); mysql_query(nodes[ind], "START SLAVE;"); diff --git a/maxscale-system-test/mysqlmon_rejoin_manual.cpp b/maxscale-system-test/mysqlmon_rejoin_manual.cpp index 6bd9c8fe9..9c91cb54b 100644 --- a/maxscale-system-test/mysqlmon_rejoin_manual.cpp +++ b/maxscale-system-test/mysqlmon_rejoin_manual.cpp @@ -123,8 +123,8 @@ int main(int argc, char** argv) test.repl->connect(); if (find_field(conn, sstatus_query.c_str(), "Master_Host", result) == 0) { - test.expect(strcmp(result, test.repl->IP[0]) == 0, - "server3 did not rejoin the cluster (%s != %s).", result, test.repl->IP[0]); + test.expect(strcmp(result, test.repl->IP_private[0]) == 0, + "server3 did not rejoin the cluster (%s != %s).", result, test.repl->IP_private[0]); } else { diff --git a/maxscale-system-test/mysqlmon_rejoin_manual2.cpp b/maxscale-system-test/mysqlmon_rejoin_manual2.cpp index 62aa46354..6986a7c29 100644 --- a/maxscale-system-test/mysqlmon_rejoin_manual2.cpp +++ b/maxscale-system-test/mysqlmon_rejoin_manual2.cpp @@ -112,7 +112,7 @@ int main(int argc, char** argv) const char CHANGE_CMD_FMT[] = "CHANGE MASTER TO MASTER_HOST = '%s', MASTER_PORT = %d, " "MASTER_USE_GTID = current_pos, MASTER_USER='repl', MASTER_PASSWORD = 'repl';"; char cmd[256]; - snprintf(cmd, sizeof(cmd), CHANGE_CMD_FMT, test.repl->IP[3], test.repl->port[3]); + snprintf(cmd, sizeof(cmd), CHANGE_CMD_FMT, test.repl->IP_private[3], test.repl->port[3]); mysql_query(nodes[0], cmd); mysql_query(nodes[0], "START SLAVE;"); test.maxscales->wait_for_monitor(); diff --git a/maxscale-system-test/nodes.cpp b/maxscale-system-test/nodes.cpp index 7c23011a9..95bbb1f11 100644 --- a/maxscale-system-test/nodes.cpp +++ b/maxscale-system-test/nodes.cpp @@ -370,9 +370,9 @@ int Nodes::read_basic_env() sprintf(env_name, "%s_%03d_hostname", prefix, i); hostname[i] = strdup(get_nc_item(env_name).c_str()); - if (hostname[i] == NULL) + if ((hostname[i] == NULL) || (strcmp(hostname[i], "") == 0)) { - hostname[i] = IP[i]; + hostname[i] = IP_private[i]; } setenv(env_name, hostname[i], 1); @@ -416,6 +416,7 @@ std::string Nodes::get_nc_item(const char* item_name) } std::string str = network_config.substr(equal + 1, end - equal - 1); + str.erase(remove(str.begin(), str.end(), ' '), str.end()); setenv(item_name, str.c_str(), 1); diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index be1c49a08..1492896f2 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -775,7 +775,7 @@ void TestConnections::process_template(int m, const char* template_name, const c } else { - IPcnf = mdn[j]->IP[i]; + IPcnf = mdn[j]->IP_private[i]; } sprintf(str, "sed -i \"s/###%s_server_IP_%0d###/%s/\" maxscale.cnf", mdn[j]->prefix, i + 1, IPcnf); @@ -1131,7 +1131,7 @@ int TestConnections::start_binlog(int m) try_query(repl->nodes[1], "SET @@global.gtid_slave_pos=''"); sprintf(sys1, "CHANGE MASTER TO MASTER_HOST='%s', MASTER_PORT=%d, MASTER_USER='repl', MASTER_PASSWORD='repl', MASTER_USE_GTID=Slave_pos", - repl->IP[0], + repl->IP_private[0], repl->port[0]); try_query(repl->nodes[1], "%s", sys1); try_query(repl->nodes[1], "start slave"); @@ -1149,7 +1149,7 @@ int TestConnections::start_binlog(int m) // repl->no_set_pos = true; repl->no_set_pos = false; tprintf("Configure first backend slave node to be slave of real master\n"); - repl->set_slave(repl->nodes[1], repl->IP[0], repl->port[0], log_file, log_pos); + repl->set_slave(repl->nodes[1], repl->IP_private[0], repl->port[0], log_file, log_pos); } if (!local_maxscale) @@ -1176,7 +1176,7 @@ int TestConnections::start_binlog(int m) try_query(binlog, "SET @@global.gtid_slave_pos=''"); sprintf(sys1, "CHANGE MASTER TO MASTER_HOST='%s', MASTER_PORT=%d, MASTER_USER='repl', MASTER_PASSWORD='repl', MASTER_USE_GTID=Slave_pos", - repl->IP[0], + repl->IP_private[0], repl->port[0]); try_query(binlog, "%s", sys1); } @@ -1184,7 +1184,7 @@ int TestConnections::start_binlog(int m) { repl->no_set_pos = true; tprintf("configuring Maxscale binlog router\n"); - repl->set_slave(binlog, repl->IP[0], repl->port[0], log_file, log_pos); + repl->set_slave(binlog, repl->IP_private[0], repl->port[0], log_file, log_pos); } // ssl between binlog router and Master if (backend_ssl) @@ -1211,7 +1211,7 @@ int TestConnections::start_binlog(int m) try_query(repl->nodes[i], "SET @@global.gtid_slave_pos=''"); sprintf(sys1, "CHANGE MASTER TO MASTER_HOST='%s', MASTER_PORT=%d, MASTER_USER='repl', MASTER_PASSWORD='repl', MASTER_USE_GTID=Slave_pos", - maxscales->IP[m], + maxscales->IP_private[m], maxscales->binlog_port[m]); try_query(repl->nodes[i], "%s", sys1); try_query(repl->nodes[i], "start slave"); @@ -1234,7 +1234,7 @@ int TestConnections::start_binlog(int m) for (i = 2; i < repl->N; i++) { try_query(repl->nodes[i], "stop slave"); - repl->set_slave(repl->nodes[i], maxscales->IP[m], maxscales->binlog_port[m], log_file, log_pos); + repl->set_slave(repl->nodes[i], maxscales->IP_private[m], maxscales->binlog_port[m], log_file, log_pos); } } @@ -1274,7 +1274,7 @@ bool TestConnections::replicate_from_master(int m) conn = open_conn_no_db(maxscales->binlog_port[m], maxscales->IP[m], repl->user_name, repl->password, ssl); if (find_field(repl->nodes[0], "show master status", "File", log_file) - || repl->set_slave(conn, repl->IP[0], repl->port[0], log_file, log_pos) + || repl->set_slave(conn, repl->IP_private[0], repl->port[0], log_file, log_pos) || execute_query(conn, "start slave")) { rval = false; @@ -1295,7 +1295,7 @@ void TestConnections::revert_replicate_from_master() for (int i = 1; i < repl->N; i++) { - repl->set_slave(repl->nodes[i], repl->IP[0], repl->port[0], log_file, (char*)"4"); + repl->set_slave(repl->nodes[i], repl->IP_private[0], repl->port[0], log_file, (char*)"4"); execute_query(repl->nodes[i], "start slave"); } } @@ -1335,8 +1335,8 @@ int TestConnections::start_mm(int m) find_field(repl->nodes[1], (char*) "show master status", (char*) "File", log_file2); find_field(repl->nodes[1], (char*) "show master status", (char*) "Position", log_pos2); - repl->set_slave(repl->nodes[0], repl->IP[1], repl->port[1], log_file2, log_pos2); - repl->set_slave(repl->nodes[1], repl->IP[0], repl->port[0], log_file1, log_pos1); + repl->set_slave(repl->nodes[0], repl->IP_private[1], repl->port[1], log_file2, log_pos2); + repl->set_slave(repl->nodes[1], repl->IP_private[0], repl->port[0], log_file1, log_pos1); repl->close_connections(); diff --git a/maxscale-system-test/utilities.cmake b/maxscale-system-test/utilities.cmake index 15a28af49..48a8e3fe0 100644 --- a/maxscale-system-test/utilities.cmake +++ b/maxscale-system-test/utilities.cmake @@ -11,7 +11,7 @@ function(add_template_manual name template) endfunction() # Default test timeout -set(TIMEOUT 900) +set(TIMEOUT 3600) # This functions adds a source file as an executable, links that file against # the common test core and creates a test from it. The first parameter is the From aa801c74c5af12a4528bab91d4aa424eb0257f74 Mon Sep 17 00:00:00 2001 From: Timofey Turenko Date: Mon, 16 Dec 2019 19:53:53 +0200 Subject: [PATCH 2/2] Use constexpr instead of define in the mxs173_throttle_filter test --- maxscale-system-test/mxs173_throttle_filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maxscale-system-test/mxs173_throttle_filter.cpp b/maxscale-system-test/mxs173_throttle_filter.cpp index e9366fca9..7e0590b7a 100644 --- a/maxscale-system-test/mxs173_throttle_filter.cpp +++ b/maxscale-system-test/mxs173_throttle_filter.cpp @@ -13,7 +13,7 @@ DEFINE_EXCEPTION(Whoopsy); -#define TIMEOUT 300 +constexpr int TIMEOUT = 300; // TODO these should be read from maxscale.cnf. Maybe the test-lib should replace // any "###ENV_VAR###", with environment variables so that code and conf can share.