2
# -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
# Copyright (C) 2010 Patrick Crews
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 2 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
""" dtr_test_execution:
23
code related to the execution of dtr test cases
25
We are provided access to a testManager with
26
dtr-specific testCases. We contact teh executionManager
27
to produce the system and server configurations we need
38
import lib.test_mgmt.test_execution as test_execution
40
class dtrTestExecutor(test_execution.testExecutor):
41
""" dtr-specific testExecutor
42
We currently execute by sending test-case
43
data to client/drizzletest...for now
47
def execute_testCase (self):
48
""" Execute a dtr testCase via calls to drizzletest (boo)
49
Eventually, we will replace drizzletest with pythonic
50
goodness, but we have these classes stored here for the moment
53
test_execution.testExecutor.execute_testCase(self)
56
# generate command line
57
drizzletest_cmd = self.generate_drizzletest_call()
59
self.logging.debug(drizzletest_cmd)
62
self.process_symlink_reqs()
63
self.process_environment_reqs()
64
self.execute_drizzletest(drizzletest_cmd)
67
self.current_test_status = self.process_drizzletest_output()
68
self.set_server_status(self.current_test_status)
71
def generate_drizzletest_call(self):
72
""" Produce the command line we use to call drizzletest
73
We have a healthy number of values, so we put this in a
78
drizzletest_arguments = [ '--no-defaults'
80
, '--tmpdir=%s' %(self.master_server.tmpdir)
81
, '--logdir=%s' %(self.master_server.logdir)
82
, '--port=%d' %(self.master_server.master_port)
86
#, '--testdir=%s' %(self.test_manager.testdir)
87
, '--test-file=%s' %(self.current_testcase.testpath)
89
, '--timer-file=%s' %(self.master_server.timer_file)
90
, '--result-file=%s' %(self.current_testcase.resultpath)
93
# We want to record a new result
94
drizzletest_arguments.append('--record')
95
drizzletest_cmd = "%s %s %s" %( self.cmd_prefix
96
, self.system_manager.code_tree.drizzletest
97
, " ".join(drizzletest_arguments))
98
return drizzletest_cmd
100
def execute_drizzletest(self, drizzletest_cmd):
101
""" Execute the commandline and return the result.
102
We use subprocess as we can pass os.environ dicts and whatnot
105
testcase_name = self.current_testcase.fullname
106
self.time_manager.start(testcase_name,'test')
107
retcode, output = self.system_manager.execute_cmd( drizzletest_cmd
109
execution_time = int(self.time_manager.stop(testcase_name)*1000) # millisec
112
self.logging.debug("drizzletest_retcode: %d" %(retcode))
113
self.logging.debug("drizzletest_output: %s" %(output))
114
self.current_test_retcode = retcode
115
self.current_test_output = output
116
self.current_test_exec_time = execution_time
118
def process_drizzletest_output(self):
119
""" Drizzletest has run, we now check out what we have """
120
retcode = self.current_test_retcode
123
elif retcode == 62 or retcode == 15872:
125
elif retcode == 63 or retcode == 1:
130
def process_environment_reqs(self):
131
""" We generate the ENV vars we need set
132
and then ask systemManager to do so
136
env_reqs = { 'DRIZZLETEST_VARDIR': (self.master_server.vardir,0,0)
137
, 'DRIZZLE_TMP_DIR': (self.master_server.tmpdir,0,0)
138
, 'MASTER_MYSOCK': (self.master_server.socket_file,0,0)
139
, 'MASTER_MYPORT': (str(self.master_server.master_port),0,0)
140
, 'MC_PORT': (str(self.master_server.mc_port),0,0)
141
, 'PBMS_PORT': (str(self.master_server.pbms_port),0,0)
142
, 'DRIZZLE_TCP_PORT': (str(self.master_server.drizzle_tcp_port),0,0)
143
, 'EXE_DRIZZLE': (self.master_server.drizzle_client,0,0)
144
, 'DRIZZLE_DUMP': ("%s --no-defaults -uroot -p%d" %( self.master_server.drizzledump
145
, self.master_server.master_port),0,0)
146
, 'DRIZZLE_SLAP': ("%s -uroot -p%d" %( self.master_server.drizzleslap
147
, self.master_server.master_port),0,0)
148
, 'DRIZZLE_IMPORT': ("%s -uroot -p%d" %( self.master_server.drizzleimport
149
, self.master_server.master_port),0,0)
150
, 'DRIZZLE': ("%s -uroot -p%d" %( self.master_server.drizzle_client
151
, self.master_server.master_port),0,0)
152
, 'DRIZZLE_ADMIN' : ("%s -uroot -p%d" %( self.master_server.drizzleadmin
153
, self.master_server.master_port),0,0)
156
self.system_manager.process_environment_reqs(env_reqs, quiet=1)
158
def process_symlink_reqs(self):
159
""" Create any symlinks we may need """
162
# handle filesystem_engine
163
if self.current_testcase.suitename == 'filesystem_engine':
164
needed_symlinks.append(( os.path.join(self.current_testcase.suitepath
166
, os.path.join(self.master_server.vardir
169
self.system_manager.create_symlinks(needed_symlinks)