Merge branch '2.3' into 2.4

This commit is contained in:
Esa Korhonen
2020-04-16 17:34:08 +03:00
27 changed files with 86 additions and 151 deletions

View File

@ -7,7 +7,7 @@
#include "testconnections.h" #include "testconnections.h"
#include "big_transaction.h" #include "sql_t1.h"
typedef void * FUNC(void * ptr); typedef void * FUNC(void * ptr);

View File

@ -3,7 +3,7 @@ add_test_executable_ex(NAME mysqlmon_multimaster SOURCE mysqlmon_multimaster.cpp
CONFIG mysqlmon_multimaster.cnf VMS repl_backend LABELS mysqlmon BREAKS_REPL) CONFIG mysqlmon_multimaster.cnf VMS repl_backend LABELS mysqlmon BREAKS_REPL)
# MySQL Monitor with Multi-master configurations (assume_unique_hostnames=OFF) # MySQL Monitor with Multi-master configurations (assume_unique_hostnames=OFF)
add_test_executable_ex(NAME mysqlmon_multimaster_serverid SOURCE mysqlmon_multimaster.cpp add_test_executable_ex(NAME mysqlmon_multimaster_serverid ORIG_NAME mysqlmon_multimaster
CONFIG mysqlmon_multimaster_serverid.cnf VMS repl_backend LABELS mysqlmon BREAKS_REPL) CONFIG mysqlmon_multimaster_serverid.cnf VMS repl_backend LABELS mysqlmon BREAKS_REPL)
# MySQL Monitor Failover Test # MySQL Monitor Failover Test

View File

@ -1,8 +1,6 @@
#pragma once #pragma once
#include "testconnections.h" class TestConnections;
#include "sql_t1.h"
#include "get_com_select_insert.h"
// pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; // pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
typedef struct typedef struct

View File

@ -1,14 +0,0 @@
#pragma once
#include <mysql.h>
#include <stdio.h>
#include <stdlib.h>
#include "sql_t1.h"
/**
* @brief big_transaction Executes big transaction (includes N INSERTs of 10000 rows)
* @param conn MYSQL connection handler
* @param N Number of INSERTs
* @return 0 if success
*/
int big_transaction(MYSQL* conn, int N);

View File

@ -1,7 +1,5 @@
#pragma once #pragma once
#include <iostream>
#include <unistd.h>
#include "testconnections.h" #include "testconnections.h"
/** /**

View File

@ -1,45 +0,0 @@
/*
* Copyright (c) 2018 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2024-03-10
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#pragma once
#include <string>
namespace base
{
/* Environment variable. Usage:
* Env user{"USER"};
* std::string home = Env{"HOME"};
* An environment variable can be empty() but
* still is_defined().
*/
class Env : public std::string
{
public:
Env(const std::string& name) : m_is_defined(false)
{
if (const char* var = getenv(name.c_str()))
{
m_is_defined = true;
this->assign(var);
}
}
bool is_defined() const
{
return m_is_defined;
}
private:
bool m_is_defined;
};
} // base

View File

