From b993db3347f5e016aaabf8626c0ed9927004692e Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Thu, 16 Nov 2023 13:01:05 +0500 Subject: [PATCH] * Execute all test cases with 'CLIENT_DEPRECATE_EOF' both enabled and disabled. --- test/tap/tests/test_warnings-t.cpp | 115 ++++++++++++++++------------- 1 file changed, 63 insertions(+), 52 deletions(-) diff --git a/test/tap/tests/test_warnings-t.cpp b/test/tap/tests/test_warnings-t.cpp index bced5eb5b5..65ed4c76d7 100644 --- a/test/tap/tests/test_warnings-t.cpp +++ b/test/tap/tests/test_warnings-t.cpp @@ -91,7 +91,7 @@ struct TestInfo { CommandLine cl; std::array,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()) { @@ -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)) { @@ -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>> 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>>& 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) { @@ -534,7 +494,7 @@ int main(int argc, char** argv) { } } - if (stmt) + if (stmt) mysql_stmt_close(stmt); } } @@ -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>> 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(); }