From 6ba5f2873a912b0a832311226f940da56f3ef638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Wed, 6 May 2020 15:21:54 +0200 Subject: [PATCH 1/5] Edits on set_testing-t.cpp Make it more verbose. Do not track session variables that cannot be set by not root --- test/tap/tests/set_testing-t.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/tap/tests/set_testing-t.cpp b/test/tap/tests/set_testing-t.cpp index c5ba38831..734855133 100644 --- a/test/tap/tests/set_testing-t.cpp +++ b/test/tap/tests/set_testing-t.cpp @@ -181,7 +181,7 @@ void queryVariables(MYSQL *mysql, json& j) { //fprintf(stderr, "TRACE : QUERY 3 : variables %s\n", query.str().c_str()); if (mysql_query(mysql, query.str().c_str())) { if (silent==0) { - fprintf(stderr,"%s\n", mysql_error(mysql)); + fprintf(stderr,"ERROR while running -- \"%s\" : (%d) %s\n", query.str().c_str(), mysql_errno(mysql), mysql_error(mysql)); } } else { MYSQL_RES *result = mysql_store_result(mysql); @@ -198,7 +198,7 @@ void queryInternalStatus(MYSQL *mysql, json& j) { //fprintf(stderr, "TRACE : QUERY 4 : variables %s\n", query); if (mysql_query(mysql, query)) { if (silent==0) { - fprintf(stderr,"%s\n", mysql_error(mysql)); + fprintf(stderr,"ERROR while running -- \"%s\" : (%d) %s\n", query, mysql_errno(mysql), mysql_error(mysql)); } } else { MYSQL_RES *result = mysql_store_result(mysql); @@ -408,12 +408,19 @@ void * my_conn_thread(void *arg) { mysql=mysqlconns[r1]; vars = varsperconn[r1]; } - + if (strcmp(username,(char *)"root")) { + if (strstr(testCases[r2].command.c_str(),"database")) { + continue; + } + if (strstr(testCases[r2].command.c_str(),"sql_log_bin")) { + continue; + } + } std::vector commands = split(testCases[r2].command.c_str(), ';'); for (auto c : commands) { if (mysql_query(mysql, c.c_str())) { if (silent==0) { - fprintf(stderr,"%s\n", mysql_error(mysql)); + fprintf(stderr,"ERROR while running -- \"%s\" : (%d) %s\n", c.c_str(), mysql_errno(mysql), mysql_error(mysql)); } } else { MYSQL_RES *result = mysql_store_result(mysql); @@ -476,6 +483,7 @@ void * my_conn_thread(void *arg) { queryInternalStatus(mysql, proxysql_vars); bool testPassed = true; + int variables_tested = 0; for (auto& el : vars.items()) { auto k = mysql_vars.find(el.key()); auto s = proxysql_vars["conn"].find(el.key()); @@ -495,11 +503,13 @@ void * my_conn_thread(void *arg) { el.value().dump().c_str(), el.key().c_str(), mysql_vars.dump().c_str(), proxysql_vars.dump().c_str(), vars.dump().c_str()); ok(testPassed, "mysql connection [%p], thread_id [%lu], command [%s]", mysql, mysql->thread_id, testCases[r2].command.c_str()); exit(0); + } else { + variables_tested++; } } { std::lock_guard lock(mtx_); - ok(testPassed, "mysql connection [%p], thread_id [%lu], command [%s]", mysql, mysql->thread_id, testCases[r2].command.c_str()); + ok(testPassed, "mysql connection [%p], thread_id [%lu], variables_tested [%d], command [%s]", mysql, mysql->thread_id, variables_tested, testCases[r2].command.c_str()); } } __sync_fetch_and_add(&query_phase_completed,1); From 207bd49b03e250384f48cd9a6f0b7805b62abf69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Wed, 6 May 2020 16:13:59 +0200 Subject: [PATCH 2/5] Count as passed the tests intentionally skipped on set_testing-t --- test/tap/tests/set_testing-t.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/tap/tests/set_testing-t.cpp b/test/tap/tests/set_testing-t.cpp index 734855133..f6934d9de 100644 --- a/test/tap/tests/set_testing-t.cpp +++ b/test/tap/tests/set_testing-t.cpp @@ -410,9 +410,11 @@ void * my_conn_thread(void *arg) { } if (strcmp(username,(char *)"root")) { if (strstr(testCases[r2].command.c_str(),"database")) { + ok(true, "mysql connection [%p], thread_id [%lu], skipped test for command [%s]", mysql, mysql->thread_id, testCases[r2].command.c_str()); continue; } if (strstr(testCases[r2].command.c_str(),"sql_log_bin")) { + ok(true, "mysql connection [%p], thread_id [%lu], skipped test for command [%s]", mysql, mysql->thread_id, testCases[r2].command.c_str()); continue; } } From eefcce253a16cdc4f1a35db27c8204315cc69cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Wed, 6 May 2020 17:54:09 +0200 Subject: [PATCH 3/5] Remove autocommit handling from set_testing Autocommit will need its own set of testing. --- test/tap/tests/set_testing-t.cpp | 18 +++++++++++++----- test/tap/tests/set_testing-t.csv | 1 - 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/test/tap/tests/set_testing-t.cpp b/test/tap/tests/set_testing-t.cpp index f6934d9de..0bd84bf57 100644 --- a/test/tap/tests/set_testing-t.cpp +++ b/test/tap/tests/set_testing-t.cpp @@ -159,21 +159,21 @@ void queryVariables(MYSQL *mysql, json& j) { std::stringstream query; if (is_mariadb) { query << "SELECT /* mysql " << mysql << " */ lower(variable_name), variable_value FROM information_schema.session_variables WHERE variable_name IN " - " ('hostname', 'sql_log_bin', 'sql_mode', 'init_connect', 'time_zone', 'autocommit', 'sql_auto_is_null', " + " ('hostname', 'sql_log_bin', 'sql_mode', 'init_connect', 'time_zone', 'sql_auto_is_null', " " 'sql_safe_updates', 'max_join_size', 'net_write_timeout', 'sql_select_limit', " " 'sql_select_limit', 'character_set_results', 'tx_isolation', 'tx_read_only', " " 'sql_auto_is_null', 'collation_connection', 'character_set_connection', 'character_set_client', 'character_set_database', 'group_concat_max_len');"; } if (is_cluster) { query << "SELECT /* mysql " << mysql << " */ * FROM performance_schema.session_variables WHERE variable_name IN " - " ('hostname', 'sql_log_bin', 'sql_mode', 'init_connect', 'time_zone', 'autocommit', 'sql_auto_is_null', " + " ('hostname', 'sql_log_bin', 'sql_mode', 'init_connect', 'time_zone', 'sql_auto_is_null', " " 'sql_safe_updates', 'session_track_gtids', 'max_join_size', 'net_write_timeout', 'sql_select_limit', " " 'sql_select_limit', 'character_set_results', 'transaction_isolation', 'transaction_read_only', " " 'sql_auto_is_null', 'collation_connection', 'character_set_connection', 'character_set_client', 'character_set_database', 'wsrep_sync_wait', 'group_concat_max_len');"; } if (!is_mariadb && !is_cluster) { query << "SELECT /* mysql " << mysql << " */ * FROM performance_schema.session_variables WHERE variable_name IN " - " ('hostname', 'sql_log_bin', 'sql_mode', 'init_connect', 'time_zone', 'autocommit', 'sql_auto_is_null', " + " ('hostname', 'sql_log_bin', 'sql_mode', 'init_connect', 'time_zone', 'sql_auto_is_null', " " 'sql_safe_updates', 'session_track_gtids', 'max_join_size', 'net_write_timeout', 'sql_select_limit', " " 'sql_select_limit', 'character_set_results', 'transaction_isolation', 'transaction_read_only', " " 'sql_auto_is_null', 'collation_connection', 'character_set_connection', 'character_set_client', 'character_set_database', 'group_concat_max_len');"; @@ -224,7 +224,7 @@ void queryInternalStatus(MYSQL *mysql, json& j) { j["conn"]["sql_log_bin"] = "OFF"; } - // autocommit {true|false} + // sql_auto_is_null {true|false} if (!el.value()["sql_auto_is_null"].dump().compare("ON") || !el.value()["sql_auto_is_null"].dump().compare("1") || !el.value()["sql_auto_is_null"].dump().compare("on") || @@ -240,6 +240,8 @@ void queryInternalStatus(MYSQL *mysql, json& j) { j["conn"]["sql_auto_is_null"] = "OFF"; } + // completely remove autocommit test +/* // autocommit {true|false} if (!el.value()["autocommit"].dump().compare("ON") || !el.value()["autocommit"].dump().compare("1") || @@ -255,7 +257,7 @@ void queryInternalStatus(MYSQL *mysql, json& j) { el.value().erase("autocommit"); j["conn"]["autocommit"] = "OFF"; } - +*/ // sql_safe_updates if (!el.value()["sql_safe_updates"].dump().compare("\"ON\"") || !el.value()["sql_safe_updates"].dump().compare("\"1\"") || @@ -410,10 +412,12 @@ void * my_conn_thread(void *arg) { } if (strcmp(username,(char *)"root")) { if (strstr(testCases[r2].command.c_str(),"database")) { + std::lock_guard lock(mtx_); ok(true, "mysql connection [%p], thread_id [%lu], skipped test for command [%s]", mysql, mysql->thread_id, testCases[r2].command.c_str()); continue; } if (strstr(testCases[r2].command.c_str(),"sql_log_bin")) { + std::lock_guard lock(mtx_); ok(true, "mysql connection [%p], thread_id [%lu], skipped test for command [%s]", mysql, mysql->thread_id, testCases[r2].command.c_str()); continue; } @@ -527,6 +531,8 @@ int main(int argc, char *argv[]) { return exit_status(); std::string fileName(std::string(cl.workdir) + "/set_testing-t.csv"); +/* + // do not connect to admin at all MYSQL* mysqladmin = mysql_init(NULL); if (!mysqladmin) return exit_status(); @@ -546,6 +552,8 @@ int main(int argc, char *argv[]) { MYSQL_QUERY(mysqladmin, "update global_variables set variable_value='true' where variable_name='mysql-enforce_autocommit_on_reads'"); MYSQL_QUERY(mysqladmin, "load mysql variables to runtime"); + mysql_close(mysqladmin); +*/ MYSQL* mysql = mysql_init(NULL); if (!mysql) return exit_status(); diff --git a/test/tap/tests/set_testing-t.csv b/test/tap/tests/set_testing-t.csv index a5ca82515..beccbd8e3 100644 --- a/test/tap/tests/set_testing-t.csv +++ b/test/tap/tests/set_testing-t.csv @@ -31,7 +31,6 @@ "SET sql_mode='PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION'", "{'sql_mode':'PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION'}" "SET time_zone='+01:00'","{'time_zone':'+01:00'}" "SET time_zone='-03:00', sql_mode='ALLOW_INVALID_DATES'","{'time_zone':'-03:00', 'sql_mode':'ALLOW_INVALID_DATES'}" -"SET autocommit=0","{'autocommit':'OFF'}" "SET time_zone='+04:00', sql_mode='NO_ENGINE_SUBSTITUTION'", "{'time_zone':'+04:00','sql_mode':'NO_ENGINE_SUBSTITUTION'}" "SET sql_safe_updates='OFF'", "{'sql_safe_updates':'OFF'}" "SET sql_safe_updates='ON'", "{'sql_safe_updates':'ON'}" From 42ae011d6421f488a7ffc9f90d9a2667ec952f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Wed, 6 May 2020 18:06:54 +0200 Subject: [PATCH 4/5] Use skip() instead of ok() in set_testing-t.cpp --- test/tap/tests/set_testing-t.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/tap/tests/set_testing-t.cpp b/test/tap/tests/set_testing-t.cpp index 0bd84bf57..cecb16bed 100644 --- a/test/tap/tests/set_testing-t.cpp +++ b/test/tap/tests/set_testing-t.cpp @@ -413,12 +413,12 @@ void * my_conn_thread(void *arg) { if (strcmp(username,(char *)"root")) { if (strstr(testCases[r2].command.c_str(),"database")) { std::lock_guard lock(mtx_); - ok(true, "mysql connection [%p], thread_id [%lu], skipped test for command [%s]", mysql, mysql->thread_id, testCases[r2].command.c_str()); + skip(1, "mysql connection [%p], command [%s]", mysql, testCases[r2].command.c_str()); continue; } if (strstr(testCases[r2].command.c_str(),"sql_log_bin")) { std::lock_guard lock(mtx_); - ok(true, "mysql connection [%p], thread_id [%lu], skipped test for command [%s]", mysql, mysql->thread_id, testCases[r2].command.c_str()); + skip(1, "mysql connection [%p], command [%s]", mysql, testCases[r2].command.c_str()); continue; } } From c1354f884d16c32fe65b22960edfc1f9b7eccd4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Fri, 29 May 2020 22:18:02 +0200 Subject: [PATCH 5/5] set_testing do not connect to admin at all --- test/tap/tests/set_testing-t.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/tap/tests/set_testing-t.cpp b/test/tap/tests/set_testing-t.cpp index cecb16bed..388cd7079 100644 --- a/test/tap/tests/set_testing-t.cpp +++ b/test/tap/tests/set_testing-t.cpp @@ -552,7 +552,6 @@ int main(int argc, char *argv[]) { MYSQL_QUERY(mysqladmin, "update global_variables set variable_value='true' where variable_name='mysql-enforce_autocommit_on_reads'"); MYSQL_QUERY(mysqladmin, "load mysql variables to runtime"); - mysql_close(mysqladmin); */ MYSQL* mysql = mysql_init(NULL); if (!mysql) @@ -621,9 +620,5 @@ int main(int argc, char *argv[]) { for (unsigned int i=0; i