Merge branch '2.3' into 2.4

This commit is contained in:
Esa Korhonen
2020-03-25 11:09:41 +02:00
12 changed files with 83 additions and 40 deletions

View File

@ -13,6 +13,7 @@
# BREAKS_REPL # BREAKS_REPL
# BREAKS_GALERA # BREAKS_GALERA
set(CTEST_BUILD_NAME "${BUILDNAME}") set(CTEST_BUILD_NAME "${BUILDNAME}")
set(CNF_TEMPLATES "" CACHE INTERNAL "")
# utilities.cmake contains all helper functions and extra tools # utilities.cmake contains all helper functions and extra tools
include(utilities.cmake) include(utilities.cmake)
@ -24,9 +25,6 @@ include_directories(${CMAKE_SOURCE_DIR}/connectors/cdc-connector)
include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_BINARY_DIR})
# Include the CDC connector headers # Include the CDC connector headers
include_directories(${CMAKE_SOURCE_DIR}/../connectors/cdc-connector/) include_directories(${CMAKE_SOURCE_DIR}/../connectors/cdc-connector/)
# The core testing library
add_subdirectory(maxtest)
include_directories(maxtest/include/maxtest) include_directories(maxtest/include/maxtest)
# Tool used to check backend state # 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 # # 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)

View File

@ -0,0 +1,4 @@
#pragma once
/** This is the working directory for all tests */
extern const char* test_dir;

View File

@ -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;

View File

@ -3,7 +3,7 @@
#include "mariadb_nodes.h" #include "mariadb_nodes.h"
#include "clustrix_nodes.h" #include "clustrix_nodes.h"
#include "maxscales.h" #include "maxscales.h"
#include "templates.h" #include "test_dir.hh"
#include <fcntl.h> #include <fcntl.h>
#include <pthread.h> #include <pthread.h>
#include <sys/time.h> #include <sys/time.h>
@ -749,7 +749,7 @@ std::string dump_status(const StringSet& current, const StringSet& expected);
* @param labels pointer to string for storing all test labels * @param labels pointer to string for storing all test labels
* @return Name of maxscale.cnf file template * @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 * @brief readenv_and_set_default Read enviromental variable and set default values if

View File

@ -25,6 +25,7 @@ add_library(maxtest SHARED
tcp_connection.cpp tcp_connection.cpp
test_binlog_fnc.cpp test_binlog_fnc.cpp
testconnections.cpp testconnections.cpp
${CMAKE_CURRENT_BINARY_DIR}/test_info.cc
# Include the CDC connector in the core library # Include the CDC connector in the core library
${CMAKE_SOURCE_DIR}/connectors/cdc-connector/cdc_connector.cpp) ${CMAKE_SOURCE_DIR}/connectors/cdc-connector/cdc_connector.cpp)

View File

@ -12,7 +12,7 @@
#include "mariadb_func.h" #include "mariadb_func.h"
#include "templates.h" #include "test_dir.hh"
#include <ctype.h> #include <ctype.h>
#include <sstream> #include <sstream>

View File

@ -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@";

View File

