refactored tests (#147)

This commit is contained in:
Timofey Turenko
2017-12-08 12:23:04 +02:00
committed by GitHub
parent c6daf8c26b
commit 3c88bf1ec6
253 changed files with 5265 additions and 3649 deletions

View File

@ -20,7 +20,7 @@
@endverbatim
* - make script non-executable
* - block and unblock node1
* - check error log for 'The file cannot be executed: /home/$maxscale_access_user/script.sh' error
* - check error log for 'The file cannot be executed: /home/$maxscales->access_user[0]/script.sh' error
* - check if Maxscale still alive
*/
@ -31,10 +31,10 @@
void test_script_monitor(TestConnections* Test, Mariadb_nodes* nodes, char * expected_filename)
{
Test->set_timeout(200);
Test->ssh_maxscale(true, "cd %s;"
"truncate -s 0 script_output;"
"chown maxscale:maxscale script_output",
Test->maxscale_access_homedir);
Test->maxscales->ssh_node_f(0, true, "cd %s;"
"truncate -s 0 script_output;"
"chown maxscale:maxscale script_output",
Test->maxscales->access_homedir[0]);
sleep(10);
Test->tprintf("Block master node");
@ -63,10 +63,10 @@ void test_script_monitor(TestConnections* Test, Mariadb_nodes* nodes, char * exp
Test->tprintf("Comparing results");
if (Test->ssh_maxscale(false, "diff %s/script_output %s", Test->maxscale_access_homedir,
expected_filename) != 0)
if (Test->maxscales->ssh_node_f(0, false, "diff %s/script_output %s", Test->maxscales->access_homedir[0],
expected_filename) != 0)
{
Test->ssh_maxscale(true, "cat %s/script_output", Test->maxscale_access_homedir);
Test->maxscales->ssh_node_f(0, true, "cat %s/script_output", Test->maxscales->access_homedir[0]);
Test->add_result(1, "Wrong script output!");
}
else
@ -83,16 +83,16 @@ int main(int argc, char *argv[])
Test->tprintf("Creating script on Maxscale machine");
Test->ssh_maxscale(false,
"%s rm -rf %s/script; mkdir %s/script; echo \"echo \\$* >> %s/script_output\" > %s/script/script.sh; \
Test->maxscales->ssh_node_f(0, false,
"%s rm -rf %s/script; mkdir %s/script; echo \"echo \\$* >> %s/script_output\" > %s/script/script.sh; \
chmod a+x %s/script/script.sh; chmod a+x %s; %s chown maxscale:maxscale %s/script -R",
Test->maxscale_access_sudo, Test->maxscale_access_homedir,
Test->maxscale_access_homedir, Test->maxscale_access_homedir,
Test->maxscale_access_homedir, Test->maxscale_access_homedir, Test->maxscale_access_homedir,
Test->maxscale_access_sudo,
Test->maxscale_access_homedir);
Test->maxscales->access_sudo[0], Test->maxscales->access_homedir[0],
Test->maxscales->access_homedir[0], Test->maxscales->access_homedir[0],
Test->maxscales->access_homedir[0], Test->maxscales->access_homedir[0], Test->maxscales->access_homedir[0],
Test->maxscales->access_sudo[0],
Test->maxscales->access_homedir[0]);
Test->restart_maxscale();
Test->maxscales->restart_maxscale(0);
FILE * f;
f = fopen("script_output_expected", "w");
@ -144,18 +144,19 @@ int main(int argc, char *argv[])
char str[2048];
sprintf(str,
"scp -i %s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet script_output_expected* %s@%s:%s/",
Test->maxscale_keyfile, Test->maxscale_access_user, Test->maxscale_IP, Test->maxscale_access_homedir);
Test->maxscales->sshkey[0], Test->maxscales->access_user[0], Test->maxscales->IP[0],
Test->maxscales->access_homedir[0]);
system(str);
sprintf(str, "%s/script_output_expected", Test->maxscale_access_homedir);
sprintf(str, "%s/script_output_expected", Test->maxscales->access_homedir[0]);
test_script_monitor(Test, Test->repl, str);
sprintf(str, "%s/script_output_expected_galera", Test->maxscale_access_homedir);
sprintf(str, "%s/script_output_expected_galera", Test->maxscales->access_homedir[0]);
test_script_monitor(Test, Test->galera, str);
Test->set_timeout(200);
Test->tprintf("Making script non-executable");
Test->ssh_maxscale(true, "chmod a-x %s/script/script.sh", Test->maxscale_access_homedir);
Test->maxscales->ssh_node_f(0, true, "chmod a-x %s/script/script.sh", Test->maxscales->access_homedir[0]);
sleep(3);
@ -171,10 +172,10 @@ int main(int argc, char *argv[])
sleep(15);
Test->tprintf("Cheching Maxscale logs");
Test->check_log_err((char *) "Cannot execute file" , true);
Test->check_log_err(0, (char *) "Cannot execute file" , true);
Test->tprintf("checking if Maxscale is alive");
Test->check_maxscale_alive();
Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;