Skip to content

Commit

Permalink
* Execute all test cases with 'CLIENT_DEPRECATE_EOF' both enabled and…
Browse files Browse the repository at this point in the history
… disabled.
  • Loading branch information
rahim-kanji committed Nov 16, 2023
1 parent 19273ac commit b993db3
Showing 1 changed file with 63 additions and 52 deletions.
115 changes: 63 additions & 52 deletions test/tap/tests/test_warnings-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct TestInfo {
CommandLine cl;
std::array<std::map<size_t, MYSQL*>,2> conn_pool;

MYSQL* get_connection(const Connection& conn) {
MYSQL* get_connection(const Connection& conn, bool enable_client_deprecate_eof) {
auto& my_conn = conn_pool[conn.conn_type];
const auto& itr = my_conn.find(conn.id);
if (itr != my_conn.end()) {
Expand All @@ -103,6 +103,12 @@ MYSQL* get_connection(const Connection& conn) {
fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxysql));
return NULL;
}

if (enable_client_deprecate_eof) {
// enable 'CLIENT_DEPRECATE_EOF' support
proxysql->options.client_flag |= CLIENT_DEPRECATE_EOF;
}

if (conn.conn_type == kAdmin) {
// Connnect to ProxySQL
if (!mysql_real_connect(proxysql, cl.host, cl.admin_username, cl.admin_password, NULL, cl.admin_port, NULL, 0)) {
Expand Down Expand Up @@ -429,59 +435,13 @@ constexpr size_t test_size(Args&&... args) {
#define TESTS_COMBINED mysql_variable_test, hostgroup_attributes_test, random_test, insert_test, query_digest_test, \
query_cache_test, warning_log_test, multiplexing_test

int main(int argc, char** argv) {

if (cl.getEnv()) {
diag("Failed to get the required environmental variables.");
return -1;
}

plan(check_count(TESTS_COMBINED));

/*plan((20 + 6) + // mysql variable test: 20 warning checks, 6 multiplex status checks
(20 + 6) + // hostgroup attributes test: 20 warning checks, 6 multiplex status checks
(14 + 4) + // random test: 14 warning checks, 4 multiplex status checks
(9 + 4) + // insert test: 9 warning checks, 4 multiplex status checks
(3 + 1) + // query digest test: 3 warning checks, 1 multiplex status checks
(18 + 5) + // query cache test: 18 warning checks, 5 multiplex status checks
(7 + 2) + // warning log test: 7 warning checks, 2 multiplex status checks
(7 + 3)); // multiplexing test: 7 warning checks, 3 multiplex status checks
*/



std::vector<std::pair<const char*, std::vector<TestInfo>>> all_tests(test_size(TESTS_COMBINED));

all_tests[0].first = "MYSQL VARIABLE (mysql-handle_warnings)";
all_tests[0].second.insert(all_tests[0].second.end(), mysql_variable_test.begin(), mysql_variable_test.end());

all_tests[1].first = "HOSTGROUP ATTRIBUTES (handle_warnings)";
all_tests[1].second.insert(all_tests[1].second.end(), hostgroup_attributes_test.begin(), hostgroup_attributes_test.end());

all_tests[2].first = "RANDOM";
all_tests[2].second.insert(all_tests[2].second.end(), random_test.begin(), random_test.end());

all_tests[3].first = "INSERT";
all_tests[3].second.insert(all_tests[3].second.end(), insert_test.begin(), insert_test.end());

all_tests[4].first = "QUERY_DIGEST";
all_tests[4].second.insert(all_tests[4].second.end(), query_digest_test.begin(), query_digest_test.end());

all_tests[5].first = "QUERY_CACHE";
all_tests[5].second.insert(all_tests[5].second.end(), query_cache_test.begin(), query_cache_test.end());

all_tests[6].first = "WARNING_LOGS";
all_tests[6].second.insert(all_tests[6].second.end(), warning_log_test.begin(), warning_log_test.end());

all_tests[7].first = "MULTIPLEXING";
all_tests[7].second.insert(all_tests[7].second.end(), multiplexing_test.begin(), multiplexing_test.end());

void execute_tests(const std::vector<std::pair<const char*, std::vector<TestInfo>>>& all_tests, bool enable_client_deprecate_eof) {
for (const auto& test : all_tests) {
diag("Executing [%s] test...", test.first);
diag("Executing [%s] test... [CLIENT_DEPRECATE_EOF=%s]", test.first, (enable_client_deprecate_eof ? "TRUE" : "FALSE"));
for (const auto& test_info : test.second) {
MYSQL_STMT* stmt = nullptr;
MYSQL* mysql = get_connection(test_info.conn);
if (!mysql) {
MYSQL* mysql = get_connection(test_info.conn, enable_client_deprecate_eof);
if (!mysql) {
goto __exit;
}
if (test_info.query_info.prepare_stmt) {
Expand Down Expand Up @@ -534,7 +494,7 @@ int main(int argc, char** argv) {
}
}

if (stmt)
if (stmt)
mysql_stmt_close(stmt);
}
}
Expand All @@ -543,9 +503,60 @@ int main(int argc, char** argv) {
for (const auto& mysql_conn : conn_pool[kAdmin]) {
mysql_close(mysql_conn.second);
}
conn_pool[kAdmin].clear();
for (const auto& mysql_conn : conn_pool[kMySQL]) {
mysql_close(mysql_conn.second);
}
conn_pool[kMySQL].clear();
}

int main(int argc, char** argv) {

if (cl.getEnv()) {
diag("Failed to get the required environmental variables.");
return -1;
}

plan(check_count(TESTS_COMBINED)*2); // also check with client_deprecate_eof flag

/*plan((20 + 6) + // mysql variable test: 20 warning checks, 6 multiplex status checks
(20 + 6) + // hostgroup attributes test: 20 warning checks, 6 multiplex status checks
(14 + 4) + // random test: 14 warning checks, 4 multiplex status checks
(9 + 4) + // insert test: 9 warning checks, 4 multiplex status checks
(3 + 1) + // query digest test: 3 warning checks, 1 multiplex status checks
(18 + 5) + // query cache test: 18 warning checks, 5 multiplex status checks
(7 + 2) + // warning log test: 7 warning checks, 2 multiplex status checks
(7 + 3)); // multiplexing test: 7 warning checks, 3 multiplex status checks
*/

std::vector<std::pair<const char*, std::vector<TestInfo>>> all_tests(test_size(TESTS_COMBINED));

all_tests[0].first = "MYSQL VARIABLE (mysql-handle_warnings)";
all_tests[0].second.insert(all_tests[0].second.end(), mysql_variable_test.begin(), mysql_variable_test.end());

all_tests[1].first = "HOSTGROUP ATTRIBUTES (handle_warnings)";
all_tests[1].second.insert(all_tests[1].second.end(), hostgroup_attributes_test.begin(), hostgroup_attributes_test.end());

all_tests[2].first = "RANDOM";
all_tests[2].second.insert(all_tests[2].second.end(), random_test.begin(), random_test.end());

all_tests[3].first = "INSERT";
all_tests[3].second.insert(all_tests[3].second.end(), insert_test.begin(), insert_test.end());

all_tests[4].first = "QUERY_DIGEST";
all_tests[4].second.insert(all_tests[4].second.end(), query_digest_test.begin(), query_digest_test.end());

all_tests[5].first = "QUERY_CACHE";
all_tests[5].second.insert(all_tests[5].second.end(), query_cache_test.begin(), query_cache_test.end());

all_tests[6].first = "WARNING_LOGS";
all_tests[6].second.insert(all_tests[6].second.end(), warning_log_test.begin(), warning_log_test.end());

all_tests[7].first = "MULTIPLEXING";
all_tests[7].second.insert(all_tests[7].second.end(), multiplexing_test.begin(), multiplexing_test.end());

execute_tests(all_tests, false);
execute_tests(all_tests, true);

return exit_status();
}

0 comments on commit b993db3

Please sign in to comment.