@ -20,6 +20,7 @@
#include "maxadmin_operations.h" #include "maxadmin_operations.h"
#include "sql_t1.h" #include "sql_t1.h"
#include "testconnections.h" #include "testconnections.h"
#include "test_info.hh"
#include "labels_table.h" #include "labels_table.h"
#include "envv.h" #include "envv.h"
@ -288,7 +289,7 @@ TestConnections::TestConnections(int argc, char* argv[])
test_name = basename(argv[0]); test_name = basename(argv[0]);
} }
const char * labels_string = NULL; const char* labels_string = "";
template_name = get_template_name(test_name, &labels_string); template_name = get_template_name(test_name, &labels_string);
tprintf("testname: '%s', template: '%s'", test_name, template_name); tprintf("testname: '%s', template: '%s'", test_name, template_name);
labels = strstr(labels_string, "LABELS;"); 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; const TestDefinition* found = nullptr;
*labels = NULL; for (int i = 0; test_definitions[i].name; i++)
while (cnf_templates[i].test_name && strcmp(cnf_templates[i].test_name, test_name) != 0)
{ {
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; *labels = found->labels;
return cnf_templates[i].test_template; 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) void TestConnections::process_template(int m, const char* template_name, const char* dest)

View File

@ -103,7 +103,9 @@ fi
if [ ! -z "${named_test}" ] ; then if [ ! -z "${named_test}" ] ; then
eval ${named_test} eval ${named_test}
else else
ctest -VV ${test_set} eval "arguments=(${test_set})"
ctest -N "${arguments[@]}"
ctest -VV "${arguments[@]}"
fi fi
if [[ "$name" =~ '-gcov' ]] if [[ "$name" =~ '-gcov' ]]

View File

@ -4,6 +4,7 @@
"hostname" : "node000", "hostname" : "node000",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"REPL_BACKEND" "REPL_BACKEND"
], ],
@ -21,6 +22,7 @@
"hostname" : "node001", "hostname" : "node001",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"REPL_BACKEND" "REPL_BACKEND"
], ],
@ -37,6 +39,7 @@
"hostname" : "node002", "hostname" : "node002",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"REPL_BACKEND" "REPL_BACKEND"
], ],
@ -53,6 +56,7 @@
"hostname" : "node003", "hostname" : "node003",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"REPL_BACKEND" "REPL_BACKEND"
], ],
@ -69,6 +73,7 @@
"hostname" : "node004", "hostname" : "node004",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"BIG_REPL_BACKEND" "BIG_REPL_BACKEND"
], ],
@ -85,6 +90,7 @@
"hostname" : "node005", "hostname" : "node005",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"BIG_REPL_BACKEND" "BIG_REPL_BACKEND"
], ],
@ -101,6 +107,7 @@
"hostname" : "node006", "hostname" : "node006",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"BIG_REPL_BACKEND" "BIG_REPL_BACKEND"
], ],
@ -117,6 +124,7 @@
"hostname" : "node007", "hostname" : "node007",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"BIG_REPL_BACKEND" "BIG_REPL_BACKEND"
], ],
@ -132,7 +140,9 @@
{ {
"hostname" : "node008", "hostname" : "node008",
"box" : "${backend_box}", "box" : "${backend_box}",
"cpu_count" : "8",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"BIG_REPL_BACKEND" "BIG_REPL_BACKEND"
], ],
@ -149,6 +159,7 @@
"hostname" : "node009", "hostname" : "node009",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"BIG_REPL_BACKEND" "BIG_REPL_BACKEND"
], ],
@ -165,6 +176,7 @@
"hostname" : "node010", "hostname" : "node010",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"BIG_REPL_BACKEND" "BIG_REPL_BACKEND"
], ],
@ -181,6 +193,7 @@
"hostname" : "node011", "hostname" : "node011",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"BIG_REPL_BACKEND" "BIG_REPL_BACKEND"
], ],
@ -197,6 +210,7 @@
"hostname" : "node012", "hostname" : "node012",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"BIG_REPL_BACKEND" "BIG_REPL_BACKEND"
], ],
@ -213,6 +227,7 @@
"hostname" : "node013", "hostname" : "node013",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"BIG_REPL_BACKEND" "BIG_REPL_BACKEND"
], ],
@ -229,6 +244,7 @@
"hostname" : "node013", "hostname" : "node013",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"BIG_REPL_BACKEND" "BIG_REPL_BACKEND"
], ],
@ -245,6 +261,7 @@
"hostname" : "galera000", "hostname" : "galera000",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"GALERA_BACKEND" "GALERA_BACKEND"
], ],
@ -261,6 +278,7 @@
"hostname" : "galera001", "hostname" : "galera001",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"GALERA_BACKEND" "GALERA_BACKEND"
], ],
@ -277,6 +295,7 @@
"hostname" : "galera002", "hostname" : "galera002",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"GALERA_BACKEND" "GALERA_BACKEND"
], ],
@ -293,6 +312,7 @@
"hostname" : "galera003", "hostname" : "galera003",
"box" : "${backend_box}", "box" : "${backend_box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"GALERA_BACKEND" "GALERA_BACKEND"
], ],
@ -309,6 +329,7 @@
"hostname" : "maxscale", "hostname" : "maxscale",
"box" : "${box}", "box" : "${box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"MAXSCALE" "MAXSCALE"
], ],
@ -324,6 +345,7 @@
"hostname" : "maxscale2", "hostname" : "maxscale2",
"box" : "${box}", "box" : "${box}",
"memory_size" : "${vm_memory}", "memory_size" : "${vm_memory}",
"cpu_count" : "8",
"labels" : [ "labels" : [
"SECOND_MAXSCALE" "SECOND_MAXSCALE"
], ],

View File

@ -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

View File

@ -1,7 +1,7 @@
# Helper function to add a configuration template # Helper function to add a configuration template
function(add_template name template labels) 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() endfunction()