Commit 24640ab9 authored by unknown's avatar unknown

Find ndb binaries

Verbose SafeProcess.pm 


mysql-test/mysql-test-run.pl:
  Cleanup how script find ndb binaries and paths
  Remove "executable_setup_failed" code, i.e either we have ndb support or we don't
  Remove ndb_extra_test, not used by any test. If there is a need for that, just 
  create a new suite
mysql-test/lib/My/Find.pm:
  Add possibility to use my_find_bin for a binary that is not required
mysql-test/lib/My/SafeProcess.pm:
  Add verbose printous that can be turned on
  Wait on process also if start_kill failed
  Turn verbose on for windows
mysql-test/lib/My/SafeProcess/safe_kill_win.cc:
  Extend sleep from 0 to 100
mysql-test/lib/mtr_cases.pm:
  Remove ndb_extra
mysql-test/suite/rpl_ndb/t/rpl_ndb_circular.test:
  Extra checks should be for Last_IO_Errno
parent 055d5da8
......@@ -26,12 +26,15 @@ use Carp;
use My::Platform;
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;
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
# paths "path_1...path_n" and return the full path
......@@ -44,13 +47,21 @@ my $bin_extension= ".exe" if IS_WINDOWS;
# ["client", "bin"],
# "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
#
#
sub my_find_bin {
my ($base, $paths, $names)= @_;
croak "usage: my_find_bin(<base>, <paths>, <names>)"
unless @_ == 3;
my ($base, $paths, $names, $required)= @_;
croak "usage: my_find_bin(<base>, <paths>, <names>, [<required>])"
unless @_ == 4 or @_ == 3;
# -------------------------------------------------------
# Find and return the first executable
......@@ -58,6 +69,10 @@ sub my_find_bin {
foreach my $path (my_find_paths($base, $paths, $names, $bin_extension)) {
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);
}
......@@ -79,7 +94,7 @@ sub my_find_bin {
#
#
sub my_find_dir {
my ($base, $paths, $dirs)= @_;
my ($base, $paths, $dirs, $required)= @_;
croak "usage: my_find_dir(<base>, <paths>[, <dirs>])"
unless (@_ == 3 or @_ == 2);
......
......@@ -59,6 +59,7 @@ use My::Find;
use My::Platform;
my %running;
my $_verbose= IS_WINDOWS;
END {
# Kill any children still running
......@@ -85,33 +86,17 @@ if (IS_WIN32PERL or IS_CYGWIN){
# Use my_safe_process.exe
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
die "Could not find my_safe_process" unless $exe;
push(@safe_process_cmd, $exe);
# Use my_safe_kill.exe
$safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill");
die "Could not find my_safe_kill" unless $safe_kill;
}
else
{
my $use_safe_process_binary= 1;
if ($use_safe_process_binary) {
# Use my_safe_process
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
die "Could not find my_safe_process" unless $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);
}
# Use my_safe_process
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
push(@safe_process_cmd, $exe);
}
......@@ -248,14 +233,14 @@ sub timer {
sub shutdown {
my $shutdown_timeout= shift;
my @processes= @_;
_verbose("shutdown, timeout: $shutdown_timeout, @processes");
return if (@processes == 0);
#print "shutdown: @processes\n";
# Call shutdown function if process has one, else
# use kill
foreach my $proc (@processes){
_verbose(" proc: $proc");
my $shutdown= $proc->{SAFE_SHUTDOWN};
if ($shutdown_timeout > 0 and defined $shutdown){
$shutdown->();
......@@ -301,7 +286,7 @@ sub shutdown {
sub start_kill {
my ($self)= @_;
croak "usage: \$safe_proc->start_kill()" unless (@_ == 1 and ref $self);
#print "start_kill $self\n";
_verbose("start_kill: $self");
my $ret= 1;
if (defined $safe_kill and $self->{SAFE_WINPID}){
......@@ -309,6 +294,7 @@ sub start_kill {
# it's time to kill it's child and return
my $pid= $self->{SAFE_WINPID};
$ret= (system($safe_kill, $pid) >> 8) == 0;
print `tasklist` unless $ret;
} else {
my $pid= $self->{SAFE_PID};
die "Can't kill not started process" unless defined $pid;
......@@ -327,10 +313,8 @@ sub kill {
my ($self)= @_;
croak "usage: \$safe_proc->kill()" unless (@_ == 1 and ref $self);
if ($self->start_kill())
{
$self->wait_one();
}
$self->start_kill();
$self->wait_one();
return 1;
}
......@@ -338,8 +322,8 @@ sub kill {
sub _collect {
my ($self)= @_;
#print "_collect\n";
$self->{EXIT_STATUS}= $?;
_verbose("_collect: $self");
# Take the process out of running list
my $pid= $self->{SAFE_PID};
......@@ -363,15 +347,17 @@ sub wait_one {
my ($self, $timeout)= @_;
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}) ) {
# No pid => not running
_verbose("No pid => not running");
return 0;
}
if ( defined $self->{EXIT_STATUS} ) {
# Exit status already set => not running
_verbose("Exit status already set => not running");
return 0;
}
......@@ -400,6 +386,7 @@ sub wait_one {
$blocking= 1;
$use_alarm= 0;
}
#_verbose("blocking: $blocking, use_alarm: $use_alarm");
my $retpid;
eval
......@@ -419,18 +406,22 @@ sub wait_one {
die "Got unexpected: $@" if ($@ !~ /waitpid timeout/);
if (!defined $retpid) {
# Got timeout
_verbose("Got timeout");
return 1;
}
# Got pid _and_ alarm, continue
_verbose("Got pid and alarm, continue");
}
if ( $retpid == 0 ) {
# 0 => still running
_verbose("0 => still running");
return 1;
}
if ( not $blocking and $retpid == -1 ) {
# still running
_verbose("still running");
return 1;
}
......@@ -514,5 +505,9 @@ sub self2str {
$str.= "]";
}
sub _verbose {
return unless $_verbose;
print STDERR " ## ", @_, "\n";
}
1;
......@@ -50,7 +50,7 @@ int main(int argc, const char** argv )
OpenEvent(EVENT_MODIFY_STATE, FALSE, safe_process_name)) == NULL)
{
if (retry_open_event--)
Sleep(0); /* yield */
Sleep(100);
else
{
fprintf(stderr, "Failed to open shutdown_event '%s', error: %d\n",
......
......@@ -803,13 +803,6 @@ sub collect_one_test_case {
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 )
{
$tinfo->{'skip'}= 1;
......@@ -966,7 +959,6 @@ my @tags=
["include/have_debug.inc", "need_debug", 1],
["include/have_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/ndb_master-slave.inc", "rpl_test", 1],
["include/ndb_master-slave.inc", "ndb_test", 1],
......
......@@ -47,6 +47,7 @@ use My::Platform;
use My::SafeProcess;
use My::ConfigFactory;
use My::Options;
use My::Find;
use mtr_cases;
use mtr_report;
......@@ -94,8 +95,6 @@ my $exe_mysqld;
our $exe_mysql;
our $exe_mysqladmin;
our $exe_mysqltest;
our $exe_ndbd;
our $exe_ndb_mgmd= "";
our $exe_libtool;
my $opt_big_test= 0;
......@@ -183,14 +182,10 @@ our $opt_warnings= 1;
our $opt_skip_ndbcluster= 0;
our $opt_skip_ndbcluster_slave= 0;
our $opt_with_ndbcluster;
our $opt_ndb_extra_test= 0;
our $exe_ndb_mgm="";
our $exe_ndb_waiter;
our $path_ndb_tools_dir= "";
our $path_ndb_examples_dir= "";
our $exe_ndb_example= "";
our $path_ndb_testrun_log;
my $exe_ndbd;
my $exe_ndb_mgmd;
my $exe_ndb_waiter;
our $path_sql_dir;
......@@ -295,7 +290,6 @@ sub command_line_setup {
'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster,
'skip-ndbcluster-slave|skip-ndb-slave'
=> \$opt_skip_ndbcluster_slave,
'ndb-extra-test' => \$opt_ndb_extra_test,
'suite|suites=s' => \$opt_suites,
'skip-rpl' => \&collect_option,
'skip-test=s' => \&collect_option,
......@@ -749,7 +743,6 @@ sub command_line_setup {
$path_testlog= "$opt_vardir/log/mysqltest.log";
$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 {
}
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 () {
#
......@@ -940,14 +895,23 @@ sub executable_setup () {
$exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin");
$exe_mysql= mtr_exe_exists("$path_client_bindir/mysql");
if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) {
mtr_warning("Could not find all required ndb binaries, " .
"all ndb tests will fail, use --skip-ndbcluster to " .
"skip testing it.");
if ( ! $opt_skip_ndbcluster )
{
$exe_ndbd=
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
......@@ -1204,13 +1168,30 @@ sub environment_setup {
# ----------------------------------------------------
# Setup env for NDB
# ----------------------------------------------------
$ENV{'NDB_MGM'}= $exe_ndb_mgm;
$ENV{'NDB_EXTRA_TEST'}= $opt_ndb_extra_test;
$ENV{'NDB_TOOLS_DIR'}= $path_ndb_tools_dir;
$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;
if ( ! $opt_skip_ndbcluster )
{
$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_EXAMPLES_OUTPUT'}= $path_ndb_testrun_log;
}
# ----------------------------------------------------
# mysql clients
......@@ -2110,23 +2091,6 @@ sub run_testcase_check_skip_test($)
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;
}
......@@ -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
skip-ndb[cluster] Skip all tests that need 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
Run test cases which name are prefixed with PREFIX
or fulfills REGEX
......
......@@ -6,8 +6,8 @@
--connection slave
RESET MASTER;
# Check Last_errno
let $the_last_errno= query_get_value(SHOW SLAVE STATUS, Last_Errno, 1);
# Check Last_IO_Errno
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;
--connection master
......@@ -18,7 +18,7 @@ START SLAVE;
# 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;
# create the table on the "slave"
......@@ -32,7 +32,7 @@ CREATE TABLE t1 (a int key, b int) ENGINE=ndb;
SHOW TABLES;
# 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;
# 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