21 #define DEFAULT_PREFIX "c:/atrt"
26 #include <my_getopt.h>
29 #include <NdbAutoPtr.hpp>
31 #include <SysLogHandler.hpp>
32 #include <FileLogHandler.hpp>
36 #define PATH_SEPARATOR DIR_SEPARATOR
39 static const char progname[] =
"ndb_atrt";
40 static const char * g_gather_progname =
"atrt-gather-result.sh";
41 static const char * g_analyze_progname =
"atrt-analyze-result.sh";
42 static const char * g_setup_progname =
"atrt-setup.sh";
44 static const char * g_log_filename = 0;
45 static const char * g_test_case_filename = 0;
46 static const char * g_report_filename = 0;
48 static int g_do_setup = 0;
49 static int g_do_deploy = 0;
50 static int g_do_sshx = 0;
51 static int g_do_start = 0;
52 static int g_do_quit = 0;
54 static int g_help = 0;
55 static int g_verbosity = 1;
56 static FILE * g_report_file = 0;
57 static FILE * g_test_case_file = stdin;
58 static int g_mode = 0;
62 const char * g_user = 0;
63 int g_baseport = 10000;
66 int g_default_ports = 0;
70 const char * g_cwd = 0;
71 const char * g_basedir = 0;
72 const char * g_my_cnf = 0;
73 const char * g_prefix = 0;
74 const char * g_prefix1 = 0;
75 const char * g_clusters = 0;
77 const char *save_file = 0;
78 const char *save_group_suffix = 0;
80 char * g_env_path = 0;
81 const char* g_mysqld_host = 0;
85 {
"help",
'?',
"Display this help and exit.",
86 (uchar **) &g_help, (uchar **) &g_help,
87 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
88 {
"version",
'V',
"Output version information and exit.", 0, 0, 0,
89 GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
90 {
"clusters", 256,
"Cluster",
91 (uchar **) &g_clusters, (uchar **) &g_clusters,
92 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
93 {
"mysqld", 256,
"atrt mysqld",
94 (uchar **) &g_mysqld_host, (uchar **) &g_mysqld_host,
95 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
96 {
"replicate", 1024,
"replicate",
97 (uchar **) &g_dummy, (uchar **) &g_dummy,
98 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
99 {
"log-file", 256,
"log-file",
100 (uchar **) &g_log_filename, (uchar **) &g_log_filename,
101 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
102 {
"testcase-file",
'f',
"testcase-file",
103 (uchar **) &g_test_case_filename, (uchar **) &g_test_case_filename,
104 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
105 {
"report-file",
'r',
"report-file",
106 (uchar **) &g_report_filename, (uchar **) &g_report_filename,
107 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
108 {
"basedir", 256,
"Base path",
109 (uchar **) &g_basedir, (uchar **) &g_basedir,
110 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
111 {
"baseport", 256,
"Base port",
112 (uchar **) &g_baseport, (uchar **) &g_baseport,
113 0, GET_INT, REQUIRED_ARG, g_baseport, 0, 0, 0, 0, 0},
114 {
"prefix", 256,
"mysql install dir",
115 (uchar **) &g_prefix, (uchar **) &g_prefix,
116 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
117 {
"prefix1", 256,
"mysql install dir 1",
118 (uchar **) &g_prefix1, (uchar **) &g_prefix1,
119 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
120 {
"verbose",
'v',
"Verbosity",
121 (uchar **) &g_verbosity, (uchar **) &g_verbosity,
122 0, GET_INT, REQUIRED_ARG, g_verbosity, 0, 0, 0, 0, 0},
123 {
"configure", 256,
"configure",
124 (uchar **) &g_do_setup, (uchar **) &g_do_setup,
125 0, GET_INT, REQUIRED_ARG, g_do_setup, 0, 0, 0, 0, 0 },
126 {
"deploy", 256,
"deploy",
127 (uchar **) &g_do_deploy, (uchar **) &g_do_deploy,
128 0, GET_INT, REQUIRED_ARG, g_do_deploy, 0, 0, 0, 0, 0 },
129 {
"sshx", 256,
"sshx",
130 (uchar **) &g_do_sshx, (uchar **) &g_do_sshx,
131 0, GET_INT, REQUIRED_ARG, g_do_sshx, 0, 0, 0, 0, 0 },
132 {
"start", 256,
"start",
133 (uchar **) &g_do_start, (uchar **) &g_do_start,
134 0, GET_INT, REQUIRED_ARG, g_do_start, 0, 0, 0, 0, 0 },
135 {
"fqpn", 256,
"Fully qualified path-names ",
136 (uchar **) &g_fqpn, (uchar **) &g_fqpn,
137 0, GET_INT, REQUIRED_ARG, g_fqpn, 0, 0, 0, 0, 0 },
138 {
"fix-nodeid", 256,
"Fix nodeid for each started process ",
139 (uchar **) &g_fix_nodeid, (uchar **) &g_fix_nodeid,
140 0, GET_INT, REQUIRED_ARG, g_fqpn, 0, 0, 0, 0, 0 },
141 {
"default-ports", 256,
"Use default ports when possible",
142 (uchar **) &g_default_ports, (uchar **) &g_default_ports,
143 0, GET_INT, REQUIRED_ARG, g_default_ports, 0, 0, 0, 0, 0 },
144 {
"mode", 256,
"Mode 0=interactive 1=regression 2=bench",
145 (uchar **) &g_mode, (uchar **) &g_mode,
146 0, GET_INT, REQUIRED_ARG, g_mode, 0, 0, 0, 0, 0 },
147 {
"quit", 256,
"Quit before starting tests",
148 (uchar **) &g_do_quit, (uchar **) &g_do_quit,
149 0, GET_BOOL, NO_ARG, g_do_quit, 0, 0, 0, 0, 0 },
150 {
"mt", 256,
"Use ndbmtd (0 = never, 1 = round-robin, 2 = only)",
151 (uchar **) &g_mt, (uchar **) &g_mt,
152 0, GET_INT, REQUIRED_ARG, g_mt, 0, 0, 0, 0, 0 },
153 { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
156 const int p_ndb = atrt_process::AP_NDB_MGMD | atrt_process::AP_NDBD;
157 const int p_servers = atrt_process::AP_MYSQLD;
158 const int p_clients = atrt_process::AP_CLIENT | atrt_process::AP_NDB_API;
161 main(
int argc,
char ** argv)
171 g_logger.
enable(Logger::LL_ALL);
174 if(!parse_args(argc, argv))
176 g_logger.
critical(
"Failed to parse arguments");
180 g_logger.
info(
"Starting...");
181 g_config.m_generated =
false;
182 g_config.m_replication = g_replicate;
183 if (!setup_config(g_config, g_mysqld_host))
185 g_logger.
critical(
"Failed to setup configuration");
189 if (!configure(g_config, g_do_setup))
191 g_logger.
critical(
"Failed to configure");
195 g_logger.
info(
"Setting up directories...");
196 if (!setup_directories(g_config, g_do_setup))
198 g_logger.
critical(
"Failed to set up directories");
204 g_logger.
info(
"Setting up files...");
205 if (!setup_files(g_config, g_do_setup, g_do_sshx))
207 g_logger.
critical(
"Failed to set up files");
214 if (!deploy(g_do_deploy, g_config))
216 g_logger.
critical(
"Failed to deploy");
227 if(!setup_hosts(g_config))
229 g_logger.
critical(
"Failed to setup hosts");
235 g_logger.
info(
"Starting xterm-ssh");
236 if (!sshx(g_config, g_do_sshx))
238 g_logger.
critical(
"Failed to start xterm-ssh");
242 g_logger.
info(
"Done...sleeping");
247 g_logger.
critical(
"Failed to do ssh command");
251 NdbSleep_SecSleep(1);
257 g_logger.
info(
"Connecting to hosts...");
258 if(!connect_hosts(g_config))
260 g_logger.
critical(
"Failed to connect to CPCD on hosts");
265 if (g_do_start && !g_test_case_filename)
267 g_logger.
info(
"Starting server processes: %x", g_do_start);
268 if (!start(g_config, g_do_start))
270 g_logger.
critical(
"Failed to start server processes");
274 if (!setup_db(g_config))
276 g_logger.
critical(
"Failed to setup database");
280 g_logger.
info(
"Done...sleeping");
285 g_logger.
info(
"Exiting");
289 NdbSleep_SecSleep(1);
301 g_logger.
debug(
"Entering main loop");
302 while(!feof(g_test_case_file))
310 g_logger.
info(
"(Re)starting server processes...");
312 if(!stop_processes(g_config, ~0))
314 g_logger.
critical(
"Failed to stop all processes");
318 if (!setup_directories(g_config, 2))
320 g_logger.
critical(
"Failed to setup directories");
324 if (!setup_files(g_config, 2, 1))
326 g_logger.
critical(
"Failed to setup files");
330 if(!setup_hosts(g_config))
332 g_logger.
critical(
"Failed to setup hosts");
336 g_logger.
debug(
"Setup complete, starting servers");
337 if (!start(g_config, p_ndb | p_servers))
339 g_logger.
critical(
"Failed to start server processes");
340 g_logger.
info(
"Gathering logs and saving them as test %u", test_no);
343 if(!gather_result(g_config, &tmp))
345 g_logger.
critical(
"Failed to gather results");
349 if(g_report_file != 0)
351 fprintf(g_report_file,
"%s ; %d ; %d ; %d\n",
352 "start servers", test_no, ERR_FAILED_TO_START, 0);
353 fflush(g_report_file);
357 resdir.
assfmt(
"result.%d", test_no);
358 remove_dir(resdir.
c_str(),
true);
360 if(rename(
"result", resdir.
c_str()) != 0)
362 g_logger.
critical(
"Failed to rename %s as %s",
363 "result", resdir.
c_str());
369 if (!setup_db(g_config))
371 g_logger.
critical(
"Failed to setup database");
375 g_logger.
info(
"All servers start completed");
380 if(!read_test_case(g_test_case_file, test_case, lineno))
383 g_logger.
info(
"#%d - %s %s",
385 test_case.m_command.
c_str(), test_case.m_args.
c_str());
388 if(!setup_test_case(g_config, test_case))
390 g_logger.
critical(
"Failed to setup test case");
394 if(!start_processes(g_config, p_clients))
396 g_logger.
critical(
"Failed to start client processes");
402 const time_t start = time(0);
406 if(!update_status(g_config, atrt_process::AP_ALL))
408 g_logger.
critical(
"Failed to get updated status for all processes");
412 if(is_running(g_config, p_ndb) != 2)
414 result = ERR_NDB_FAILED;
418 if(is_running(g_config, p_servers) != 2)
420 result = ERR_SERVERS_FAILED;
424 if(is_running(g_config, p_clients) == 0)
431 result = ERR_COMMAND_FAILED;
436 if(now > (start + test_case.m_max_time))
438 g_logger.
debug(
"Timed out");
439 result = ERR_MAX_TIME_ELAPSED;
440 g_logger.
info(
"Timeout '%s' after %ld seconds", test_case.m_name.
c_str(), test_case.m_max_time);
443 NdbSleep_SecSleep(1);
446 const time_t elapsed = time(0) - start;
448 if(!stop_processes(g_config, p_clients))
450 g_logger.
critical(
"Failed to stop client processes");
454 int tmp, *rp = result ? &tmp : &result;
455 if(!gather_result(g_config, rp))
457 g_logger.
critical(
"Failed to gather result after test run");
461 g_logger.
info(
"#%d %s(%d)",
463 (result == 0 ?
"OK" :
"FAILED"), result);
465 if(g_report_file != 0)
467 fprintf(g_report_file,
"%s ; %d ; %d ; %ld\n",
468 test_case.m_name.
c_str(), test_no, result, elapsed);
469 fflush(g_report_file);
472 if(g_mode == 0 && result)
475 (
"Encountered failed test in interactive mode - terminating");
480 resdir.
assfmt(
"result.%d", test_no);
481 remove_dir(resdir.
c_str(),
true);
483 if(test_case.m_report || g_mode == 2 || (g_mode && result))
485 if(rename(
"result", resdir.
c_str()) != 0)
487 g_logger.
critical(
"Failed to rename %s as %s",
488 "result", resdir.
c_str());
494 remove_dir(
"result",
true);
497 if (reset_config(g_config))
510 if(g_report_file != 0){
511 fclose(g_report_file);
515 if(g_test_case_file != 0 && g_test_case_file != stdin){
516 fclose(g_test_case_file);
517 g_test_case_file = 0;
520 g_logger.
info(
"Stopping all processes, result: %d", return_code);
521 stop_processes(g_config, atrt_process::AP_ALL);
527 get_one_option(
int arg,
const struct my_option * opt,
char *
value)
533 g_replicate.
append(value);
540 parse_args(
int argc,
char** argv)
543 if (getcwd(buf,
sizeof(buf)) == 0)
545 g_logger.
error(
"Unable to get current working directory");
553 mycnf.
append(DIR_SEPARATOR);
555 if (argc > 1 && lstat(argv[argc-1], &sbuf) == 0)
557 mycnf.
append(argv[argc-1]);
562 if (lstat(mycnf.c_str(), &sbuf) != 0)
564 g_logger.
error(
"Could not find out which config file to use! "
565 "Pass it as last argument to atrt: 'atrt <config file>' "
566 "(default: '%s')", mycnf.c_str());
571 to_fwd_slashes((
char*)g_cwd);
573 g_logger.
info(
"Bootstrapping using %s", mycnf.c_str());
575 const char *groups[] = {
"atrt", 0 };
576 int ret = load_defaults(mycnf.c_str(), groups, &argc, &argv);
580 g_logger.
error(
"Failed to load defaults, returned (%d)",ret);
584 save_file = my_defaults_file;
585 save_group_suffix = my_defaults_group_suffix;
587 if (my_defaults_extra_file)
589 g_logger.
error(
"--defaults-extra-file(%s) is not supported...",
590 my_defaults_extra_file);
594 ret = handle_options(&argc, &argv, g_options, get_one_option);
597 g_logger.
error(
"handle_options failed, ret: %d, argc: %d, *argv: '%s'",
604 const char * arg = argv[argc-2];
609 g_do_setup = (g_do_setup == 0) ? 1 : g_do_setup;
621 g_do_sshx = atrt_process::AP_CLIENT | atrt_process::AP_NDB_API;
624 g_do_sshx = atrt_process::AP_ALL;
630 g_do_start = p_ndb | p_servers;
642 g_logger.
error(
"Unknown switch '%c'", *arg);
649 if(g_log_filename != 0)
656 int tmp = Logger::LL_WARNING - g_verbosity;
657 tmp = (tmp < Logger::LL_DEBUG ? Logger::LL_DEBUG : tmp);
658 g_logger.
disable(Logger::LL_ALL);
659 g_logger.
enable(Logger::LL_ON);
666 g_logger.
info(
"basedir not specified, using %s", g_basedir);
670 g_logger.
info(
"basedir, %s", g_basedir);
675 g_prefix = DEFAULT_PREFIX;
683 const char* env = getenv(
"PATH");
684 if (env && strlen(env))
686 tmp.
assfmt(
"PATH=%s:%s/mysql-test/ndb",
691 tmp.
assfmt(
"PATH=%s/mysql-test/ndb", g_prefix);
694 g_env_path = strdup(tmp.
c_str());
700 my_print_help(g_options);
701 my_print_variables(g_options);
705 if(g_test_case_filename)
707 g_test_case_file = fopen(g_test_case_filename,
"r");
708 if(g_test_case_file == 0)
710 g_logger.
critical(
"Unable to open file: %s", g_test_case_filename);
717 g_do_start = p_ndb | p_servers;
724 g_logger.
critical(
"ssx specified...not possible with testfile");
729 g_logger.
info(
"No test case file given with -f <test file>, "
730 "running in interactive mode from stdin");
737 tmp.
append(PATH_SEPARATOR);
739 if (lstat(tmp.
c_str(), &sbuf) != 0)
741 g_logger.
error(
"Could not find a my.cnf file in the basedir '%s', "
742 "you probably need to configure it with "
743 "'atrt --configure=1 <config_file>'", g_basedir);
747 if (!S_ISREG(sbuf.st_mode))
749 g_logger.
error(
"%s is not a regular file", tmp.
c_str());
753 g_my_cnf = strdup(tmp.
c_str());
758 g_my_cnf = strdup(mycnf.c_str());
761 g_logger.
info(
"Using --prefix=\"%s\"", g_prefix);
765 g_logger.
info(
"Using --prefix1=\"%s\"", g_prefix1);
770 if(g_report_filename)
772 g_report_file = fopen(g_report_filename,
"w");
773 if(g_report_file == 0)
775 g_logger.
critical(
"Unable to create report file: %s", g_report_filename);
782 g_logger.
critical(
"No clusters specified");
787 g_user = strdup(getenv(
"LOGNAME"));
791 g_logger.
info(
"No default user specified, will use 'sakila'.");
792 g_logger.
info(
"Please set LOGNAME environment variable for other username");
799 for(
size_t i = 0;
i<config.m_hosts.size();
i++){
800 if(config.m_hosts[
i]->m_cpcd->connect() != 0){
801 g_logger.
error(
"Unable to connect to cpc %s:%d",
802 config.m_hosts[
i]->m_cpcd->getHost(),
803 config.m_hosts[
i]->m_cpcd->getPort());
806 g_logger.
debug(
"Connected to %s:%d",
807 config.m_hosts[
i]->m_cpcd->getHost(),
808 config.m_hosts[
i]->m_cpcd->getPort());
818 g_logger.
critical(
"Unable to create mgm handle");
823 proc.m_options.m_loaded.get(
"--PortNumber=", &val);
828 g_logger.
critical(
"Unable to create parse connectstring");
834 proc.m_ndb_mgm_handle = handle;
838 g_logger.
critical(
"Unable to connect to ndb mgm %s", tmp.
c_str());
844 for(
size_t i = 0;
i<config.m_processes.size();
i++){
846 if((proc.m_type & atrt_process::AP_NDB_MGMD) != 0){
847 if(!connect_ndb_mgm(proc)){
856 static int remap(
int i){
868 for (
size_t i = 0; i<config.m_clusters.size(); i++)
872 if (strcmp(cluster->m_name.
c_str(),
".atrt") == 0)
885 for(
size_t j = 0; j<cluster->m_processes.size(); j++){
887 if((proc.m_type & atrt_process::AP_NDB_MGMD) != 0){
888 handle = proc.m_ndb_mgm_handle;
911 time_t now = time(0);
912 time_t end = now + 360;
925 g_logger.
error(
"Unable to poll db state: %d %s %s",
929 if(err == NDB_MGM_SERVER_NOT_CONNECTED && connect_ndb_mgm(config)){
930 g_logger.
error(
"Reconnected...");
942 min2 = (min2 < s ? min2 : s );
946 g_logger.
critical(
"Strange DB status during start: %d %d",
952 g_logger.
critical(
"wait ndb failed node: %d %d %d %d",
959 g_logger.
critical(
"wait ndb failed %d %d %d", min, min2, goal);
972 g_logger.
critical(
"wait ndb timed out %d %d %d", min, min2, goal);
979 return cnt == config.m_clusters.size();
984 if(proc.m_proc.m_id != -1){
985 g_logger.
critical(
"starting already started process: %u",
986 (
unsigned)proc.m_index);
992 proc.m_host->m_hostname.
c_str(),
993 proc.m_proc.m_cwd.
c_str(),
994 proc.m_proc.m_cwd.
c_str());
997 const int r1 = sh(tmp.
c_str());
1000 g_logger.
critical(
"Failed to setup process");
1006 if(proc.m_host->m_cpcd->define_process(proc.m_proc, reply) != 0){
1008 reply.get(
"errormessage", msg);
1009 g_logger.
error(
"Unable to define process: %s", msg.
c_str());
1015 if(proc.m_host->m_cpcd->start_process(proc.m_proc.m_id, reply) != 0){
1017 reply.get(
"errormessage", msg);
1018 g_logger.
error(
"Unable to start process: %s", msg.
c_str());
1027 for(
size_t i = 0; i<config.m_processes.size(); i++){
1029 if(IF_WIN(!(proc.m_type & atrt_process::AP_MYSQLD), 1)
1030 && (types & proc.m_type) != 0 && proc.m_proc.m_path !=
""){
1031 if(!start_process(proc)){
1041 if(proc.m_proc.m_id == -1){
1047 if(proc.m_host->m_cpcd->stop_process(proc.m_proc.m_id, reply) != 0){
1049 reply.get(
"status", &status);
1052 reply.get(
"errormessage", msg);
1053 g_logger.
error(
"Unable to stop process: %s(%d)", msg.
c_str(), status);
1060 if(proc.m_host->m_cpcd->undefine_process(proc.m_proc.m_id, reply) != 0){
1062 reply.get(
"errormessage", msg);
1063 g_logger.
error(
"Unable to undefine process: %s", msg.
c_str());
1066 proc.m_proc.m_id = -1;
1073 for(
size_t i = 0; i<config.m_processes.size(); i++){
1075 if((types & proc.m_type) != 0){
1076 if(!stop_process(proc)){
1090 m_procs.fill(config.m_hosts.size(), dummy);
1091 for(
size_t i = 0; i<config.m_hosts.size(); i++){
1093 config.m_hosts[
i]->m_cpcd->list_processes(m_procs[i], p);
1096 for(
size_t i = 0; i<config.m_processes.size(); i++){
1098 if(proc.m_proc.m_id != -1){
1101 for(
size_t j = 0; j<h_procs.size(); j++){
1102 if(proc.m_proc.m_id == h_procs[j].m_id){
1104 proc.m_proc.m_status = h_procs[j].m_status;
1109 g_logger.
error(
"update_status: not found");
1110 g_logger.
error(
"id: %d host: %s cmd: %s",
1112 proc.m_host->m_hostname.
c_str(),
1113 proc.m_proc.m_path.
c_str());
1114 for(
size_t j = 0; j<h_procs.size(); j++){
1115 g_logger.
error(
"found: %d %s", h_procs[j].m_id,
1116 h_procs[j].m_path.c_str());
1127 int found = 0, running = 0;
1128 for(
size_t i = 0; i<config.m_processes.size(); i++){
1130 if((types & proc.m_type) != 0){
1132 if(proc.m_proc.m_status ==
"running")
1135 if(IF_WIN(proc.m_type & atrt_process::AP_MYSQLD, 0)) {
1142 if(found == running)
1154 tmp.
trim(
" \t\n\r");
1157 tmp.
split(split,
":=", 2);
1159 if(split.size() != 2)
1162 p.
put(split[0].trim().c_str(), split[1].trim().c_str());
1177 if(!fgets(buf, 1024, file))
1186 if(insert(tmp.
c_str(), p) != 0)
1195 tmp.
trim(
" \t\n\r");
1197 tmp.
split(split,
" ", 2);
1198 tc.m_command = split[0];
1199 if(split.size() == 2)
1200 tc.m_args = split[1];
1203 tc.m_max_time = 60000;
1209 if(!p.get(
"cmd", tc.m_command)){
1210 g_logger.
critical(
"Invalid test file: cmd is missing near line: %d", line);
1214 if(!p.get(
"args", tc.m_args))
1217 const char * mt = 0;
1218 if(!p.get(
"max-time", &mt))
1219 tc.m_max_time = 60000;
1221 tc.m_max_time = atoi(mt);
1223 if(p.get(
"type", &mt) && strcmp(mt,
"bench") == 0)
1228 if(p.get(
"run-all", &mt) && strcmp(mt,
"yes") == 0)
1231 tc.m_run_all=
false;
1233 if (!p.get(
"name", &mt))
1235 tc.m_name.
assfmt(
"%s %s",
1236 tc.m_command.
c_str(),
1250 if (!remove_dir(
"result",
true))
1252 g_logger.
critical(
"setup_test_case: Failed to clear result");
1257 for(; i<config.m_processes.size(); i++)
1260 if(proc.m_type == atrt_process::AP_NDB_API ||
1261 proc.m_type == atrt_process::AP_CLIENT)
1264 if (tc.m_command.
c_str()[0] !=
'/')
1266 cmd.
appfmt(
"%s/bin/", g_prefix);
1272 proc.m_proc.m_path =
"/usr/bin/valgrind";
1277 proc.m_proc.m_path = cmd;
1278 proc.m_proc.m_args.
assign(tc.m_args);
1284 for(i++; i<config.m_processes.size(); i++){
1286 if(proc.m_type == atrt_process::AP_NDB_API ||
1287 proc.m_type == atrt_process::AP_CLIENT)
1289 proc.m_proc.m_path.
assign(
"");
1290 proc.m_proc.m_args.
assign(
"");
1300 for(
size_t i = 0; i<config.m_hosts.size(); i++)
1303 config.m_hosts[i]->m_hostname.c_str(),
1304 config.m_hosts[
i]->m_basedir.c_str());
1308 const int r1 = sh(tmp.
c_str());
1311 g_logger.
critical(
"Failed to gather result!");
1315 g_logger.
debug(
"system(%s)", g_analyze_progname);
1316 const int r2 = sh(g_analyze_progname);
1318 if(r2 == -1 || r2 == (127 << 8))
1320 g_logger.
critical(
"Failed to analyze results");
1330 if (!remove_dir(
"result",
true))
1332 g_logger.
critical(
"setup_hosts: Failed to clear result");
1336 for(
size_t i = 0; i<config.m_hosts.size(); i++){
1338 tmp.
appfmt(
" %s %s/ %s/",
1339 config.m_hosts[i]->m_hostname.c_str(),
1341 config.m_hosts[
i]->m_basedir.c_str());
1344 const int r1 = sh(tmp.
c_str());
1346 g_logger.
critical(
"Failed to setup %s",
1347 config.m_hosts[i]->m_hostname.c_str());
1356 do_rsync(
const char *dir,
const char *dst)
1359 tmp.
appfmt(
" %s %s/ %s", dst, dir, dir);
1361 g_logger.
info(
"rsyncing %s to %s", dir, dst);
1363 const int r1 = sh(tmp.
c_str());
1366 g_logger.
critical(
"Failed to rsync %s to %s", dir, dst);
1376 for (
size_t i = 0; i<config.m_hosts.size(); i++)
1380 if (!do_rsync(g_basedir, config.m_hosts[i]->m_hostname.c_str()))
1386 if (!do_rsync(g_prefix, config.m_hosts[i]->m_hostname.c_str()))
1390 !do_rsync(g_prefix1, config.m_hosts[i]->m_hostname.c_str()))
1401 for (
size_t i = 0; i<config.m_processes.size(); i++)
1406 const char *
type = 0;
1407 switch(proc.m_type){
1408 case atrt_process::AP_NDB_MGMD:
1409 type = (mask & proc.m_type) ?
"ndb_mgmd" : 0;
1411 case atrt_process::AP_NDBD:
1412 type = (mask & proc.m_type) ?
"ndbd" : 0;
1414 case atrt_process::AP_MYSQLD:
1415 type = (mask & proc.m_type) ?
"mysqld" : 0;
1417 case atrt_process::AP_NDB_API:
1418 type = (mask & proc.m_type) ?
"ndbapi" : 0;
1420 case atrt_process::AP_CLIENT:
1421 type = (mask & proc.m_type) ?
"client" : 0;
1431 #define SYS_SSH "bash '-c echo\"%s(%s) on %s\";" \
1432 "ssh -t %s sh %s/ssh-login.sh' &"
1434 #define SYS_SSH "xterm -fg black -title \"%s(%s) on %s\"" \
1435 " -e 'ssh -t -X %s sh %s/ssh-login.sh' &"
1440 proc.m_cluster->m_name.
c_str(),
1441 proc.m_host->m_hostname.
c_str(),
1442 proc.m_host->m_hostname.
c_str(),
1443 proc.m_proc.m_cwd.
c_str());
1446 const int r1 = sh(tmp.
c_str());
1449 g_logger.
critical(
"Failed sshx (%s)",
1453 NdbSleep_MilliSleep(300);
1462 if (proc_mask & atrt_process::AP_NDB_MGMD)
1463 if(!start_processes(g_config, atrt_process::AP_NDB_MGMD))
1466 if (proc_mask & atrt_process::AP_NDBD)
1468 if(!connect_ndb_mgm(g_config)){
1472 if(!start_processes(g_config, atrt_process::AP_NDBD))
1478 for(Uint32 i = 0; i<3; i++)
1485 if(!start_processes(g_config, p_servers & proc_mask))
1494 bool changed =
false;
1495 for(
size_t i = 0; i<config.m_processes.size(); i++)
1498 if (proc.m_save.m_saved)
1500 if (!stop_process(proc))
1504 proc.m_save.m_saved =
false;
1505 proc.m_proc = proc.m_save.m_proc;
1506 proc.m_proc.m_id = -1;