Pass pointer to current mysqld to mysqld_arguments in order to make the

code eaiser and more extensible
parent ab28345a
......@@ -353,7 +353,7 @@ sub do_before_start_slave ($);
sub ndbd_start ($$$);
sub ndb_mgmd_start ($);
sub mysqld_start ($$$);
sub mysqld_arguments ($$$$$);
sub mysqld_arguments ($$$$);
sub stop_all_servers ();
sub run_mysqltest ($);
sub usage ($);
......@@ -3606,21 +3606,20 @@ sub do_before_start_slave ($) {
}
sub mysqld_arguments ($$$$$) {
sub mysqld_arguments ($$$$) {
my $args= shift;
my $type= shift;
my $idx= shift;
my $mysqld= shift;
my $extra_opt= shift;
my $slave_master_info= shift;
my $idx= $mysqld->{'idx'};
my $sidx= ""; # Index as string, 0 is empty string
if ( $idx > 0 )
if ( $idx> 0 )
{
$sidx= "$idx";
$sidx= $idx;
}
my $prefix= ""; # If mysqltest server arg
if ( $glob_use_embedded_server )
{
$prefix= "--server-arg=";
......@@ -3657,36 +3656,53 @@ sub mysqld_arguments ($$$$$) {
}
}
mtr_add_arg($args, "%s--pid-file=%s", $prefix,
$mysqld->{'path_pid'});
mtr_add_arg($args, "%s--port=%d", $prefix,
$mysqld->{'port'});
mtr_add_arg($args, "%s--socket=%s", $prefix,
$mysqld->{'path_sock'});
mtr_add_arg($args, "%s--datadir=%s", $prefix,
$mysqld->{'path_myddir'});
if ( $mysql_version_id >= 50106 )
{
# Turn on logging to bothe tables and file
mtr_add_arg($args, "%s--log-output=table,file", $prefix);
}
mtr_add_arg($args, "%s--log=%s", $prefix, $mysqld->{'path_mylog'});
# Check if "extra_opt" contains --skip-log-bin
my $skip_binlog= grep(/^--skip-log-bin/, @$extra_opt);
if ( $type eq 'master' )
if ( $mysqld->{'type'} eq 'master' )
{
my $id= $idx > 0 ? $idx + 101 : 1;
if (! ($opt_skip_master_binlog || $skip_binlog) )
{
mtr_add_arg($args, "%s--log-bin=%s/log/master-bin%s", $prefix,
$opt_vardir, $sidx);
}
mtr_add_arg($args, "%s--pid-file=%s", $prefix,
$master->[$idx]->{'path_pid'});
mtr_add_arg($args, "%s--port=%d", $prefix,
$master->[$idx]->{'port'});
mtr_add_arg($args, "%s--server-id=%d", $prefix, $id);
mtr_add_arg($args, "%s--socket=%s", $prefix,
$master->[$idx]->{'path_sock'});
mtr_add_arg($args, "%s--innodb_data_file_path=ibdata1:10M:autoextend", $prefix);
mtr_add_arg($args, "%s--server-id=%d", $prefix,
$idx > 0 ? $idx + 101 : 1);
mtr_add_arg($args, "%s--innodb_data_file_path=ibdata1:10M:autoextend",
$prefix);
mtr_add_arg($args, "%s--local-infile", $prefix);
mtr_add_arg($args, "%s--datadir=%s", $prefix,
$master->[$idx]->{'path_myddir'});
if ( $idx > 0 or !$use_innodb)
{
mtr_add_arg($args, "%s--skip-innodb", $prefix);
}
my $cluster= $clusters->[$master->[$idx]->{'cluster'}];
my $cluster= $clusters->[$mysqld->{'cluster'}];
if ( $opt_skip_ndbcluster ||
!$cluster->{'pid'})
{
......@@ -3702,26 +3718,12 @@ sub mysqld_arguments ($$$$$) {
mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
}
}
if ( $mysql_version_id <= 50106 )
{
# Force mysqld to use log files up until 5.1.6
mtr_add_arg($args, "%s--log=%s", $prefix, $master->[0]->{'path_mylog'});
}
else
{
# Turn on logging, will be sent to tables
mtr_add_arg($args, "%s--log=", $prefix);
}
}
if ( $type eq 'slave' )
else
{
my $slave_server_id= 2 + $idx;
my $slave_rpl_rank= $slave_server_id;
mtr_error("unknown mysqld type")
unless $mysqld->{'type'} eq 'slave';
mtr_add_arg($args, "%s--datadir=%s", $prefix,
$slave->[$idx]->{'path_myddir'});
mtr_add_arg($args, "%s--init-rpl-role=slave", $prefix);
if (! ( $opt_skip_slave_binlog || $skip_binlog ))
{
......@@ -3731,18 +3733,14 @@ sub mysqld_arguments ($$$$$) {
}
mtr_add_arg($args, "%s--master-retry-count=10", $prefix);
mtr_add_arg($args, "%s--pid-file=%s", $prefix,
$slave->[$idx]->{'path_pid'});
mtr_add_arg($args, "%s--port=%d", $prefix,
$slave->[$idx]->{'port'});
mtr_add_arg($args, "%s--relay-log=%s/log/slave%s-relay-bin", $prefix,
$opt_vardir, $sidx);
mtr_add_arg($args, "%s--report-host=127.0.0.1", $prefix);
mtr_add_arg($args, "%s--report-port=%d", $prefix,
$slave->[$idx]->{'port'});
$mysqld->{'port'});
mtr_add_arg($args, "%s--report-user=root", $prefix);
mtr_add_arg($args, "%s--skip-innodb", $prefix);
mtr_add_arg($args, "%s--skip-ndbcluster", $prefix);
mtr_add_arg($args, "%s--skip-slave-start", $prefix);
# Directory where slaves find the dumps generated by "load data"
......@@ -3751,8 +3749,6 @@ sub mysqld_arguments ($$$$$) {
my $slave_load_path= "../tmp";
mtr_add_arg($args, "%s--slave-load-tmpdir=%s", $prefix,
$slave_load_path);
mtr_add_arg($args, "%s--socket=%s", $prefix,
$slave->[$idx]->{'path_sock'});
mtr_add_arg($args, "%s--set-variable=slave_net_timeout=10", $prefix);
if ( @$slave_master_info )
......@@ -3770,13 +3766,16 @@ sub mysqld_arguments ($$$$$) {
mtr_add_arg($args, "%s--master-password=", $prefix);
mtr_add_arg($args, "%s--master-port=%d", $prefix,
$master->[0]->{'port'}); # First master
my $slave_server_id= 2 + $idx;
my $slave_rpl_rank= $slave_server_id;
mtr_add_arg($args, "%s--server-id=%d", $prefix, $slave_server_id);
mtr_add_arg($args, "%s--rpl-recovery-rank=%d", $prefix, $slave_rpl_rank);
}
if ( $opt_skip_ndbcluster_slave ||
$slave->[$idx]->{'cluster'} == -1 ||
!$clusters->[$slave->[$idx]->{'cluster'}]->{'pid'} )
$mysqld->{'cluster'} == -1 ||
!$clusters->[$mysqld->{'cluster'}]->{'pid'} )
{
mtr_add_arg($args, "%s--skip-ndbcluster", $prefix);
}
......@@ -3784,41 +3783,22 @@ sub mysqld_arguments ($$$$$) {
{
mtr_add_arg($args, "%s--ndbcluster", $prefix);
mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
$clusters->[$slave->[$idx]->{'cluster'}]->{'connect_string'});
$clusters->[$mysqld->{'cluster'}]->{'connect_string'});
if ( $mysql_version_id >= 50100 )
{
mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
}
}
if ( $mysql_version_id <= 50106 )
{
# Force mysqld to use log files up until 5.1.6
mtr_add_arg($args, "%s--log=%s", $prefix, $slave->[0]->{'path_mylog'});
}
else
{
# Turn on logging, will be sent to tables
mtr_add_arg($args, "%s--log=", $prefix);
}
} # end slave
if ( $opt_debug )
{
if ( $type eq 'master' )
{
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/master%s.trace",
$prefix, $path_vardir_trace, $sidx);
}
if ( $type eq 'slave' )
{
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/slave%s.trace",
$prefix, $path_vardir_trace, $sidx);
}
mtr_add_arg($args, "%s--debug=d:t:i:A,%s/log/%s%s.trace",
$prefix, $path_vardir_trace, $mysqld->{'type'}, $sidx);
}
# FIXME always set nowdays??? SMALL_SERVER
mtr_add_arg($args, "%s--key_buffer_size=1M", $prefix);
mtr_add_arg($args, "%s--sort_buffer=256K", $prefix);
mtr_add_arg($args, "%s--max_heap_table_size=1M", $prefix);
......@@ -3844,18 +3824,10 @@ sub mysqld_arguments ($$$$$) {
mtr_add_arg($args, "%s--gdb", $prefix);
}
# If we should run all tests cases, we will use a local server for that
if ( -w "/" )
{
# We are running as root; We need to add the --root argument
mtr_add_arg($args, "%s--user=root", $prefix);
}
my $found_skip_core= 0;
foreach my $arg ( @opt_extra_mysqld_opt, @$extra_opt )
{
# Allow --skip-core-file to be set in master.opt file
# Allow --skip-core-file to be set in <testname>-[master|slave].opt file
if ($arg eq "--skip-core-file")
{
$found_skip_core= 1;
......@@ -3879,7 +3851,7 @@ sub mysqld_arguments ($$$$$) {
mtr_add_arg($args, "%s--rpl-recovery-rank=1", $prefix);
mtr_add_arg($args, "%s--init-rpl-role=master", $prefix);
}
elsif ( $type eq 'master' )
elsif ( $mysqld->{'type'} eq 'master' )
{
mtr_add_arg($args, "%s--open-files-limit=1024", $prefix);
}
......@@ -3930,7 +3902,7 @@ sub mysqld_start ($$$) {
valgrind_arguments($args, \$exe);
}
mysqld_arguments($args,$type,$idx,$extra_opt,$slave_master_info);
mysqld_arguments($args,$mysqld,$extra_opt,$slave_master_info);
if ( $opt_gdb || $opt_manual_gdb)
{
......@@ -4674,7 +4646,7 @@ sub run_mysqltest ($) {
if ( $glob_use_embedded_server )
{
mysqld_arguments($args,'master',0,$tinfo->{'master_opt'},[]);
mysqld_arguments($args,$master->[0],$tinfo->{'master_opt'},[]);
}
# ----------------------------------------------------------------------
......
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