#454 Add command to run nose tests

pull/455/head
Andrei-Adnan Ismail 11 years ago
parent e8b289aaa3
commit a5df074442

@ -16,8 +16,10 @@ The most commonly used scenarios.py commands are:
"""
import os
import subprocess
import sys
from docopt import docopt
import nose
from test.docker_fleet import DockerFleet
@ -57,6 +59,10 @@ def stop():
with open(PROXYSQL_SCENARIO_FILE, 'rt') as f:
dirname = ''.join(f.readlines()).strip()
DockerFleet().stop_temp_scenario(dirname, delete_folder=True)
try:
os.remove(PROXYSQL_SCENARIO_FILE)
except:
pass
def _build_image(image, dir):
subprocess.call(["docker", "rmi", "-f", "proxysql:%s" % image])
@ -88,6 +94,9 @@ def build_image(image):
for image in dockerfiles.iterkeys():
_build_image(image, dockerfiles[image]['dir'])
def test():
nose.run(argv=['.'])
if __name__ == '__main__':
args = docopt(__doc__,
@ -139,4 +148,10 @@ if __name__ == '__main__':
if len(args['<args>']) > 0:
build_image(args['<args>'][0])
else:
build_image('all')
build_image('all')
elif args['<command>'] == 'test':
if (not os.path.exists(PROXYSQL_SCENARIO_FILE)):
print("There doesn't seem to be a running scenario. Aborting.")
else:
test()

@ -5,7 +5,7 @@ from proxysql_base_test import ProxySQLBaseTest
class AdminTablesTest(ProxySQLBaseTest):
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.
@ -31,7 +31,4 @@ class AdminTablesTest(ProxySQLBaseTest):
# If we reached this point without an error, it means that the test
# has passed.
self.assertEqual(1, 1)
def test_monitor_tables_locking_errors(self):
self.run_in_docker_scenarios(self._test_monitor_tables_locking_errors)
self.assertEqual(1, 1)

@ -4,7 +4,7 @@ from MySQLdb import OperationalError
class AdminTest(ProxySQLBaseTest):
def _test_stop_main_thread(self):
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
@ -13,7 +13,4 @@ class AdminTest(ProxySQLBaseTest):
self.run_query_proxysql_admin("PROXYSQL STOP")
self.assertEqual(0, 1)
except OperationalError:
self.assertEqual(1, 1)
def test_stop_main_thread(self):
self.run_in_docker_scenarios(self._test_stop_main_thread)
self.assertEqual(1, 1)

@ -6,7 +6,7 @@ from proxysql_base_test import ProxySQLBaseTest
class AuthenticationTest(ProxySQLBaseTest):
def _test_existing_user_with_correct_password_works(self):
def test_existing_user_with_correct_password_works(self):
version1 = self.run_query_mysql(
"SELECT @@version_comment LIMIT 1", "test",
return_result=True,
@ -19,10 +19,7 @@ class AuthenticationTest(ProxySQLBaseTest):
self.assertEqual(version1, version2)
def test_existing_user_with_correct_password_works(self):
self.run_in_docker_scenarios(self._test_existing_user_with_correct_password_works)
def _test_existing_user_with_correct_password_but_not_registerd_within_proxysql_does_not_work(self):
def test_existing_user_with_correct_password_but_not_registerd_within_proxysql_does_not_work(self):
try:
self.run_query_proxysql("SELECT @@version_comment LIMIT 1", "test",
return_result=True,
@ -33,10 +30,7 @@ class AuthenticationTest(ProxySQLBaseTest):
except OperationalError:
self.assertEqual(1, 1)
def test_existing_user_with_correct_password_but_not_registerd_within_proxysql_does_not_work(self):
self.run_in_docker_scenarios(self._test_existing_user_with_correct_password_works)
def _test_existing_user_with_incorrect_password_does_not_work(self):
def test_existing_user_with_incorrect_password_does_not_work(self):
try:
self.run_query_proxysql("SELECT @@version_comment LIMIT 1", "test",
return_result=True,
@ -47,17 +41,11 @@ class AuthenticationTest(ProxySQLBaseTest):
except OperationalError:
self.assertEqual(1, 1)
def test_existing_user_with_incorrect_password_does_not_work(self):
self.run_in_docker_scenarios(self._test_existing_user_with_incorrect_password_does_not_work)
def _test_inexisting_user_with_random_password_does_not_work(self):
def test_inexisting_user_with_random_password_does_not_work(self):
try:
self.run_query_proxysql("SELECT @@version_comment LIMIT 1", "test",
return_result=True,
username="johnny", password="randomdoe")
self.assertEqual(1, 0)
except OperationalError:
self.assertEqual(1, 1)
def test_inexisting_user_with_random_password_does_not_work(self):
self.run_in_docker_scenarios(self._test_inexisting_user_with_random_password_does_not_work)
self.assertEqual(1, 1)

@ -4,11 +4,8 @@ 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 = self.run_query_proxysql("SELECT * FROM strings", "test")
self.assertEqual(set([row[0] for row in rows]),
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)
set(['a', 'ab', 'abc', 'abcd']))

@ -6,6 +6,7 @@ import time
from proxysql_base_test import ProxySQLBaseTest
"""
class ReplicationTopologyAwareness(ProxySQLBaseTest):
def _test_insert_sent_through_proxysql_is_visible_in_slave_servers(self):
@ -177,4 +178,5 @@ class ReplicationTopologyAwareness(ProxySQLBaseTest):
# The old master, and the other slaves should still be in the slave hostgroup
for ip in slave_ips:
self.assertEqual(hostgroups[ip], 1)
self.assertEqual(hostgroups[ip], 1)
"""

@ -2,8 +2,5 @@ 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):
self.run_in_docker_scenarios(self._test_proxy_doesnt_crash_under_mild_sysbench_load)
self.run_sysbench_proxysql()
Loading…
Cancel
Save