@ -1,10 +1,5 @@
#pragma once #pragma once
#include <iostream>
#include <unistd.h>
using namespace std;
/** /**
* @brief execute_cmd Execute shell command * @brief execute_cmd Execute shell command
* @param cmd Command line * @param cmd Command line

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "testconnections.h" class TestConnections;
/** /**
* @brief copy_rules Copy rules file for firewall filter to Maxscale machine * @brief copy_rules Copy rules file for firewall filter to Maxscale machine

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "testconnections.h" class Mariadb_nodes;
/** /**
* @brief get_global_status_allnodes Reads COM_SELECT and COM_INSERT variables from all nodes and stores into * @brief get_global_status_allnodes Reads COM_SELECT and COM_INSERT variables from all nodes and stores into

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "testconnections.h" class TestConnections;
#define FAILOVER_WAIT_TIME 20 #define FAILOVER_WAIT_TIME 20

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
class TestConnections;
int create_tcp_socket(); int create_tcp_socket();
char* get_ip(char* host); char* get_ip(char* host);
char* build_get_query(char* host, const char* page); char* build_get_query(char* host, const char* page);

View File

@ -5,11 +5,6 @@
#include "mariadb_func.h" #include "mariadb_func.h"
#include "mariadb_nodes.h" #include "mariadb_nodes.h"
#define DEFAULT_MAXSCALE_CNF "/etc/maxscale.cnf"
#define DEFAULT_MAXSCALE_LOG_DIR "/var/log/maxscale/"
#define DEFAULT_MAXSCALE_BINLOG_DIR "/var/lib/maxscale/Binlog_Service/"
#define DEFAULT_MAXADMIN_PASSWORD "mariadb"
class Maxscales: public Nodes class Maxscales: public Nodes
{ {
public: public:

View File

@ -2,11 +2,11 @@
#include <errno.h> #include <errno.h>
#include <string> #include <string>
#include "mariadb_func.h"
#include <set> #include <set>
#include <string> #include <string>
#include <maxbase/ccdefs.hh> #include <maxbase/ccdefs.hh>
#include "mariadb_func.h"
typedef std::set<std::string> StringSet; typedef std::set<std::string> StringSet;

View File

@ -2,10 +2,8 @@
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
#include "testconnections.h"
#include <jansson.h> #include <jansson.h>
#include "testconnections.h"
using namespace std;
class RDS class RDS
{ {

View File

@ -1,25 +0,0 @@
#ifndef SQL_CONST_H
#define SQL_CONST_H
const char* create_repl_user =
"grant replication slave on *.* to repl@'%%' identified by 'repl'; "
"FLUSH PRIVILEGES";
const char* setup_slave =
"change master to MASTER_HOST='%s', "
"MASTER_USER='repl', "
"MASTER_PASSWORD='repl', "
"MASTER_LOG_FILE='%s', "
"MASTER_LOG_POS=%s, "
"MASTER_PORT=%d; "
"start slave;";
const char* setup_slave_no_pos =
"change master to MASTER_HOST='%s', "
"MASTER_USER='repl', "
"MASTER_PASSWORD='repl', "
"MASTER_LOG_FILE='mar-bin.000001', "
"MASTER_LOG_POS=4, "
"MASTER_PORT=%d";
#endif // SQL_CONST_H

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "mariadb_func.h" #include <mysql.h>
#include "testconnections.h"
/** /**
* @brief execute_select_query_and_check Execute query and check that result contains expected number of rows * @brief execute_select_query_and_check Execute query and check that result contains expected number of rows

View File

@ -1,9 +1,6 @@
#pragma once #pragma once
#include <iostream> class TestConnections;
#include "testconnections.h"
#include "maxadmin_operations.h"
#include "sql_t1.h"
/** /**
* @brief check_sha1 Check that checksum of binlog files on Maxscale machines and all backends are equal * @brief check_sha1 Check that checksum of binlog files on Maxscale machines and all backends are equal

View File

@ -1,6 +1,5 @@
add_library(maxtest SHARED add_library(maxtest SHARED
big_load.cc big_load.cc
big_transaction.cc
blob_test.cc blob_test.cc
clustrix_nodes.cpp clustrix_nodes.cpp
config_operations.cc config_operations.cc

View File

@ -1,5 +1,10 @@
#include "big_load.h" #include "big_load.h"
#include <pthread.h> #include <pthread.h>
#include "testconnections.h"
#include "sql_t1.h"
#include "get_com_select_insert.h"
void load(long int* new_inserts, void load(long int* new_inserts,
long int* new_selects, long int* new_selects,

View File

@ -1,23 +0,0 @@
#include "big_transaction.h"
int big_transaction(MYSQL* conn, int N)
{
int local_result = 0;
char sql[1000000];
local_result += create_t1(conn);
local_result += execute_query(conn, (char*) "START TRANSACTION");
local_result += execute_query(conn, (char*) "SET autocommit = 0");
for (int i = 0; i < N; i++)
{
create_insert_string(sql, 10000, i);
local_result += execute_query(conn, "%s", sql);
local_result += execute_query(conn, "CREATE TABLE t2(id int);");
local_result += execute_query(conn, "%s", sql);
local_result += execute_query(conn, "DROP TABLE t2;");
local_result += execute_query(conn, "%s", sql);
}
local_result += execute_query(conn, (char*) "COMMIT");
return local_result;
}

View File

@ -1,5 +1,6 @@
#include "fw_copy_rules.h" #include "fw_copy_rules.h"
#include <sstream> #include <sstream>
#include "testconnections.h"
void copy_rules(TestConnections* Test, const char* rules_name, const char* rules_dir) void copy_rules(TestConnections* Test, const char* rules_name, const char* rules_dir)
{ {

View File

@ -1,4 +1,4 @@
#include "testconnections.h" #include "mariadb_nodes.h"
/** /**
* Reads COM_SELECT and COM_INSERT variables from all nodes and stores into 'selects' and 'inserts' * Reads COM_SELECT and COM_INSERT variables from all nodes and stores into 'selects' and 'inserts'

View File

@ -1,5 +1,6 @@
#include "keepalived_func.h" #include "keepalived_func.h"
#include "get_my_ip.h" #include "get_my_ip.h"
#include "testconnections.h"
char* print_version_string(TestConnections* Test) char* print_version_string(TestConnections* Test)
{ {

View File

@ -11,7 +11,6 @@
*/ */
#include "mariadb_nodes.h" #include "mariadb_nodes.h"
#include "sql_const.h"
#include <climits> #include <climits>
#include <string> #include <string>
#include <sstream> #include <sstream>
@ -28,6 +27,27 @@ using std::endl;
namespace namespace
{ {
static bool g_require_gtid = false; static bool g_require_gtid = false;
const char setup_slave_no_pos[] =
"change master to MASTER_HOST='%s', "
"MASTER_USER='repl', "
"MASTER_PASSWORD='repl', "
"MASTER_LOG_FILE='mar-bin.000001', "
"MASTER_LOG_POS=4, "
"MASTER_PORT=%d";
const char setup_slave[] =
"change master to MASTER_HOST='%s', "
"MASTER_USER='repl', "
"MASTER_PASSWORD='repl', "
"MASTER_LOG_FILE='%s', "
"MASTER_LOG_POS=%s, "
"MASTER_PORT=%d; "
"start slave;";
const char create_repl_user[] =
"grant replication slave on *.* to repl@'%%' identified by 'repl'; "
"FLUSH PRIVILEGES";
} }
void Mariadb_nodes::require_gtid(bool value) void Mariadb_nodes::require_gtid(bool value)

