2337.1.10
by patrick crews
Merge trunk + initial changes for code_management |
1 |
#! /usr/bin/env python
|
2 |
# -*- mode: python; indent-tabs-mode: nil; -*-
|
|
3 |
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
4 |
#
|
|
2337.1.11
by patrick crews
Added environment manager + test_execution cleanup. |
5 |
# Copyright (C) 2011 Patrick Crews
|
2337.1.10
by patrick crews
Merge trunk + initial changes for code_management |
6 |
#
|
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
|
|
20 |
||
21 |
"""code_management.py
|
|
22 |
code for handling awareness / validation / management of
|
|
23 |
server source code. We want to be able to provide dbqp
|
|
24 |
with an array of basedir values and have tests execute appropriately.
|
|
25 |
||
26 |
This includes allowing for advanced testing modes that utilize combos
|
|
27 |
of the available servers, etc.
|
|
28 |
||
29 |
"""
|
|
30 |
||
31 |
# imports
|
|
32 |
import os |
|
33 |
import sys |
|
34 |
||
35 |
class codeManager: |
|
36 |
""" Class that handles / provides the various server sources that
|
|
37 |
may be provided to dbqp
|
|
38 |
||
39 |
"""
|
|
40 |
||
41 |
def __init__(self, system_manager, variables): |
|
42 |
self.system_manager = system_manager |
|
43 |
self.logging = self.system_manager.logging |
|
44 |
self.code_trees = {} # we store type: codeTree |
|
45 |
||
46 |
# We go through the various --basedir values provided
|
|
47 |
provided_basedirs = variables['basedir'] |
|
48 |
for basedir in provided_basedirs: |
|
49 |
# We initialize a codeTree object
|
|
50 |
# and store some information about it
|
|
51 |
code_type, code_tree = self.process_codeTree(basedir, variables) |
|
52 |
self.add_codeTree(code_type, code_tree) |
|
53 |
||
54 |
||
55 |
def add_codeTree(self, code_type, code_tree): |
|
56 |
# We add the codeTree to a list under 'type'
|
|
57 |
# (mysql, drizzle, etc)
|
|
58 |
# This organization may need to change at some point
|
|
59 |
# but will work for now
|
|
60 |
if code_type not in self.code_trees: |
|
61 |
self.code_trees[code_type] = [] |
|
62 |
self.code_trees[code_type].append(code_tree) |
|
63 |
||
64 |
def process_codeTree(self, basedir, variables): |
|
65 |
"""Import the appropriate module depending on the type of tree
|
|
66 |
we are testing.
|
|
67 |
||
68 |
Drizzle is the only supported type currently
|
|
69 |
||
70 |
"""
|
|
71 |
||
72 |
self.logging.verbose("Processing code rooted at basedir: %s..." %(basedir)) |
|
73 |
code_type = self.get_code_type(basedir) |
|
74 |
if code_type == 'drizzle': |
|
75 |
# base_case
|
|
76 |
from lib.sys_mgmt.codeTree import drizzleTree |
|
77 |
test_tree = drizzleTree(variables,self.system_manager) |
|
78 |
return code_type, test_tree |
|
79 |
else: |
|
80 |
self.logging.error("Tree_type: %s not supported yet" %(tree_type)) |
|
81 |
sys.exit(1) |
|
82 |
||
83 |
def get_code_type(self, basedir): |
|
84 |
""" We do some quick scans of the basedir to determine
|
|
85 |
what type of tree we are dealing with (mysql, drizzle, etc)
|
|
86 |
||
87 |
"""
|
|
88 |
# We'll do something later, but we're cheating for now
|
|
89 |
# as we KNOW we're using drizzle code by default (only)
|
|
90 |
return 'drizzle' |
|
2337.1.12
by patrick crews
Additional work on allowing dbqp to handle multiple server types / versions (even simultaneously) |
91 |
|
92 |
def get_tree(self, server_type, server_version): |
|
93 |
""" We return an appropriate server tree for use in testing """
|
|
94 |
||
95 |
# We can make this more robust later on
|
|
96 |
return self.code_trees[server_type][0] |
|
2337.1.10
by patrick crews
Merge trunk + initial changes for code_management |
97 |
|
98 |