From 9e983cdcefd87db009da21438ea0fbe7167e680c Mon Sep 17 00:00:00 2001 From: Andrei Ismail Date: Wed, 15 Jul 2015 16:58:06 +0300 Subject: [PATCH] #295 Stress testing monitor tables locking errors --- test/admin_tables_test.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/admin_tables_test.py diff --git a/test/admin_tables_test.py b/test/admin_tables_test.py new file mode 100644 index 000000000..dece71ee0 --- /dev/null +++ b/test/admin_tables_test.py @@ -0,0 +1,37 @@ +from multiprocessing.pool import ThreadPool +import random + +from proxysql_base_test import ProxySQLBaseTest + +class AdminTablesTest(ProxySQLBaseTest): + + SCENARIO = "./scenarios/1backend" + + def test_monitor_tables_locking_errors(self): + """Test that intensive read/write operations to the MySQL Monitor tables + do not trigger locking errors. + + This test will be successful if there will be no generated error at + the end. + """ + + # Setting these variables will cause the Monitor to connect more + # frequently to the backend hosts to check their health, thus increasing + # the probability of locking errors to appear. + ProxySQLBaseTest.run_query_proxysql_admin("UPDATE global_variables SET variable_value=100 WHERE variable_name='mysql-monitor_connect_interval'") + ProxySQLBaseTest.run_query_proxysql_admin("UPDATE global_variables SET variable_value=100 WHERE variable_name='mysql-monitor_ping_interval'") + ProxySQLBaseTest.run_query_proxysql_admin("LOAD MYSQL VARIABLES TO RUNTIME") + + queries = [] + q1 = "select * from monitor.mysql_server_connect_log ORDER BY RANDOM() LIMIT 10" + q2 = "select * from monitor.mysql_server_ping_log ORDER BY RANDOM() LIMIT 10" + for _ in xrange(10000): + queries.append(random.choice([q1, q2])) + + pool = ThreadPool(processes=5) + pool.map(ProxySQLBaseTest.run_query_proxysql_admin, + queries) + + # If we reached this point without an error, it means that the test + # has passed. + self.assertEqual(1, 1) \ No newline at end of file