2
# -*- mode: python; indent-tabs-mode: nil; -*-
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
# Copyright (C) 2011 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
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.
26
This includes allowing for advanced testing modes that utilize combos
27
of the available servers, etc.
36
""" Class that handles / provides the various server sources that
37
may be provided to dbqp
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
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)
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)
64
def process_codeTree(self, basedir, variables):
65
"""Import the appropriate module depending on the type of tree
68
Drizzle is the only supported type currently
72
self.logging.verbose("Processing code rooted at basedir: %s..." %(basedir))
73
code_type = self.get_code_type(basedir)
74
if code_type == 'drizzle':
76
from lib.sys_mgmt.codeTree import drizzleTree
77
test_tree = drizzleTree(variables,self.system_manager)
78
return code_type, test_tree
80
self.logging.error("Tree_type: %s not supported yet" %(tree_type))
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)
88
# We'll do something later, but we're cheating for now
89
# as we KNOW we're using drizzle code by default (only)
92
def get_tree(self, server_type, server_version):
93
""" We return an appropriate server tree for use in testing """
95
# We can make this more robust later on
96
return self.code_trees[server_type][0]