From 76be6e2c08f0690886a1cd31c9b5e5930c5ee188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Tue, 10 Aug 2021 19:11:36 +0200 Subject: [PATCH 1/4] Testing various SET commands in Admin --- test/tap/tap/utils.h | 8 ++ test/tap/tests/admin_set_variables1-t.cpp | 155 ++++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 test/tap/tests/admin_set_variables1-t.cpp diff --git a/test/tap/tap/utils.h b/test/tap/tap/utils.h index 19f859669a..558608455d 100644 --- a/test/tap/tap/utils.h +++ b/test/tap/tap/utils.h @@ -17,6 +17,14 @@ } \ } while(0) +#define MYSQL_QUERY_err(mysql, query) \ + do { \ + if (mysql_query(mysql, query)) { \ + fprintf(stderr, "File %s, line %d, Error: %s\n", \ + __FILE__, __LINE__, mysql_error(mysql)); \ + } \ + } while(0) + #ifdef __cplusplus extern "C" { #endif diff --git a/test/tap/tests/admin_set_variables1-t.cpp b/test/tap/tests/admin_set_variables1-t.cpp new file mode 100644 index 0000000000..8467a17727 --- /dev/null +++ b/test/tap/tests/admin_set_variables1-t.cpp @@ -0,0 +1,155 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "tap.h" +#include "command_line.h" +#include "utils.h" + +using std::string; + +/* this test: + * enables mysql-have_ssl + * change the values of multiple variables +*/ + +std::unordered_map vars; + +int run_SET_queries(MYSQL *proxysql_admin) { + for (std::unordered_map::iterator it = vars.begin(); it != vars.end() ; it++) { + std::string s = "SET " + it->first + " = \"" + it->second + "\""; + diag("Running %s", s.c_str()); + if (it->first == "mysql-init_connect") { + MYSQL_QUERY_err(proxysql_admin, s.c_str()); + } else { + MYSQL_QUERY(proxysql_admin, s.c_str()); + } + // absolutely useless to run at every query + // but we run it just to create more load + MYSQL_QUERY(proxysql_admin, "LOAD MYSQL VARIABLES TO RUNTIME"); + MYSQL_QUERY(proxysql_admin, "SAVE MYSQL VARIABLES FROM RUNTIME"); + if (it->first == "mysql-init_connect") { + s = "UPDATE global_variables SET variable_value = \"" + it->second + "\" WHERE variable_name = \"" + it->first + "\""; + diag("Running %s", s.c_str()); + MYSQL_QUERY(proxysql_admin, s.c_str()); + MYSQL_QUERY(proxysql_admin, "LOAD MYSQL VARIABLES TO RUNTIME"); + MYSQL_QUERY(proxysql_admin, "SAVE MYSQL VARIABLES FROM RUNTIME"); + } + } + return 0; +} + +int check_variables(CommandLine& cl) { + MYSQL* proxysql_admin = mysql_init(NULL); // redefined locally + mysql_ssl_set(proxysql_admin, NULL, NULL, NULL, NULL, NULL); + if (!mysql_real_connect(proxysql_admin, cl.host, cl.admin_username, cl.admin_password, NULL, cl.admin_port, NULL, CLIENT_SSL|CLIENT_COMPRESS)) { + // the test intentionally create a new connection + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxysql_admin)); + exit(exit_status()); + } + MYSQL_QUERY(proxysql_admin, "SHOW VARIABLES"); + MYSQL_RES* proxy_res = mysql_store_result(proxysql_admin); + MYSQL_ROW row; + while ((row = mysql_fetch_row(proxy_res))) { + std::string vn(row[0]); + std::string vv(row[1]); + auto search = vars.find(vn); + if (search != vars.end()) { + ok (vv == vars[vn] , "VN: %s . Expected: %s , Actual: %s" , vn.c_str(), vars[vn].c_str() , vv.c_str()); + } + } + mysql_free_result(proxy_res); + mysql_close(proxysql_admin); + return 0; +} + +int main() { + CommandLine cl; + + if (cl.getEnv()) { + diag("Failed to get the required environmental variables."); + return -1; + } + + + MYSQL* proxysql_admin = mysql_init(NULL); + // Initialize connections + if (!proxysql_admin) { + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxysql_admin)); + return -1; + } + + if (!mysql_real_connect(proxysql_admin, cl.host, cl.admin_username, cl.admin_password, NULL, cl.admin_port, NULL, 0)) { + fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxysql_admin)); + return -1; + } + + MYSQL_QUERY(proxysql_admin, "SET mysql-have_ssl='true'"); + MYSQL_QUERY(proxysql_admin, "SET mysql-have_compress='true'"); + MYSQL_QUERY(proxysql_admin, "LOAD MYSQL VARIABLES TO RUNTIME"); + + vars["mysql-ssl_p2s_ca"]="test-ca.pem"; + vars["mysql-ssl_p2s_cert"]="test-cert.pem"; + vars["mysql-ssl_p2s_key"]="test-cert.pem"; + vars["mysql-ssl_p2s_cipher"]="XXXX"; + vars["mysql-init_connect"]="sql_mode=''"; + vars["mysql-ldap_user_variable"]="aa"; + vars["mysql-add_ldap_user_comment"]="comment"; + vars["mysql-binlog_reader_connect_retry_msec"]="1200"; + vars["mysql-wait_timeout"]="17280000"; + vars["mysql-eventslog_format"]="2"; + vars["mysql-server_version"]="5.5.30"; + vars["mysql-have_compress"]="false"; + vars["mysql-use_tcp_keepalive"]="false"; + + plan(vars.size()*3); + run_SET_queries(proxysql_admin); + check_variables(cl); + + // this will fail input validation + vars["mysql-binlog_reader_connect_retry_msec"]="120001"; + vars["mysql-wait_timeout"]="1728000001"; + vars["mysql-eventslog_format"]="3"; + vars["mysql-server_version"]="5.1.30"; + vars["mysql-have_compress"]="2"; + vars["mysql-use_tcp_keepalive"]="3"; + run_SET_queries(proxysql_admin); + + // change the values in vars . We don't load these to proxysql + // because this is what we expect. + // therefore we only validate + vars["mysql-binlog_reader_connect_retry_msec"]="1200"; + vars["mysql-wait_timeout"]="17280000"; + vars["mysql-eventslog_format"]="2"; + vars["mysql-server_version"]="5.5.30"; + vars["mysql-have_compress"]="false"; + vars["mysql-use_tcp_keepalive"]="false"; + check_variables(cl); + + vars["mysql-ssl_p2s_ca"]=""; + vars["mysql-ssl_p2s_cert"]=""; + vars["mysql-ssl_p2s_key"]=""; + vars["mysql-ssl_p2s_cipher"]=""; + vars["mysql-init_connect"]=""; + vars["mysql-ldap_user_variable"]=""; + vars["mysql-add_ldap_user_comment"]=""; + vars["mysql-binlog_reader_connect_retry_msec"]="1200"; + vars["mysql-wait_timeout"]="17280000"; + vars["mysql-eventslog_format"]="2"; + vars["mysql-server_version"]="5.5.30"; + vars["mysql-have_compress"]="true"; + vars["mysql-use_tcp_keepalive"]="true"; + run_SET_queries(proxysql_admin); + check_variables(cl); + + mysql_close(proxysql_admin); + return exit_status(); +} From 2145507c22ca90943e802976c5a1c6bb5fabeb29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Thu, 12 Aug 2021 11:52:53 +0200 Subject: [PATCH 2/4] If a session is locked on hostgroup , autocommit is copied from backend connection Closes #3459 --- lib/MySQL_Session.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 9a9f583ea4..0086c3a745 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -4436,6 +4436,14 @@ int MySQL_Session::handler() { handler_rc0_Process_GTID(myconn); + // if we are locked on hostgroup, the value of autocommit is copied from the backend connection + // see bug #3549 + if (locked_on_hostgroup >= 0) { + assert(myconn != NULL); + assert(myconn->mysql != NULL); + autocommit = myconn->mysql->server_status & SERVER_STATUS_AUTOCOMMIT; + } + if (mirror == false) { // Support for LAST_INSERT_ID() if (myconn->mysql->insert_id) { From 9a85ca9917af3ad40cc7cc8a390851e783b2fb61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Thu, 12 Aug 2021 12:05:47 +0200 Subject: [PATCH 3/4] Copying regression test from PR 3550 --- .../reg_test_3549-autocommit_tracking-t.cpp | 301 ++++++++++++++++++ 1 file changed, 301 insertions(+) create mode 100644 test/tap/tests/reg_test_3549-autocommit_tracking-t.cpp diff --git a/test/tap/tests/reg_test_3549-autocommit_tracking-t.cpp b/test/tap/tests/reg_test_3549-autocommit_tracking-t.cpp new file mode 100644 index 0000000000..5243c78411 --- /dev/null +++ b/test/tap/tests/reg_test_3549-autocommit_tracking-t.cpp @@ -0,0 +1,301 @@ +/** + * @file reg_test_3549-autocommit_tracking-t.cpp + * @brief This test verifies that ProxySQL is properly tracking autocommit being + * set, being properly forwarded to the client after changing its status. + * + * TODO: This test should serve as the template from which construct a more + * complete test for 'autocommit' tracking, for client and backend sides. + */ + +#include +#include +#include +#include + +#include + +#include "proxysql_utils.h" +#include "tap.h" +#include "command_line.h" +#include "utils.h" +#include "json.hpp" + +using nlohmann::json; + +using query_spec = std::tuple; + +void fetch_and_discard_results(MYSQL_RES* result, bool verbose=false) { + MYSQL_ROW row = nullptr; + unsigned int num_fields = 0; + unsigned int i = 0; + unsigned int j = 0; + + num_fields = mysql_num_fields(result); + while ((row = mysql_fetch_row(result))) { + unsigned long *lengths = mysql_fetch_lengths(result); + + if (verbose) { + printf("# RowNum_%d: ", j); + } + + for(i = 0; i < num_fields; i++) { + if (verbose) { + printf("[%.*s] ", (int) lengths[i], row[i] ? row[i] : "NULL"); + } + } + + if (verbose) { + printf("\n"); + } + + j++; + } +} + +/** + * @brief Execute the supplied queries and fetch and ignore the data in case of + * being necessary. + * + * @param proxysql An already opened MYSQL connection to ProxySQL. + * + * @param queries The query to be executed. + */ +int execute_and_fetch_query(MYSQL* proxysql, const std::string& query) { + int query_err = mysql_query(proxysql, query.c_str()); + if (query_err == EXIT_SUCCESS) { + MYSQL_RES* result = mysql_store_result(proxysql); + if (result) { + fetch_and_discard_results(result, false); + mysql_free_result(result); + } + } + + return query_err; +} + +void parse_result_json_column(MYSQL_RES *result, json& j) { + if(!result) return; + MYSQL_ROW row; + + while ((row = mysql_fetch_row(result))) { + j = json::parse(row[0]); + } +} + +bool check_client_autocommit(MYSQL* proxysql) { + if (proxysql == NULL) return false; + return proxysql->server_status & SERVER_STATUS_AUTOCOMMIT; +} + +using test_spec = std::vector>; + +/** + * @brief Executes the provided queries specs, and logs if an error is found with + * the query execution, or the value expected after the query doesn't match. + * + * @param proxysql An already opened MYSQL connection to ProxySQL. + * @param queries_specs The queries specs to execute and check. + * + * @return 'EXIT_SUCCESS' if all the queries were properly executed, + * 'EXIT_FAILURE' otherwise. + */ +int execute_queries_specs(MYSQL* proxysql, const test_spec& queries_specs) { + for (const auto& query_spec : queries_specs) { + std::string query = std::get<0>(query_spec); + int exp_autocommit = std::get<1>(query_spec); + + int myerr = execute_and_fetch_query(proxysql, query); + if (myerr != EXIT_SUCCESS) { + diag( + "Query failed to be executed:" + " (query: '%s', exp_err: '%d', act_err: '%d', err_msg: '%s', line: '%d')", + query.c_str(), EXIT_SUCCESS, mysql_errno(proxysql), mysql_error(proxysql), __LINE__ + ); + return EXIT_FAILURE; + } else { + bool autocommit = check_client_autocommit(proxysql); + if (autocommit != exp_autocommit) { + diag( + "Unexpected autocommit value for:" + " (query: '%s', exp_autocommit: '%d', autocommit: '%d', line: '%d')", + query.c_str(), exp_autocommit, autocommit, __LINE__ + ); + return EXIT_FAILURE; + } + } + } + + return EXIT_SUCCESS; +} + +/** + * @brief The tests definition. + */ +std::vector> test_definitions { + { + // Check if autocommit is properly set by using simple queries, + // target to be handled by 'handler_special_queries' in ProxySQL side. + "simple_set_autocommit_no_lock", + { + { "SET autocommit=1", 1 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 1 }, + { "SET autocommit=0", 0 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 0 } + } + }, + { + "simple_set_autocommit_no_lock_2", + { + { "SET autocommit=0", 0 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 0 }, + { "COMMIT", 0 }, + { "SET autocommit=1", 1 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 1 } + } + }, + { + "simple_set_autocommit_lock_1", + { + { "SET @session_var=1", 1 }, + { "SET autocommit=1", 1 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 1 }, + { "SET autocommit=0", 0 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 0 } + } + }, + { + "simple_set_autocommit_lock_2", + { + { "SET @session_var=1", 1 }, + { "SET autocommit=0", 0 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 0 }, + { "COMMIT", 0 }, + { "SET autocommit=1", 1 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 1 } + } + }, + { + // Check if autocommit is properly set by using complex queries, + // target to be handled by 'handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY_qpo' + // in ProxySQL side. + "complex_set_autocommit_no_lock_1", + { + { "SET time_zone='+04:00', character_set_client='latin1', max_join_size=10000, autocommit=1", 1 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 1 }, + { "SET time_zone='+04:00', character_set_client='latin1', max_join_size=10000, autocommit=0", 0 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 0 } + } + }, + { + "complex_set_autocommit_no_lock_2", + { + { "SET time_zone='+04:00', character_set_client='latin1', max_join_size=10000, autocommit=0", 0 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 0 }, + { "COMMIT", 0 }, + { "SET time_zone='+04:00', character_set_client='latin1', max_join_size=10000, autocommit=1", 1 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 1 } + } + }, + { + "complex_set_autocommit_lock_1", + { + { "SET @session_var=1", 1 }, + { "SET time_zone='+04:00', character_set_client='latin1', max_join_size=10000, autocommit=1", 1 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 1 }, + { "SET time_zone='+04:00', character_set_client='latin1', max_join_size=10000, autocommit=0", 0 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 0 } + } + }, + { + "complex_set_autocommit_lock_2", + { + { "SET @session_var=1", 1 }, + { "SET time_zone='+04:00', character_set_client='latin1', max_join_size=10000, autocommit=0", 0 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 0 }, + { "COMMIT", 0 }, + { "SET time_zone='+04:00', character_set_client='latin1', max_join_size=10000, autocommit=1", 1 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 1 } + } + }, + { + "mix_set_autocommit_1", + { + { "SET time_zone='+04:00', character_set_client='latin1', max_join_size=10000, autocommit=0", 0 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 0 }, + { "COMMIT", 0 }, + { "SET time_zone='+04:00', character_set_client='latin1', max_join_size=10000, autocommit=1", 1 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 1 }, + { "SET autocommit=0", 0 }, + { "COMMIT", 0 }, + { "SET autocommit=1", 1 }, + { "BEGIN", 1 }, + { "SET @session_var=1", 1 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 1 }, + { "COMMIT", 1 }, + } + }, + { + "mix_set_autocommit_2", + { + { "SET time_zone='+04:00', character_set_client='latin1', max_join_size=10000, autocommit=0", 0 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 0 }, + { "COMMIT", 0 }, + { "SET time_zone='+04:00', character_set_client='latin1', max_join_size=10000, autocommit=1", 1 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 1 }, + { "SET autocommit=0", 0 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 0 }, + { "COMMIT", 0 }, + { "BEGIN", 0 }, + { "SET @session_var=1", 0 }, + { "SELECT /*+ ;hostgroup=0 */ 1", 0 }, + { "COMMIT", 0 }, + } + }, +}; + +/** + * @brief Execute the supplied test definition on the provided, already oppened + * MySQL connection to ProxySQL. + * + * @param proxysql An already oppened connection to ProxySQL. + * @param test_def The test definition to be verified. + */ +void execute_test_definition(MYSQL* proxysql, std::pair test_def) { + int queries_res = execute_queries_specs(proxysql, test_def.second); + std::string t_ok_msg { + "Autocommit should match expected values for '%s' queries" + }; + std::string ok_msg {}; + string_format(t_ok_msg, ok_msg, test_def.first.c_str()); + + ok( + queries_res == EXIT_SUCCESS, + "%s", ok_msg.c_str() + ); +} + +int main(int argc, char** argv) { + CommandLine cl; + + if (cl.getEnv()) { + diag("Failed to get the required environmental variables."); + return -1; + } + + for (const auto& test_def : test_definitions) { + MYSQL* proxysql_mysql = mysql_init(NULL); + if (!mysql_real_connect(proxysql_mysql, cl.host, cl.username, cl.password, NULL, cl.port, NULL, 0)) { + fprintf( + stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxysql_mysql) + ); + return EXIT_FAILURE; + } + + // perform the next test + execute_test_definition(proxysql_mysql, test_def); + + mysql_close(proxysql_mysql); + } + + return exit_status(); +} From 811091de52998e75d572b300dbfb3cc5b6e48fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Thu, 12 Aug 2021 12:13:04 +0200 Subject: [PATCH 4/4] Removed a TAP test from wrong PR --- test/tap/tests/admin_set_variables1-t.cpp | 155 ---------------------- 1 file changed, 155 deletions(-) delete mode 100644 test/tap/tests/admin_set_variables1-t.cpp diff --git a/test/tap/tests/admin_set_variables1-t.cpp b/test/tap/tests/admin_set_variables1-t.cpp deleted file mode 100644 index 8467a17727..0000000000 --- a/test/tap/tests/admin_set_variables1-t.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "tap.h" -#include "command_line.h" -#include "utils.h" - -using std::string; - -/* this test: - * enables mysql-have_ssl - * change the values of multiple variables -*/ - -std::unordered_map vars; - -int run_SET_queries(MYSQL *proxysql_admin) { - for (std::unordered_map::iterator it = vars.begin(); it != vars.end() ; it++) { - std::string s = "SET " + it->first + " = \"" + it->second + "\""; - diag("Running %s", s.c_str()); - if (it->first == "mysql-init_connect") { - MYSQL_QUERY_err(proxysql_admin, s.c_str()); - } else { - MYSQL_QUERY(proxysql_admin, s.c_str()); - } - // absolutely useless to run at every query - // but we run it just to create more load - MYSQL_QUERY(proxysql_admin, "LOAD MYSQL VARIABLES TO RUNTIME"); - MYSQL_QUERY(proxysql_admin, "SAVE MYSQL VARIABLES FROM RUNTIME"); - if (it->first == "mysql-init_connect") { - s = "UPDATE global_variables SET variable_value = \"" + it->second + "\" WHERE variable_name = \"" + it->first + "\""; - diag("Running %s", s.c_str()); - MYSQL_QUERY(proxysql_admin, s.c_str()); - MYSQL_QUERY(proxysql_admin, "LOAD MYSQL VARIABLES TO RUNTIME"); - MYSQL_QUERY(proxysql_admin, "SAVE MYSQL VARIABLES FROM RUNTIME"); - } - } - return 0; -} - -int check_variables(CommandLine& cl) { - MYSQL* proxysql_admin = mysql_init(NULL); // redefined locally - mysql_ssl_set(proxysql_admin, NULL, NULL, NULL, NULL, NULL); - if (!mysql_real_connect(proxysql_admin, cl.host, cl.admin_username, cl.admin_password, NULL, cl.admin_port, NULL, CLIENT_SSL|CLIENT_COMPRESS)) { - // the test intentionally create a new connection - fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxysql_admin)); - exit(exit_status()); - } - MYSQL_QUERY(proxysql_admin, "SHOW VARIABLES"); - MYSQL_RES* proxy_res = mysql_store_result(proxysql_admin); - MYSQL_ROW row; - while ((row = mysql_fetch_row(proxy_res))) { - std::string vn(row[0]); - std::string vv(row[1]); - auto search = vars.find(vn); - if (search != vars.end()) { - ok (vv == vars[vn] , "VN: %s . Expected: %s , Actual: %s" , vn.c_str(), vars[vn].c_str() , vv.c_str()); - } - } - mysql_free_result(proxy_res); - mysql_close(proxysql_admin); - return 0; -} - -int main() { - CommandLine cl; - - if (cl.getEnv()) { - diag("Failed to get the required environmental variables."); - return -1; - } - - - MYSQL* proxysql_admin = mysql_init(NULL); - // Initialize connections - if (!proxysql_admin) { - fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxysql_admin)); - return -1; - } - - if (!mysql_real_connect(proxysql_admin, cl.host, cl.admin_username, cl.admin_password, NULL, cl.admin_port, NULL, 0)) { - fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, mysql_error(proxysql_admin)); - return -1; - } - - MYSQL_QUERY(proxysql_admin, "SET mysql-have_ssl='true'"); - MYSQL_QUERY(proxysql_admin, "SET mysql-have_compress='true'"); - MYSQL_QUERY(proxysql_admin, "LOAD MYSQL VARIABLES TO RUNTIME"); - - vars["mysql-ssl_p2s_ca"]="test-ca.pem"; - vars["mysql-ssl_p2s_cert"]="test-cert.pem"; - vars["mysql-ssl_p2s_key"]="test-cert.pem"; - vars["mysql-ssl_p2s_cipher"]="XXXX"; - vars["mysql-init_connect"]="sql_mode=''"; - vars["mysql-ldap_user_variable"]="aa"; - vars["mysql-add_ldap_user_comment"]="comment"; - vars["mysql-binlog_reader_connect_retry_msec"]="1200"; - vars["mysql-wait_timeout"]="17280000"; - vars["mysql-eventslog_format"]="2"; - vars["mysql-server_version"]="5.5.30"; - vars["mysql-have_compress"]="false"; - vars["mysql-use_tcp_keepalive"]="false"; - - plan(vars.size()*3); - run_SET_queries(proxysql_admin); - check_variables(cl); - - // this will fail input validation - vars["mysql-binlog_reader_connect_retry_msec"]="120001"; - vars["mysql-wait_timeout"]="1728000001"; - vars["mysql-eventslog_format"]="3"; - vars["mysql-server_version"]="5.1.30"; - vars["mysql-have_compress"]="2"; - vars["mysql-use_tcp_keepalive"]="3"; - run_SET_queries(proxysql_admin); - - // change the values in vars . We don't load these to proxysql - // because this is what we expect. - // therefore we only validate - vars["mysql-binlog_reader_connect_retry_msec"]="1200"; - vars["mysql-wait_timeout"]="17280000"; - vars["mysql-eventslog_format"]="2"; - vars["mysql-server_version"]="5.5.30"; - vars["mysql-have_compress"]="false"; - vars["mysql-use_tcp_keepalive"]="false"; - check_variables(cl); - - vars["mysql-ssl_p2s_ca"]=""; - vars["mysql-ssl_p2s_cert"]=""; - vars["mysql-ssl_p2s_key"]=""; - vars["mysql-ssl_p2s_cipher"]=""; - vars["mysql-init_connect"]=""; - vars["mysql-ldap_user_variable"]=""; - vars["mysql-add_ldap_user_comment"]=""; - vars["mysql-binlog_reader_connect_retry_msec"]="1200"; - vars["mysql-wait_timeout"]="17280000"; - vars["mysql-eventslog_format"]="2"; - vars["mysql-server_version"]="5.5.30"; - vars["mysql-have_compress"]="true"; - vars["mysql-use_tcp_keepalive"]="true"; - run_SET_queries(proxysql_admin); - check_variables(cl); - - mysql_close(proxysql_admin); - return exit_status(); -}