2.2 fix restore (#152)
* refactor test backend fixing * return comatibility with 5.5 for backend restore * remove backend configuration scripts * adopt test backed restore function for 2.2 test fw
This commit is contained in:
parent
b9e7eaf3aa
commit
1006ec506a
@ -18,15 +18,23 @@ int main(int argc, char *argv[])
|
||||
Test->tprintf("Connecting to Maxscale maxscales->routers[0] with Master/Slave backend\n");
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
Test->tprintf("Testing connections\n");
|
||||
|
||||
Test->add_result(Test->test_maxscale_connections(0, true, true, true), "Can't connect to backend\n");
|
||||
Test->tprintf("Connecting to Maxscale router with Galera backend\n");
|
||||
MYSQL * g_conn = open_conn(4016 , Test->maxscales->IP[0], Test->maxscales->user_name,
|
||||
Test->maxscales->password, Test->ssl);
|
||||
if (g_conn != NULL )
|
||||
|
||||
if ((Test->galera != NULL) && (Test->galera->N != 0))
|
||||
{
|
||||
Test->tprintf("Testing connection\n");
|
||||
Test->add_result(Test->try_query(g_conn, (char *) "SELECT 1"),
|
||||
(char *) "Error executing query against RWSplit Galera\n");
|
||||
Test->tprintf("Connecting to Maxscale router with Galera backend\n");
|
||||
MYSQL * g_conn = open_conn(4016 , Test->maxscales->IP[0], Test->maxscales->user_name, Test->maxscales->password, Test->ssl);
|
||||
if (g_conn != NULL )
|
||||
{
|
||||
Test->tprintf("Testing connection\n");
|
||||
Test->add_result(Test->try_query(g_conn, (char *) "SELECT 1"),
|
||||
(char *) "Error executing query against RWSplit Galera\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Test->tprintf("Galera is not in use\n");
|
||||
}
|
||||
Test->tprintf("Closing connections\n");
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
@ -45,7 +53,6 @@ int main(int argc, char *argv[])
|
||||
Test->tprintf("Snapshots are not in use\n");
|
||||
}
|
||||
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -44,25 +44,34 @@ Mariadb_nodes::~Mariadb_nodes()
|
||||
}
|
||||
}
|
||||
|
||||
int Mariadb_nodes::connect(int i)
|
||||
{
|
||||
if (nodes[i] == NULL || mysql_ping(nodes[i]) != 0)
|
||||
{
|
||||
if (nodes[i])
|
||||
{
|
||||
mysql_close(nodes[i]);
|
||||
}
|
||||
nodes[i] = open_conn_db_timeout(port[i], IP[i], "test", user_name, password, 50, ssl);
|
||||
}
|
||||
|
||||
if ((nodes[i] != NULL) && (mysql_errno(nodes[i]) != 0))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int Mariadb_nodes::connect()
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
if (nodes[i] == NULL || mysql_ping(nodes[i]) != 0)
|
||||
{
|
||||
if (nodes[i])
|
||||
{
|
||||
mysql_close(nodes[i]);
|
||||
}
|
||||
nodes[i] = open_conn_db_timeout(port[i], IP[i], "test", user_name, password, 50, ssl);
|
||||
}
|
||||
|
||||
if ((nodes[i] != NULL) && (mysql_errno(nodes[i]) != 0))
|
||||
{
|
||||
res++;
|
||||
}
|
||||
res += connect(i);
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -181,7 +190,7 @@ int Mariadb_nodes::read_env()
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(cleanup_db_command[i], " ");
|
||||
sprintf(cleanup_db_command[i], "rm -rf /var/lib/mysql/*; killall -9 mysqld");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -341,13 +350,38 @@ int Mariadb_nodes::start_replication()
|
||||
char dtr[1024];
|
||||
int local_result = 0;
|
||||
|
||||
// Start all nodes
|
||||
// Start all nodes
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
local_result += start_node(i, (char*)"");
|
||||
ssh_node_f(i, true,
|
||||
"mysql --force -u root %s -e \"STOP SLAVE; STOP ALL SLAVES; RESET SLAVE; RESET SLAVE ALL; RESET MASTER; SET GLOBAL read_only=OFF;\"",
|
||||
socket_cmd[i]);
|
||||
if (start_node(i, (char *) ""))
|
||||
{
|
||||
printf("Start of node %d failed, trying to cleanup and re-initialize node\n", i);
|
||||
cleanup_db_node(i);
|
||||
prepare_server(i);
|
||||
local_result += start_node(i, (char *) "");
|
||||
}
|
||||
|
||||
printf("trying to get version\n");
|
||||
if (connect(i))
|
||||
{
|
||||
printf("Connect attempt to node %d failed\n", i);
|
||||
}
|
||||
get_version(i);
|
||||
close_connections();
|
||||
printf("Node %d: Version is %s\n", i, version_major[i]);
|
||||
if (strcmp(version_major[i], "5.5") == 0)
|
||||
{
|
||||
ssh_node_f(i, true,
|
||||
"mysql --force -u root %s -e \"STOP SLAVE; RESET SLAVE; RESET MASTER; SET GLOBAL read_only=OFF;\"",
|
||||
socket_cmd[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ssh_node_f(i, true,
|
||||
"mysql --force -u root %s -e \"STOP SLAVE; STOP ALL SLAVES; RESET SLAVE; RESET SLAVE ALL; RESET MASTER; SET GLOBAL read_only=OFF;\"",
|
||||
socket_cmd[i]);
|
||||
}
|
||||
|
||||
ssh_node_f(i, true, "sudo rm -f /etc/my.cnf.d/kerb.cnf");
|
||||
ssh_node_f(i, true,
|
||||
"for i in `mysql -ss --force -u root %s -e \"SHOW DATABASES\"|grep -iv 'mysql\\|information_schema\\|performance_schema'`; "
|
||||
@ -357,29 +391,38 @@ int Mariadb_nodes::start_replication()
|
||||
|
||||
sprintf(str, "%s/create_user.sh", test_dir);
|
||||
sprintf(dtr, "%s", access_homedir[0]);
|
||||
copy_to_node_legacy(str, dtr , 0);
|
||||
sprintf(str, "export node_user=\"%s\"; export node_password=\"%s\"; %s/create_user.sh %s",
|
||||
user_name, password, access_homedir[0], socket_cmd[0]);
|
||||
printf("cmd: %s\n", str);
|
||||
ssh_node(0, str, false);
|
||||
copy_to_node(0, str, dtr);
|
||||
ssh_node_f(0, false, "export node_user=\"%s\"; export node_password=\"%s\"; %s/create_user.sh %s",
|
||||
user_name, password, access_homedir[0], socket_cmd[0]);
|
||||
|
||||
// Create a database dump from the master and distribute it to the slaves
|
||||
ssh_node_f(0, true, "mysql --force -u root %s -e \"CREATE DATABASE test\"; "
|
||||
"mysqldump --all-databases --add-drop-database --flush-privileges --master-data=1 --gtid %s > /tmp/master_backup.sql",
|
||||
socket_cmd[0], socket_cmd[0]);
|
||||
if (version_major[0][0] == '5')
|
||||
{
|
||||
printf("Version 5 on master detected, do not use --gtid flag for mysqldump\n");
|
||||
ssh_node_f(0, true, "mysql --force -u root %s -e \"CREATE DATABASE test\"; "
|
||||
"mysqldump --all-databases --add-drop-database --flush-privileges --master-data=1 %s > /tmp/master_backup.sql",
|
||||
socket_cmd[0], socket_cmd[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ssh_node_f(0, true, "mysql --force -u root %s -e \"CREATE DATABASE test\"; "
|
||||
"mysqldump --all-databases --add-drop-database --flush-privileges --master-data=1 --gtid %s > /tmp/master_backup.sql",
|
||||
socket_cmd[0], socket_cmd[0]);
|
||||
}
|
||||
sprintf(str, "%s/master_backup.sql", test_dir);
|
||||
copy_from_node_legacy("/tmp/master_backup.sql", str, 0);
|
||||
copy_from_node(0, "/tmp/master_backup.sql", str);
|
||||
|
||||
for (int i = 1; i < N; i++)
|
||||
{
|
||||
// Reset all nodes by first loading the dump and then starting the replication
|
||||
printf("Starting node %d\n", i);
|
||||
printf("Setting node %d\n", i);
|
||||
fflush(stdout);
|
||||
copy_to_node_legacy(str, "/tmp/master_backup.sql", i);
|
||||
copy_to_node(i, str, "/tmp/master_backup.sql");
|
||||
ssh_node_f(i, true, "mysql --force -u root %s -e \"STOP SLAVE;\"",
|
||||
socket_cmd[i]);
|
||||
socket_cmd[i]);
|
||||
ssh_node_f(i, true, "mysql --force -u root %s < /tmp/master_backup.sql",
|
||||
socket_cmd[i]);
|
||||
printf("change master to...\n");
|
||||
ssh_node_f(i, true, "mysql --force -u root %s -e \"CHANGE MASTER TO MASTER_HOST=\\\"%s\\\", MASTER_PORT=%d, "
|
||||
"MASTER_USER=\\\"repl\\\", MASTER_PASSWORD=\\\"repl\\\";"
|
||||
"START SLAVE;\"", socket_cmd[i], IP_private[0], port[0]);
|
||||
@ -390,8 +433,8 @@ int Mariadb_nodes::start_replication()
|
||||
|
||||
int Galera_nodes::start_galera()
|
||||
{
|
||||
char sys1[4096];
|
||||
char str[1024];
|
||||
char sys1[1024];
|
||||
int i;
|
||||
int local_result = 0;
|
||||
local_result += stop_nodes();
|
||||
@ -401,10 +444,17 @@ int Galera_nodes::start_galera()
|
||||
|
||||
printf("Starting new Galera cluster\n");
|
||||
fflush(stdout);
|
||||
|
||||
ssh_node(0, "echo [mysqld] > cluster_address.cnf", false);
|
||||
ssh_node(0, "echo wsrep_cluster_address=gcomm:// >> cluster_address.cnf", false);
|
||||
ssh_node(0, "cp cluster_address.cnf /etc/my.cnf.d/", true);
|
||||
local_result += start_node(0, (char*)" --wsrep-cluster-address=gcomm://");
|
||||
|
||||
if (start_node(0, (char *) " --wsrep-cluster-address=gcomm://") != 0)
|
||||
{
|
||||
cleanup_db_node(i);
|
||||
prepare_server(i);
|
||||
local_result += start_node(0, (char *) " --wsrep-cluster-address=gcomm://");
|
||||
}
|
||||
|
||||
sprintf(str, "%s/create_user_galera.sh", test_dir);
|
||||
copy_to_node_legacy(str, "~/", 0);
|
||||
@ -582,11 +632,19 @@ bool Mariadb_nodes::check_master_node(MYSQL *conn)
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief bad_slave_thread_status Check if filed in the slave status outpur is not 'yes'
|
||||
* @param conn MYSQL struct (connection have to be open)
|
||||
* @param field Filed to check
|
||||
* @param node Node index
|
||||
* @return false if requested filed is 'Yes'
|
||||
*/
|
||||
static bool bad_slave_thread_status(MYSQL *conn, const char *field, int node)
|
||||
{
|
||||
char str[1024] = "";
|
||||
bool rval = false;
|
||||
|
||||
// Doing 3 attempts to check status
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (find_field(conn, "SHOW SLAVE STATUS;", field, str) != 0)
|
||||
@ -597,9 +655,10 @@ static bool bad_slave_thread_status(MYSQL *conn, const char *field, int node)
|
||||
}
|
||||
else if (strcmp(str, "Yes") == 0 || strcmp(str, "No") == 0)
|
||||
{
|
||||
printf("Node %d: filed %s is %s\n", node, field, str);
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Node %d: filed %s is %s\n", node, field, str);
|
||||
/** Any other state is transient and we should try again */
|
||||
sleep(1);
|
||||
}
|
||||
@ -610,16 +669,23 @@ static bool bad_slave_thread_status(MYSQL *conn, const char *field, int node)
|
||||
fflush(stdout);
|
||||
rval = true;
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief multi_source_replication Check if slave is connected to more then one master
|
||||
* @param conn MYSQL struct (have to be open)
|
||||
* @param node Node index
|
||||
* @return false if multisource replication is not detected
|
||||
*/
|
||||
static bool multi_source_replication(MYSQL *conn, int node)
|
||||
{
|
||||
bool rval = true;
|
||||
MYSQL_RES *res;
|
||||
|
||||
if (mysql_query(conn, "SHOW ALL SLAVES STATUS") == 0 &&
|
||||
(res = mysql_store_result(conn)))
|
||||
(res = mysql_store_result(conn)))
|
||||
{
|
||||
if (mysql_num_rows(res) == 1)
|
||||
{
|
||||
@ -631,6 +697,12 @@ static bool multi_source_replication(MYSQL *conn, int node)
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Node %d does not support SHOW ALL SLAVE STATUS, ignoring multi source replication check\n", node);
|
||||
fflush(stdout);
|
||||
rval = false;
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
@ -639,7 +711,6 @@ int Mariadb_nodes::check_replication()
|
||||
{
|
||||
int master = 0;
|
||||
int res = 0;
|
||||
char str[1024];
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
@ -661,6 +732,10 @@ int Mariadb_nodes::check_replication()
|
||||
if (!check_master_node(nodes[i]))
|
||||
{
|
||||
res = 1;
|
||||
if (verbose)
|
||||
{
|
||||
printf("Master node check failed for node %d\n", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bad_slave_thread_status(nodes[i], "Slave_IO_Running", i) ||
|
||||
@ -668,14 +743,24 @@ int Mariadb_nodes::check_replication()
|
||||
multi_source_replication(nodes[i], i))
|
||||
{
|
||||
res = 1;
|
||||
if (verbose)
|
||||
{
|
||||
printf("Slave %d check failed\n", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
printf("Replication check for %s gave code %d\n", prefix, res);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Mariadb_nodes::fix_replication()
|
||||
{
|
||||
verbose = true;
|
||||
if (check_replication())
|
||||
{
|
||||
unblock_all_nodes();
|
||||
@ -687,7 +772,8 @@ bool Mariadb_nodes::fix_replication()
|
||||
}
|
||||
|
||||
int attempts = 2;
|
||||
int attempts_with_cleanup = 2;
|
||||
int attempts_with_cleanup = 1;
|
||||
int attempts_with_revert = 1;
|
||||
|
||||
while (check_replication() && attempts > 0)
|
||||
{
|
||||
@ -698,6 +784,7 @@ bool Mariadb_nodes::fix_replication()
|
||||
|
||||
start_replication();
|
||||
close_connections();
|
||||
check_replication();
|
||||
|
||||
attempts--;
|
||||
|
||||
@ -708,16 +795,27 @@ bool Mariadb_nodes::fix_replication()
|
||||
printf("****** BACKEND IS STILL BROKEN! Trying to cleanup all nodes *****\n");
|
||||
stop_nodes();
|
||||
cleanup_db_nodes();
|
||||
prepare_servers();
|
||||
attempts_with_cleanup--;
|
||||
attempts = 2;
|
||||
sleep(30);
|
||||
sleep(10);
|
||||
start_replication();
|
||||
sleep(30);
|
||||
sleep(10);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("****** BACKEND IS STILL BROKEN! Exiting *****\n");
|
||||
return false;
|
||||
if (attempts_with_revert > 0)
|
||||
{
|
||||
printf("****** BACKEND IS STILL BROKEN! Trying to revert all nodes from snapshot *****\n");
|
||||
revert_nodes_snapshot();
|
||||
attempts_with_cleanup = 1;
|
||||
attempts = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("****** BACKEND IS STILL BROKEN! Exiting *****\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -727,6 +825,21 @@ bool Mariadb_nodes::fix_replication()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Mariadb_nodes::revert_nodes_snapshot()
|
||||
{
|
||||
char str[1024];
|
||||
bool rval = true;
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
sprintf(str, "%s clean --node-name %s_%03d", revert_snapshot_command, prefix, i);
|
||||
if (system(str))
|
||||
{
|
||||
rval = false;
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
int Galera_nodes::check_galera()
|
||||
{
|
||||
int res1 = 0;
|
||||
@ -910,38 +1023,59 @@ int Mariadb_nodes::execute_query_all_nodes(const char* sql)
|
||||
return local_result;
|
||||
}
|
||||
|
||||
int Mariadb_nodes::get_version(int i)
|
||||
{
|
||||
char * str;
|
||||
int ec;
|
||||
int local_result = 0;
|
||||
if (find_field(nodes[i], "SELECT @@version", "@@version", version[i]))
|
||||
{
|
||||
printf("Failed to get version: %s, trying ssh node and use MariaDB client\n", mysql_error(nodes[i]));
|
||||
str = ssh_node_output(i, "mysql --batch --silent -e \"select @@version\"", true, &ec);
|
||||
if (ec)
|
||||
{
|
||||
local_result++;
|
||||
printf("Failed to get version, node %d is broken\n", i);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(version[i], str);
|
||||
free(str);
|
||||
}
|
||||
|
||||
}
|
||||
strcpy(version_number[i], version[i]);
|
||||
str = strchr(version_number[i], '-');
|
||||
if (str != NULL)
|
||||
{
|
||||
str[0] = 0;
|
||||
}
|
||||
strcpy(version_major[i], version_number[i]);
|
||||
if (strstr(version_major[i], "5.") == version_major[i])
|
||||
{
|
||||
version_major[i][3] = 0;
|
||||
}
|
||||
if (strstr(version_major[i], "10.") == version_major[i])
|
||||
{
|
||||
version_major[i][4] = 0;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
printf("Node %s%d: %s\t %s \t %s\n", prefix, i, version[i], version_number[i], version_major[i]);
|
||||
}
|
||||
return local_result;
|
||||
}
|
||||
|
||||
int Mariadb_nodes::get_versions()
|
||||
{
|
||||
int local_result = 0;
|
||||
char * str;
|
||||
|
||||
v51 = false;
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
if ((local_result += find_field(nodes[i], (char *) "SELECT @@version", (char *) "@@version", version[i])))
|
||||
{
|
||||
printf("Failed to get version: %s\n", mysql_error(nodes[i]));
|
||||
}
|
||||
strcpy(version_number[i], version[i]);
|
||||
str = strchr(version_number[i], '-');
|
||||
if (str != NULL)
|
||||
{
|
||||
str[0] = 0;
|
||||
}
|
||||
strcpy(version_major[i], version_number[i]);
|
||||
if (strstr(version_major[i], "5.") == version_major[i])
|
||||
{
|
||||
version_major[i][3] = 0;
|
||||
}
|
||||
if (strstr(version_major[i], "10.") == version_major[i])
|
||||
{
|
||||
version_major[i][4] = 0;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
printf("Node %s%d: %s\t %s \t %s\n", prefix, i, version[i], version_number[i], version_major[i]);
|
||||
}
|
||||
local_result += get_version(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
@ -1129,7 +1263,7 @@ void Mariadb_nodes::close_active_connections()
|
||||
}
|
||||
|
||||
const char *sql =
|
||||
"select id from information_schema.processlist where id != @@pseudo_thread_id and user not in ('system user', 'repl')";
|
||||
"select id from information_schema.processlist where id != @@pseudo_thread_id and user not in ('system user', 'repl')";
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
@ -1152,6 +1286,7 @@ void Mariadb_nodes::close_active_connections()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Mariadb_nodes::stash_server_settings(int node)
|
||||
{
|
||||
ssh_node(node, "sudo mkdir /etc/my.cnf.d.backup", true);
|
||||
@ -1173,3 +1308,105 @@ void Mariadb_nodes::add_server_setting(int node, const char* setting)
|
||||
ssh_node_f(node, true, "sudo sed -i '$a [server]' /etc/my.cnf.d/server.cnf", setting);
|
||||
ssh_node_f(node, true, "sudo sed -i '$a %s' /etc/my.cnf.d/server.cnf", setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief extract_version_from_string Tries to find MariaDB server version number in the output of 'mysqld --version'
|
||||
* Function does not allocate any memory
|
||||
* @param version String returned by 'mysqld --version'
|
||||
* @return pointer to the string with version number
|
||||
*/
|
||||
char * extract_version_from_string(char * version)
|
||||
{
|
||||
int pos1 = 0;
|
||||
int pos2 = 0;
|
||||
int l = strlen(version);
|
||||
while ((! isdigit(version[pos1])) && (pos1 < l))
|
||||
{
|
||||
pos1++;
|
||||
}
|
||||
pos2 = pos1;
|
||||
while (((isdigit(version[pos2]) || version[pos2] == '.')) && (pos2 < l))
|
||||
{
|
||||
pos2++;
|
||||
}
|
||||
version[pos2] = '\0';
|
||||
return &version[pos1];
|
||||
}
|
||||
|
||||
int Mariadb_nodes::prepare_server(int i)
|
||||
{
|
||||
int ec;
|
||||
|
||||
char * version;
|
||||
char * version_digits;
|
||||
char * tmp_pass;
|
||||
char str1[1024];
|
||||
char str2[1024];
|
||||
|
||||
ssh_node(i, stop_db_command[i], true);
|
||||
sleep(5);
|
||||
ssh_node(i, "sed -i \"s/bind-address/#bind-address/g\" /etc/mysql/my.cnf.d/*.cnf", true);
|
||||
ssh_node(i, "ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/usr.sbin.mysqld; sudo service apparmor restart", true);
|
||||
version = ssh_node_output(i, "/usr/sbin/mysqld --version", false, &ec);
|
||||
if (ec == 0)
|
||||
{
|
||||
version_digits = extract_version_from_string(version);
|
||||
printf("Detected server version on node %d is %s\n", i, version_digits);
|
||||
|
||||
if (memcmp(version_digits, "5.", 2) == 0)
|
||||
{
|
||||
ssh_node(i, "sed -i \"s/binlog_row_image=full//\" /etc/my.cnf.d/*.cnf", true);
|
||||
}
|
||||
if (memcmp(version_digits, "5.7", 3) == 0)
|
||||
{
|
||||
// Disable 'validate_password' plugin, searach for random temporal
|
||||
// password in the log and reseting passord to empty string
|
||||
ssh_node(i, "/usr/sbin/mysqld --initialize; sudo chown -R mysql:mysql /var/lib/mysql", true);
|
||||
ssh_node(i, start_db_command[i], true);
|
||||
tmp_pass = ssh_node_output(i, "cat /var/log/mysqld.log | grep \"temporary password\" | sed -n -e 's/^.*: //p'", true, &ec);
|
||||
ssh_node_f(i, true, "mysqladmin -uroot -p'%s' password '%s'", tmp_pass, tmp_pass);
|
||||
ssh_node_f(i, false, "echo \"UNINSTALL PLUGIN validate_password\" | sudo mysql -uroot -p'%s'", tmp_pass);
|
||||
ssh_node(i, stop_db_command[i], true);
|
||||
ssh_node(i, start_db_command[i], true);
|
||||
ssh_node_f(i, true, "mysqladmin -uroot -p'%s' password ''", tmp_pass);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Executing mysql_install_db on node %d\n", i);
|
||||
ssh_node(i, "mysql_install_db; sudo chown -R mysql:mysql /var/lib/mysql", true);
|
||||
printf("Starting server on node %d\n", i);
|
||||
if (ssh_node(i, start_db_command[i], true))
|
||||
{
|
||||
printf("Server start on node %d failed\n", i);
|
||||
}
|
||||
}
|
||||
sleep(15);
|
||||
sprintf(str1, "%s/mdbci/backend/create_*_user.sql", test_dir);
|
||||
sprintf(str2, "%s/", access_homedir[i]);
|
||||
copy_to_node(i, str1, str2);
|
||||
sprintf(str1, "mysql < %s/create_repl_user.sql", access_homedir[i]);
|
||||
ssh_node(i, str1, true);
|
||||
sprintf(str1, "mysql < %s/create_skysql_user.sql", access_homedir[i]);
|
||||
ssh_node(i, str1, true);
|
||||
|
||||
free(version);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int Mariadb_nodes::prepare_servers()
|
||||
{
|
||||
int rval = 0;
|
||||
for (int i; i < N; i++)
|
||||
{
|
||||
if (prepare_server(i))
|
||||
{
|
||||
rval = 1;
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
@ -139,6 +139,18 @@ public:
|
||||
* @brief Open connctions to all backend nodes (to 'test' DB)
|
||||
* @return 0 in case of success
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief make_snapshot_command Command line to create a snapshot of all VMs
|
||||
*/
|
||||
char * take_snapshot_command;
|
||||
|
||||
/**
|
||||
* @brief revert_snapshot_command Command line to revert a snapshot of all VMs
|
||||
*/
|
||||
char * revert_snapshot_command;
|
||||
|
||||
int connect(int i);
|
||||
int connect();
|
||||
|
||||
/**
|
||||
@ -295,7 +307,14 @@ public:
|
||||
int execute_query_all_nodes(const char* sql);
|
||||
|
||||
/**
|
||||
* @brief execute 'SELECT @@version' against all nodes and store result in 'version' fied
|
||||
* @brief execute 'SELECT @@version' against one node and store result in 'version' field
|
||||
* @param i Node index
|
||||
* @return 0 in case of success
|
||||
*/
|
||||
int get_version(int i);
|
||||
|
||||
/**
|
||||
* @brief execute 'SELECT @@version' against all nodes and store result in 'version' field
|
||||
* @return 0 in case of success
|
||||
*/
|
||||
int get_versions();
|
||||
@ -377,6 +396,21 @@ public:
|
||||
*/
|
||||
void add_server_setting(int node, const char* setting);
|
||||
|
||||
/**
|
||||
* @brief revert_nodes_snapshot Execute MDBCI snapshot revert command for all nodes
|
||||
* @return true in case of success
|
||||
*/
|
||||
bool revert_nodes_snapshot();
|
||||
|
||||
/**
|
||||
* @brief prepare_server Initialize MariaDB setup (run mysql_install_db) and create test users
|
||||
* Tries to detect Mysql 5.7 installation and disable 'validate_password' pluging
|
||||
* @param i Node index
|
||||
* @return 0 in case of success
|
||||
*/
|
||||
virtual int prepare_server(int i);
|
||||
int prepare_servers();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -403,6 +437,13 @@ public:
|
||||
{
|
||||
return check_galera();
|
||||
}
|
||||
|
||||
//int prepare_galera_server(int i);
|
||||
|
||||
//virtual int prepare_server(int i)
|
||||
//{
|
||||
// return prepare_galera_server(i);
|
||||
//}
|
||||
};
|
||||
|
||||
#endif // MARIADB_NODES_H
|
||||
|
@ -1,15 +1,15 @@
|
||||
create user skysql@'%' identified by 'skysql';
|
||||
create user skysql@'localhost' identified by 'skysql';
|
||||
#create user skysql@'%' identified by 'skysql';
|
||||
#create user skysql@'localhost' identified by 'skysql';
|
||||
GRANT ALL PRIVILEGES ON *.* TO skysql@'%' WITH GRANT OPTION;
|
||||
GRANT ALL PRIVILEGES ON *.* TO skysql@'localhost' WITH GRANT OPTION;
|
||||
|
||||
create user maxuser@'%' identified by 'maxpwd';
|
||||
create user maxuser@'localhost' identified by 'maxpwd';
|
||||
#create user maxuser@'%' identified by 'maxpwd';
|
||||
#create user maxuser@'localhost' identified by 'maxpwd';
|
||||
GRANT ALL PRIVILEGES ON *.* TO maxuser@'%' WITH GRANT OPTION;
|
||||
GRANT ALL PRIVILEGES ON *.* TO maxuser@'localhost' WITH GRANT OPTION;
|
||||
|
||||
create user maxskysql@'%' identified by 'skysql';
|
||||
create user maxskysql@'localhost' identified by 'skysql';
|
||||
#create user maxskysql@'%' identified by 'skysql';
|
||||
#create user maxskysql@'localhost' identified by 'skysql';
|
||||
GRANT ALL PRIVILEGES ON *.* TO maxskysql@'%' WITH GRANT OPTION;
|
||||
GRANT ALL PRIVILEGES ON *.* TO maxskysql@'localhost' WITH GRANT OPTION;
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
N=$galera_N
|
||||
|
||||
x=`expr $N - 1`
|
||||
for i in $(seq 0 $x)
|
||||
do
|
||||
num=`printf "%03d" $i`
|
||||
sshkey_var=galera_"$num"_keyfile
|
||||
user_var=galera_"$num"_whoami
|
||||
IP_var=galera_"$num"_network
|
||||
|
||||
sshkey=${!sshkey_var}
|
||||
user=${!user_var}
|
||||
IP=${!IP_var}
|
||||
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo mysql_install_db; sudo chown -R mysql:mysql /var/lib/mysql"
|
||||
done
|
@ -1,61 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
x=`expr $node_N - 1`
|
||||
for i in $(seq 0 $x)
|
||||
do
|
||||
num=`printf "%03d" $i`
|
||||
sshkey_var=node_"$num"_keyfile
|
||||
user_var=node_"$num"_whoami
|
||||
IP_var=node_"$num"_network
|
||||
start_cmd_var=node_"$num"_start_db_command
|
||||
stop_cmd_var=node_"$num"_stop_db_command
|
||||
|
||||
sshkey=${!sshkey_var}
|
||||
user=${!user_var}
|
||||
IP=${!IP_var}
|
||||
start_cmd=${!start_cmd_var}
|
||||
stop_cmd=${!stop_cmd_var}
|
||||
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo $stop_cmd"
|
||||
sleep 5
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP 'sudo sed -i "s/bind-address/#bind-address/g" /etc/mysql/my.cnf'
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP 'sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/usr.sbin.mysqld; sudo service apparmor restart'
|
||||
|
||||
mysql_version=`ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP 'mysql --version'`
|
||||
echo $mysql_version | grep "5\."
|
||||
if [ $? == 0 ] ; then
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo sed -i \"s/binlog_row_image=full//\" /etc/my.cnf.d/*.cnf"
|
||||
fi
|
||||
|
||||
echo $mysql_version | grep "5\.7"
|
||||
if [ $? == 0 ] ; then
|
||||
# ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo sed -i \"s/## x001/validate-password=OFF/\" /etc/my.cnf.d/*.cnf"
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo mysqld --initialize; sudo chown -R mysql:mysql /var/lib/mysql"
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo $start_cmd"
|
||||
|
||||
mysql_root_password=`ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo cat /var/log/mysqld.log | grep \"temporary password\" | sed -n -e 's/^.*: //p'"`
|
||||
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo mysqladmin -uroot -p'$mysql_root_password' password '$mysql_root_password'"
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "echo \"UNINSTALL PLUGIN validate_password\" | sudo mysql -uroot -p'$mysql_root_password' "
|
||||
|
||||
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo $stop_cmd"
|
||||
# ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo sed -i \"s/## x001/validate-password=OFF/\" /etc/my.cnf.d/*.cnf"
|
||||
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo $start_cmd"
|
||||
|
||||
# mysql_root_password=`ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo cat /var/log/mysqld.log | grep \"temporary password\" | sed -n -e 's/^.*: //p'"`
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "echo \"show plugins\" | sudo mysql -uroot -p'$mysql_root_password' "
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo mysqladmin -uroot -p'$mysql_root_password' password ''"
|
||||
# ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo $start_cmd"
|
||||
else
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo mysql_install_db; sudo chown -R mysql:mysql /var/lib/mysql"
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo $start_cmd"
|
||||
fi
|
||||
sleep 15
|
||||
scp -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${script_dir}/create_*_user.sql $user@$IP://home/$user/
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo mysql < /home/$user/create_repl_user.sql"
|
||||
ssh -i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $user@$IP "sudo mysql < /home/$user/create_skysql_user.sql"
|
||||
done
|
@ -1,9 +0,0 @@
|
||||
. ${script_dir}/set_env.sh $name
|
||||
|
||||
${script_dir}/backend/setup_repl.sh
|
||||
${script_dir}/backend/galera/setup_galera.sh
|
||||
|
||||
${script_dir}/configure_core.sh
|
||||
|
||||
rm ~/vagrant_lock
|
||||
|
@ -52,7 +52,7 @@ if [ $? != 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp ~/build-scripts/team_keys .
|
||||
#cp ~/build-scripts/team_keys .
|
||||
${mdbci_dir}/mdbci public_keys --key ${team_keys} $name
|
||||
|
||||
rm ~/vagrant_lock
|
||||
|
@ -58,17 +58,15 @@ export name=`echo $name | sed "s/?//g"`
|
||||
|
||||
. ${script_dir}/configure_log_dir.sh
|
||||
|
||||
cd ${script_dir}/..
|
||||
|
||||
cmake . -DBUILDNAME=$name -DCMAKE_BUILD_TYPE=Debug
|
||||
make
|
||||
|
||||
${script_dir}/create_config.sh
|
||||
res=$?
|
||||
|
||||
if [ $res == 0 ] ; then
|
||||
. ${script_dir}/configure_backend.sh
|
||||
${mdbci_dir}/mdbci snapshot take --path-to-nodes $name --snapshot-name clean
|
||||
# . ${script_dir}/configure_backend.sh
|
||||
. ${script_dir}/set_env.sh $name
|
||||
cd ${script_dir}/..
|
||||
cmake . -DBUILDNAME=$name -DCMAKE_BUILD_TYPE=Debug
|
||||
make
|
||||
|
||||
if [ ! -z "${named_test}" ] ; then
|
||||
./${named_test}
|
||||
@ -82,6 +80,7 @@ if [ $res == 0 ] ; then
|
||||
rm ~/vagrant_lock
|
||||
exit 1
|
||||
fi
|
||||
${mdbci_dir}/mdbci snapshot take --path-to-nodes $name --snapshot-name clean
|
||||
ctest -VV -D Nightly ${test_set}
|
||||
fi
|
||||
|
||||
|
65
maxscale-system-test/mdbci/templates/nogalera.json.template
Normal file
65
maxscale-system-test/mdbci/templates/nogalera.json.template
Normal file
@ -0,0 +1,65 @@
|
||||
{
|
||||
"node_000" :
|
||||
{
|
||||
"hostname" : "node000",
|
||||
"box" : "${backend_box}",
|
||||
"memory_size" : "${vm_memory}",
|
||||
"product" : {
|
||||
"name": "${product}",
|
||||
"version": "${version}",
|
||||
"cnf_template" : "server1.cnf",
|
||||
"cnf_template_path": "${cnf_path}"
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"node_001" :
|
||||
{
|
||||
"hostname" : "node001",
|
||||
"box" : "${backend_box}",
|
||||
"memory_size" : "${vm_memory}",
|
||||
"product" : {
|
||||
"name": "${product}",
|
||||
"version": "${version}",
|
||||
"cnf_template" : "server2.cnf",
|
||||
"cnf_template_path": "${cnf_path}"
|
||||
}
|
||||
},
|
||||
|
||||
"node_002" :
|
||||
{
|
||||
"hostname" : "node002",
|
||||
"box" : "${backend_box}",
|
||||
"memory_size" : "${vm_memory}",
|
||||
"product" : {
|
||||
"name": "${product}",
|
||||
"version": "${version}",
|
||||
"cnf_template" : "server3.cnf",
|
||||
"cnf_template_path": "${cnf_path}"
|
||||
}
|
||||
},
|
||||
|
||||
"node_003" :
|
||||
{
|
||||
"hostname" : "node003",
|
||||
"box" : "${backend_box}",
|
||||
"memory_size" : "${vm_memory}",
|
||||
"product" : {
|
||||
"name": "${product}",
|
||||
"version": "${version}",
|
||||
"cnf_template" : "server4.cnf",
|
||||
"cnf_template_path": "${cnf_path}"
|
||||
}
|
||||
},
|
||||
|
||||
"maxscale" :
|
||||
{
|
||||
"hostname" : "maxscale",
|
||||
"box" : "${box}",
|
||||
"memory_size" : "${vm_memory}",
|
||||
"product" : {
|
||||
"name": "maxscale"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -203,13 +203,17 @@ TestConnections::TestConnections(int argc, char *argv[]):
|
||||
galera = new Galera_nodes("galera", test_dir, verbose);
|
||||
//galera->use_ipv6 = use_ipv6;
|
||||
galera->use_ipv6 = false;
|
||||
galera->take_snapshot_command = take_snapshot_command;
|
||||
galera->revert_snapshot_command = revert_snapshot_command;
|
||||
}
|
||||
else
|
||||
{
|
||||
galera = repl;
|
||||
galera = NULL;
|
||||
}
|
||||
|
||||
repl->use_ipv6 = use_ipv6;
|
||||
repl->take_snapshot_command = take_snapshot_command;
|
||||
repl->revert_snapshot_command = revert_snapshot_command;
|
||||
|
||||
maxscales = new Maxscales("maxscale", test_dir, verbose);
|
||||
|
||||
@ -551,8 +555,14 @@ void TestConnections::process_template(int m, const char *template_name, const c
|
||||
mdn[0] = repl;
|
||||
mdn[1] = galera;
|
||||
int i, j;
|
||||
int mdn_n = 1;
|
||||
|
||||
for (j = 0; j < 2; j++)
|
||||
if (galera == NULL)
|
||||
{
|
||||
mdn_n =1;
|
||||
}
|
||||
|
||||
for (j = 0; j < mdn_n; j++)
|
||||
{
|
||||
for (i = 0; i < mdn[j]->N; i++)
|
||||
{
|
||||
@ -657,6 +667,8 @@ int TestConnections::copy_mariadb_logs(Mariadb_nodes * repl, char * prefix)
|
||||
int exit_code;
|
||||
char str[4096];
|
||||
|
||||
if (repl == NULL) return local_result;
|
||||
|
||||
sprintf(str, "mkdir -p LOGS/%s", test_name);
|
||||
system(str);
|
||||
for (i = 0; i < repl->N; i++)
|
||||
|
Loading…
x
Reference in New Issue
Block a user