2
# -*- mode: python; 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
randgen-specific testCases. We contact the executionManager
27
to produce the system and server configurations we need
38
import lib.test_mgmt.test_execution as test_execution
40
class testExecutor(test_execution.testExecutor):
41
""" randgen-specific testExecutor
45
def execute_testCase (self):
46
""" Execute a randgen testCase
49
test_execution.testExecutor.execute_testCase(self)
53
self.execute_randgen()
56
self.current_test_status = self.process_randgen_output()
57
self.set_server_status(self.current_test_status)
58
self.server_manager.reset_servers(self.name)
63
def execute_randgen(self):
64
""" Execute the commandline and return the result.
65
We use subprocess as we can pass os.environ dicts and whatnot
69
testcase_name = self.current_testcase.fullname
70
self.time_manager.start(testcase_name,'test')
71
randgen_outfile = os.path.join(self.logdir,'randgen.out')
72
randgen_output = open(randgen_outfile,'w')
73
dsn = "--dsn=dbi:drizzle:host=localhost:port=%d:user=root:password="":database=test" %(self.master_server.master_port)
74
randgen_cmd = " ".join([self.current_testcase.test_command, dsn])
75
randgen_subproc = subprocess.Popen( randgen_cmd
77
, cwd=self.system_manager.randgen_path
78
, env=self.working_environment
79
, stdout = randgen_output
80
, stderr = subprocess.STDOUT
82
randgen_subproc.wait()
83
retcode = randgen_subproc.returncode
84
execution_time = int(self.time_manager.stop(testcase_name)*1000) # millisec
86
randgen_output.close()
87
randgen_file = open(randgen_outfile,'r')
88
output = ''.join(randgen_file.readlines())
89
self.logging.debug(output)
92
self.logging.debug("randgen_retcode: %d" %(retcode))
93
self.current_test_retcode = retcode
94
self.current_test_output = output
95
self.current_test_exec_time = execution_time
97
def process_randgen_output(self):
98
""" randgen has run, we now check out what we have """
99
retcode = self.current_test_retcode