~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.2 by Stewart Smith
dbqp source (and all its libs) 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
#
2124.2.1 by Patrick Crews
Updates to system_management.py to have better naming for symlinks in shm
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
"""test_mode.py
22
   code for dealing with testing modes
23
   A given mode should have a systemInitializer, testManager, and testExecutor
24
   that define how to setup, manage, and execute test cases
25
26
"""
27
28
# imports
29
import sys
30
31
def handle_mode(variables, system_manager):
32
    """ Deals with the 'mode' option and returns
33
        the appropriate code objects for the test-runner to play with
34
35
    """
2194.2.1 by patrick crews
Integrated randgen with dbqp. We now have mode=randgen and a set of randgen test suites (very basic now). Output = same as dtr : ) We also have mode=cleanup to kill any servers we have started. Docs updates too. Gendata utility allows us to populate test servers
36
2337.1.15 by patrick crews
Code cleanup / reorganization
37
    test_mode = variables['mode'].strip()
2194.2.1 by patrick crews
Integrated randgen with dbqp. We now have mode=randgen and a set of randgen test suites (very basic now). Output = same as dtr : ) We also have mode=cleanup to kill any servers we have started. Docs updates too. Gendata utility allows us to populate test servers
38
    system_manager.logging.info("Using testing mode: %s" %test_mode)
39
2337.1.15 by patrick crews
Code cleanup / reorganization
40
    if test_mode == 'cleanup':
2194.2.1 by patrick crews
Integrated randgen with dbqp. We now have mode=randgen and a set of randgen test suites (very basic now). Output = same as dtr : ) We also have mode=cleanup to kill any servers we have started. Docs updates too. Gendata utility allows us to populate test servers
41
        # cleanup mode - we try to kill any servers whose pid's we detect
42
        # in our workdir.  Might extend to other things (file cleanup, etc)
43
        # at some later point
44
        system_manager.cleanup(exit=True)
2337.1.15 by patrick crews
Code cleanup / reorganization
45
46
    else: # we expect something from dbqp_modes
47
        supported_modes = [ 'dtr'
48
                          , 'randgen'
49
                          , 'sysbench'
50
                          , 'sqlbench'
51
                          , 'crashme'
52
                          , 'native'
53
                          ]
54
        if test_mode not in supported_modes:
55
            system_manager.logging.error("invalid mode argument: %s" %test_mode)
56
            sys.exit(1)
57
        
58
        mgmt_module = "lib.dbqp_modes.%s.%s_test_management" %(test_mode, test_mode)
59
        tmp = __import__(mgmt_module, globals(), locals(), ['testManager'], -1)
60
        testManager = tmp.testManager
61
62
        exec_module = "%s.%s_test_execution" %(test_mode, test_mode)
63
        tmp = __import__(exec_module, globals(), locals(), ['testExecutor'], -1)
64
        testExecutor = tmp.testExecutor        
2194.2.1 by patrick crews
Integrated randgen with dbqp. We now have mode=randgen and a set of randgen test suites (very basic now). Output = same as dtr : ) We also have mode=cleanup to kill any servers we have started. Docs updates too. Gendata utility allows us to populate test servers
65
2337.1.1 by patrick crews
Cleanup of option handling + test modes. Initial work for expanding dbqp capabilities to do neat things
66
    test_manager = testManager( variables, system_manager )
2194.2.1 by patrick crews
Integrated randgen with dbqp. We now have mode=randgen and a set of randgen test suites (very basic now). Output = same as dtr : ) We also have mode=cleanup to kill any servers we have started. Docs updates too. Gendata utility allows us to populate test servers
67
    return (test_manager, testExecutor)
68