From cb86e08a6dfd9bfb1d829708a1350cde2c08e7ae Mon Sep 17 00:00:00 2001 From: Andrei-Adnan Ismail Date: Wed, 21 Oct 2015 13:58:39 +0300 Subject: [PATCH] #410 Migrating tests to new multiple-OS format --- test/admin_tables_test.py | 18 +++++++++--------- test/admin_test.py | 19 +++++++++++-------- test/one_backend_test.py | 9 ++++++--- test/sysbench_test.py | 5 ++++- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/test/admin_tables_test.py b/test/admin_tables_test.py index dece71ee0..47bdf5614 100644 --- a/test/admin_tables_test.py +++ b/test/admin_tables_test.py @@ -5,9 +5,7 @@ from proxysql_base_test import ProxySQLBaseTest class AdminTablesTest(ProxySQLBaseTest): - SCENARIO = "./scenarios/1backend" - - def test_monitor_tables_locking_errors(self): + def _test_monitor_tables_locking_errors(self): """Test that intensive read/write operations to the MySQL Monitor tables do not trigger locking errors. @@ -18,9 +16,9 @@ class AdminTablesTest(ProxySQLBaseTest): # 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") + self.run_query_proxysql_admin("UPDATE global_variables SET variable_value=100 WHERE variable_name='mysql-monitor_connect_interval'") + self.run_query_proxysql_admin("UPDATE global_variables SET variable_value=100 WHERE variable_name='mysql-monitor_ping_interval'") + self.run_query_proxysql_admin("LOAD MYSQL VARIABLES TO RUNTIME") queries = [] q1 = "select * from monitor.mysql_server_connect_log ORDER BY RANDOM() LIMIT 10" @@ -29,9 +27,11 @@ class AdminTablesTest(ProxySQLBaseTest): queries.append(random.choice([q1, q2])) pool = ThreadPool(processes=5) - pool.map(ProxySQLBaseTest.run_query_proxysql_admin, - queries) + pool.map(self.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 + self.assertEqual(1, 1) + + def test_monitor_tables_locking_errors(self): + self.run_in_docker_scenarios(self._test_monitor_tables_locking_errors) \ No newline at end of file diff --git a/test/admin_test.py b/test/admin_test.py index 665dffba5..1b7aca353 100644 --- a/test/admin_test.py +++ b/test/admin_test.py @@ -1,16 +1,19 @@ from proxysql_base_test import ProxySQLBaseTest from MySQLdb import OperationalError -from nose.tools import raises class AdminTest(ProxySQLBaseTest): - SCENARIO = "./scenarios/1backend" + def _test_stop_main_thread(self): + try: + # This test will just assert that PROXYSQL STOP works correctly + # Since September 2015, the behaviour has been changed - PROXYSQL STOP + # executes faster and immediately shuts down the connections, thus this + # test is expected to raise OperationalError + self.run_query_proxysql_admin("PROXYSQL STOP") + self.assertEqual(0, 1) + except OperationalError: + self.assertEqual(1, 1) - @raises(OperationalError) def test_stop_main_thread(self): - # This test will just assert that PROXYSQL STOP works correctly - # Since September 2015, the behaviour has been changed - PROXYSQL STOP - # executes faster and immediately shuts down the connections, thus this - # test is expected to raise OperationalError - ProxySQLBaseTest.run_query_proxysql_admin("PROXYSQL STOP") \ No newline at end of file + self.run_in_docker_scenarios(self._test_stop_main_thread) \ No newline at end of file diff --git a/test/one_backend_test.py b/test/one_backend_test.py index 6db092385..af02d7e25 100644 --- a/test/one_backend_test.py +++ b/test/one_backend_test.py @@ -4,8 +4,11 @@ from proxysql_base_test import ProxySQLBaseTest class OneBackendTest(ProxySQLBaseTest): - def test_select_strings_returns_correct_result(self): + def _test_select_strings_returns_correct_result(self): - rows = ProxySQLBaseTest.run_query_proxysql("SELECT * FROM strings", "test") + rows = self.run_query_proxysql("SELECT * FROM strings", "test") self.assertEqual(set([row[0] for row in rows]), - set(['a', 'ab', 'abc', 'abcd'])) \ No newline at end of file + set(['a', 'ab', 'abc', 'abcd'])) + + def test_select_strings_returns_correct_result(self): + self.run_in_docker_scenarios(self._test_select_strings_returns_correct_result) \ No newline at end of file diff --git a/test/sysbench_test.py b/test/sysbench_test.py index 47a66bc6e..2bef5762b 100644 --- a/test/sysbench_test.py +++ b/test/sysbench_test.py @@ -2,5 +2,8 @@ from proxysql_base_test import ProxySQLBaseTest class SysBenchTest(ProxySQLBaseTest): + def _test_proxy_doesnt_crash_under_mild_sysbench_load(self): + self.run_sysbench_proxysql() + def test_proxy_doesnt_crash_under_mild_sysbench_load(self): - ProxySQLBaseTest.run_sysbench_proxysql() \ No newline at end of file + self.run_in_docker_scenarios(self._test_proxy_doesnt_crash_under_mild_sysbench_load) \ No newline at end of file