Commit c2db9397 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-18565 Galera mtr-suite fails if galera library is not installed

revert/simplify f5390eea

remove galera-specific checks from mtr and the main suite
parent 81511b47
......@@ -3,7 +3,7 @@
--let $galera_have_debug_sync = `SELECT 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters'`
--if (!$galera_have_debug_sync) {
--skip "Test requires Galera debug library with debug_sync functionality"
--skip Test requires Galera debug library with debug_sync functionality
}
--enable_query_log
#
# suite.pm will make sure that all tests including this file
# will be skipped as needed
#
#
# suite.pm will make sure that all tests including this file
# will be skipped as needed
#
......@@ -100,8 +100,6 @@ else
$bindir = getcwd();
}
our $wsrep_check_version;
# Find the safe process binary or script
sub find_bin {
if (IS_WIN32PERL or IS_CYGWIN)
......@@ -121,10 +119,6 @@ sub find_bin {
"my_safe_process");
push(@safe_process_cmd, $exe);
}
# Wsrep version check utility:
$wsrep_check_version=
my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"],
"wsrep_check_version", NOT_REQUIRED);
}
......
......@@ -14,6 +14,8 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
IF (WIN32)
ADD_EXECUTABLE(my_safe_process safe_process_win.cc)
ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc)
......
......@@ -13,122 +13,39 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#include <stdlib.h>
#include <stdio.h>
#include <my_global.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef _WIN32
#include <windows.h>
#define dlsym(lib, name) GetProcAddress((HMODULE)lib, name)
#define dlopen(libname, unused) LoadLibraryEx(libname, NULL, 0)
#define dlclose(lib) FreeLibrary((HMODULE)lib)
#elif defined(HAVE_DLFCN_H)
#include <dlfcn.h>
#else
#define NO_DLL
#endif
#ifndef NO_DLL
#include "../../../../wsrep-lib/wsrep-API/v26/wsrep_api.h"
/**************************************************************************
* Library loader
**************************************************************************/
static int wsrep_check_iface_version(const char *found, const char *iface_ver)
{
if (strcmp(found, iface_ver)) {
return ERANGE;
}
return 0;
}
typedef int (*wsrep_loader_fun)(wsrep_t*);
static wsrep_loader_fun wsrep_dlf(void *dlh, const char *sym)
{
union {
wsrep_loader_fun dlfun;
void *obj;
} alias;
alias.obj = dlsym(dlh, sym);
return alias.dlfun;
}
static int wsrep_check_version_symbol(void *dlh)
{
char** dlversion = NULL;
dlversion = (char**) dlsym(dlh, "wsrep_interface_version");
if (dlversion == NULL)
return EINVAL;
return wsrep_check_iface_version(*dlversion, WSREP_INTERFACE_VERSION);
}
static int wsrep_print_version(void *dlh)
{
char** dlversion = NULL;
dlversion = (char**) dlsym(dlh, "wsrep_interface_version");
if (dlversion == NULL)
return EINVAL;
printf("found: %s, need: %s\n", *dlversion, WSREP_INTERFACE_VERSION);
return 0;
}
int main(int argc, char **argv)
{
int rc = EINVAL;
void *dlh;
wsrep_loader_fun dlfun;
const char *provider= getenv("WSREP_PROVIDER");
if (!provider)
{
fprintf(stderr, "WSREP_PROVIDER is not set\n");
return 1;
}
if (!(dlh = dlopen(provider, RTLD_NOW | RTLD_LOCAL)))
{
fprintf(stderr, "Can't open WSREP_PROVIDER (%s) library, error: %s\n",
provider, dlerror());
goto err;
}
if (!(dlfun = wsrep_dlf(dlh, "wsrep_loader")))
{
fprintf(stderr, "Can't find 'wsrep_loader' symbol in %s\n",
provider);
goto err;
}
if (argc < 2 || strcmp(argv[1], "-p")) {
rc = wsrep_check_version_symbol(dlh);
}
else {
rc = wsrep_print_version(dlh);
}
err:
if (dlh) dlclose(dlh);
if (rc == 0)
return 0;
else if (rc == ERANGE)
return 2;
else
return 1;
}
#else
int main(void)
{
int rc= 1;
void *dlh;
const char *provider= getenv("WSREP_PROVIDER");
char** dlversion= NULL;
if (!provider || !*provider)
{
printf("WSREP_PROVIDER is not set\n");
return 1;
}
if (!(dlh= dlopen(provider, RTLD_NOW | RTLD_LOCAL)))
{
printf("Can't open WSREP_PROVIDER (%s) library, error: %s\n",
provider, dlerror());
return 1;
}
dlversion= (char**) dlsym(dlh, "wsrep_interface_version");
if (dlversion && *dlversion)
{
rc= strcmp(*dlversion, WSREP_INTERFACE_VERSION) ? 2 : 0;
if (rc)
printf("Wrong wsrep provider library version, found: %s, need: %s\n", *dlversion, WSREP_INTERFACE_VERSION);
}
else
printf("Galera library does not contain a version symbol");
dlclose(dlh);
return rc;
}
#endif
......@@ -140,10 +140,6 @@ my $opt_start_dirty;
my $opt_start_exit;
my $start_only;
my $file_wsrep_provider;
my $extra_path;
my $mariabackup_path;
my $mariabackup_exe;
my $garbd_exe;
our @global_suppressions;
......@@ -379,170 +375,6 @@ $| = 1; # Automatically flush STDOUT
main();
sub have_wsrep() {
my $wsrep_on= $mysqld_variables{'wsrep-on'};
return defined $wsrep_on
}
sub have_wsrep_provider() {
return $file_wsrep_provider ne "";
}
sub have_mariabackup() {
return $mariabackup_path ne "";
}
sub have_garbd() {
return $garbd_exe ne "";
}
sub check_wsrep_version() {
if ($My::SafeProcess::wsrep_check_version ne "") {
system($My::SafeProcess::wsrep_check_version);
return ($? >> 8) == 0;
}
else {
return 0;
}
}
sub wsrep_version_message() {
if ($My::SafeProcess::wsrep_check_version ne "") {
my $output= `$My::SafeProcess::wsrep_check_version -p`;
if (($? >> 8) == 0) {
$output =~ s/\s+\z//;
return "Wsrep provider version mismatch (".$output.")";
}
else {
return "Galera library does not contain a version symbol";
}
}
else {
return "Unable to find a wsrep version check utility";
}
}
sub which($) { return `sh -c "command -v $_[0]"` }
sub check_garbd_support() {
if (defined $ENV{'MTR_GARBD_EXE'}) {
if (mtr_file_exists($ENV{'MTR_GARBD_EXE'}) ne "") {
$garbd_exe= $ENV{'MTR_GARBD_EXE'};
} else {
mtr_error("MTR_GARBD_EXE env set to an invalid path");
}
}
else {
my $wsrep_path= dirname($file_wsrep_provider);
$garbd_exe=
mtr_file_exists($wsrep_path."/garb/garbd",
$wsrep_path."/../../bin/garb/garbd");
if ($garbd_exe ne "") {
$ENV{MTR_GARBD_EXE}= $garbd_exe;
}
}
}
sub check_wsrep_support() {
$garbd_exe= "";
if (have_wsrep()) {
mtr_report(" - binaries built with wsrep patch");
# ADD scripts to $PATH to that wsrep_sst_* can be found
my ($spath) = grep { -f "$_/wsrep_sst_rsync"; } "$bindir/scripts", $path_client_bindir;
mtr_error("No SST scripts") unless $spath;
my $separator= (IS_WINDOWS) ? ';' : ':';
$ENV{PATH}="$spath$separator$ENV{PATH}";
# ADD mysql client library path to path so that wsrep_notify_cmd can find mysql
# client for loading the tables. (Don't assume each machine has mysql install)
my ($cpath) = grep { -f "$_/mysql"; } "$bindir/scripts", $path_client_bindir;
mtr_error("No scritps") unless $cpath;
$ENV{PATH}="$cpath$separator$ENV{PATH}" unless $cpath eq $spath;
# ADD my_print_defaults script path to path so that SST scripts can find it
my $my_print_defaults_exe=
mtr_exe_maybe_exists(
"$bindir/extra/my_print_defaults",
"$path_client_bindir/my_print_defaults");
my $epath= "";
if ($my_print_defaults_exe ne "") {
$epath= dirname($my_print_defaults_exe);
}
mtr_error("No my_print_defaults") unless $epath;
$ENV{PATH}="$epath$separator$ENV{PATH}" unless ($epath eq $spath) or
($epath eq $cpath);
$extra_path= $epath;
if (!IS_WINDOWS) {
if (which("socat")) {
$ENV{MTR_GALERA_TFMT}="socat";
} elsif (which("nc")) {
$ENV{MTR_GALERA_TFMT}="nc";
}
}
# Check whether WSREP_PROVIDER environment variable is set.
if (defined $ENV{'WSREP_PROVIDER'}) {
$file_wsrep_provider= "";
if ($ENV{'WSREP_PROVIDER'} ne "none") {
if (mtr_file_exists($ENV{'WSREP_PROVIDER'}) ne "") {
$file_wsrep_provider= $ENV{'WSREP_PROVIDER'};
} else {
mtr_error("WSREP_PROVIDER env set to an invalid path");
}
check_garbd_support();
}
# WSREP_PROVIDER is valid; set to a valid path or "none").
mtr_verbose("WSREP_PROVIDER env set to $ENV{'WSREP_PROVIDER'}");
} else {
# WSREP_PROVIDER env not defined. Lets try to locate the wsrep provider
# library.
$file_wsrep_provider=
mtr_file_exists("/usr/lib64/galera-4/libgalera_smm.so",
"/usr/lib64/galera/libgalera_smm.so",
"/usr/lib/galera-4/libgalera_smm.so",
"/usr/lib/galera/libgalera_smm.so");
if ($file_wsrep_provider ne "") {
# wsrep provider library found !
mtr_verbose("wsrep provider library found : $file_wsrep_provider");
$ENV{'WSREP_PROVIDER'}= $file_wsrep_provider;
check_garbd_support();
} else {
mtr_verbose("Could not find wsrep provider library, setting it to 'none'");
$ENV{'WSREP_PROVIDER'}= "none";
}
}
} else {
$file_wsrep_provider= "";
$extra_path= "";
}
}
sub check_mariabackup_support() {
$mariabackup_path= "";
$mariabackup_exe=
mtr_exe_maybe_exists(
"$bindir/extra/mariabackup$opt_vs_config/mariabackup",
"$path_client_bindir/mariabackup");
if ($mariabackup_exe ne "") {
my $bpath= dirname($mariabackup_exe);
my $separator= (IS_WINDOWS) ? ';' : ':';
$ENV{PATH}="$bpath$separator$ENV{PATH}" unless $bpath eq $extra_path;
$mariabackup_path= $bpath;
$ENV{XTRABACKUP}= $mariabackup_exe;
$ENV{XBSTREAM}= mtr_exe_maybe_exists(
"$bindir/extra/mariabackup/$opt_vs_config/mbstream",
"$path_client_bindir/mbstream");
$ENV{INNOBACKUPEX}= "$mariabackup_exe --innobackupex";
}
}
sub main {
$ENV{MTR_PERL}=$^X;
......@@ -587,8 +419,7 @@ sub main {
}
check_ssl_support();
check_debug_support();
check_wsrep_support();
check_mariabackup_support();
environment_setup();
if (!$opt_suites) {
$opt_suites= join ',', collect_default_suites(@DEFAULT_SUITES);
......@@ -2578,10 +2409,23 @@ sub environment_setup {
my $exe_innochecksum=
mtr_exe_maybe_exists("$bindir/extra$opt_vs_config/innochecksum",
"$path_client_bindir/innochecksum");
if ($exe_innochecksum)
{
$ENV{'INNOCHECKSUM'}= native_path($exe_innochecksum);
}
$ENV{'INNOCHECKSUM'}= native_path($exe_innochecksum) if $exe_innochecksum;
# ----------------------------------------------------
# mariabackup
# ----------------------------------------------------
my $exe_mariabackup= mtr_exe_maybe_exists(
"$bindir/extra/mariabackup$opt_vs_config/mariabackup",
"$path_client_bindir/mariabackup");
$ENV{XTRABACKUP}= native_path($exe_mariabackup) if $exe_mariabackup;
my $exe_xbstream= mtr_exe_maybe_exists(
"$bindir/extra/mariabackup/$opt_vs_config/mbstream",
"$path_client_bindir/mbstream");
$ENV{XBSTREAM}= native_path($exe_xbstream) if $exe_xbstream;
$ENV{INNOBACKUPEX}= "$exe_mariabackup --innobackupex";
# Create an environment variable to make it possible
# to detect that valgrind is being used from test cases
......
......@@ -47,21 +47,6 @@ sub skip_combinations {
$skip{'main/plugin_loaderr.test'} = 'needs compiled-in innodb'
unless $::mysqld_variables{'innodb'} eq "ON";
$skip{'include/have_mariabackup.inc'} = 'Need mariabackup'
unless ::have_mariabackup();
$skip{'include/have_mariabackup.inc'} = 'Need socket statistics utility'
unless IS_WINDOWS || ::which("ss");
$skip{'include/have_mariabackup.inc'} = 'Need socat or nc'
unless IS_WINDOWS || $ENV{MTR_GALERA_TFMT};
$skip{'include/have_garbd.inc'} = 'Need garbd'
unless ::have_garbd();
$skip{'include/have_file_key_management.inc'} = 'Needs file_key_management plugin'
unless $ENV{FILE_KEY_MANAGEMENT_SO};
# disable tests that use ipv6, if unsupported
sub ipv6_ok() {
use Socket;
......
if (!$XTRABACKUP) {
skip Needs mariabackup;
}
if (!$MTR_GALERA_TFMT) {
skip Needs socat or nc;
}
package My::Suite::Galera;
use File::Basename;
use My::Find;
@ISA = qw(My::Suite);
return "Not run for embedded server" if $::opt_embedded_server;
return "WSREP is not compiled in" if not ::have_wsrep();
use lib 'suite';
use wsrep::common;
return "No wsrep provider library" unless ::have_wsrep_provider();
@ISA = qw(My::Suite);
return ::wsrep_version_message() unless ::check_wsrep_version();
return wsrep_not_ok() if wsrep_not_ok();
push @::global_suppressions,
(
......@@ -69,4 +64,10 @@ push @::global_suppressions,
qr(WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to .*),
);
sub skip_combinations {
my %skip = ();
$skip{'include/have_mariabackup.inc'} = 'Need ss' unless `ss -V`;
%skip;
}
bless { };
......@@ -10,3 +10,6 @@ wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true'
[mysqld.2]
wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true'
[sst]
transferfmt=@ENV.MTR_GALERA_TFMT
streamfmt=xbstream
......@@ -12,3 +12,6 @@ wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true'
[mysqld.2]
wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true'
[sst]
transferfmt=@ENV.MTR_GALERA_TFMT
streamfmt=xbstream
if (!$MTR_GARBD_EXE) {
skip Needs garbd;
}
package My::Suite::GALERA_3NODES;
use File::Basename;
use My::Find;
@ISA = qw(My::Suite);
return "Not run for embedded server" if $::opt_embedded_server;
use lib 'suite';
use wsrep::common;
return "WSREP is not compiled in" if not ::have_wsrep();
return "No wsrep provider library" unless ::have_wsrep_provider();
@ISA = qw(My::Suite);
return ::wsrep_version_message() unless ::check_wsrep_version();
return wsrep_not_ok() if wsrep_not_ok();
push @::global_suppressions,
(
......
......@@ -4,7 +4,7 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
--source include/have_mariabackup.inc
--source suite/galera/include/have_mariabackup.inc
--let $galera_connection_name = node_3
--let $galera_server_number = 3
......
package My::Suite::Galera_sr;
use File::Basename;
use My::Find;
@ISA = qw(My::Suite);
return "Not run for embedded server" if $::opt_embedded_server;
use lib 'suite';
use wsrep::common;
return "WSREP is not compiled in" if not ::have_wsrep();
return "No wsrep provider library" unless ::have_wsrep_provider();
@ISA = qw(My::Suite);
return ::wsrep_version_message() unless ::check_wsrep_version();
return wsrep_not_ok() if wsrep_not_ok();
push @::global_suppressions,
(
......
......@@ -7,12 +7,13 @@ use strict;
return "Not run for embedded server" if $::opt_embedded_server;
return "No mariabackup" unless ::have_mariabackup();
return "No mariabackup" unless $ENV{XTRABACKUP};
my $have_qpress = index(`qpress 2>&1`,"Compression") > 0;
sub skip_combinations {
my %skip;
$skip{'include/have_file_key_management.inc'} = 'needs file_key_management plugin' unless $ENV{FILE_KEY_MANAGEMENT_SO};
$skip{'compress_qpress.test'}= 'needs qpress executable in PATH' unless $have_qpress;
%skip;
}
......
package wsrep::common;
use base qw(Exporter);
our @EXPORT= qw(wsrep_not_ok);
use File::Basename;
use Memoize;
memoize 'wrong_wsrep_version';
memoize 'check_garbd_support';
memoize 'check_wsrep_support';
memoize 'wsrep_not_ok';
use mtr_report;
my $extra_path;
my $mariabackup_path;
my $mariabackup_exe;
my $garbd_exe;
my $file_wsrep_provider;
sub wrong_wsrep_version() {
my $check_version= dirname($My::SafeProcess::safe_process_cmd[0]) . '/wsrep_check_version';
my $checked = `$check_version -p`;
chomp($checked);
return $? ? $checked : undef;
}
sub which($) { return `sh -c "command -v $_[0]"` }
sub check_garbd_support() {
my $wsrep_path= dirname($file_wsrep_provider);
$garbd_exe= ::mtr_file_exists($wsrep_path."/garb/garbd",
$wsrep_path."/../../bin/garb/garbd",
'/usr/bin/garbd');
$ENV{MTR_GARBD_EXE}= $garbd_exe if $garbd_exe;
}
sub check_wsrep_support() {
mtr_report(" - binaries built with wsrep patch");
# ADD scripts to $PATH to that wsrep_sst_* can be found
my ($spath) = grep { -f "$_/wsrep_sst_rsync"; } "$::bindir/scripts", $::path_client_bindir;
mtr_error("No SST scripts") unless $spath;
$ENV{PATH}="$spath:$ENV{PATH}";
# ADD mysql client library path to path so that wsrep_notify_cmd can find mysql
# client for loading the tables. (Don't assume each machine has mysql install)
my ($cpath) = grep { -f "$_/mysql"; } "$::bindir/scripts", $::path_client_bindir;
mtr_error("No scritps") unless $cpath;
$ENV{PATH}="$cpath:$ENV{PATH}" unless $cpath eq $spath;
# ADD my_print_defaults script path to path so that SST scripts can find it
my $my_print_defaults_exe=
::mtr_exe_maybe_exists(
"$::bindir/extra/my_print_defaults",
"$::path_client_bindir/my_print_defaults");
my $epath= "";
if ($my_print_defaults_exe ne "") {
$epath= dirname($my_print_defaults_exe);
}
mtr_error("No my_print_defaults") unless $epath;
$ENV{PATH}="$epath:$ENV{PATH}" unless ($epath eq $spath) or
($epath eq $cpath);
$extra_path= $epath;
if (which("socat")) {
$ENV{MTR_GALERA_TFMT}="socat";
} elsif (which("nc")) {
$ENV{MTR_GALERA_TFMT}="nc";
}
$ENV{PATH}=dirname($ENV{XTRABACKUP}).":$ENV{PATH}" if $ENV{XTRABACKUP};
# Check whether WSREP_PROVIDER environment variable is set.
if (defined $ENV{'WSREP_PROVIDER'}) {
$file_wsrep_provider= "";
if ($ENV{'WSREP_PROVIDER'} ne "none") {
if (::mtr_file_exists($ENV{'WSREP_PROVIDER'}) ne "") {
$file_wsrep_provider= $ENV{'WSREP_PROVIDER'};
} else {
mtr_error("WSREP_PROVIDER env set to an invalid path");
}
check_garbd_support();
}
# WSREP_PROVIDER is valid; set to a valid path or "none").
mtr_verbose("WSREP_PROVIDER env set to $ENV{'WSREP_PROVIDER'}");
} else {
# WSREP_PROVIDER env not defined. Lets try to locate the wsrep provider
# library.
$file_wsrep_provider=
::mtr_file_exists("/usr/lib64/galera-4/libgalera_smm.so",
"/usr/lib64/galera/libgalera_smm.so",
"/usr/lib/galera-4/libgalera_smm.so",
"/usr/lib/galera/libgalera_smm.so");
if ($file_wsrep_provider ne "") {
# wsrep provider library found !
mtr_verbose("wsrep provider library found : $file_wsrep_provider");
$ENV{'WSREP_PROVIDER'}= $file_wsrep_provider;
check_garbd_support();
} else {
mtr_verbose("Could not find wsrep provider library, setting it to 'none'");
$ENV{'WSREP_PROVIDER'}= "none";
}
}
}
sub wsrep_not_ok() {
return "Not run for embedded server" if $::opt_embedded_server;
return "WSREP is not compiled in" if not $::mysqld_variables{'wsrep-on'};
check_wsrep_support();
return "No wsrep provider library" unless $file_wsrep_provider;
return wrong_wsrep_version() if wrong_wsrep_version();
undef;
}
1;
package My::Suite::WSREP;
use File::Basename;
use My::Find;
@ISA = qw(My::Suite);
return "Not run for embedded server" if $::opt_embedded_server;
use lib 'suite';
use wsrep::common;
return "WSREP is not compiled in" unless ::have_wsrep();
return "No wsrep provider library" unless ::have_wsrep_provider();
@ISA = qw(My::Suite);
return ::wsrep_version_message() unless ::check_wsrep_version();
return wsrep_not_ok() if wsrep_not_ok();
push @::global_suppressions,
(
......
......@@ -4,15 +4,9 @@ use My::Find;
@ISA = qw(My::Suite);
return "Not run for embedded server" if $::opt_embedded_server;
return "WSREP is not compiled in" if not ::have_wsrep();
return "No wsrep provider library" unless ::have_wsrep_provider();
return ::wsrep_version_message() unless ::check_wsrep_version();
return "No WSREP_INFO plugin" unless $ENV{WSREP_INFO_SO};
use lib 'suite';
use wsrep::common;
return wsrep_not_ok() if wsrep_not_ok();
push @::global_suppressions,
(
......
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