diff --git a/maxscale-system-test/long_test.cpp b/maxscale-system-test/long_test.cpp index 334fad231..97447b13a 100644 --- a/maxscale-system-test/long_test.cpp +++ b/maxscale-system-test/long_test.cpp @@ -7,7 +7,7 @@ #include "testconnections.h" -#include "big_transaction.h" +#include "sql_t1.h" typedef void * FUNC(void * ptr); diff --git a/maxscale-system-test/mariadbmonitor/CMakeLists.txt b/maxscale-system-test/mariadbmonitor/CMakeLists.txt index 9e5dece35..d5971e14e 100644 --- a/maxscale-system-test/mariadbmonitor/CMakeLists.txt +++ b/maxscale-system-test/mariadbmonitor/CMakeLists.txt @@ -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) # 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) # MySQL Monitor Failover Test diff --git a/maxscale-system-test/maxtest/include/maxtest/big_load.h b/maxscale-system-test/maxtest/include/maxtest/big_load.h index d45f6757e..9445d6d5e 100644 --- a/maxscale-system-test/maxtest/include/maxtest/big_load.h +++ b/maxscale-system-test/maxtest/include/maxtest/big_load.h @@ -1,8 +1,6 @@ #pragma once -#include "testconnections.h" -#include "sql_t1.h" -#include "get_com_select_insert.h" +class TestConnections; // pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; typedef struct diff --git a/maxscale-system-test/maxtest/include/maxtest/big_transaction.h b/maxscale-system-test/maxtest/include/maxtest/big_transaction.h deleted file mode 100644 index b59f5f2d6..000000000 --- a/maxscale-system-test/maxtest/include/maxtest/big_transaction.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include -#include -#include -#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); diff --git a/maxscale-system-test/maxtest/include/maxtest/different_size.h b/maxscale-system-test/maxtest/include/maxtest/different_size.h index db9b4a010..1a319e583 100644 --- a/maxscale-system-test/maxtest/include/maxtest/different_size.h +++ b/maxscale-system-test/maxtest/include/maxtest/different_size.h @@ -1,7 +1,5 @@ #pragma once -#include -#include #include "testconnections.h" /** diff --git a/maxscale-system-test/maxtest/include/maxtest/env.hh b/maxscale-system-test/maxtest/include/maxtest/env.hh deleted file mode 100644 index 21f3f9595..000000000 --- a/maxscale-system-test/maxtest/include/maxtest/env.hh +++ /dev/null @@ -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 - -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 diff --git a/maxscale-system-test/maxtest/include/maxtest/execute_cmd.hh b/maxscale-system-test/maxtest/include/maxtest/execute_cmd.hh index 12569eb76..569a9f204 100644 --- a/maxscale-system-test/maxtest/include/maxtest/execute_cmd.hh +++ b/maxscale-system-test/maxtest/include/maxtest/execute_cmd.hh @@ -1,10 +1,5 @@ #pragma once -#include -#include - -using namespace std; - /** * @brief execute_cmd Execute shell command * @param cmd Command line diff --git a/maxscale-system-test/maxtest/include/maxtest/fw_copy_rules.h b/maxscale-system-test/maxtest/include/maxtest/fw_copy_rules.h index 4d959d4a8..1d3eb9fd5 100644 --- a/maxscale-system-test/maxtest/include/maxtest/fw_copy_rules.h +++ b/maxscale-system-test/maxtest/include/maxtest/fw_copy_rules.h @@ -1,6 +1,6 @@ #pragma once -#include "testconnections.h" +class TestConnections; /** * @brief copy_rules Copy rules file for firewall filter to Maxscale machine diff --git a/maxscale-system-test/maxtest/include/maxtest/get_com_select_insert.h b/maxscale-system-test/maxtest/include/maxtest/get_com_select_insert.h index cf4c3b999..4aaca5b22 100644 --- a/maxscale-system-test/maxtest/include/maxtest/get_com_select_insert.h +++ b/maxscale-system-test/maxtest/include/maxtest/get_com_select_insert.h @@ -1,6 +1,6 @@ #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 diff --git a/maxscale-system-test/maxtest/include/maxtest/keepalived_func.h b/maxscale-system-test/maxtest/include/maxtest/keepalived_func.h index ee71feb0e..a6becd01d 100644 --- a/maxscale-system-test/maxtest/include/maxtest/keepalived_func.h +++ b/maxscale-system-test/maxtest/include/maxtest/keepalived_func.h @@ -1,6 +1,6 @@ #pragma once -#include "testconnections.h" +class TestConnections; #define FAILOVER_WAIT_TIME 20 diff --git a/maxscale-system-test/maxtest/include/maxtest/maxinfo_func.h b/maxscale-system-test/maxtest/include/maxtest/maxinfo_func.h index 712dc1114..3da4c9362 100644 --- a/maxscale-system-test/maxtest/include/maxtest/maxinfo_func.h +++ b/maxscale-system-test/maxtest/include/maxtest/maxinfo_func.h @@ -1,5 +1,7 @@ #pragma once +class TestConnections; + int create_tcp_socket(); char* get_ip(char* host); char* build_get_query(char* host, const char* page); diff --git a/maxscale-system-test/maxtest/include/maxtest/maxscales.hh b/maxscale-system-test/maxtest/include/maxtest/maxscales.hh index ec012d771..6d37271f7 100644 --- a/maxscale-system-test/maxtest/include/maxtest/maxscales.hh +++ b/maxscale-system-test/maxtest/include/maxtest/maxscales.hh @@ -5,11 +5,6 @@ #include "mariadb_func.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 { public: diff --git a/maxscale-system-test/maxtest/include/maxtest/nodes.hh b/maxscale-system-test/maxtest/include/maxtest/nodes.hh index f343ad47a..7db5d4325 100644 --- a/maxscale-system-test/maxtest/include/maxtest/nodes.hh +++ b/maxscale-system-test/maxtest/include/maxtest/nodes.hh @@ -2,11 +2,11 @@ #include #include -#include "mariadb_func.h" #include #include #include +#include "mariadb_func.h" typedef std::set StringSet; diff --git a/maxscale-system-test/maxtest/include/maxtest/rds_vpc.h b/maxscale-system-test/maxtest/include/maxtest/rds_vpc.h index 6de075d8c..690f23723 100644 --- a/maxscale-system-test/maxtest/include/maxtest/rds_vpc.h +++ b/maxscale-system-test/maxtest/include/maxtest/rds_vpc.h @@ -2,10 +2,8 @@ #include #include -#include "testconnections.h" #include - -using namespace std; +#include "testconnections.h" class RDS { diff --git a/maxscale-system-test/maxtest/include/maxtest/sql_const.h b/maxscale-system-test/maxtest/include/maxtest/sql_const.h deleted file mode 100644 index 215f58d22..000000000 --- a/maxscale-system-test/maxtest/include/maxtest/sql_const.h +++ /dev/null @@ -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 diff --git a/maxscale-system-test/maxtest/include/maxtest/sql_t1.h b/maxscale-system-test/maxtest/include/maxtest/sql_t1.h index 602df992e..298456a58 100644 --- a/maxscale-system-test/maxtest/include/maxtest/sql_t1.h +++ b/maxscale-system-test/maxtest/include/maxtest/sql_t1.h @@ -1,7 +1,6 @@ #pragma once -#include "mariadb_func.h" -#include "testconnections.h" +#include /** * @brief execute_select_query_and_check Execute query and check that result contains expected number of rows diff --git a/maxscale-system-test/maxtest/include/maxtest/test_binlog_fnc.h b/maxscale-system-test/maxtest/include/maxtest/test_binlog_fnc.h index 44fde18f8..27c770d11 100644 --- a/maxscale-system-test/maxtest/include/maxtest/test_binlog_fnc.h +++ b/maxscale-system-test/maxtest/include/maxtest/test_binlog_fnc.h @@ -1,9 +1,6 @@ #pragma once -#include -#include "testconnections.h" -#include "maxadmin_operations.h" -#include "sql_t1.h" +class TestConnections; /** * @brief check_sha1 Check that checksum of binlog files on Maxscale machines and all backends are equal diff --git a/maxscale-system-test/maxtest/src/CMakeLists.txt b/maxscale-system-test/maxtest/src/CMakeLists.txt index b7d62176c..5b9848d5d 100644 --- a/maxscale-system-test/maxtest/src/CMakeLists.txt +++ b/maxscale-system-test/maxtest/src/CMakeLists.txt @@ -1,6 +1,5 @@ add_library(maxtest SHARED big_load.cc - big_transaction.cc blob_test.cc clustrix_nodes.cpp config_operations.cc diff --git a/maxscale-system-test/maxtest/src/big_load.cc b/maxscale-system-test/maxtest/src/big_load.cc index 018e2400a..859655310 100644 --- a/maxscale-system-test/maxtest/src/big_load.cc +++ b/maxscale-system-test/maxtest/src/big_load.cc @@ -1,5 +1,10 @@ #include "big_load.h" + #include +#include "testconnections.h" +#include "sql_t1.h" +#include "get_com_select_insert.h" + void load(long int* new_inserts, long int* new_selects, diff --git a/maxscale-system-test/maxtest/src/big_transaction.cc b/maxscale-system-test/maxtest/src/big_transaction.cc deleted file mode 100644 index f5d446847..000000000 --- a/maxscale-system-test/maxtest/src/big_transaction.cc +++ /dev/null @@ -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; -} diff --git a/maxscale-system-test/maxtest/src/fw_copy_rules.cc b/maxscale-system-test/maxtest/src/fw_copy_rules.cc index 37d076840..4ffca302b 100644 --- a/maxscale-system-test/maxtest/src/fw_copy_rules.cc +++ b/maxscale-system-test/maxtest/src/fw_copy_rules.cc @@ -1,5 +1,6 @@ #include "fw_copy_rules.h" #include +#include "testconnections.h" void copy_rules(TestConnections* Test, const char* rules_name, const char* rules_dir) { diff --git a/maxscale-system-test/maxtest/src/get_com_select_insert.cc b/maxscale-system-test/maxtest/src/get_com_select_insert.cc index 78929909e..35e468f88 100644 --- a/maxscale-system-test/maxtest/src/get_com_select_insert.cc +++ b/maxscale-system-test/maxtest/src/get_com_select_insert.cc @@ -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' diff --git a/maxscale-system-test/maxtest/src/keepalived_func.cc b/maxscale-system-test/maxtest/src/keepalived_func.cc index 7b15d7394..57e65c537 100644 --- a/maxscale-system-test/maxtest/src/keepalived_func.cc +++ b/maxscale-system-test/maxtest/src/keepalived_func.cc @@ -1,5 +1,6 @@ #include "keepalived_func.h" #include "get_my_ip.h" +#include "testconnections.h" char* print_version_string(TestConnections* Test) { diff --git a/maxscale-system-test/maxtest/src/mariadb_nodes.cc b/maxscale-system-test/maxtest/src/mariadb_nodes.cc index d6a83fe0f..6203b0446 100644 --- a/maxscale-system-test/maxtest/src/mariadb_nodes.cc +++ b/maxscale-system-test/maxtest/src/mariadb_nodes.cc @@ -11,7 +11,6 @@ */ #include "mariadb_nodes.h" -#include "sql_const.h" #include #include #include @@ -28,6 +27,27 @@ using std::endl; namespace { 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) diff --git a/maxscale-system-test/maxtest/src/maxscales.cc b/maxscale-system-test/maxtest/src/maxscales.cc index c9ae3b271..d7b82fec4 100644 --- a/maxscale-system-test/maxtest/src/maxscales.cc +++ b/maxscale-system-test/maxtest/src/maxscales.cc @@ -1,9 +1,12 @@ #include "maxscales.hh" -#include -#include #include #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, const char *test_cwd, bool verbose, diff --git a/maxscale-system-test/maxtest/src/sql_t1.cc b/maxscale-system-test/maxtest/src/sql_t1.cc index a518cdac8..a27b8c071 100644 --- a/maxscale-system-test/maxtest/src/sql_t1.cc +++ b/maxscale-system-test/maxtest/src/sql_t1.cc @@ -1,6 +1,8 @@ #include "sql_t1.h" +#include #include +#include "mariadb_func.h" pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static char** sql = NULL; diff --git a/maxscale-system-test/utilities.cmake b/maxscale-system-test/utilities.cmake index a846587b1..34f65c259 100644 --- a/maxscale-system-test/utilities.cmake +++ b/maxscale-system-test/utilities.cmake @@ -87,9 +87,11 @@ endfunction() # Same as "add_test_executable" but with a local config template file. Called using named arguments as in # add_test_executable_ex(NAME SOURCE CONFIG VMS -# LABELS