diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index dde0ea387..3d68494b6 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -13,6 +13,7 @@ # BREAKS_REPL # BREAKS_GALERA set(CTEST_BUILD_NAME "${BUILDNAME}") +set(CNF_TEMPLATES "" CACHE INTERNAL "") # utilities.cmake contains all helper functions and extra tools include(utilities.cmake) @@ -24,9 +25,6 @@ include_directories(${CMAKE_SOURCE_DIR}/connectors/cdc-connector) include_directories(${CMAKE_BINARY_DIR}) # Include the CDC connector headers include_directories(${CMAKE_SOURCE_DIR}/../connectors/cdc-connector/) - -# The core testing library -add_subdirectory(maxtest) include_directories(maxtest/include/maxtest) # Tool used to check backend state @@ -1225,4 +1223,6 @@ add_test_executable(clustrix_distribution.cpp clustrix_distribution clustrix_dis # DO NOT ADD TESTS AFTER THIS # ############################### -configure_file(templates.h.in ${CMAKE_CURRENT_BINARY_DIR}/templates.h @ONLY) +# The core testing library +configure_file(maxtest/src/test_info.cc.in maxtest/src/test_info.cc @ONLY) +add_subdirectory(maxtest) diff --git a/maxscale-system-test/maxtest/include/maxtest/test_dir.hh b/maxscale-system-test/maxtest/include/maxtest/test_dir.hh new file mode 100644 index 000000000..4c9a37dbe --- /dev/null +++ b/maxscale-system-test/maxtest/include/maxtest/test_dir.hh @@ -0,0 +1,4 @@ +#pragma once +/** This is the working directory for all tests */ +extern const char* test_dir; + diff --git a/maxscale-system-test/maxtest/include/maxtest/test_info.hh b/maxscale-system-test/maxtest/include/maxtest/test_info.hh new file mode 100644 index 000000000..7eb5ad61a --- /dev/null +++ b/maxscale-system-test/maxtest/include/maxtest/test_info.hh @@ -0,0 +1,14 @@ +#pragma once +#include "test_dir.hh" + +struct TestDefinition +{ + const char* name; + const char* config_template; + const char* labels; +}; + +extern const TestDefinition* test_definitions; + +/** The default template to use */ +extern const char* default_template; diff --git a/maxscale-system-test/maxtest/include/maxtest/testconnections.h b/maxscale-system-test/maxtest/include/maxtest/testconnections.h index 694bb474c..35274e067 100644 --- a/maxscale-system-test/maxtest/include/maxtest/testconnections.h +++ b/maxscale-system-test/maxtest/include/maxtest/testconnections.h @@ -3,7 +3,7 @@ #include "mariadb_nodes.h" #include "clustrix_nodes.h" #include "maxscales.h" -#include "templates.h" +#include "test_dir.hh" #include #include #include @@ -749,7 +749,7 @@ std::string dump_status(const StringSet& current, const StringSet& expected); * @param labels pointer to string for storing all test labels * @return Name of maxscale.cnf file template */ -const char *get_template_name(char * test_name, const char **labels); +const char* get_template_name(char* test_name, const char**labels); /** * @brief readenv_and_set_default Read enviromental variable and set default values if diff --git a/maxscale-system-test/maxtest/src/CMakeLists.txt b/maxscale-system-test/maxtest/src/CMakeLists.txt index d805ede44..5c3a61c18 100644 --- a/maxscale-system-test/maxtest/src/CMakeLists.txt +++ b/maxscale-system-test/maxtest/src/CMakeLists.txt @@ -25,6 +25,7 @@ add_library(maxtest SHARED tcp_connection.cpp test_binlog_fnc.cpp testconnections.cpp + ${CMAKE_CURRENT_BINARY_DIR}/test_info.cc # Include the CDC connector in the core library ${CMAKE_SOURCE_DIR}/connectors/cdc-connector/cdc_connector.cpp) diff --git a/maxscale-system-test/maxtest/src/mariadb_func.cpp b/maxscale-system-test/maxtest/src/mariadb_func.cpp index 8a0ade2e9..34ca954b8 100644 --- a/maxscale-system-test/maxtest/src/mariadb_func.cpp +++ b/maxscale-system-test/maxtest/src/mariadb_func.cpp @@ -12,7 +12,7 @@ #include "mariadb_func.h" -#include "templates.h" +#include "test_dir.hh" #include #include diff --git a/maxscale-system-test/maxtest/src/test_info.cc.in b/maxscale-system-test/maxtest/src/test_info.cc.in new file mode 100644 index 000000000..ed4947e58 --- /dev/null +++ b/maxscale-system-test/maxtest/src/test_info.cc.in @@ -0,0 +1,11 @@ +#include "test_info.hh" + +const TestDefinition test_definitions_arr[] = +{ +@CNF_TEMPLATES@{nullptr, nullptr, nullptr} +}; + +const TestDefinition* test_definitions = test_definitions_arr; +const char* default_template = "replication"; +const char* test_dir = "@CMAKE_CURRENT_SOURCE_DIR@"; + diff --git a/maxscale-system-test/maxtest/src/testconnections.cpp b/maxscale-system-test/maxtest/src/testconnections.cpp index 337c0e2ee..7c5ae3c42 100644 --- a/maxscale-system-test/maxtest/src/testconnections.cpp +++ b/maxscale-system-test/maxtest/src/testconnections.cpp @@ -20,6 +20,7 @@ #include "maxadmin_operations.h" #include "sql_t1.h" #include "testconnections.h" +#include "test_info.hh" #include "labels_table.h" #include "envv.h" @@ -288,7 +289,7 @@ TestConnections::TestConnections(int argc, char* argv[]) test_name = basename(argv[0]); } - const char * labels_string = NULL; + const char* labels_string = ""; template_name = get_template_name(test_name, &labels_string); tprintf("testname: '%s', template: '%s'", test_name, template_name); labels = strstr(labels_string, "LABELS;"); @@ -761,25 +762,31 @@ void TestConnections::print_env() } } -const char * get_template_name(char * test_name, const char ** labels) +const char* get_template_name(char* test_name, const char** labels) { - int i = 0; - *labels = NULL; - while (cnf_templates[i].test_name && strcmp(cnf_templates[i].test_name, test_name) != 0) + const TestDefinition* found = nullptr; + for (int i = 0; test_definitions[i].name; i++) { - i++; + auto* test = &test_definitions[i]; + if (strcmp(test->name, test_name) == 0) + { + found = test; + break; + } } - if (cnf_templates[i].test_name) + if (found) { - *labels = (char *) cnf_templates[i].test_labels; - return cnf_templates[i].test_template; + *labels = found->labels; + return found->config_template; + } + else + { + printf("Failed to find configuration template for test '%s', using default template '%s'.\n", + test_name, default_template); + return default_template; } - printf("Failed to find configuration template for test '%s', using default template '%s'.\n", - test_name, - default_template); - return default_template; } void TestConnections::process_template(int m, const char* template_name, const char* dest) diff --git a/maxscale-system-test/mdbci/run_test.sh b/maxscale-system-test/mdbci/run_test.sh index ec6a1fc93..450d8518b 100755 --- a/maxscale-system-test/mdbci/run_test.sh +++ b/maxscale-system-test/mdbci/run_test.sh @@ -103,7 +103,9 @@ fi if [ ! -z "${named_test}" ] ; then eval ${named_test} else - ctest -VV ${test_set} + eval "arguments=(${test_set})" + ctest -N "${arguments[@]}" + ctest -VV "${arguments[@]}" fi if [[ "$name" =~ '-gcov' ]] diff --git a/maxscale-system-test/mdbci/templates/default.json.template b/maxscale-system-test/mdbci/templates/default.json.template index 8ccf66d12..2853513d2 100644 --- a/maxscale-system-test/mdbci/templates/default.json.template +++ b/maxscale-system-test/mdbci/templates/default.json.template @@ -4,6 +4,7 @@ "hostname" : "node000", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "REPL_BACKEND" ], @@ -21,6 +22,7 @@ "hostname" : "node001", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "REPL_BACKEND" ], @@ -37,6 +39,7 @@ "hostname" : "node002", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "REPL_BACKEND" ], @@ -53,6 +56,7 @@ "hostname" : "node003", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "REPL_BACKEND" ], @@ -69,6 +73,7 @@ "hostname" : "node004", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "BIG_REPL_BACKEND" ], @@ -85,6 +90,7 @@ "hostname" : "node005", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "BIG_REPL_BACKEND" ], @@ -101,6 +107,7 @@ "hostname" : "node006", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "BIG_REPL_BACKEND" ], @@ -117,6 +124,7 @@ "hostname" : "node007", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "BIG_REPL_BACKEND" ], @@ -132,7 +140,9 @@ { "hostname" : "node008", "box" : "${backend_box}", + "cpu_count" : "8", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "BIG_REPL_BACKEND" ], @@ -149,6 +159,7 @@ "hostname" : "node009", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "BIG_REPL_BACKEND" ], @@ -165,6 +176,7 @@ "hostname" : "node010", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "BIG_REPL_BACKEND" ], @@ -181,6 +193,7 @@ "hostname" : "node011", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "BIG_REPL_BACKEND" ], @@ -197,6 +210,7 @@ "hostname" : "node012", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "BIG_REPL_BACKEND" ], @@ -213,6 +227,7 @@ "hostname" : "node013", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "BIG_REPL_BACKEND" ], @@ -229,6 +244,7 @@ "hostname" : "node013", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "BIG_REPL_BACKEND" ], @@ -245,6 +261,7 @@ "hostname" : "galera000", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "GALERA_BACKEND" ], @@ -261,6 +278,7 @@ "hostname" : "galera001", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "GALERA_BACKEND" ], @@ -277,6 +295,7 @@ "hostname" : "galera002", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "GALERA_BACKEND" ], @@ -293,6 +312,7 @@ "hostname" : "galera003", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "GALERA_BACKEND" ], @@ -309,6 +329,7 @@ "hostname" : "maxscale", "box" : "${box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "MAXSCALE" ], @@ -324,6 +345,7 @@ "hostname" : "maxscale2", "box" : "${box}", "memory_size" : "${vm_memory}", + "cpu_count" : "8", "labels" : [ "SECOND_MAXSCALE" ], diff --git a/maxscale-system-test/templates.h.in b/maxscale-system-test/templates.h.in deleted file mode 100644 index 0caabb8c8..000000000 --- a/maxscale-system-test/templates.h.in +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef TEMPLATES_H -#define TEMPLATES_H - -static struct -{ - const char* test_name; - const char* test_template; - const char* test_labels; -} cnf_templates[] __attribute__((unused)) = { -@CNF_TEMPLATES@ {NULL, NULL, NULL}}; - -/** The default template to use */ -static const char * default_template __attribute__((unused)) = "replication"; - -/** This is the working directory for all tests */ -static const char *test_dir __attribute__((unused)) = "@CMAKE_CURRENT_SOURCE_DIR@"; - -#endif diff --git a/maxscale-system-test/utilities.cmake b/maxscale-system-test/utilities.cmake index d64984920..09e6a4a62 100644 --- a/maxscale-system-test/utilities.cmake +++ b/maxscale-system-test/utilities.cmake @@ -1,7 +1,7 @@ # Helper function to add a configuration template function(add_template name template labels) - set(CNF_TEMPLATES "${CNF_TEMPLATES}{\"${name}\",\"${template}\", \"${labels}\"}," CACHE INTERNAL "") + set(CNF_TEMPLATES "${CNF_TEMPLATES}{\"${name}\", \"${template}\", \"${labels}\"}," CACHE INTERNAL "") endfunction()