Find ndb binaries

Verbose SafeProcess.pm 
parent c74678e2
...@@ -26,12 +26,15 @@ use Carp; ...@@ -26,12 +26,15 @@ use Carp;
use My::Platform; use My::Platform;
use base qw(Exporter); use base qw(Exporter);
our @EXPORT= qw(my_find_bin my_find_dir); our @EXPORT= qw(my_find_bin my_find_dir NOT_REQUIRED);
our $vs_config_dir; our $vs_config_dir;
my $bin_extension= ".exe" if IS_WINDOWS; my $bin_extension= ".exe" if IS_WINDOWS;
# Helper function to be used for fourth parameter to find functions
sub NOT_REQUIRED { return 0; }
# #
# my_find_bin - find an executable with "name_1...name_n" in # my_find_bin - find an executable with "name_1...name_n" in
# paths "path_1...path_n" and return the full path # paths "path_1...path_n" and return the full path
...@@ -44,13 +47,21 @@ my $bin_extension= ".exe" if IS_WINDOWS; ...@@ -44,13 +47,21 @@ my $bin_extension= ".exe" if IS_WINDOWS;
# ["client", "bin"], # ["client", "bin"],
# "mysql"); # "mysql");
# #
#
# To check if something exists, use the required parameter
# set to 0, the function will return an empty string if the
# binary is not found
# my $mysql_exe= my_find_bin($basedir,
# ["client", "bin"],
# "mysql", 0);
#
# NOTE: The function honours MTR_VS_CONFIG environment variable # NOTE: The function honours MTR_VS_CONFIG environment variable
# #
# #
sub my_find_bin { sub my_find_bin {
my ($base, $paths, $names)= @_; my ($base, $paths, $names, $required)= @_;
croak "usage: my_find_bin(<base>, <paths>, <names>)" croak "usage: my_find_bin(<base>, <paths>, <names>, [<required>])"
unless @_ == 3; unless @_ == 4 or @_ == 3;
# ------------------------------------------------------- # -------------------------------------------------------
# Find and return the first executable # Find and return the first executable
...@@ -58,6 +69,10 @@ sub my_find_bin { ...@@ -58,6 +69,10 @@ sub my_find_bin {
foreach my $path (my_find_paths($base, $paths, $names, $bin_extension)) { foreach my $path (my_find_paths($base, $paths, $names, $bin_extension)) {
return $path if ( -x $path or (IS_WINDOWS and -f $path) ); return $path if ( -x $path or (IS_WINDOWS and -f $path) );
} }
if (defined $required and $required == NOT_REQUIRED){
# Return empty string to indicate not found
return "";
}
find_error($base, $paths, $names); find_error($base, $paths, $names);
} }
...@@ -79,7 +94,7 @@ sub my_find_bin { ...@@ -79,7 +94,7 @@ sub my_find_bin {
# #
# #
sub my_find_dir { sub my_find_dir {
my ($base, $paths, $dirs)= @_; my ($base, $paths, $dirs, $required)= @_;
croak "usage: my_find_dir(<base>, <paths>[, <dirs>])" croak "usage: my_find_dir(<base>, <paths>[, <dirs>])"
unless (@_ == 3 or @_ == 2); unless (@_ == 3 or @_ == 2);
......
...@@ -59,6 +59,7 @@ use My::Find; ...@@ -59,6 +59,7 @@ use My::Find;
use My::Platform; use My::Platform;
my %running; my %running;
my $_verbose= IS_WINDOWS;
END { END {
# Kill any children still running # Kill any children still running
...@@ -85,33 +86,17 @@ if (IS_WIN32PERL or IS_CYGWIN){ ...@@ -85,33 +86,17 @@ if (IS_WIN32PERL or IS_CYGWIN){
# Use my_safe_process.exe # Use my_safe_process.exe
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"], my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process"); "my_safe_process");
die "Could not find my_safe_process" unless $exe;
push(@safe_process_cmd, $exe); push(@safe_process_cmd, $exe);
# Use my_safe_kill.exe # Use my_safe_kill.exe
$safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill"); $safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill");
die "Could not find my_safe_kill" unless $safe_kill;
} }
else else
{ {
my $use_safe_process_binary= 1;
if ($use_safe_process_binary) {
# Use my_safe_process # Use my_safe_process
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"], my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process"); "my_safe_process");
die "Could not find my_safe_process" unless $exe;
push(@safe_process_cmd, $exe); push(@safe_process_cmd, $exe);
}
else
{
# Use safe_process.pl
my $script= "lib/My/SafeProcess/safe_process.pl";
$script= "../$script" unless -f $script;
die "Could not find safe_process.pl" unless -f $script;
# Call $script with Perl interpreter
push(@safe_process_cmd, $^X, $script);
}
} }
...@@ -248,14 +233,14 @@ sub timer { ...@@ -248,14 +233,14 @@ sub timer {
sub shutdown { sub shutdown {
my $shutdown_timeout= shift; my $shutdown_timeout= shift;
my @processes= @_; my @processes= @_;
_verbose("shutdown, timeout: $shutdown_timeout, @processes");
return if (@processes == 0); return if (@processes == 0);
#print "shutdown: @processes\n";
# Call shutdown function if process has one, else # Call shutdown function if process has one, else
# use kill # use kill
foreach my $proc (@processes){ foreach my $proc (@processes){
_verbose(" proc: $proc");
my $shutdown= $proc->{SAFE_SHUTDOWN}; my $shutdown= $proc->{SAFE_SHUTDOWN};
if ($shutdown_timeout > 0 and defined $shutdown){ if ($shutdown_timeout > 0 and defined $shutdown){
$shutdown->(); $shutdown->();
...@@ -301,7 +286,7 @@ sub shutdown { ...@@ -301,7 +286,7 @@ sub shutdown {
sub start_kill { sub start_kill {
my ($self)= @_; my ($self)= @_;
croak "usage: \$safe_proc->start_kill()" unless (@_ == 1 and ref $self); croak "usage: \$safe_proc->start_kill()" unless (@_ == 1 and ref $self);
#print "start_kill $self\n"; _verbose("start_kill: $self");
my $ret= 1; my $ret= 1;
if (defined $safe_kill and $self->{SAFE_WINPID}){ if (defined $safe_kill and $self->{SAFE_WINPID}){
...@@ -309,6 +294,7 @@ sub start_kill { ...@@ -309,6 +294,7 @@ sub start_kill {
# it's time to kill it's child and return # it's time to kill it's child and return
my $pid= $self->{SAFE_WINPID}; my $pid= $self->{SAFE_WINPID};
$ret= (system($safe_kill, $pid) >> 8) == 0; $ret= (system($safe_kill, $pid) >> 8) == 0;
print `tasklist` unless $ret;
} else { } else {
my $pid= $self->{SAFE_PID}; my $pid= $self->{SAFE_PID};
die "Can't kill not started process" unless defined $pid; die "Can't kill not started process" unless defined $pid;
...@@ -327,10 +313,8 @@ sub kill { ...@@ -327,10 +313,8 @@ sub kill {
my ($self)= @_; my ($self)= @_;
croak "usage: \$safe_proc->kill()" unless (@_ == 1 and ref $self); croak "usage: \$safe_proc->kill()" unless (@_ == 1 and ref $self);
if ($self->start_kill()) $self->start_kill();
{
$self->wait_one(); $self->wait_one();
}
return 1; return 1;
} }
...@@ -338,8 +322,8 @@ sub kill { ...@@ -338,8 +322,8 @@ sub kill {
sub _collect { sub _collect {
my ($self)= @_; my ($self)= @_;
#print "_collect\n";
$self->{EXIT_STATUS}= $?; $self->{EXIT_STATUS}= $?;
_verbose("_collect: $self");
# Take the process out of running list # Take the process out of running list
my $pid= $self->{SAFE_PID}; my $pid= $self->{SAFE_PID};
...@@ -363,15 +347,17 @@ sub wait_one { ...@@ -363,15 +347,17 @@ sub wait_one {
my ($self, $timeout)= @_; my ($self, $timeout)= @_;
croak "usage: \$safe_proc->wait_one([timeout])" unless ref $self; croak "usage: \$safe_proc->wait_one([timeout])" unless ref $self;
#print "wait_one $self, $timeout\n"; _verbose("wait_one $self, $timeout");
if ( ! defined($self->{SAFE_PID}) ) { if ( ! defined($self->{SAFE_PID}) ) {
# No pid => not running # No pid => not running
_verbose("No pid => not running");
return 0; return 0;
} }
if ( defined $self->{EXIT_STATUS} ) { if ( defined $self->{EXIT_STATUS} ) {
# Exit status already set => not running # Exit status already set => not running
_verbose("Exit status already set => not running");
return 0; return 0;
} }
...@@ -400,6 +386,7 @@ sub wait_one { ...@@ -400,6 +386,7 @@ sub wait_one {
$blocking= 1; $blocking= 1;
$use_alarm= 0; $use_alarm= 0;
} }
#_verbose("blocking: $blocking, use_alarm: $use_alarm");
my $retpid; my $retpid;
eval eval
...@@ -419,18 +406,22 @@ sub wait_one { ...@@ -419,18 +406,22 @@ sub wait_one {
die "Got unexpected: $@" if ($@ !~ /waitpid timeout/); die "Got unexpected: $@" if ($@ !~ /waitpid timeout/);
if (!defined $retpid) { if (!defined $retpid) {
# Got timeout # Got timeout
_verbose("Got timeout");
return 1; return 1;
} }
# Got pid _and_ alarm, continue # Got pid _and_ alarm, continue
_verbose("Got pid and alarm, continue");
} }
if ( $retpid == 0 ) { if ( $retpid == 0 ) {
# 0 => still running # 0 => still running
_verbose("0 => still running");
return 1; return 1;
} }
if ( not $blocking and $retpid == -1 ) { if ( not $blocking and $retpid == -1 ) {
# still running # still running
_verbose("still running");
return 1; return 1;
} }
...@@ -514,5 +505,9 @@ sub self2str { ...@@ -514,5 +505,9 @@ sub self2str {
$str.= "]"; $str.= "]";
} }
sub _verbose {
return unless $_verbose;
print STDERR " ## ", @_, "\n";
}
1; 1;
...@@ -50,7 +50,7 @@ int main(int argc, const char** argv ) ...@@ -50,7 +50,7 @@ int main(int argc, const char** argv )
OpenEvent(EVENT_MODIFY_STATE, FALSE, safe_process_name)) == NULL) OpenEvent(EVENT_MODIFY_STATE, FALSE, safe_process_name)) == NULL)
{ {
if (retry_open_event--) if (retry_open_event--)
Sleep(0); /* yield */ Sleep(100);
else else
{ {
fprintf(stderr, "Failed to open shutdown_event '%s', error: %d\n", fprintf(stderr, "Failed to open shutdown_event '%s', error: %d\n",
......
...@@ -803,13 +803,6 @@ sub collect_one_test_case { ...@@ -803,13 +803,6 @@ sub collect_one_test_case {
return $tinfo return $tinfo
} }
if ( $tinfo->{'ndb_extra'} and ! $::opt_ndb_extra_test )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Test need 'ndb_extra' option";
return $tinfo
}
if ( $tinfo->{'need_debug'} && ! $::debug_compiled_binaries ) if ( $tinfo->{'need_debug'} && ! $::debug_compiled_binaries )
{ {
$tinfo->{'skip'}= 1; $tinfo->{'skip'}= 1;
...@@ -966,7 +959,6 @@ my @tags= ...@@ -966,7 +959,6 @@ my @tags=
["include/have_debug.inc", "need_debug", 1], ["include/have_debug.inc", "need_debug", 1],
["include/have_ndb.inc", "ndb_test", 1], ["include/have_ndb.inc", "ndb_test", 1],
["include/have_multi_ndb.inc", "ndb_test", 1], ["include/have_multi_ndb.inc", "ndb_test", 1],
["include/have_ndb_extra.inc", "ndb_extra", 1],
["include/master-slave.inc", "rpl_test", 1], ["include/master-slave.inc", "rpl_test", 1],
["include/ndb_master-slave.inc", "rpl_test", 1], ["include/ndb_master-slave.inc", "rpl_test", 1],
["include/ndb_master-slave.inc", "ndb_test", 1], ["include/ndb_master-slave.inc", "ndb_test", 1],
......
...@@ -47,6 +47,7 @@ use My::Platform; ...@@ -47,6 +47,7 @@ use My::Platform;
use My::SafeProcess; use My::SafeProcess;
use My::ConfigFactory; use My::ConfigFactory;
use My::Options; use My::Options;
use My::Find;
use mtr_cases; use mtr_cases;
use mtr_report; use mtr_report;
...@@ -94,8 +95,6 @@ my $exe_mysqld; ...@@ -94,8 +95,6 @@ my $exe_mysqld;
our $exe_mysql; our $exe_mysql;
our $exe_mysqladmin; our $exe_mysqladmin;
our $exe_mysqltest; our $exe_mysqltest;
our $exe_ndbd;
our $exe_ndb_mgmd= "";
our $exe_libtool; our $exe_libtool;
my $opt_big_test= 0; my $opt_big_test= 0;
...@@ -183,14 +182,10 @@ our $opt_warnings= 1; ...@@ -183,14 +182,10 @@ our $opt_warnings= 1;
our $opt_skip_ndbcluster= 0; our $opt_skip_ndbcluster= 0;
our $opt_skip_ndbcluster_slave= 0; our $opt_skip_ndbcluster_slave= 0;
our $opt_with_ndbcluster; our $opt_with_ndbcluster;
our $opt_ndb_extra_test= 0;
our $exe_ndb_mgm=""; my $exe_ndbd;
our $exe_ndb_waiter; my $exe_ndb_mgmd;
our $path_ndb_tools_dir= ""; my $exe_ndb_waiter;
our $path_ndb_examples_dir= "";
our $exe_ndb_example= "";
our $path_ndb_testrun_log;
our $path_sql_dir; our $path_sql_dir;
...@@ -295,7 +290,6 @@ sub command_line_setup { ...@@ -295,7 +290,6 @@ sub command_line_setup {
'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster, 'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster,
'skip-ndbcluster-slave|skip-ndb-slave' 'skip-ndbcluster-slave|skip-ndb-slave'
=> \$opt_skip_ndbcluster_slave, => \$opt_skip_ndbcluster_slave,
'ndb-extra-test' => \$opt_ndb_extra_test,
'suite|suites=s' => \$opt_suites, 'suite|suites=s' => \$opt_suites,
'skip-rpl' => \&collect_option, 'skip-rpl' => \&collect_option,
'skip-test=s' => \&collect_option, 'skip-test=s' => \&collect_option,
...@@ -749,7 +743,6 @@ sub command_line_setup { ...@@ -749,7 +743,6 @@ sub command_line_setup {
$path_testlog= "$opt_vardir/log/mysqltest.log"; $path_testlog= "$opt_vardir/log/mysqltest.log";
$path_current_testlog= "$opt_vardir/log/current_test"; $path_current_testlog= "$opt_vardir/log/current_test";
$path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
} }
...@@ -880,44 +873,6 @@ sub collect_mysqld_features { ...@@ -880,44 +873,6 @@ sub collect_mysqld_features {
} }
sub executable_setup_ndb () {
# Look for ndb tols and binaries
my $ndb_path= mtr_file_exists("$basedir/ndb",
"$basedir/storage/ndb",
"$basedir/bin");
$exe_ndbd=
mtr_exe_maybe_exists("$ndb_path/src/kernel/ndbd",
"$ndb_path/ndbd");
$exe_ndb_mgm=
mtr_exe_maybe_exists("$ndb_path/src/mgmclient/ndb_mgm",
"$ndb_path/ndb_mgm");
$exe_ndb_mgmd=
mtr_exe_maybe_exists("$ndb_path/src/mgmsrv/ndb_mgmd",
"$ndb_path/ndb_mgmd");
$exe_ndb_waiter=
mtr_exe_maybe_exists("$ndb_path/tools/ndb_waiter",
"$ndb_path/ndb_waiter");
# May not exist
$path_ndb_tools_dir= mtr_file_exists("$ndb_path/tools",
"$ndb_path");
# May not exist
$path_ndb_examples_dir=
mtr_file_exists("$ndb_path/ndbapi-examples",
"$ndb_path/examples");
# May not exist
$exe_ndb_example=
mtr_file_exists("$path_ndb_examples_dir/ndbapi_simple/ndbapi_simple");
return ( $exe_ndbd eq "" or
$exe_ndb_mgm eq "" or
$exe_ndb_mgmd eq "" or
$exe_ndb_waiter eq "");
}
sub executable_setup () { sub executable_setup () {
# #
...@@ -940,14 +895,23 @@ sub executable_setup () { ...@@ -940,14 +895,23 @@ sub executable_setup () {
$exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin"); $exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin");
$exe_mysql= mtr_exe_exists("$path_client_bindir/mysql"); $exe_mysql= mtr_exe_exists("$path_client_bindir/mysql");
if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) { if ( ! $opt_skip_ndbcluster )
mtr_warning("Could not find all required ndb binaries, " . {
"all ndb tests will fail, use --skip-ndbcluster to " . $exe_ndbd=
"skip testing it."); my_find_bin($basedir,
["storage/ndb/src/kernel", "libexec"],
"ndbd");
$exe_ndb_mgmd=
my_find_bin($basedir,
["storage/ndb/src/mgmsrv", "libexec"],
"ndb_mgmd");
$exe_ndb_waiter=
my_find_bin($basedir,
["storage/ndb/tools/", "bin"],
"ndb_waiter");
foreach my $cluster ( clusters()) {
$cluster->{"executable_setup_failed"}= 1;
}
} }
# Look for mysqltest executable # Look for mysqltest executable
...@@ -1204,13 +1168,30 @@ sub environment_setup { ...@@ -1204,13 +1168,30 @@ sub environment_setup {
# ---------------------------------------------------- # ----------------------------------------------------
# Setup env for NDB # Setup env for NDB
# ---------------------------------------------------- # ----------------------------------------------------
$ENV{'NDB_MGM'}= $exe_ndb_mgm; if ( ! $opt_skip_ndbcluster )
$ENV{'NDB_EXTRA_TEST'}= $opt_ndb_extra_test; {
$ENV{'NDB_TOOLS_DIR'}= $path_ndb_tools_dir; $ENV{'NDB_MGM'}=
my_find_bin($basedir,
["storage/ndb/src/mgmclient", "bin"],
"ndb_mgm");
$ENV{'NDB_TOOLS_DIR'}=
my_find_dir($basedir,
["storage/ndb/tools", "bin"]);
$ENV{'NDB_EXAMPLES_DIR'}=
my_find_dir($basedir,
["storage/ndb/ndbapi-examples", "bin"]);
$ENV{'NDB_EXAMPLES_BINARY'}=
my_find_bin($basedir,
["storage/ndb/ndbapi-examples/ndbapi_simple", "bin"],
"ndbapi_simple", NOT_REQUIRED);
my $path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
$ENV{'NDB_TOOLS_OUTPUT'}= $path_ndb_testrun_log; $ENV{'NDB_TOOLS_OUTPUT'}= $path_ndb_testrun_log;
$ENV{'NDB_EXAMPLES_DIR'}= $path_ndb_examples_dir;
$ENV{'NDB_EXAMPLES_BINARY'}= $exe_ndb_example;
$ENV{'NDB_EXAMPLES_OUTPUT'}= $path_ndb_testrun_log; $ENV{'NDB_EXAMPLES_OUTPUT'}= $path_ndb_testrun_log;
}
# ---------------------------------------------------- # ----------------------------------------------------
# mysql clients # mysql clients
...@@ -2110,23 +2091,6 @@ sub run_testcase_check_skip_test($) ...@@ -2110,23 +2091,6 @@ sub run_testcase_check_skip_test($)
return 1; return 1;
} }
if ($tinfo->{'ndb_test'})
{
foreach my $cluster ( clusters() )
{
# If test needs this cluster, check binaries was found ok
if ( $cluster->{'executable_setup_failed'} )
{
$tinfo->{comment}=
"Failed to find cluster binaries";
mtr_report_test_failed($tinfo, undef);
return 1;
}
}
}
return 0; return 0;
} }
...@@ -3628,7 +3592,6 @@ Options to control what test suites or cases to run ...@@ -3628,7 +3592,6 @@ Options to control what test suites or cases to run
with-ndbcluster-only Run only tests that include "ndb" in the filename with-ndbcluster-only Run only tests that include "ndb" in the filename
skip-ndb[cluster] Skip all tests that need cluster skip-ndb[cluster] Skip all tests that need cluster
skip-ndb[cluster]-slave Skip all tests that need a slave cluster skip-ndb[cluster]-slave Skip all tests that need a slave cluster
ndb-extra Run extra tests from ndb directory
do-test=PREFIX or REGEX do-test=PREFIX or REGEX
Run test cases which name are prefixed with PREFIX Run test cases which name are prefixed with PREFIX
or fulfills REGEX or fulfills REGEX
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
--connection slave --connection slave
RESET MASTER; RESET MASTER;
# Check Last_errno # Check Last_IO_Errno
let $the_last_errno= query_get_value(SHOW SLAVE STATUS, Last_Errno, 1); let $the_last_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
echo Last errno after reset master on slave: $the_last_errno; echo Last errno after reset master on slave: $the_last_errno;
--connection master --connection master
...@@ -18,7 +18,7 @@ START SLAVE; ...@@ -18,7 +18,7 @@ START SLAVE;
# Check Last_errno # Check Last_errno
let $the_last_errno= query_get_value(SHOW SLAVE STATUS, Last_Errno, 1); let $the_last_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
echo Last errno after start slave: $the_last_errno; echo Last errno after start slave: $the_last_errno;
# create the table on the "slave" # create the table on the "slave"
...@@ -32,7 +32,7 @@ CREATE TABLE t1 (a int key, b int) ENGINE=ndb; ...@@ -32,7 +32,7 @@ CREATE TABLE t1 (a int key, b int) ENGINE=ndb;
SHOW TABLES; SHOW TABLES;
# Check Last_errno # Check Last_errno
let $the_last_errno= query_get_value(SHOW SLAVE STATUS, Last_Errno, 1); let $the_last_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
echo Last errno after table on both: $the_last_errno; echo Last errno after table on both: $the_last_errno;
# insert some values on the slave and master # insert some values on the slave and master
......
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