Merge branch '2.3' into 2.4
This commit is contained in:
commit
def264f117
@ -10,9 +10,10 @@
|
||||
* @param format Default value format string
|
||||
* @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
|
||||
@ -30,3 +31,7 @@ int readenv_int(const char * name, int def);
|
||||
* @return Enviromental variable value converted to bool
|
||||
*/
|
||||
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};
|
||||
|
||||
/**
|
||||
* @brief SysbenchDir path to SysBench directory (sysbanch should be >= 0.5)
|
||||
*/
|
||||
char sysbench_dir[4096];
|
||||
|
||||
/**
|
||||
* @brief copy_mariadb_logs copies MariaDB logs from backend
|
||||
* @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_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_network_config; /**< Content of MDBCI network_config file */
|
||||
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_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_local_maxscale {false}; /**< MaxScale runs locally, specified using -l. */
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
using std::string;
|
||||
|
||||
char * readenv(const char * name, const char *format, ...)
|
||||
char* readenv(const char * name, const char *format, ...)
|
||||
{
|
||||
char * env = getenv(name);
|
||||
if (!env)
|
||||
@ -31,7 +31,7 @@ char * readenv(const char * name, const char *format, ...)
|
||||
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;
|
||||
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_start(valist, format);
|
||||
int bytes_required = vsnprintf(nullptr, 0, format, valist);
|
||||
rval = string_printf(format, valist);
|
||||
va_end(valist);
|
||||
|
||||
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;
|
||||
}
|
||||
setenv(name, rval.c_str(), 1);
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
@ -91,3 +81,31 @@ bool readenv_bool(const char * name, bool 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";
|
||||
|
||||
sprintf(m_ssl_options,
|
||||
"--ssl-cert=%s/ssl-cert/client-cert.pem --ssl-key=%s/ssl-cert/client-key.pem",
|
||||
test_dir,
|
||||
test_dir);
|
||||
setenv("ssl_options", m_ssl_options, 1);
|
||||
m_ssl_options = string_printf("--ssl-cert=%s/ssl-cert/client-cert.pem --ssl-key=%s/ssl-cert/client-key.pem",
|
||||
test_dir, test_dir);
|
||||
setenv("ssl_options", m_ssl_options.c_str(), 1);
|
||||
|
||||
if (maxscale::require_columnstore)
|
||||
{
|
||||
@ -651,7 +648,7 @@ void TestConnections::expect(bool result, const char* format, ...)
|
||||
|
||||
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;
|
||||
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());
|
||||
exit(MDBCI_FAIL);
|
||||
}
|
||||
m_mdbci_template = envvar_read_write_def_str("template", "default");
|
||||
m_target = envvar_read_write_def_str("target", "develop");
|
||||
m_mdbci_template = envvar_get_set("template", "default");
|
||||
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;
|
||||
|
||||
if (!m_mdbci_config_name.empty())
|
||||
@ -718,10 +715,10 @@ void TestConnections::read_env()
|
||||
smoke = readenv_bool("smoke", false);
|
||||
m_threads = readenv_int("threads", 4);
|
||||
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 ",
|
||||
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 ",
|
||||
m_mdbci_config_name.c_str());
|
||||
no_vm_revert = readenv_bool("no_vm_revert", true);
|
||||
@ -2240,7 +2237,7 @@ int TestConnections::call_mdbci(const char* options)
|
||||
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;
|
||||
system(cmd.c_str());
|
||||
read_env();
|
||||
@ -2261,27 +2258,28 @@ int TestConnections::call_mdbci(const char* options)
|
||||
|
||||
int TestConnections::process_mdbci_template()
|
||||
{
|
||||
char* product = readenv("product", "mariadb");
|
||||
char* box = readenv("box", "centos_7_libvirt");
|
||||
char* __attribute__ ((unused)) backend_box = readenv("backend_box", "%s", box);
|
||||
char* version = readenv("version", "10.3");
|
||||
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);
|
||||
string box = envvar_get_set("box", "centos_7_libvirt");
|
||||
envvar_get_set("backend_box", "%s", box.c_str());
|
||||
envvar_get_set("target", "develop");
|
||||
envvar_get_set("vm_memory", "2048");
|
||||
|
||||
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",
|
||||
(m_vm_path + "/cnf/mysql56/").c_str(),
|
||||
1);
|
||||
cnf_path = string_printf("%s/cnf/mysql56/", m_vm_path.c_str());
|
||||
}
|
||||
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";
|
||||
std::string sys = std::string("envsubst < ") + name + " > " + m_vm_path + ".json";
|
||||
string name = string(test_dir) + "/mdbci/templates/" + m_mdbci_template + ".json.template";
|
||||
string sys = string("envsubst < ") + name + " > " + m_vm_path + ".json";
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << sys << std::endl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user