-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-18565: Galera mtr-suite fails if galera library is not installed
Currently, running mtr with an incorrect (for example, new or obsolete) version of wsrep_provider (for example, with the 26 version of libgalera_smm.so) leads to the failure of tests in several suites with vague error diagnostics. As for the galera_3nodes suite, the mtr also does not effectively check all the prerequisites after merge with MDEV-18426 fixes. For example, tests that using mariabackup do not check for presence of ss and socat/nc. This is due to improper handling of relative paths in mtr scripts. In addition, some tests in different suites can be run without setting the environment variables such as MTR_GALERA_TFMT, XBSTREAM, and so on. To eliminate all these issues, this patch makes the following changes: 1. Added auxiliary wsrep_mtr_check utility (which located in the mysql-test/lib/My/SafeProcess subdirectory), which compares the versions of the wsrep API that used by the server and by the wsrep provider library, and it does this comparison safely, without accessing the API if the versions do not match. 2. All checks related to the presence of mariabackup and utilities that necessary for its operation transferred from the local directories of different mtr suites (from the suite.pm files) to the main suite.pm file. This not only reduces the amount of code and eliminates duplication of identical code fragments, but also avoids problems due to the inability of mtr to consider relative paths to include files when checking skip combinations. 3. Setting the values of auxiliary environment variables that are necessary for Galera, SST scripts and mariabackup (to work properly) is moved to the main mysql-test-run.pl script, so as not to duplicate this code in different suites, and to avoid partial corrections of the same errors for different suites (while other suites remain uncorrected). 4. Fixed duplication of the have_file_key_management.inc and have_filekeymanagement.inc files between different suites, these checks are also transferred to the top level. 5. Added garbd presence check and garbd path variable. https://jira.mariadb.org/browse/MDEV-18565
- Loading branch information
Showing
18 changed files
with
329 additions
and
167 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# | ||
# suite.pm will make sure that all tests including this file | ||
# will be skipped as needed | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* Copyright (c) 2009, 2019, MariaDB | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; version 2 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <stdio.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; | ||
|
||
if (!(dlh = dlopen(getenv("WSREP_PROVIDER"), RTLD_NOW | RTLD_LOCAL))) { | ||
goto err; | ||
} | ||
|
||
if (!(dlfun = wsrep_dlf(dlh, "wsrep_loader"))) { | ||
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) | ||
{ | ||
return 1; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.