~drizzle-trunk/drizzle/development

2144.1.1 by patrick crews
Overhaul of code. We can run rabbitmq : ) We now better encapsulate a per-executor working environment = one step closer to --parallel >: ) using subprocess goodness for server control
1
#! /usr/bin/env python
2235.5.1 by Stewart Smith
dbqp source should use emacs python mode, not emacs C mode
2
# -*- mode: python; indent-tabs-mode: nil; -*-
2088.9.1 by patrick crews
Updated tree so that test-run.pl and test-run.py may live together in peace for a time
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
#
5
# Copyright (C) 2010 Patrick Crews
6
#
2121.3.2 by patrick crews
Updated license verbiage
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.
11
#
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.
16
#
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
2121.3.1 by patrick crews
Added licensing text to dbqp files
20
2088.9.1 by patrick crews
Updated tree so that test-run.pl and test-run.py may live together in peace for a time
21
2088.9.9 by patrick crews
Renamed test-run.py to better reflect what it will be doing
22
""" dbqp.py
23
24
DataBase Quality Platform - system for executing various
25
testing systems and the helper code 
26
2337.1.1 by patrick crews
Cleanup of option handling + test modes. Initial work for expanding dbqp capabilities to do neat things
27
Designed to be a modular test-runner.  Different testing tools
28
and databases may be plugged into the system via hacking the
29
appropriate modules
2088.9.1 by patrick crews
Updated tree so that test-run.pl and test-run.py may live together in peace for a time
30
2337.1.1 by patrick crews
Cleanup of option handling + test modes. Initial work for expanding dbqp capabilities to do neat things
31
Currently geared towards Drizzle / will expand to MySQL
2088.9.1 by patrick crews
Updated tree so that test-run.pl and test-run.py may live together in peace for a time
32
"""
33
34
# imports
35
import os
36
import sys
2337.1.1 by patrick crews
Cleanup of option handling + test modes. Initial work for expanding dbqp capabilities to do neat things
37
38
import lib.dbqp_opts.test_run_options as test_run_options
2337.1.2 by patrick crews
Additional tweaks
39
from lib.dbqp_modes.test_mode import handle_mode
2088.9.1 by patrick crews
Updated tree so that test-run.pl and test-run.py may live together in peace for a time
40
from lib.server_mgmt.server_management import serverManager
41
from lib.sys_mgmt.system_management import systemManager
42
from lib.test_mgmt.execution_management import executionManager
43
44
# functions
45
46
47
# main
2088.9.4 by patrick crews
Updates to server management and signalling a bad server start
48
variables = test_run_options.variables
2088.9.18 by patrick crews
Updates to allow for timing of test cases and reporting and whatnot
49
system_manager = None
50
server_manager = None
51
test_manager = None
52
test_executor = None
53
execution_manager = None
2088.9.4 by patrick crews
Updates to server management and signalling a bad server start
54
2088.9.10 by patrick crews
Updates to filesystem_engine and transaction_log tests to allow dbqp + test-run.pl to live together and execute all tests
55
try:
2211.3.1 by patrick crews
Nested try/excepts in try/finally to accomodate rhel's crazy-old python 2.4 : (
56
    # We do this nested try to accomodate red hat
57
    # running python 2.4...seriously?  2.4?
58
    try:
59
        # Some system-level work is constant regardless
60
        # of the test to be run
61
        system_manager = systemManager(variables)
62
63
        # Create our server_manager
64
        server_manager = serverManager(system_manager, variables)
65
66
        # Get our mode-specific test_manager and test_executor
67
        (test_manager,test_executor) = handle_mode(variables, system_manager)
68
69
        # Gather our tests for execution
70
        test_manager.gather_tests()
71
72
        # Initialize test execution manager
73
        execution_manager = executionManager(server_manager, system_manager
74
                                        , test_manager, test_executor
75
                                        , variables)
76
77
        # Execute our tests!
78
        execution_manager.execute_tests()
79
    
80
    except Exception, e:
81
       print Exception, e
82
83
    except KeyboardInterrupt:
84
      print "\n\nDetected <Ctrl>+c, shutting down and cleaning up..."
2088.9.18 by patrick crews
Updates to allow for timing of test cases and reporting and whatnot
85
2088.9.10 by patrick crews
Updates to filesystem_engine and transaction_log tests to allow dbqp + test-run.pl to live together and execute all tests
86
finally:
2088.9.15 by patrick crews
Removed innodb_bug53756.test as it was using MTR2 functionality we don't have. Tweaks to error handling for certain cases (non-existent suite)
87
# TODO - make a more robust cleanup
88
# At the moment, runaway servers are our biggest concern
2124.2.10 by Patrick Crews
Added --start-and-exit option
89
    if server_manager and not variables['startandexit']:
2151.8.5 by patrick crews
Additional changes to make gdb work better
90
        if variables['gdb']:
2177.2.1 by Patrick Crews
Fix of stupid syntax error
91
            server_manager.cleanup_all_servers()
2151.8.5 by patrick crews
Additional changes to make gdb work better
92
        else:
93
            server_manager.cleanup()
2151.8.1 by patrick crews
Updates to allow several dbqp's run run on one system (via uuid) and fix to return a relevant code post-execution (ie 1 if tests failed or timed out))
94
    if not variables['startandexit']:
95
        if test_manager:
96
            fail_count = test_manager.has_failing_tests()
97
            sys.exit(test_manager.has_failing_tests())
98
        else:
99
            # return 1 as we likely have a problem if we don't have a
100
            # test_manager
101
            sys.exit(1)
102