Merge branch '2.2' into develop

This commit is contained in:
Markus Mäkelä 2018-04-23 14:05:52 +03:00
commit f4bdf3012d
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
59 changed files with 172 additions and 235 deletions

View File

@ -13,6 +13,7 @@ plugin modules that tailor the behavior of the program.
* [Configuration](#configuration)
* [Special Parameter Types](#special-parameter-types)
* [Global Settings](#global-settings)
* [REST API Configuration](#rest-api-configuration)
* [Service](#service)
* [Server](#server)
* [Listener](#listener)
@ -607,61 +608,6 @@ is placed in the configuration file. However, in the `[maxscale]` section,
to ensure that substitution will take place, place the
`substitute_variables=true` line first.
### REST API Configuration
The MaxScale REST API is an HTTP interface that provides JSON format data
intended to be consumed by monitoring appllications and visualization tools.
The following options must be defined under the `[maxscale]` section in the
configuration file.
#### `admin_host`
The network interface where the HTTP admin interface listens on. The default
value is the IPv4 address `127.0.0.1` which only listens for local connections.
#### `admin_port`
The port where the HTTP admin interface listens on. The default value is port
8989.
#### `admin_auth`
Enable HTTP admin interface authentication using HTTP Basic Access
authentication. This is not a secure method of authentication without HTTPS but
it does add a small layer of security. This option is enabled by default.
The admin interface authentication uses the same user as MaxAdmin network
interface. This means that new users can be added with both MaxAdmin and the
REST API. The default credentials for the interface are `admin:mariadb`.
#### `admin_ssl_key`
The path to the TLS private key in PEM format for the admin interface.
If the `admin_ssl_key`, `admin_ssl_cert` and `admin_ssl_ca_cert` options are all
defined, the admin interface will use encrypted HTTPS instead of plain HTTP.
#### `admin_ssl_cert`
The path to the TLS public certificate in PEM format. See `admin_ssl_key`
documentation for more details.
#### `admin_ssl_ca_cert`
The path to the TLS CA certificate in PEM format. See `admin_ssl_key`
documentation for more details.
#### `admin_enabled`
Enable or disable the admin interface. This allows the admin interface to
be completely disabled to prevent access to it.
#### `admin_log_auth_failures`
Log authentication failures for the admin interface. This parameter expects a
boolean value and is enabled by default.
#### `sql_mode`
Specifies whether the query classifier parser should initially expect _MariaDB_
@ -760,6 +706,61 @@ Note that you need to specify with `retain_last_statements` how many statements
MaxScale should retain for each session. Unless it has been set to another value
than `0`, this configuration setting will not have an effect.
### REST API Configuration
The MaxScale REST API is an HTTP interface that provides JSON format data
intended to be consumed by monitoring appllications and visualization tools.
The following options must be defined under the `[maxscale]` section in the
configuration file.
#### `admin_host`
The network interface where the HTTP admin interface listens on. The default
value is the IPv4 address `127.0.0.1` which only listens for local connections.
#### `admin_port`
The port where the HTTP admin interface listens on. The default value is port
8989.
#### `admin_auth`
Enable HTTP admin interface authentication using HTTP Basic Access
authentication. This is not a secure method of authentication without HTTPS but
it does add a small layer of security. This option is enabled by default.
The admin interface authentication uses the same user as MaxAdmin network
interface. This means that new users can be added with both MaxAdmin and the
REST API. The default credentials for the interface are `admin:mariadb`.
#### `admin_ssl_key`
The path to the TLS private key in PEM format for the admin interface.
If the `admin_ssl_key`, `admin_ssl_cert` and `admin_ssl_ca_cert` options are all
defined, the admin interface will use encrypted HTTPS instead of plain HTTP.
#### `admin_ssl_cert`
The path to the TLS public certificate in PEM format. See `admin_ssl_key`
documentation for more details.
#### `admin_ssl_ca_cert`
The path to the TLS CA certificate in PEM format. See `admin_ssl_key`
documentation for more details.
#### `admin_enabled`
Enable or disable the admin interface. This allows the admin interface to
be completely disabled to prevent access to it.
#### `admin_log_auth_failures`
Log authentication failures for the admin interface. This parameter expects a
boolean value and is enabled by default.
### Service
A service represents the database service that MariaDB MaxScale offers to the

View File

@ -21,6 +21,11 @@ Although JSON does not define a syntax for comments, some of the JSON examples
have C-style inline comments in them. These comments use `//` to mark the start
of the comment and extend to the end of the current line.
## Configuration
Read the [REST API](../Getting-Started/Configuration-Guide.md#rest-api-configuration)
section of the configuration guide for more details on how to configure the REST API.
## Authentication
The MaxScale REST API uses [HTTP Basic Access](https://tools.ietf.org/html/rfc2617#section-2)

View File

@ -21,10 +21,10 @@ set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of
build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug
Release RelWithDebInfo MinSizeRel.")
set(CMAKE_CXX_FLAGS "-std=c++11 -ggdb -Werror")
set(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -ggdb -Werror")
set(CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -ggdb -Werror")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-std=c++11 -ggdb -Werror")
set(CMAKE_CXX_FLAGS "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function")
set(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function")
set(CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function")
enable_testing()
@ -53,7 +53,7 @@ add_library(testcore SHARED testconnections.cpp nodes.cpp mariadb_nodes.cpp maxs
blob_test.cpp keepalived_func.cpp
# Include the CDC connector in the core library
${CMAKE_SOURCE_DIR}/../connectors/cdc-connector/cdc_connector.cpp)
target_link_libraries(testcore ${MYSQL_CLIENT} ${JANSSON_LIBRARIES} z nsl m pthread ssl dl rt crypto crypt)
target_link_libraries(testcore ${MYSQL_CLIENT} ${JANSSON_LIBRARIES} z m pthread ssl dl rt crypto crypt)
install(TARGETS testcore DESTINATION system-test)
add_dependencies(testcore connector-c jansson)

View File

@ -60,8 +60,6 @@ void load(long int *new_inserts, long int *new_selects, long int *selects, long
pthread_t thread1[threads_num];
pthread_t thread2[threads_num];
int iret1[threads_num];
int iret2[threads_num];
Test->tprintf("COM_INSERT and COM_SELECT before executing test\n");
@ -72,8 +70,8 @@ void load(long int *new_inserts, long int *new_selects, long int *selects, long
/* Create independent threads each of them will execute function */
for (int i = 0; i < threads_num; i++)
{
iret1[i] = pthread_create(&thread1[i], NULL, query_thread1, &data);
iret2[i] = pthread_create(&thread2[i], NULL, query_thread2, &data);
pthread_create(&thread1[i], NULL, query_thread1, &data);
pthread_create(&thread2[i], NULL, query_thread2, &data);
}
Test->tprintf("Threads are running %d seconds \n", run_time);
sleep(run_time);

View File

@ -28,9 +28,8 @@ int main(int argc, char *argv[])
Test->start_binlog(0);
pthread_t threads;
int iret;
exit_flag = 0;
iret = pthread_create( &threads, NULL, disconnect_thread, NULL);
pthread_create( &threads, NULL, disconnect_thread, NULL);
Test->repl->connect();
for (int i = 0; i < 100000; i++)

View File

@ -132,15 +132,12 @@ int main(int argc, char *argv[])
Test->tprintf("Starting binlog configuration\n");
Test->start_binlog(0);
pthread_t disconnec_thread_t;
int disconnect_iret;
pthread_t transaction_thread_t;
int transaction_iret;
exit_flag = 0;
Test->tprintf("Starting query thread\n");
transaction_iret = pthread_create(&transaction_thread_t, NULL, transaction_thread, NULL);
pthread_create(&transaction_thread_t, NULL, transaction_thread, NULL);
Test->tprintf("Sleeping\n");
Test->stop_timeout();
@ -226,10 +223,9 @@ const char * setup_slave_gtid =
MASTER_USE_GTID=Slave_pos";
int select_new_master(TestConnections * test)
void select_new_master(TestConnections * test)
{
char log_file[256];
char log_file_new[256];
char log_pos[256];
char maxscale_log_file[256];
@ -265,7 +261,7 @@ int select_new_master(TestConnections * test)
if (!maxscale_log_file[0] || !maxscale_log_pos[0])
{
test->add_result(1, "Failed to query for master status");
return 1;
return;
}
test->tprintf("Real master file: %s\n", maxscale_log_file);
@ -320,7 +316,6 @@ int select_new_master(TestConnections * test)
test->tprintf("slave started!\n");
test->repl->close_connections();
}
void *disconnect_thread( void *ptr )

View File

@ -3,9 +3,9 @@
int test_longblob(TestConnections* Test, MYSQL * conn, char * blob_name, unsigned long chunk_size, int chunks,
int rows)
{
unsigned long size = chunk_size;
int size = chunk_size;
unsigned long * data;
unsigned long i, j;
int i, j;
MYSQL_BIND param[1];
char sql[256];
int global_res = Test->global_result;
@ -171,9 +171,9 @@ int check_longblob_data(TestConnections* Test, MYSQL * conn, unsigned long chunk
{
Test->add_result(1, "id field is wrong! Expected %d, but it is %d\n", row + 1, r_id);
}
for (int y = 0; y < chunk_size * chunks; y++)
for (int y = 0; y < (int)chunk_size * chunks; y++)
{
if (data[y] != y)
if ((int)data[y] != y)
{
Test->add_result(1, "expected %d, got %d", data[y], y);
break;
@ -188,6 +188,8 @@ int check_longblob_data(TestConnections* Test, MYSQL * conn, unsigned long chunk
mysql_stmt_free_result(stmt);
mysql_stmt_close(stmt);
return 0;
}

View File

@ -12,7 +12,6 @@ int main(int argc, char *argv[])
{
char my_ip[1024];
char my_ip_db[1024];
char sql[1024];
char * first_dot;
TestConnections * Test = new TestConnections(argc, argv);

View File

@ -140,7 +140,6 @@ int main(int argc, char *argv[])
char sql[100];
pthread_t parall_traffic1;
int check_iret;
MYSQL * conn;
MYSQL * rwsplit_conn[conn_N];
@ -199,7 +198,7 @@ int main(int argc, char *argv[])
Test->tprintf("Opening more connection to ReadConn slave in parallel thread\n");
check_iret = pthread_create( &parall_traffic1, NULL, parall_traffic, NULL);
pthread_create( &parall_traffic1, NULL, parall_traffic, NULL);
for (i = 0; i < Test->repl->N; i++)
{

View File

@ -57,7 +57,6 @@ int main(int argc, char *argv[])
pthread_t parall_traffic1[100];
int check_iret[100];
Test->set_timeout(60);
Test->repl->connect();
@ -75,7 +74,7 @@ int main(int argc, char *argv[])
for (int j = 0; j < 25; j++)
{
check_iret[j] = pthread_create(&parall_traffic1[j], NULL, parall_traffic, NULL);
pthread_create(&parall_traffic1[j], NULL, parall_traffic, NULL);
}
Test->tprintf("Doing change_user in the loop");

View File

@ -17,7 +17,6 @@ int main(int argc, char *argv[])
test.set_timeout(60);
for (int i = 0; i < 2; i++)
{
char result[1024];
test.add_result(test.maxscales->ssh_node_f(0, true, "maxadmin show dbusers \"RW Split Router\"|grep 'User names'"),
"Old style objects in maxadmin commands should succeed");
test.add_result(test.maxscales->ssh_node_f(0, true, "maxadmin show dbusers RW-Split-Router|grep 'User names'"),

View File

@ -196,6 +196,7 @@ int bind_by_row(MYSQL *mysql)
return show_mysql_error(mysql);
}
return 0;
}
int main(int argc, char** argv)

View File

@ -136,9 +136,6 @@ void init(TestConnections& test)
void run(TestConnections& test)
{
init(test);
MYSQL* pMysql = test.maxscales->conn_rwsplit[0];
int value;
// Let's populate the cache.

View File

@ -145,9 +145,6 @@ void init(TestConnections& test)
void run(TestConnections& test)
{
init(test);
MYSQL* pMysql = test.maxscales->conn_rwsplit[0];
int value;
// Let's set a long hard_ttl so that it will not interfere

View File

@ -130,13 +130,9 @@ bool cdc_com(TestConnections *Test)
if (nfds > 0)
{
// for each ready socket
//for(int i = 0; i < nfds; i++)
//{
int fd = events[0].data.fd;
char *json = read_sc(sock);
Test->tprintf("%s", json);
//}
if (ignore_first > 0)
{
ignore_first--; // ignoring first reads
@ -251,4 +247,6 @@ void *query_thread(void *ptr)
}
Test->repl->close_connections();
return NULL;
}

View File

@ -30,7 +30,7 @@ int main(int argc, char *argv[])
Test->set_timeout(60);
Test->repl->change_master(1, 0);
Test->tprintf("executing 3 INSERTs\n");
for (int i = 0; i++; i < 3)
for (int i = 0; i < 3; i++)
{
Test->set_timeout(60);
sprintf(sql, "INSERT INTO t1 (x1, fl) VALUES(%d, 2);", i);

View File

@ -12,7 +12,7 @@
using namespace std;
int check_max_conn(int router, int max_conn, TestConnections * Test)
void check_max_conn(int router, int max_conn, TestConnections * Test)
{
MYSQL * conn[max_conn + 1];

View File

@ -15,7 +15,6 @@ int main(int argc, char *argv[])
{
TestConnections * Test = new TestConnections(argc, argv);
Test->set_timeout(20);
int q;
long int i1, i2;
long int selects[256];

View File

@ -40,7 +40,6 @@ int hash_password(TestConnections *test)
test->maxscales->stop_maxscale(0);
test->stop_timeout();
int res = 0;
int exit_code;
test->tprintf("Creating a new encrypted password\n");
char *enc_pw = test->maxscales->ssh_node_output(0, "maxpasswd /var/lib/maxscale/ skysql", true, &exit_code);

View File

@ -62,7 +62,6 @@ int main(int argc, char *argv[])
char pass_file[4096];
char deny_file[4096];
char rules_dir[4096];
FILE* file;
sprintf(rules_dir, "%s/fw2/", test_dir);
int N = 5;

View File

@ -33,11 +33,11 @@ int get_my_ip(char * remote_ip, char * my_ip )
serv.sin_addr.s_addr = inet_addr( remote_ip );
serv.sin_port = htons( dns_port );
int err = connect( sock , (const struct sockaddr*) &serv , sizeof(serv) );
connect( sock , (const struct sockaddr*) &serv , sizeof(serv) );
struct sockaddr_in name;
socklen_t namelen = sizeof(name);
err = getsockname(sock, (struct sockaddr*) &name, &namelen);
getsockname(sock, (struct sockaddr*) &name, &namelen);
char buffer[100];
const char* p = inet_ntop(AF_INET, &name.sin_addr, buffer, 100);

View File

@ -390,7 +390,7 @@ int execute_query_count_rows(MYSQL* conn, const char* sql)
{
rval = 0;
for (int i = 0; i < total && i < 1024; i++)
for (unsigned int i = 0; i < total && i < 1024; i++)
{
rval += num_of_rows[i];
}
@ -403,7 +403,6 @@ int get_conn_num(MYSQL* conn, std::string ip, std::string hostname, std::string
{
MYSQL_RES *res;
MYSQL_ROW row;
unsigned long long int num_fields;
unsigned long long int rows;
unsigned long long int i;
unsigned int conn_num = 0;
@ -436,7 +435,7 @@ int get_conn_num(MYSQL* conn, std::string ip, std::string hostname, std::string
}
else
{
num_fields = mysql_num_fields(res);
mysql_num_fields(res);
rows = mysql_num_rows(res);
for (i = 0; i < rows; i++)
{
@ -472,7 +471,6 @@ int find_field(MYSQL* conn, const char* sql, const char* field_name, char* value
MYSQL_RES *res;
MYSQL_ROW row;
MYSQL_FIELD *field;
unsigned long long int num_fields;
unsigned int ret = 1;
unsigned long long int filed_i = 0;
unsigned long long int i = 0;
@ -492,7 +490,7 @@ int find_field(MYSQL* conn, const char* sql, const char* field_name, char* value
}
else
{
num_fields = mysql_num_fields(res);
mysql_num_fields(res);
while ((field = mysql_fetch_field(res)) && ret != 0)
{
if (strstr(field->name, field_name) != NULL)
@ -536,7 +534,7 @@ Row get_row(MYSQL* conn, std::string sql)
if (row)
{
for (int i = 0; i < mysql_num_fields(res); i++)
for (unsigned int i = 0; i < mysql_num_fields(res); i++)
{
rval.push_back(row[i]);
}

View File

@ -102,7 +102,7 @@ void Mariadb_nodes::close_connections()
int Mariadb_nodes::read_env()
void Mariadb_nodes::read_env()
{
char * env;
char env_name[64];
@ -207,7 +207,7 @@ int Mariadb_nodes::read_env()
}
}
int Mariadb_nodes::print_env()
void Mariadb_nodes::print_env()
{
for (int i = 0; i < N; i++)
{
@ -255,7 +255,7 @@ int Mariadb_nodes::find_master()
return master_node;
}
int Mariadb_nodes::change_master(int NewMaster, int OldMaster)
void Mariadb_nodes::change_master(int NewMaster, int OldMaster)
{
for (int i = 0; i < N; i++)
{

View File

@ -38,7 +38,7 @@ public:
*/
Mariadb_nodes(const char *pref, const char *test_cwd, bool verbose);
~Mariadb_nodes();
virtual ~Mariadb_nodes();
/**
* @brief MYSQL structs for every backend node
@ -168,14 +168,13 @@ public:
/**
* @brief reads IP, Ports, sshkeys for every node from enviromental variables as well as number of nodes (N) and User/Password
* @return 0
*/
int read_env();
void read_env();
/**
* @brief prints all nodes information
* @return 0
*/
int print_env();
void print_env();
/**
* @brief find_master Tries to find Master node
@ -186,9 +185,8 @@ public:
* @brief change_master set a new master node for Master/Slave setup
* @param NewMaster index of new Master node
* @param OldMaster index of current Master node
* @return 0 in case of success
*/
int change_master(int NewMaster, int OldMaster);
void change_master(int NewMaster, int OldMaster);
/**
* @brief stop_nodes stops mysqld on all nodes

View File

@ -107,7 +107,7 @@ char * get_maxinfo(const char * page, TestConnections* Test)
//Test->tprintf("Query is:\n<<START>>\n%s<<END>>\n", get);
//Send the query to the server
int sent = 0;
size_t sent = 0;
while (sent < strlen(get))
{
tmpres = send(sock, get + sent, strlen(get) - sent, 0);
@ -178,7 +178,7 @@ char * read_sc(int sock)
int send_so(int sock, char * data)
{
int tmpres;
int sent = 0;
size_t sent = 0;
while (sent < strlen(data))
{
tmpres = send(sock, data + sent, strlen(data) - sent, 0);
@ -298,4 +298,5 @@ int get_x_fl_from_json(char * line, long long int * x1, long long int * fl)
json_decref(x_json);
json_decref(fl_json);
json_decref(root);
return 0;
}

View File

@ -15,7 +15,7 @@ char * get_maxinfo(const char *page, TestConnections* Test);
char * read_sc(int sock);
int send_so(int sock, char * data);
static char hexconvtab[] = "0123456789abcdef";
static char hexconvtab[] __attribute__((unused)) = "0123456789abcdef";
static char* bin2hex(const unsigned char *old, const size_t oldlen);
char * cdc_auth_srt(char * user, char * password);
int setnonblocking(int sock);

View File

@ -31,7 +31,6 @@ int main(int argc, char *argv[])
{
TestConnections test(argc, argv);
char server_id[2][1024];
test.repl->connect();
std::string master = test.repl->get_server_id_str(0);
std::string slave = test.repl->get_server_id_str(1);

View File

@ -15,7 +15,7 @@ using namespace std;
bool query(TestConnections& test)
{
test.maxscales->connect();
execute_query_silent(test.maxscales->conn_rwsplit[0], "SET @a = 1") == 0;
execute_query_silent(test.maxscales->conn_rwsplit[0], "SET @a = 1");
sleep(5);
Row row = get_row(test.maxscales->conn_rwsplit[0], "SELECT @a");
test.maxscales->disconnect();

View File

@ -35,7 +35,6 @@ void run(TestConnections& test)
MYSQL* pMysql = mysql_init(NULL);
test.assert(pMysql, "Could not create MYSQL handle.");
const char* zHost = test.maxscales->IP[0];
const char* zUser = test.maxscales->user_name;
const char* zPassword = test.maxscales->password;
int port = test.maxscales->rwsplit_port[0];

View File

@ -30,7 +30,7 @@ struct TestCase
std::function<bool (MYSQL*, MYSQL_STMT*, Bind&)> func;
};
bool run_test(TestConnections& test, TestCase test_case)
void run_test(TestConnections& test, TestCase test_case)
{
test.maxscales->connect();

View File

@ -19,11 +19,11 @@ static int test_long_data(MYSQL *conn, int sqlsize)
MYSQL_STMT *stmt;
stmt = mysql_stmt_init(conn);
int rc, int_data;
int int_data;
MYSQL_RES *result;
MYSQL_BIND my_bind[1];
rc = mysql_autocommit(conn, 1);
mysql_autocommit(conn, 1);
if (NULL == stmt)
{

View File

@ -24,7 +24,7 @@ void create_data_file(char* filename, size_t size)
while (filesize < maxsize)
{
char buffer[1024];
sprintf(buffer, "%d,'%x','%x'\n", i, i << 10 + i, i << 5 + i);
sprintf(buffer, "%d,'%x','%x'\n", i, i << (10 + i), i << (5 + i));
int written = write(fd, buffer, strlen(buffer));
if (written <= 0)
{
@ -67,8 +67,8 @@ int main(int argc, char *argv[])
test->tprintf("Re-connect to Maxscale\n");
test->set_timeout(20);
test->maxscales->connect_maxscale(0);
char query[1024];
snprintf(query, sizeof (filename),
char query[1024 + sizeof(filename)];
snprintf(query, sizeof (query),
"LOAD DATA LOCAL INFILE '%s' INTO TABLE test.dump FIELDS TERMINATED BY ','",
filename);
test->tprintf("Loading data\n");

View File

@ -76,10 +76,8 @@ int main(int argc, char *argv[])
}
pthread_t thread1[threads_num];
int iret1[threads_num];
pthread_t thread_master[master_load_threads_num];
int iret_master[master_load_threads_num];
Test->repl->connect();
Test->maxscales->connect_maxscale(0);
@ -98,13 +96,13 @@ int main(int argc, char *argv[])
/* Create independent threads each of them will create some load on Master */
for (i = 0; i < master_load_threads_num; i++)
{
iret_master[i] = pthread_create(&thread_master[i], NULL, query_thread_master, &data_master[i]);
pthread_create(&thread_master[i], NULL, query_thread_master, &data_master[i]);
}
/* Create independent threads each of them will execute function */
for (i = 0; i < threads_num; i++)
{
iret1[i] = pthread_create(&thread1[i], NULL, query_thread1, &data[i]);
pthread_create(&thread1[i], NULL, query_thread1, &data[i]);
}
Test->tprintf("Threads are running %d seconds \n", run_time);

View File

@ -54,7 +54,6 @@ int main(int argc, char *argv[])
pthread_t thread1[threads_num];
int iret1[threads_num];
//Test->repl->flush_hosts();
Test->set_timeout(20);
@ -98,7 +97,7 @@ int main(int argc, char *argv[])
/* Create independent threads each of them will execute function */
for (i = 0; i < threads_num; i++)
{
iret1[i] = pthread_create(&thread1[i], NULL, query_thread1, &data[i]);
pthread_create(&thread1[i], NULL, query_thread1, &data[i]);
}
Test->tprintf("Threads are running %d seconds \n", run_time);
@ -132,7 +131,7 @@ int main(int argc, char *argv[])
}
for (i = 0; i < threads_num; i++)
{
iret1[i] = pthread_create(&thread1[i], NULL, query_thread1, &data[i]);
pthread_create(&thread1[i], NULL, query_thread1, &data[i]);
}
Test->set_timeout(3 * run_time + 60);

View File

@ -25,7 +25,6 @@ int main(int argc, char *argv[])
{
Test = new TestConnections(argc, argv);
pthread_t restart_t;
int check_iret;
int i, j;
@ -33,7 +32,7 @@ int main(int argc, char *argv[])
Test->set_timeout(2000);
check_iret = pthread_create(&restart_t, NULL, kill_vm_thread, NULL);
pthread_create(&restart_t, NULL, kill_vm_thread, NULL);
int iter = 1000;
if (Test->smoke)

View File

@ -32,12 +32,11 @@ void sht_rst_service()
int threads_num = 5;
pthread_t thread1[threads_num];
int iret1[threads_num];
int i;
for (i = 0; i < threads_num; i++)
{
iret1[i] = pthread_create(&thread1[i], NULL, query_thread1, NULL);
pthread_create(&thread1[i], NULL, query_thread1, NULL);
}
Test->tprintf("Trying to shutdown and restart RW Split router in the loop\n");
@ -94,4 +93,6 @@ void *query_thread1( void *ptr )
Test->maxscales->execute_maxadmin_command(0, shutdown_cmd);
Test->maxscales->execute_maxadmin_command(0, restart_cmd);
}
return NULL;
}

View File

@ -137,14 +137,9 @@ int main(int argc, char *argv[])
add_remove_maxadmin_user(Test);
Test->tprintf("trying long wierd user\n");
char * st10 = Test->maxscales->ssh_node_output(0,
Test->maxscales->ssh_node_output(0,
"maxadmin enable account yygrgtrпрекури6н33имн756ККККЕН:УИГГГГ*?:*:*fj34oru34h275g23457g2v90590+u764gv56837fbv62381§SDFERGtrg45ergfergergefewfergt456ty",
true, &exit_code);
/*Test->tprintf("Result: %s\n", st10);
if (strstr(st10, "has been successfully added") == NULL)
{
Test->add_result(1, "Wrong list of MaxAdmin users\n");
}*/
Test->check_maxscale_alive(0);
Test->maxscales->ssh_node_f(0, true, "rm -rf /var/lib/maxscale/passwd");

View File

@ -54,6 +54,8 @@ void* test_thr(void *data)
mysql_close(mysql);
}
return NULL;
}
#define THREADS 5

View File

@ -16,7 +16,7 @@ int main(int argc, char *argv[])
sleep(1);
test->maxscales->connect_maxscale(0);
test->try_query(test->maxscales->conn_rwsplit[0], "select @@server_id") == 0;
test->try_query(test->maxscales->conn_rwsplit[0], "select @@server_id");
config.create_ssl_listener(Config::SERVICE_RCONN_SLAVE);
MYSQL *conn = open_conn(test->maxscales->readconn_master_port[0], test->maxscales->IP[0],

View File

@ -185,7 +185,6 @@ void check(XTestConnections& test)
}
std::string values;
MYSQL_ROW row;
int num_rows = mysql_num_rows(pRes);
test.add_result(num_rows != i_end, "Query returned %d rows when %d rows were expected",
num_rows, i_end);

View File

@ -227,7 +227,7 @@ private:
int id = s_nRows * random_decimal_fraction();
ss_dassert(id >= 0);
ss_dassert(id <= s_nRows);
ss_dassert(id <= (int)s_nRows);
return id;
}
@ -503,8 +503,6 @@ void check_server_statuses(TestConnections& test)
void run(TestConnections& test)
{
int n_threads = Client::DEFAULT_N_CLIENTS;
cout << "\nConnecting to MaxScale." << endl;
test.maxscales->connect_maxscale();

View File

@ -66,7 +66,6 @@ static void expect(TestConnections& test, const char* zServer, const char* zStat
int main(int argc, char** argv)
{
char result_tmp[bufsize];
interactive = strcmp(argv[argc - 1], "interactive") == 0;
Mariadb_nodes::require_gtid(true);
TestConnections test(argc, argv);

View File

@ -230,7 +230,7 @@ private:
int id = s_nRows * random_decimal_fraction();
ss_dassert(id >= 0);
ss_dassert(id <= s_nRows);
ss_dassert(id <= (int)s_nRows);
return id;
}
@ -559,8 +559,6 @@ void switchover(TestConnections& test, int next_master_id, int current_master_id
void run(TestConnections& test)
{
int n_threads = Client::DEFAULT_N_CLIENTS;
cout << "\nConnecting to MaxScale." << endl;
test.maxscales->connect_maxscale();

View File

@ -23,7 +23,7 @@ int main(int argc, char *argv[])
char** local_argv = &argv[1];
TestConnections * Test = new TestConnections(local_argc, local_argv);
(void)Test;
sleep(3);
return 0;

View File

@ -35,7 +35,6 @@ json_t * RDS::get_subnets_group_descr(char * json)
{
json_t *root;
json_error_t error;
char * j;
root = json_loads( json, 0, &error );
if ( !root )
@ -167,7 +166,6 @@ int RDS::destroy_subnets()
int RDS::destroy_route_tables()
{
json_t *root;
json_error_t error;
char cmd[1024];
char * json;
@ -202,6 +200,7 @@ int RDS::destroy_route_tables()
}
}
return 0;
}
int RDS::detach_and_destroy_gw()
@ -552,7 +551,7 @@ int RDS::destroy_subnets_group()
char * result;
sprintf(cmd, "aws rds delete-db-subnet-group --db-subnet-group-name %s", get_subnetgroup_name());
puts(cmd);
execute_cmd(cmd, &result);
return execute_cmd(cmd, &result);
}
int RDS::create_rds_db(int N)
@ -679,7 +678,7 @@ int RDS::delete_rds_cluster()
detach_and_destroy_gw();
printf("Destroy vpc\n");
destroy_vpc();
return destroy_vpc();
}
int RDS::wait_for_nodes(size_t N)

View File

@ -79,10 +79,7 @@ int check_com_select(long int *new_selects, long int *new_inserts, long int *sel
int check_com_insert(long int *new_selects, long int *new_inserts, long int *selects, long int *inserts,
Mariadb_nodes * Nodes, int expected)
{
int i;
int result = 0;
int NodesNum = Nodes->N;
int diff_ins = new_inserts[0] - inserts[0];
int diff_sel = new_selects[0] - selects[0];

View File

@ -22,7 +22,6 @@ int main(int argc, char *argv[])
MYSQL *conn[TestConnNum];
int i;
int conn_num;
int res = 0;
MYSQL * backend_conn;
for (i = 0; i < Test->repl->N; i++)

View File

@ -61,11 +61,11 @@ serversize_rws=1000000
#include "testconnections.h"
void check_conn_num(TestConnections* Test, int * Nc, unsigned int conn_num)
void check_conn_num(TestConnections* Test, int * Nc)
{
for (int i = 0; i < 4; i++)
{
conn_num = get_conn_num(Test->galera->nodes[i], Test->maxscales->IP[0], Test->maxscales->hostname[0],
int conn_num = get_conn_num(Test->galera->nodes[i], Test->maxscales->IP[0], Test->maxscales->hostname[0],
(char *) "test");
Test->tprintf("connections to node %d: %u (expected: %u)\n", i, conn_num, Nc[i]);
if ((i < 4) && (Nc[i] != conn_num))
@ -96,7 +96,6 @@ int main(int argc, char *argv[])
Test->tprintf("Sleeping 15 seconds\n");
sleep(15);
unsigned int conn_num;
int Nc[4];
Nc[0] = maxscale_conn_num / 6;
@ -105,7 +104,7 @@ int main(int argc, char *argv[])
Nc[3] = 0;
Test->set_timeout(30);
check_conn_num(Test, Nc, conn_num);
check_conn_num(Test, Nc);
for (i = 0; i < maxscale_conn_num; i++)
{
@ -136,7 +135,7 @@ int main(int argc, char *argv[])
Nc[0] = maxscale_conn_num;
Test->set_timeout(30);
check_conn_num(Test, Nc, conn_num);
check_conn_num(Test, Nc);
for (i = 0; i < maxscale_conn_num; i++)

View File

@ -17,11 +17,6 @@ int main(int argc, char *argv[])
TestConnections * Test = new TestConnections(argc, argv);
Test->set_timeout(3000);
int options_set = 3;
if (Test->smoke)
{
options_set = 1;
}
Test->repl->connect();
execute_query(Test->repl->nodes[0], (char *) "DROP TABLE IF EXISTS t1;");
@ -30,12 +25,8 @@ int main(int argc, char *argv[])
Test->binlog_master_gtid = true;
Test->binlog_slave_gtid = true;
// for (int option = 0; option < options_set; option++)
//{
// Test->binlog_cmd_option = option;
Test->start_binlog(0);
test_binlog(Test);
//}
Test->check_log_err(0, "SET NAMES utf8mb4", false);
Test->check_log_err(0, "set autocommit=1", false);

View File

@ -149,7 +149,7 @@ char* allocate_insert_string(int fl, int N)
sql_size = 16;
}
if (fl >= sql_size)
if ((size_t)fl >= sql_size)
{
fprintf(stderr, "Insert index %d is too large, setting it to %lu", fl, sql_size - 1);
fl = sql_size - 1;
@ -212,7 +212,6 @@ int check_if_t1_exists(MYSQL *conn)
{
MYSQL_RES *res;
MYSQL_ROW row;
unsigned long long int num_fields;
int t1 = 0;
if (conn != NULL)
@ -232,7 +231,7 @@ int check_if_t1_exists(MYSQL *conn)
}
else
{
num_fields = mysql_num_fields(res);
mysql_num_fields(res);
if (mysql_num_rows(res) > 0)
{
while ((row = mysql_fetch_row(res)) != NULL)

View File

@ -16,14 +16,13 @@ TestConnections * Test ;
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
int exit_flag = 0;
int start_flag = 0;
unsigned int old_slave;
int old_slave;
void *kill_vm_thread( void *ptr );
int main(int argc, char *argv[])
{
Test = new TestConnections(argc, argv);
pthread_t kill_vm_thread1;
int check_iret;
char sys1[4096];
int port[3];
@ -53,7 +52,7 @@ int main(int argc, char *argv[])
for (int k = 0; k < 3; k++)
{
Test->tprintf("Trying test with port %d\n", port[k]);
check_iret = pthread_create( &kill_vm_thread1, NULL, kill_vm_thread, NULL);
pthread_create( &kill_vm_thread1, NULL, kill_vm_thread, NULL);
if (port[k] == Test->maxscales->readconn_slave_port[0] )
{
@ -137,7 +136,7 @@ void *kill_vm_thread( void *ptr )
fflush(stdout);
old_slave = 1;
}
char sys1[4096];
printf("Killing VM %s\n", Test->repl->IP[old_slave]);
fflush(stdout);
Test->repl->block_node(old_slave);

View File

@ -5,13 +5,13 @@ static struct
{
const char* test_name;
const char* test_template;
} cnf_templates[] = {
} cnf_templates[] __attribute__((unused)) = {
@CNF_TEMPLATES@ {NULL, NULL}};
/** The default template to use */
static const char * default_template = "replication";
static const char * default_template __attribute__((unused)) = "replication";
/** This is the working directory for all tests */
static const char *test_dir = "@CMAKE_SOURCE_DIR@";
static const char *test_dir __attribute__((unused)) = "@CMAKE_SOURCE_DIR@";
#endif

View File

@ -22,7 +22,7 @@ static std::string required_repl_version;
static std::string required_galera_version;
}
static int signal_set(int sig, void (*handler)(int))
static void signal_set(int sig, void (*handler)(int))
{
struct sigaction sigact = {};
sigact.sa_handler = handler;
@ -67,7 +67,6 @@ void TestConnections::require_galera_version(const char *version)
TestConnections::TestConnections(int argc, char *argv[]):
enable_timeouts(true),
global_result(0),
use_ipv6(false),
use_snapshots(false),
no_backend_log_copy(false),
verbose(false),
@ -79,7 +78,8 @@ TestConnections::TestConnections(int argc, char *argv[]):
binlog_slave_gtid(false),
no_galera(false),
no_vm_revert(true),
threads(4)
threads(4),
use_ipv6(false)
{
signal_set(SIGSEGV, sigfatal_handler);
signal_set(SIGABRT, sigfatal_handler);
@ -381,7 +381,7 @@ void TestConnections::assert(bool result, const char *format, ...)
}
}
int TestConnections::read_env()
void TestConnections::read_env()
{
char *env;
@ -497,9 +497,8 @@ int TestConnections::read_env()
}
}
int TestConnections::print_env()
void TestConnections::print_env()
{
int i;
printf("Maxscale IP\t%s\n", maxscales->IP[0]);
printf("Maxscale User name\t%s\n", maxscales->user_name);
printf("Maxscale Password\t%s\n", maxscales->password);
@ -611,7 +610,7 @@ void TestConnections::process_template(int m, const char *template_name, const c
maxscales->copy_to_node_legacy((char *) "maxscale.cnf", (char *) dest, m);
}
int TestConnections::init_maxscales()
void TestConnections::init_maxscales()
{
for (int i = 0; i < maxscales->N; i++)
{
@ -619,7 +618,7 @@ int TestConnections::init_maxscales()
}
}
int TestConnections::init_maxscale(int m)
void TestConnections::init_maxscale(int m)
{
const char * template_name = get_template_name(test_name);
@ -664,7 +663,7 @@ int TestConnections::init_maxscale(int m)
for (waits = 0; waits < 15; waits++)
{
if (maxscales->ssh_node(m, "/bin/sh -c \"maxadmin help > /dev/null || exit 1\"", true) == 0);
if (maxscales->ssh_node(m, "/bin/sh -c \"maxadmin help > /dev/null || exit 1\"", true) == 0)
{
break;
}
@ -1517,11 +1516,8 @@ int TestConnections::get_client_ip(int m, char * ip)
MYSQL_RES *res;
MYSQL_ROW row;
int ret = 1;
unsigned long long int num_fields;
//unsigned long long int row_i=0;
unsigned long long int rows;
unsigned long long int i;
unsigned int conn_num = 0;
maxscales->connect_rwsplit(m);
if (execute_query(maxscales->conn_rwsplit[m],
@ -1540,7 +1536,6 @@ int TestConnections::get_client_ip(int m, char * ip)
{
printf("Error: can't execute SQL-query: show processlist\n");
printf("%s\n\n", mysql_error(conn));
conn_num = 0;
}
else
{
@ -1548,11 +1543,10 @@ int TestConnections::get_client_ip(int m, char * ip)
if (res == NULL)
{
printf("Error: can't get the result description\n");
conn_num = -1;
}
else
{
num_fields = mysql_num_fields(res);
mysql_num_fields(res);
rows = mysql_num_rows(res);
for (i = 0; i < rows; i++)
{
@ -1598,7 +1592,7 @@ int TestConnections::stop_timeout()
return 0;
}
int TestConnections::tprintf(const char *format, ...)
void TestConnections::tprintf(const char *format, ...)
{
timeval t2;
gettimeofday(&t2, NULL);
@ -1906,8 +1900,6 @@ int TestConnections::revert_snapshot(char * snapshot_name)
bool TestConnections::test_bad_config(int m, const char *config)
{
char src[PATH_MAX];
process_template(m, config, "./");
// Set the timeout to prevent hangs with configurations that work

View File

@ -251,28 +251,24 @@ public:
/**
* @brief ReadEnv Reads all Maxscale and Master/Slave and Galera setups info from environmental variables
* @return 0 in case of success
*/
int read_env();
void read_env();
/**
* @brief PrintIP Prints all Maxscale and Master/Slave and Galera setups info
* @return 0
*/
int print_env();
void print_env();
/**
* @brief InitMaxscale Copies MaxSclae.cnf and start MaxScale
* @param m Number of Maxscale node
* @return 0 if case of success
*/
int init_maxscale(int m = 0);
void init_maxscale(int m = 0);
/**
* @brief InitMaxscale Copies MaxSclae.cnf and start MaxScale on all Maxscale nodes
* @return 0 if case of success
*/
int init_maxscales();
void init_maxscales();
/**
* @brief start_binlog configure first node as Master, Second as slave connected to Master and others as slave connected to MaxScale binlog router
@ -366,11 +362,9 @@ public:
int stop_timeout();
/**
* @brief printf adds timestam to printf
* @param __format
* @return
* @brief printf with automatic timestamps
*/
int tprintf(const char *format, ...);
void tprintf(const char *format, ...);
/**
* @brief Creats t1 table, insert data into it and checks if data can be correctly read from all Maxscale services

View File

@ -1,7 +1,3 @@
if(NOT ${CMAKE_VERSION} VERSION_LESS 3.0.0)
cmake_policy(SET CMP0046 OLD)
endif()
include(ExternalProject)
ExternalProject_Add(maxscale_sqlite
@ -10,7 +6,6 @@ ExternalProject_Add(maxscale_sqlite
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/sqlite-src-3110100/configure --with-pic --enable-maxscale
BUILD_COMMAND make sqlite3.c
INSTALL_COMMAND "")
add_dependencies(maxscale_sqlite ${CMAKE_CURRENT_SOURCE_DIR}/sqlite-src-3110100/src/parse.y)
include_directories(${CMAKE_BINARY_DIR}/sqlite-bld-3110100/tsrc)
include_directories(${CMAKE_BINARY_DIR}/sqlite-bld-3110100)

View File

@ -1454,10 +1454,7 @@ handle_global_item(const char *name, const char *value)
{
if (strcmp(value, CN_AUTO) == 0)
{
if ((gateway.n_threads = get_processor_count()) > 1)
{
gateway.n_threads--;
}
gateway.n_threads = get_processor_count();
}
else
{
@ -1819,6 +1816,12 @@ handle_global_item(const char *name, const char *value)
}
else
{
#ifndef SS_DEBUG
if (strcmp(name, "log_debug") == 0)
{
MXS_WARNING("The 'log_debug' option has no effect in release mode.");
}
#endif
for (i = 0; lognames[i].name; i++)
{
if (strcasecmp(name, lognames[i].name) == 0)
@ -2585,7 +2588,8 @@ config_get_release_string(char* release)
}
have_distribution = true;
strncpy(release, new_to, RELEASE_STR_LENGTH);
strncpy(release, new_to, RELEASE_STR_LENGTH - 1);
release[RELEASE_STR_LENGTH - 1] = '\0';
}
}
}

View File

@ -46,12 +46,12 @@ typedef enum { MES_RC_FAIL, MES_RC_SUCCESS, MES_RC_TIMEOUT } skygw_mes_rc_t;
static const char* timestamp_formatstr = "%04d-%02d-%02d %02d:%02d:%02d ";
/** One for terminating '\0' */
static const size_t timestamp_len = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 3 + 1) * sizeof(char);
static const size_t timestamp_len = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 3 + 1 + 16) * sizeof(char);
static const char* timestamp_formatstr_hp = "%04d-%02d-%02d %02d:%02d:%02d.%03d ";
/** One for terminating '\0' */
static const size_t timestamp_len_hp = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3 + 3 + 1) * sizeof(
char);
static const size_t timestamp_len_hp = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3 + 3 + 1 + 16) *
sizeof(char);
struct skygw_thread_st
{

View File

@ -117,7 +117,7 @@ int ini_parse_file(FILE* file,
end = find_char_or_comment(start + 1, ']');
if (*end == ']') {
*end = '\0';
strncpy0(section, start + 1, sizeof(section));
strncpy0(section, start + 1, sizeof(section) - 1);
*prev_name = '\0';
}
else if (!error) {
@ -141,7 +141,7 @@ int ini_parse_file(FILE* file,
rstrip(value);
/* Valid name[=:]value pair found, call handler */
strncpy0(prev_name, name, sizeof(prev_name));
strncpy0(prev_name, name, sizeof(prev_name) - 1);
if (!handler(user, section, name, value) && !error)
error = lineno;
}

View File

@ -1669,7 +1669,7 @@ blr_file_next_exists(ROUTER_INSTANCE *router,
sprintf(buf, BINLOG_NAMEFMT, router->fileroot, filenum + 1);
sprintf(bigbuf, "%s/%s", router->binlogdir, buf);
// Set the new file name in the output
strncpy(next_file, buf, BINLOG_FNAMELEN);
memcpy(next_file, buf, BINLOG_FNAMELEN);
next_file[BINLOG_FNAMELEN] = '\0';
}
else
@ -1712,7 +1712,7 @@ blr_file_next_exists(ROUTER_INSTANCE *router,
result.gtid_elms.server_id,
result.file);
// Set the new file name in the output
strncpy(next_file, result.file, BINLOG_FNAMELEN);
memcpy(next_file, result.file, BINLOG_FNAMELEN);
next_file[BINLOG_FNAMELEN] = '\0';
MXS_DEBUG("The next Binlog file from GTID maps repo is [%s]",