2
# -*- mode: python; indent-tabs-mode: nil; -*-
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
# Copyright (C) 2010 Patrick Crews
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
(DataBase) Quality Platform - system for executing various
25
testing systems and the helper code
27
Designed to be a modular test-runner. Different testing tools
28
and databases may be plugged into the system via hacking the
31
Currently geared towards Drizzle and MySQL systems
32
Runs: Drizzle, MySQL, Percona Server, Galera dbms's
40
import lib.opts.test_run_options as test_run_options
41
from lib.opts.defaults import get_defaults
42
from lib.modes.test_mode import handle_mode
43
from lib.server_mgmt.server_management import serverManager
44
from lib.sys_mgmt.system_management import systemManager
45
from lib.test_mgmt.execution_management import executionManager
48
def handle_sys_config(input_args, defaults):
49
""" Look for / update defaults based on sys_config file
53
key_string = '--sys-config'
55
for input_arg in input_args:
56
if input_arg.startswith(key_string):
57
module_file = input_arg.split(key_string)[1].replace('=','').strip()
58
module_file = os.path.abspath(module_file)
61
module_parent = os.path.dirname(module_file)
62
sys.path.append(module_parent)
63
module_name = os.path.basename(module_file).replace('.py','')
64
project = imp.load_source(module_name, module_file)
65
defaults = project.get_project_defaults(module_file, defaults)
69
# We base / look for a lot of things based on the location of
71
qp_rootdir = os.path.dirname(os.path.abspath(sys.argv[0]))
73
defaults = get_defaults(qp_rootdir,project_name)
74
defaults = handle_sys_config(sys.argv, defaults)
76
variables = test_run_options.parse_qp_options(defaults)
77
variables['qp_root'] = qp_rootdir
83
execution_manager = None
86
# Some system-level work is constant regardless
87
# of the test to be run
88
system_manager = systemManager(variables)
90
# Create our server_manager
91
server_manager = serverManager(system_manager, variables)
93
# Get our mode-specific test_manager and test_executor
94
(test_manager,test_executor) = handle_mode(variables, system_manager)
96
# Gather our tests for execution
97
test_manager.gather_tests()
99
# Initialize test execution manager
100
execution_manager = executionManager(server_manager, system_manager
101
, test_manager, test_executor
105
execution_manager.execute_tests()
110
except KeyboardInterrupt:
111
print "\n\nDetected <Ctrl>+c, shutting down and cleaning up..."
114
# TODO - make a more robust cleanup
115
# At the moment, runaway servers are our biggest concern
116
if server_manager and not variables['startandexit']:
118
server_manager.cleanup_all_servers()
120
server_manager.cleanup()
121
if not variables['startandexit']:
123
fail_count = test_manager.has_failing_tests()
124
sys.exit(test_manager.has_failing_tests())
126
# return 1 as we likely have a problem if we don't have a