Commit 0cf4750f authored by unknown's avatar unknown

mysqltest can now talk to manager and start/stop servers with

server_start/server_stop
changed rpl000018 to use the new server restart feature instead of a
hack


BitKeeper/deleted/.del-rpl000018-master.sh~bc8072e13b26b005:
  Delete: mysql-test/t/rpl000018-master.sh
client/mysqltest.c:
  server_start/server_stop
mysql-test/mysql-test-run.sh:
  tell mysqltest about the manager
mysql-test/r/rpl000018.result:
  fixed bug
mysql-test/t/rpl000018.test:
  use server restart instead of fake binlog hack
sql/log_event.cc:
  so far useless change
parent 29f148bd
...@@ -80,12 +80,23 @@ ...@@ -80,12 +80,23 @@
* the server - to solve the problem, we try again * the server - to solve the problem, we try again
* after some sleep if connection fails the first * after some sleep if connection fails the first
* time */ * time */
#ifndef MYSQL_MANAGER_PORT
#define MYSQL_MANAGER_PORT 23546
#endif
enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD,
OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT};
static int record = 0, verbose = 0, silent = 0, opt_sleep=0; static int record = 0, verbose = 0, silent = 0, opt_sleep=0;
static char *db = 0, *pass=0; static char *db = 0, *pass=0;
const char* user = 0, *host = 0, *unix_sock = 0; const char* user = 0, *host = 0, *unix_sock = 0;
static int port = 0, opt_big_test=0; static int port = 0, opt_big_test=0;
static uint start_lineno, *lineno; static uint start_lineno, *lineno;
const char* manager_user="root",*manager_host="localhost";
char *manager_pass=0;
int manager_port=MYSQL_MANAGER_PORT;
int manager_wait_timeout=3;
MYSQL_MANAGER* manager=0;
static char **default_argv; static char **default_argv;
static const char *load_default_groups[]= { "mysqltest","client",0 }; static const char *load_default_groups[]= { "mysqltest","client",0 };
...@@ -168,6 +179,7 @@ Q_PING, Q_EVAL, ...@@ -168,6 +179,7 @@ Q_PING, Q_EVAL,
Q_RPL_PROBE, Q_ENABLE_RPL_PARSE, Q_RPL_PROBE, Q_ENABLE_RPL_PARSE,
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT, Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG, Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
Q_SERVER_START, Q_SERVER_STOP,
Q_UNKNOWN, /* Unknown command. */ Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */ Q_COMMENT, /* Comments, ignored. */
Q_COMMENT_WITH_COMMAND Q_COMMENT_WITH_COMMAND
...@@ -200,6 +212,7 @@ const char *command_names[] = { ...@@ -200,6 +212,7 @@ const char *command_names[] = {
"rpl_probe", "enable_rpl_parse", "rpl_probe", "enable_rpl_parse",
"disable_rpl_parse", "eval_result", "disable_rpl_parse", "eval_result",
"enable_query_log", "disable_query_log", "enable_query_log", "disable_query_log",
"server_start", "server_stop",
0 0
}; };
...@@ -243,6 +256,7 @@ static int initialize_replace_buffer(void); ...@@ -243,6 +256,7 @@ static int initialize_replace_buffer(void);
static void free_replace_buffer(void); static void free_replace_buffer(void);
static void do_eval(DYNAMIC_STRING* query_eval, const char* query); static void do_eval(DYNAMIC_STRING* query_eval, const char* query);
void str_to_file(const char* fname, char* str, int size); void str_to_file(const char* fname, char* str, int size);
int do_server_op(struct st_query* q,const char* op);
struct st_replace *glob_replace; struct st_replace *glob_replace;
static char *out_buff; static char *out_buff;
...@@ -321,6 +335,8 @@ static void free_used_memory() ...@@ -321,6 +335,8 @@ static void free_used_memory()
{ {
uint i; uint i;
DBUG_ENTER("free_used_memory"); DBUG_ENTER("free_used_memory");
if (manager)
mysql_manager_close(manager);
close_cons(); close_cons();
close_files(); close_files();
hash_free(&var_hash); hash_free(&var_hash);
...@@ -580,6 +596,44 @@ int open_file(const char* name) ...@@ -580,6 +596,44 @@ int open_file(const char* name)
return 0; return 0;
} }
int do_server_start(struct st_query* q)
{
return do_server_op(q,"start");
}
int do_server_stop(struct st_query* q)
{
return do_server_op(q,"stop");
}
int do_server_op(struct st_query* q,const char* op)
{
char* p=q->first_argument;
char com_buf[256],*com_p;
com_p=strmov(com_buf,op);
com_p=strmov(com_p,"_exec ");
if (!*p)
die("Missing server name in server_%s\n",op);
while (*p && !isspace(*p))
{
*com_p++=*p++;
}
*com_p++=' ';
com_p=int10_to_str(manager_wait_timeout,com_p,10);
*com_p++ = '\n';
*com_p=0;
if (mysql_manager_command(manager,com_buf,(int)(com_p-com_buf)))
die("Error in command: %s(%d)",manager->last_error,manager->last_errno);
while (!manager->eof)
{
if (mysql_manager_fetch_line(manager,com_buf,sizeof(com_buf)))
die("Error fetching result line: %s(%d)", manager->last_error,
manager->last_errno);
}
return 0;
}
int do_source(struct st_query* q) int do_source(struct st_query* q)
{ {
char* p=q->first_argument, *name; char* p=q->first_argument, *name;
...@@ -1125,6 +1179,17 @@ char* safe_get_param(char* str, char** arg, const char* msg) ...@@ -1125,6 +1179,17 @@ char* safe_get_param(char* str, char** arg, const char* msg)
DBUG_RETURN(str); DBUG_RETURN(str);
} }
void init_manager()
{
if (!(manager=mysql_manager_init(0)))
die("Failed in mysql_manager_init()");
if (!mysql_manager_connect(manager,manager_host,manager_user,
manager_pass,manager_port))
die("Could not connect to MySQL manager: %s(%d)",manager->last_error,
manager->last_errno);
}
int safe_connect(MYSQL* con, const char* host, const char* user, int safe_connect(MYSQL* con, const char* host, const char* user,
const char* pass, const char* pass,
const char* db, int port, const char* sock) const char* db, int port, const char* sock)
...@@ -1519,7 +1584,6 @@ int read_query(struct st_query** q_ptr) ...@@ -1519,7 +1584,6 @@ int read_query(struct st_query** q_ptr)
return 0; return 0;
} }
struct option long_options[] = struct option long_options[] =
{ {
{"debug", optional_argument, 0, '#'}, {"debug", optional_argument, 0, '#'},
...@@ -1527,6 +1591,11 @@ struct option long_options[] = ...@@ -1527,6 +1591,11 @@ struct option long_options[] =
{"big-test", no_argument, 0, 'B'}, {"big-test", no_argument, 0, 'B'},
{"help", no_argument, 0, '?'}, {"help", no_argument, 0, '?'},
{"host", required_argument, 0, 'h'}, {"host", required_argument, 0, 'h'},
{"manager-user",required_argument, 0, OPT_MANAGER_USER},
{"manager-host",required_argument, 0, OPT_MANAGER_HOST},
{"manager-password",required_argument,0,OPT_MANAGER_PASSWD},
{"manager-port",required_argument,0,OPT_MANAGER_PORT},
{"manager-wait-timeout",required_argument,0,OPT_MANAGER_WAIT_TIMEOUT},
{"password", optional_argument, 0, 'p'}, {"password", optional_argument, 0, 'p'},
{"port", required_argument, 0, 'P'}, {"port", required_argument, 0, 'P'},
{"quiet", no_argument, 0, 'q'}, {"quiet", no_argument, 0, 'q'},
...@@ -1604,6 +1673,23 @@ int parse_args(int argc, char **argv) ...@@ -1604,6 +1673,23 @@ int parse_args(int argc, char **argv)
case 'r': case 'r':
record = 1; record = 1;
break; break;
case (int)OPT_MANAGER_WAIT_TIMEOUT:
manager_wait_timeout=atoi(optarg);
break;
case (int)OPT_MANAGER_PORT:
manager_port=atoi(optarg);
break;
case (int)OPT_MANAGER_HOST:
manager_host=optarg;
break;
case (int)OPT_MANAGER_USER:
manager_user=optarg;
break;
case (int)OPT_MANAGER_PASSWD:
my_free(manager_pass,MYF(MY_ALLOW_ZERO_PTR));
manager_pass=my_strdup(optarg,MYF(MY_FAE));
while (*optarg) *optarg++= 'x'; /* Destroy argument */
break;
case 'u': case 'u':
user = optarg; user = optarg;
break; break;
...@@ -2010,13 +2096,14 @@ int main(int argc, char** argv) ...@@ -2010,13 +2096,14 @@ int main(int argc, char** argv)
if (!*cur_file) if (!*cur_file)
*cur_file = stdin; *cur_file = stdin;
*lineno=1; *lineno=1;
init_manager();
if (!( mysql_init(&cur_con->mysql))) if (!( mysql_init(&cur_con->mysql)))
die("Failed in mysql_init()"); die("Failed in mysql_init()");
cur_con->name = my_strdup("default", MYF(MY_WME)); cur_con->name = my_strdup("default", MYF(MY_WME));
if (!cur_con->name) if (!cur_con->name)
die("Out of memory"); die("Out of memory");
if (safe_connect(&cur_con->mysql, host, if (safe_connect(&cur_con->mysql, host,
user, pass, db, port, unix_sock)) user, pass, db, port, unix_sock))
die("Failed in mysql_real_connect(): %s", mysql_error(&cur_con->mysql)); die("Failed in mysql_real_connect(): %s", mysql_error(&cur_con->mysql));
...@@ -2042,6 +2129,8 @@ int main(int argc, char** argv) ...@@ -2042,6 +2129,8 @@ int main(int argc, char** argv)
case Q_DISABLE_QUERY_LOG: disable_query_log=1; break; case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
case Q_SOURCE: do_source(q); break; case Q_SOURCE: do_source(q); break;
case Q_SLEEP: do_sleep(q); break; case Q_SLEEP: do_sleep(q); break;
case Q_SERVER_START: do_server_start(q); break;
case Q_SERVER_STOP: do_server_stop(q); break;
case Q_INC: do_inc(q); break; case Q_INC: do_inc(q); break;
case Q_DEC: do_dec(q); break; case Q_DEC: do_dec(q); break;
case Q_ECHO: do_echo(q); break; case Q_ECHO: do_echo(q); break;
......
...@@ -336,7 +336,9 @@ then ...@@ -336,7 +336,9 @@ then
fi fi
MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB --user=$DBUSER --password=$DBPASSWD --silent -v --tmpdir=$MYSQL_TMP_DIR" MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB \
--user=$DBUSER --password=$DBPASSWD --silent -v \
--tmpdir=$MYSQL_TMP_DIR"
MYSQL_TEST_BIN=$MYSQL_TEST MYSQL_TEST_BIN=$MYSQL_TEST
MYSQL_TEST="$MYSQL_TEST $MYSQL_TEST_ARGS" MYSQL_TEST="$MYSQL_TEST $MYSQL_TEST_ARGS"
GDB_CLIENT_INIT=$MYSQL_TMP_DIR/gdbinit.client GDB_CLIENT_INIT=$MYSQL_TMP_DIR/gdbinit.client
...@@ -521,6 +523,13 @@ start_manager() ...@@ -521,6 +523,13 @@ start_manager()
$MYSQL_MANAGER --log=$MYSQL_MANAGER_LOG --port=$MYSQL_MANAGER_PORT \ $MYSQL_MANAGER --log=$MYSQL_MANAGER_LOG --port=$MYSQL_MANAGER_PORT \
--password-file=$MYSQL_MANAGER_PW_FILE --password-file=$MYSQL_MANAGER_PW_FILE
abort_if_failed "Could not start MySQL manager" abort_if_failed "Could not start MySQL manager"
mysqltest_manager_args="--manager-user=$MYSQL_MANAGER_USER \
--manager-password=$MYSQL_MANAGER_PW \
--manager-port=$MYSQL_MANAGER_PORT \
--manager-wait-timeout=$START_WAIT_TIMEOUT"
MYSQL_TEST="$MYSQL_TEST $mysqltest_manager_args"
MYSQL_TEST_ARGS="$MYSQL_TEST_ARGS $mysqltest_manager_args"
} }
stop_manager() stop_manager()
...@@ -552,7 +561,7 @@ manager_term() ...@@ -552,7 +561,7 @@ manager_term()
shift shift
$MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \ $MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \
--password=$MYSQL_MANAGER_PW --port=$MYSQL_MANAGER_PORT <<EOF --password=$MYSQL_MANAGER_PW --port=$MYSQL_MANAGER_PORT <<EOF
stop_exec $ident $TERM_WAIT_TIMEOUT stop_exec $ident $STOP_WAIT_TIMEOUT
EOF EOF
abort_if_failed "Could not execute manager command" abort_if_failed "Could not execute manager command"
} }
...@@ -561,14 +570,16 @@ EOF ...@@ -561,14 +570,16 @@ EOF
start_master() start_master()
{ {
[ x$MASTER_RUNNING = 1 ] && return [ x$MASTER_RUNNING = 1 ] && return
# Remove old berkeley db log files that can confuse the server
$RM -f $MASTER_MYDDIR/log.*
# Remove stale binary logs
$RM -f $MYSQL_TEST_DIR/var/log/master-bin.*
#run master initialization shell script if one exists #run master initialization shell script if one exists
if [ -f "$master_init_script" ] ; if [ -f "$master_init_script" ] ;
then then
/bin/sh $master_init_script /bin/sh $master_init_script
fi fi
cd $BASEDIR # for gcov cd $BASEDIR # for gcov
# Remove old berkeley db log files that can confuse the server
$RM -f $MASTER_MYDDIR/log.*
#start master #start master
if [ -z "$DO_BENCH" ] if [ -z "$DO_BENCH" ]
then then
...@@ -630,6 +641,9 @@ start_slave() ...@@ -630,6 +641,9 @@ start_slave()
[ x$SKIP_SLAVE = x1 ] && return [ x$SKIP_SLAVE = x1 ] && return
[ x$SLAVE_RUNNING = 1 ] && return [ x$SLAVE_RUNNING = 1 ] && return
# Remove stale binary logs
$RM -f $MYSQL_TEST_DIR/var/log/slave-bin.*
#run slave initialization shell script if one exists #run slave initialization shell script if one exists
if [ -f "$slave_init_script" ] ; if [ -f "$slave_init_script" ] ;
then then
......
...@@ -4,7 +4,6 @@ show master logs; ...@@ -4,7 +4,6 @@ show master logs;
Log_name Log_name
master-bin.001 master-bin.001
master-bin.002 master-bin.002
master-bin.003
drop table if exists t1; drop table if exists t1;
create table t1(n int); create table t1(n int);
insert into t1 values (3351); insert into t1 values (3351);
......
rm -f $MYSQL_TEST_DIR/var/master-data/master-bin.*
cp $MYSQL_TEST_DIR/std_data/master-bin.001 $MYSQL_TEST_DIR/var/master-data/
echo ./master-bin.001 > $MYSQL_TEST_DIR/var/master-data/master-bin.index
connect (master,localhost,root,,test,0,mysql-master.sock); connect (master,localhost,root,,test,0,mysql-master.sock);
connect (slave,localhost,root,,test,0,mysql-slave.sock); connect (slave,localhost,root,,test,0,mysql-slave.sock);
server_stop master;
server_start master;
connection slave; connection slave;
reset slave; reset slave;
slave start; slave start;
......
...@@ -1646,6 +1646,7 @@ int Stop_log_event::exec_event(struct st_master_info* mi) ...@@ -1646,6 +1646,7 @@ int Stop_log_event::exec_event(struct st_master_info* mi)
if(mi->pos > 4) // stop event should be ignored after rotate event if(mi->pos > 4) // stop event should be ignored after rotate event
{ {
close_temporary_tables(thd); close_temporary_tables(thd);
//clean_up_load_tmp_dir();
mi->inc_pos(get_event_len(), log_seq); mi->inc_pos(get_event_len(), log_seq);
flush_master_info(mi); flush_master_info(mi);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment