diff --git a/maxscale-system-test/maxtest/src/testconnections.cpp b/maxscale-system-test/maxtest/src/testconnections.cpp index 16274e977..3e0461652 100644 --- a/maxscale-system-test/maxtest/src/testconnections.cpp +++ b/maxscale-system-test/maxtest/src/testconnections.cpp @@ -40,8 +40,8 @@ const string label_cs_be = "COLUMNSTORE_BACKEND"; const StringSet recognized_mdbci_labels = {label_repl_be, label_big_be, label_galera_be, label_2nd_mxs, label_cs_be}; -const int MDBCI_FAIL = 200; // Exit code when failure caused by MDBCI non-zero exit -const int BROKEN_VM_FAIL = 201; // Exit code when failure caused by broken VMs +const int MDBCI_FAIL = 200; // Exit code when failure caused by MDBCI non-zero exit +const int BROKEN_VM_FAIL = 201; // Exit code when failure caused by broken VMs } namespace maxscale @@ -147,19 +147,19 @@ TestConnections::TestConnections(int argc, char* argv[]) static struct option long_options[] = { - {"help", no_argument, 0, 'h' }, - {"verbose", no_argument, 0, 'v' }, - {"silent", no_argument, 0, 'n' }, - {"quiet", no_argument, 0, 'q' }, - {"no-maxscale-start", no_argument, 0, 's' }, - {"no-maxscale-init", no_argument, 0, 'i' }, - {"no-nodes-check", no_argument, 0, 'r' }, - {"restart-galera", no_argument, 0, 'g' }, - {"no-timeouts", no_argument, 0, 'z' }, - {"no-galera", no_argument, 0, 'y' }, - {"local-maxscale", optional_argument, 0, 'l' }, - {"reinstall-maxscale",no_argument, 0, 'm' }, - {0, 0, 0, 0 } + {"help", no_argument, 0, 'h'}, + {"verbose", no_argument, 0, 'v'}, + {"silent", no_argument, 0, 'n'}, + {"quiet", no_argument, 0, 'q'}, + {"no-maxscale-start", no_argument, 0, 's'}, + {"no-maxscale-init", no_argument, 0, 'i'}, + {"no-nodes-check", no_argument, 0, 'r'}, + {"restart-galera", no_argument, 0, 'g'}, + {"no-timeouts", no_argument, 0, 'z'}, + {"no-galera", no_argument, 0, 'y'}, + {"local-maxscale", optional_argument, 0, 'l'}, + {"reinstall-maxscale", no_argument, 0, 'm'}, + {0, 0, 0, 0 } }; int c; @@ -288,7 +288,6 @@ TestConnections::TestConnections(int argc, char* argv[]) { exit(MDBCI_FAIL); } - } if (m_required_mdbci_labels.count(label_repl_be) == 0) @@ -461,7 +460,7 @@ TestConnections::TestConnections(int argc, char* argv[]) if (mdbci_call_needed) { int ec; - char * ver = maxscales->ssh_node_output(0, "maxscale --version-full", false, &ec); + char* ver = maxscales->ssh_node_output(0, "maxscale --version-full", false, &ec); if (ec) { tprintf("Error retrival of Maxscale version info"); @@ -746,14 +745,18 @@ void TestConnections::process_template(int m, const string& cnf_template_path, c if (backend_ssl) { tprintf("Adding ssl settings\n"); - system("sed -i \"s|type=server|type=server\\nssl=required\\nssl_cert=/###access_homedir###/certs/client-cert.pem\\nssl_key=/###access_homedir###/certs/client-key.pem\\nssl_ca_cert=/###access_homedir###/certs/ca.pem|g\" maxscale.cnf"); + const char sed_cmd[] = "sed -i " + "\"s|type=server|type=server\\nssl=required\\nssl_cert=/###access_homedir###/" + "certs/client-cert.pem\\nssl_key=/###access_homedir###/certs/client-key.pem" + "\\nssl_ca_cert=/###access_homedir###/certs/ca.pem|g\" maxscale.cnf"; + system(sed_cmd); } sprintf(str, "sed -i \"s/###threads###/%d/\" maxscale.cnf", m_threads); system(str); - Mariadb_nodes * mdn[2]; - char * IPcnf; + Mariadb_nodes* mdn[2]; + char* IPcnf; mdn[0] = repl; mdn[1] = galera; int i, j; @@ -782,13 +785,17 @@ void TestConnections::process_template(int m, const string& cnf_template_path, c system(str); } - sprintf(str, "sed -i \"s/###%s###/%s/\" maxscale.cnf", mdn[j]->cnf_server_name.c_str(), mdn[j]->cnf_servers().c_str()); + sprintf(str, + "sed -i \"s/###%s###/%s/\" maxscale.cnf", + mdn[j]->cnf_server_name.c_str(), mdn[j]->cnf_servers().c_str()); system(str); - sprintf(str, "sed -i \"s/###%s_line###/%s/\" maxscale.cnf", mdn[j]->cnf_server_name.c_str(), mdn[j]->cnf_servers_line().c_str()); + sprintf(str, + "sed -i \"s/###%s_line###/%s/\" maxscale.cnf", + mdn[j]->cnf_server_name.c_str(), mdn[j]->cnf_servers_line().c_str()); system(str); mdn[j]->connect(); - execute_query(mdn[j]->nodes[0], (char *) "CREATE DATABASE IF NOT EXISTS test"); + execute_query(mdn[j]->nodes[0], (char*) "CREATE DATABASE IF NOT EXISTS test"); mdn[j]->close_connections(); } } @@ -803,7 +810,7 @@ void TestConnections::process_template(int m, const string& cnf_template_path, c { system("sed -i \"s/###repl51###/mysql51_replication=true/g\" maxscale.cnf"); } - maxscales->copy_to_node_legacy((char *) "maxscale.cnf", (char *) dest, m); + maxscales->copy_to_node_legacy((char*) "maxscale.cnf", (char*) dest, m); } void TestConnections::init_maxscales() @@ -1230,7 +1237,8 @@ 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_private[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); } } @@ -2163,7 +2171,7 @@ bool TestConnections::test_bad_config(int m, const string& config) "maxscale -U maxscale -lstdout &> /dev/null && sleep 1 && pkill -9 maxscale") == 0; } -int TestConnections::call_mdbci(const char * options) +int TestConnections::call_mdbci(const char* options) { struct stat buf; string filepath = m_mdbci_vm_path + "/" + m_mdbci_config_name; @@ -2174,26 +2182,22 @@ int TestConnections::call_mdbci(const char * options) tprintf("Failed to generate MDBCI virtual machines template"); return 1; } - if (system((std::string("mdbci --override --template ") + m_vm_path + - ".json generate " + m_mdbci_config_name).c_str() )) + if (system((std::string("mdbci --override --template ") + m_vm_path + + ".json generate " + m_mdbci_config_name).c_str())) { tprintf("MDBCI failed to generate virtual machines description"); return 1; } - if (system((std::string("cp -r ") + test_dir + std::string("/mdbci/cnf ") + - m_vm_path + "/").c_str())) + if (system((std::string("cp -r ") + test_dir + std::string("/mdbci/cnf ") + + m_vm_path + "/").c_str())) { tprintf("Failed to copy my.cnf files"); return 1; } } - if (system((std::string("mdbci up ") + - m_mdbci_config_name + - std::string(" --labels ") + - m_mdbci_labels_str + - std::string(" ") + - std::string(options)).c_str() )) + if (system((std::string("mdbci up ") + m_mdbci_config_name + " --labels " + m_mdbci_labels_str + " " + + options).c_str())) { tprintf("MDBCI failed to bring up virtual machines"); return 1; @@ -2221,15 +2225,15 @@ int TestConnections::call_mdbci(const char * options) int TestConnections::process_mdbci_template() { - char * product = readenv("product", "mariadb"); - char * box = readenv("box", "centos_7_libvirt"); - char * __attribute__((unused)) backend_box = readenv("backend_box", "%s", box); - char * version = readenv("version", "10.3"); - char * __attribute__((unused)) target = readenv("target", "develop"); - char * __attribute__((unused)) vm_memory = readenv("vm_memory", "2048"); - char * __attribute__((unused)) galera_version = readenv("galera_version", "%s", version); + char* product = readenv("product", "mariadb"); + char* box = readenv("box", "centos_7_libvirt"); + char* __attribute__ ((unused)) backend_box = readenv("backend_box", "%s", box); + char* version = readenv("version", "10.3"); + char* __attribute__ ((unused)) target = readenv("target", "develop"); + char* __attribute__ ((unused)) vm_memory = readenv("vm_memory", "2048"); + char* __attribute__ ((unused)) galera_version = readenv("galera_version", "%s", version); - if (strcmp(product, "mysql") == 0 ) + if (strcmp(product, "mysql") == 0) { setenv("cnf_path", (m_vm_path + "/cnf/mysql56/").c_str(), @@ -2276,7 +2280,7 @@ int TestConnections::reinstall_maxscales() for (int i = 0; i < maxscales->N; i++) { printf("Installing Maxscale on node %d\n", i); - //TODO: make it via MDBCI and compatible with any distro + // TODO: make it via MDBCI and compatible with any distro maxscales->ssh_node(i, "yum remove maxscale -y", true); maxscales->ssh_node(i, "yum clean all", true);