View File

@ -1,9 +1,12 @@
#include "maxscales.hh" #include "maxscales.hh"
#include <sstream>
#include <unordered_map>
#include <string> #include <string>
#include "envv.hh" #include "envv.hh"
#define DEFAULT_MAXSCALE_CNF "/etc/maxscale.cnf"
#define DEFAULT_MAXSCALE_LOG_DIR "/var/log/maxscale/"
#define DEFAULT_MAXSCALE_BINLOG_DIR "/var/lib/maxscale/Binlog_Service/"
#define DEFAULT_MAXADMIN_PASSWORD "mariadb"
Maxscales::Maxscales(const char *pref, Maxscales::Maxscales(const char *pref,
const char *test_cwd, const char *test_cwd,
bool verbose, bool verbose,

View File

@ -1,6 +1,8 @@
#include "sql_t1.h" #include "sql_t1.h"
#include <cstdio>
#include <pthread.h> #include <pthread.h>
#include "mariadb_func.h"
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static char** sql = NULL; static char** sql = NULL;

View File

@ -87,9 +87,11 @@ endfunction()
# Same as "add_test_executable" but with a local config template file. Called using named arguments as in # Same as "add_test_executable" but with a local config template file. Called using named arguments as in
# add_test_executable_ex(NAME <testname> SOURCE <source.cc> CONFIG <configfile.cnf> VMS <backends setup> # add_test_executable_ex(NAME <testname> SOURCE <source.cc> CONFIG <configfile.cnf> VMS <backends setup>
# LABELS <label list>) # LABELS <label list>).
#
# If creating a derived test, denote the original test with ORIG_NAME.
function(add_test_executable_ex) function(add_test_executable_ex)
set(arg_names NAME SOURCE CONFIG LIBS VMS LABELS) set(arg_names NAME SOURCE CONFIG LIBS VMS LABELS ORIG_NAME)
set(now_parsing "") set(now_parsing "")
foreach(elem ${ARGN}) foreach(elem ${ARGN})
list(FIND arg_names ${elem} arg_names_ind) list(FIND arg_names ${elem} arg_names_ind)
@ -112,6 +114,8 @@ function(add_test_executable_ex)
list(APPEND vms_setup ${elem}) list(APPEND vms_setup ${elem})
elseif("${now_parsing}" STREQUAL "LABELS") elseif("${now_parsing}" STREQUAL "LABELS")
list(APPEND labels ${elem}) list(APPEND labels ${elem})
elseif("${now_parsing}" STREQUAL "ORIG_NAME")
list(APPEND orig_name ${elem})
endif() endif()
endif() endif()
endforeach() endforeach()
@ -124,8 +128,30 @@ function(add_test_executable_ex)
message(FATAL_ERROR "NAME ${errmsg}") message(FATAL_ERROR "NAME ${errmsg}")
endif() endif()
list(LENGTH source_file list_len) # If original name was given, source file should not.
if (NOT ${list_len} EQUAL 1) list(LENGTH orig_name n_orig_name)
list(LENGTH source_file n_source_file)
if ("${n_orig_name}" GREATER 1)
message(FATAL_ERROR "ORIG_NAME has multiple values.")
elseif("${n_orig_name}" EQUAL 1)
if ("${n_source_file}" GREATER 0)
message(FATAL_ERROR "Both ORIG_NAME and SOURCE are defined.")
endif()
# Also check link libraries
list(LENGTH link_libraries n_link_libraries)
if ("${n_link_libraries}" GREATER 0)
message(FATAL_ERROR "Both ORIG_NAME and LIBS are defined.")
endif()
get_test_property(${orig_name} TIMEOUT to)
if (NOT to)
message(FATAL_ERROR "${orig_name} is not an existing test.")
endif()
elseif(NOT ${n_source_file} EQUAL 1)
message(FATAL_ERROR "SOURCE ${errmsg}") message(FATAL_ERROR "SOURCE ${errmsg}")
endif() endif()
@ -157,12 +183,15 @@ function(add_test_executable_ex)
set(config_file_path "${CMAKE_CURRENT_SOURCE_DIR}/${config_file}") set(config_file_path "${CMAKE_CURRENT_SOURCE_DIR}/${config_file}")
add_test_info(${name} ${config_file_path} "${vms_upper}") add_test_info(${name} ${config_file_path} "${vms_upper}")
add_executable(${name} ${source_file})
list(APPEND link_libraries maxtest) if ("${n_source_file}" EQUAL 1)
target_link_libraries(${name} ${link_libraries}) add_executable(${name} ${source_file})
list(APPEND link_libraries maxtest)
add_test(NAME ${name} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name} ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(${name} ${link_libraries})
add_test(NAME ${name} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name} ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(NAME ${name} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${orig_name} ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
list(APPEND ctest_labels ${vms_upper} ${labels}) list(APPEND ctest_labels ${vms_upper} ${labels})
add_test_properties(${name} ${ctest_labels}) add_test_properties(${name} ${ctest_labels})