2
# -*- mode: python; indent-tabs-mode: nil; -*-
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
# Copyright (C) 2011 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
25
def execute_sqlbench(test_cmd, test_executor, servers):
26
""" Execute the commandline and return the result.
27
We use subprocess as we can pass os.environ dicts and whatnot
32
sqlbench_outfile = os.path.join(bot.logdir,'sqlbench.out')
33
sqlbench_output = open(sqlbench_outfile,'w')
34
bot.logging.info("Executing sqlbench: %s" %(test_cmd))
35
bot.logging.info("This may take some time...")
36
sqlbench_subproc = subprocess.Popen( test_cmd
38
, cwd=os.path.join(bot.system_manager.testdir, 'sql-bench')
39
, env=bot.working_environment
40
, stdout = sqlbench_output
41
, stderr = subprocess.STDOUT
43
sqlbench_subproc.wait()
44
retcode = sqlbench_subproc.returncode
46
sqlbench_output.close()
47
sqlbench_file = open(sqlbench_outfile,'r')
48
output = ''.join(sqlbench_file.readlines())
51
bot.current_test_retcode = retcode
52
bot.current_test_output = output
53
test_status = process_sqlbench_output(bot)
54
return test_status, retcode, output
56
def process_sqlbench_output(bot):
58
# Check for 'Failed' in sql-bench output
59
# The tests don't die on a failed test and
60
# require some checking of the output file
62
for inline in bot.current_test_output:
63
if 'Failed' in inline:
65
logging.info(inline.strip())
66
if bot.current_test_retcode == 0 and not error_flag: