Merge branch '2.3' into 2.4
This commit is contained in:
@ -10,9 +10,10 @@
|
|||||||
* @param format Default value format string
|
* @param format Default value format string
|
||||||
* @return Enviromental variable value
|
* @return Enviromental variable value
|
||||||
*/
|
*/
|
||||||
char * readenv(const char * name, const char *format, ...);
|
char * readenv(const char* name, const char* format, ...) __attribute__ ((format (printf, 2, 3)));
|
||||||
|
|
||||||
std::string envvar_read_write_def_str(const char* name, const char* format, ...);
|
std::string envvar_get_set(const char* name, const char* format, ...)
|
||||||
|
__attribute__ ((format (printf, 2, 3)));;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief readenv_int Read integer value of enviromental variable, if empty - set dafault
|
* @brief readenv_int Read integer value of enviromental variable, if empty - set dafault
|
||||||
@ -30,3 +31,7 @@ int readenv_int(const char * name, int def);
|
|||||||
* @return Enviromental variable value converted to bool
|
* @return Enviromental variable value converted to bool
|
||||||
*/
|
*/
|
||||||
bool readenv_bool(const char * name, bool def);
|
bool readenv_bool(const char * name, bool def);
|
||||||
|
|
||||||
|
std::string string_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
|
||||||
|
|
||||||
|
std::string string_printf(const char *format, va_list args);
|
||||||
@ -102,11 +102,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
Maxscales* maxscales {nullptr};
|
Maxscales* maxscales {nullptr};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief SysbenchDir path to SysBench directory (sysbanch should be >= 0.5)
|
|
||||||
*/
|
|
||||||
char sysbench_dir[4096];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief copy_mariadb_logs copies MariaDB logs from backend
|
* @brief copy_mariadb_logs copies MariaDB logs from backend
|
||||||
* @param repl Mariadb_nodes object
|
* @param repl Mariadb_nodes object
|
||||||
@ -591,7 +586,7 @@ private:
|
|||||||
|
|
||||||
std::string m_mdbci_config_name; /**< Name of MDBCI VMs set */
|
std::string m_mdbci_config_name; /**< Name of MDBCI VMs set */
|
||||||
std::string m_mdbci_vm_path; /**< Path to directory with MDBCI VMs descriptions */
|
std::string m_mdbci_vm_path; /**< Path to directory with MDBCI VMs descriptions */
|
||||||
std::string m_mdbci_template; /**< Name of mdbci VMs tempate file */
|
std::string m_mdbci_template; /**< Name of mdbci VMs template file */
|
||||||
std::string m_target; /**< Name of Maxscale repository in the CI */
|
std::string m_target; /**< Name of Maxscale repository in the CI */
|
||||||
std::string m_network_config; /**< Content of MDBCI network_config file */
|
std::string m_network_config; /**< Content of MDBCI network_config file */
|
||||||
std::string m_vm_path; /**< Path to the VM Vagrant directory */
|
std::string m_vm_path; /**< Path to the VM Vagrant directory */
|
||||||
@ -604,7 +599,7 @@ private:
|
|||||||
std::string m_take_snapshot_command; /**< Command line to create a snapshot of all VMs */
|
std::string m_take_snapshot_command; /**< Command line to create a snapshot of all VMs */
|
||||||
std::string m_revert_snapshot_command; /**< Command line to revert a snapshot of all VMs */
|
std::string m_revert_snapshot_command; /**< Command line to revert a snapshot of all VMs */
|
||||||
|
|
||||||
char m_ssl_options[1024]; /**< String with ssl configuration for command line client */
|
std::string m_ssl_options; /**< String with ssl configuration for command line client */
|
||||||
|
|
||||||
bool m_enable_timeouts {true}; /**< Whether timeouts are enabled or not */
|
bool m_enable_timeouts {true}; /**< Whether timeouts are enabled or not */
|
||||||
bool m_local_maxscale {false}; /**< MaxScale runs locally, specified using -l. */
|
bool m_local_maxscale {false}; /**< MaxScale runs locally, specified using -l. */
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char * readenv(const char * name, const char *format, ...)
|
char* readenv(const char * name, const char *format, ...)
|
||||||
{
|
{
|
||||||
char * env = getenv(name);
|
char * env = getenv(name);
|
||||||
if (!env)
|
if (!env)
|
||||||
@ -31,7 +31,7 @@ char * readenv(const char * name, const char *format, ...)
|
|||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
string envvar_read_write_def_str(const char* name, const char* format, ...)
|
string envvar_get_set(const char* name, const char* format, ...)
|
||||||
{
|
{
|
||||||
string rval;
|
string rval;
|
||||||
const char* old_value = getenv(name);
|
const char* old_value = getenv(name);
|
||||||
@ -43,19 +43,9 @@ string envvar_read_write_def_str(const char* name, const char* format, ...)
|
|||||||
{
|
{
|
||||||
va_list valist;
|
va_list valist;
|
||||||
va_start(valist, format);
|
va_start(valist, format);
|
||||||
int bytes_required = vsnprintf(nullptr, 0, format, valist);
|
rval = string_printf(format, valist);
|
||||||
va_end(valist);
|
va_end(valist);
|
||||||
|
setenv(name, rval.c_str(), 1);
|
||||||
if (bytes_required >= 0)
|
|
||||||
{
|
|
||||||
int buflen = bytes_required + 1;
|
|
||||||
char buf[buflen];
|
|
||||||
va_start(valist, format);
|
|
||||||
vsnprintf(buf, buflen, format, valist);
|
|
||||||
va_end(valist);
|
|
||||||
setenv(name, buf, 1);
|
|
||||||
rval = buf;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
@ -91,3 +81,31 @@ bool readenv_bool(const char * name, bool def)
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string string_printf(const char* format, ...)
|
||||||
|
{
|
||||||
|
string rval;
|
||||||
|
va_list valist;
|
||||||
|
va_start(valist, format);
|
||||||
|
rval = string_printf(format, valist);
|
||||||
|
va_end(valist);
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string string_printf(const char* format, va_list args)
|
||||||
|
{
|
||||||
|
va_list args_copy;
|
||||||
|
va_copy(args_copy, args);
|
||||||
|
int bytes_required = vsnprintf(nullptr, 0, format, args_copy);
|
||||||
|
va_end(args_copy);
|
||||||
|
|
||||||
|
string rval;
|
||||||
|
if (bytes_required > 0)
|
||||||
|
{
|
||||||
|
int buflen = bytes_required + 1;
|
||||||
|
char buf[buflen];
|
||||||
|
vsnprintf(buf, buflen, format, args);
|
||||||
|
rval = buf;
|
||||||
|
}
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|||||||
@ -346,12 +346,9 @@ TestConnections::TestConnections(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_get_logs_command = (string)test_dir + "/get_logs.sh";
|
m_get_logs_command = (string)test_dir + "/get_logs.sh";
|
||||||
|
m_ssl_options = string_printf("--ssl-cert=%s/ssl-cert/client-cert.pem --ssl-key=%s/ssl-cert/client-key.pem",
|
||||||
sprintf(m_ssl_options,
|
test_dir, test_dir);
|
||||||
"--ssl-cert=%s/ssl-cert/client-cert.pem --ssl-key=%s/ssl-cert/client-key.pem",
|
setenv("ssl_options", m_ssl_options.c_str(), 1);
|
||||||
test_dir,
|
|
||||||
test_dir);
|
|
||||||
setenv("ssl_options", m_ssl_options, 1);
|
|
||||||
|
|
||||||
if (maxscale::require_columnstore)
|
if (maxscale::require_columnstore)
|
||||||
{
|
{
|
||||||
@ -651,7 +648,7 @@ void TestConnections::expect(bool result, const char* format, ...)
|
|||||||
|
|
||||||
void TestConnections::read_mdbci_info()
|
void TestConnections::read_mdbci_info()
|
||||||
{
|
{
|
||||||
m_mdbci_vm_path = envvar_read_write_def_str("MDBCI_VM_PATH", "%s/vms/", getenv("HOME"));
|
m_mdbci_vm_path = envvar_get_set("MDBCI_VM_PATH", "%s/vms/", getenv("HOME"));
|
||||||
|
|
||||||
string cmd = "mkdir -p " + m_mdbci_vm_path;
|
string cmd = "mkdir -p " + m_mdbci_vm_path;
|
||||||
if (system(cmd.c_str()))
|
if (system(cmd.c_str()))
|
||||||
@ -659,10 +656,10 @@ void TestConnections::read_mdbci_info()
|
|||||||
tprintf("Unable to create MDBCI VMs direcory '%s', exiting", m_mdbci_vm_path.c_str());
|
tprintf("Unable to create MDBCI VMs direcory '%s', exiting", m_mdbci_vm_path.c_str());
|
||||||
exit(MDBCI_FAIL);
|
exit(MDBCI_FAIL);
|
||||||
}
|
}
|
||||||
m_mdbci_template = envvar_read_write_def_str("template", "default");
|
m_mdbci_template = envvar_get_set("template", "default");
|
||||||
m_target = envvar_read_write_def_str("target", "develop");
|
m_target = envvar_get_set("target", "develop");
|
||||||
|
|
||||||
m_mdbci_config_name = envvar_read_write_def_str("mdbci_config_name", "local");
|
m_mdbci_config_name = envvar_get_set("mdbci_config_name", "local");
|
||||||
m_vm_path = m_mdbci_vm_path + "/" + m_mdbci_config_name;
|
m_vm_path = m_mdbci_vm_path + "/" + m_mdbci_config_name;
|
||||||
|
|
||||||
if (!m_mdbci_config_name.empty())
|
if (!m_mdbci_config_name.empty())
|
||||||
@ -718,10 +715,10 @@ void TestConnections::read_env()
|
|||||||
smoke = readenv_bool("smoke", false);
|
smoke = readenv_bool("smoke", false);
|
||||||
m_threads = readenv_int("threads", 4);
|
m_threads = readenv_int("threads", 4);
|
||||||
m_use_snapshots = readenv_bool("use_snapshots", false);
|
m_use_snapshots = readenv_bool("use_snapshots", false);
|
||||||
m_take_snapshot_command = envvar_read_write_def_str(
|
m_take_snapshot_command = envvar_get_set(
|
||||||
"take_snapshot_command", "mdbci snapshot take --path-to-nodes %s --snapshot-name ",
|
"take_snapshot_command", "mdbci snapshot take --path-to-nodes %s --snapshot-name ",
|
||||||
m_mdbci_config_name.c_str());
|
m_mdbci_config_name.c_str());
|
||||||
m_revert_snapshot_command = envvar_read_write_def_str(
|
m_revert_snapshot_command = envvar_get_set(
|
||||||
"revert_snapshot_command", "mdbci snapshot revert --path-to-nodes %s --snapshot-name ",
|
"revert_snapshot_command", "mdbci snapshot revert --path-to-nodes %s --snapshot-name ",
|
||||||
m_mdbci_config_name.c_str());
|
m_mdbci_config_name.c_str());
|
||||||
no_vm_revert = readenv_bool("no_vm_revert", true);
|
no_vm_revert = readenv_bool("no_vm_revert", true);
|
||||||
@ -2240,7 +2237,7 @@ int TestConnections::call_mdbci(const char* options)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string team_keys = readenv("team_keys", "~/.ssh/id_rsa.pub");
|
std::string team_keys = envvar_get_set("team_keys", "~/.ssh/id_rsa.pub");
|
||||||
string cmd = "mdbci public_keys --key " + team_keys + " " + m_mdbci_config_name;
|
string cmd = "mdbci public_keys --key " + team_keys + " " + m_mdbci_config_name;
|
||||||
system(cmd.c_str());
|
system(cmd.c_str());
|
||||||
read_env();
|
read_env();
|
||||||
@ -2261,27 +2258,28 @@ int TestConnections::call_mdbci(const char* options)
|
|||||||
|
|
||||||
int TestConnections::process_mdbci_template()
|
int TestConnections::process_mdbci_template()
|
||||||
{
|
{
|
||||||
char* product = readenv("product", "mariadb");
|
string box = envvar_get_set("box", "centos_7_libvirt");
|
||||||
char* box = readenv("box", "centos_7_libvirt");
|
envvar_get_set("backend_box", "%s", box.c_str());
|
||||||
char* __attribute__ ((unused)) backend_box = readenv("backend_box", "%s", box);
|
envvar_get_set("target", "develop");
|
||||||
char* version = readenv("version", "10.3");
|
envvar_get_set("vm_memory", "2048");
|
||||||
char* __attribute__ ((unused)) target = readenv("target", "develop");
|
|
||||||
char* __attribute__ ((unused)) vm_memory = readenv("vm_memory", "2048");
|
|
||||||
char* __attribute__ ((unused)) galera_version = readenv("galera_version", "%s", version);
|
|
||||||
|
|
||||||
if (strcmp(product, "mysql") == 0)
|
string version = envvar_get_set("version", "10.3");
|
||||||
|
envvar_get_set("galera_version", "%s", version.c_str());
|
||||||
|
|
||||||
|
string product = envvar_get_set("product", "mariadb");
|
||||||
|
string cnf_path;
|
||||||
|
if (product == "mysql")
|
||||||
{
|
{
|
||||||
setenv("cnf_path",
|
cnf_path = string_printf("%s/cnf/mysql56/", m_vm_path.c_str());
|
||||||
(m_vm_path + "/cnf/mysql56/").c_str(),
|
|
||||||
1);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setenv("cnf_path", (m_vm_path + "/cnf/").c_str(), 1);
|
cnf_path = string_printf("%s/cnf/", m_vm_path.c_str());
|
||||||
}
|
}
|
||||||
|
setenv("cnf_path", cnf_path.c_str(), 1);
|
||||||
|
|
||||||
std::string name = std::string(test_dir) + "/mdbci/templates/" + m_mdbci_template + ".json.template";
|
string name = string(test_dir) + "/mdbci/templates/" + m_mdbci_template + ".json.template";
|
||||||
std::string sys = std::string("envsubst < ") + name + " > " + m_vm_path + ".json";
|
string sys = string("envsubst < ") + name + " > " + m_vm_path + ".json";
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
std::cout << sys << std::endl;
|
std::cout << sys << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user