Copy test logs in parallel
The log copying is now done in parallel for all VMs.
This commit is contained in:
@ -698,43 +698,38 @@ void TestConnections::init_maxscale(int m)
|
||||
}
|
||||
}
|
||||
|
||||
void TestConnections::copy_one_mariadb_log(int i, std::string filename)
|
||||
{
|
||||
int exit_code;
|
||||
char* mariadb_log = repl->ssh_node_output(i, "cat /var/lib/mysql/*.err 2>/dev/null", true, &exit_code);
|
||||
FILE* f = fopen(filename.c_str(), "w");
|
||||
|
||||
int TestConnections::copy_mariadb_logs(Mariadb_nodes * repl, char * prefix)
|
||||
if (f != NULL)
|
||||
{
|
||||
fwrite(mariadb_log, sizeof(char), strlen(mariadb_log), f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
free(mariadb_log);
|
||||
}
|
||||
|
||||
int TestConnections::copy_mariadb_logs(Mariadb_nodes* repl, const char* prefix, std::vector<std::thread>& threads)
|
||||
{
|
||||
int local_result = 0;
|
||||
char * mariadb_log;
|
||||
FILE * f;
|
||||
int i;
|
||||
int exit_code;
|
||||
char str[4096];
|
||||
|
||||
if (repl == NULL)
|
||||
if (repl)
|
||||
{
|
||||
return local_result;
|
||||
}
|
||||
|
||||
sprintf(str, "mkdir -p LOGS/%s", test_name);
|
||||
system(str);
|
||||
for (i = 0; i < repl->N; i++)
|
||||
{
|
||||
if (strcmp(repl->IP[i], "127.0.0.1") != 0) // Do not copy MariaDB logs in case of local backend
|
||||
for (int i = 0; i < repl->N; i++)
|
||||
{
|
||||
mariadb_log = repl->ssh_node_output(i, (char *) "cat /var/lib/mysql/*.err", true, &exit_code);
|
||||
sprintf(str, "LOGS/%s/%s%d_mariadb_log", test_name, prefix, i);
|
||||
f = fopen(str, "w");
|
||||
if (f != NULL)
|
||||
if (strcmp(repl->IP[i], "127.0.0.1") != 0) // Do not copy MariaDB logs in case of local backend
|
||||
{
|
||||
fwrite(mariadb_log, sizeof(char), strlen(mariadb_log), f);
|
||||
fclose(f);
|
||||
char str[4096];
|
||||
sprintf(str, "LOGS/%s/%s%d_mariadb_log", test_name, prefix, i);
|
||||
threads.emplace_back(&TestConnections::copy_one_mariadb_log, this, i, str);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error writing MariaDB log");
|
||||
local_result = 1;
|
||||
}
|
||||
free(mariadb_log);
|
||||
}
|
||||
}
|
||||
|
||||
return local_result;
|
||||
}
|
||||
|
||||
@ -742,10 +737,16 @@ int TestConnections::copy_all_logs()
|
||||
{
|
||||
set_timeout(300);
|
||||
|
||||
char str[PATH_MAX + 1];
|
||||
sprintf(str, "mkdir -p LOGS/%s", test_name);
|
||||
system(str);
|
||||
|
||||
std::vector<std::thread> threads;
|
||||
|
||||
if (!no_backend_log_copy)
|
||||
{
|
||||
copy_mariadb_logs(repl, (char *) "node");
|
||||
copy_mariadb_logs(galera, (char *) "galera");
|
||||
copy_mariadb_logs(repl, "node", threads);
|
||||
copy_mariadb_logs(galera, "galera", threads);
|
||||
}
|
||||
|
||||
int rv = 0;
|
||||
@ -755,6 +756,11 @@ int TestConnections::copy_all_logs()
|
||||
rv = copy_maxscale_logs(0);
|
||||
}
|
||||
|
||||
for (auto& a: threads)
|
||||
{
|
||||
a.join();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
int TestConnections::copy_maxscale_logs(double timestamp)
|
||||
|
||||
@ -9,6 +9,8 @@
|
||||
#include <sys/time.h>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
|
||||
typedef std::set<std::string> StringSet;
|
||||
|
||||
@ -128,7 +130,7 @@ public:
|
||||
* @param prefix file name prefix
|
||||
* @return 0 if success
|
||||
*/
|
||||
int copy_mariadb_logs(Mariadb_nodes *repl, char * prefix);
|
||||
int copy_mariadb_logs(Mariadb_nodes* repl, const char* prefix, std::vector<std::thread>& threads);
|
||||
|
||||
/**
|
||||
* @brief no_backend_log_copy if true logs from backends are not copied
|
||||
@ -524,6 +526,7 @@ public:
|
||||
|
||||
private:
|
||||
void report_result(const char *format, va_list argp);
|
||||
void copy_one_mariadb_log(int i, std::string filename);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user