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_randgen(test_cmd, test_executor, servers, schema='test'):
26
randgen_outfile = os.path.join(test_executor.logdir,'randgen.out')
27
randgen_output = open(randgen_outfile,'w')
28
server_type = test_executor.master_server.type
29
if server_type in ['percona','galera']:
30
# it is mysql for dbd::perl purposes
32
dsn = "--dsn=dbi:%s:host=127.0.0.1:port=%d:user=root:password="":database=%s" %( server_type
33
, servers[0].master_port
35
randgen_cmd = " ".join([test_cmd, dsn])
36
randgen_subproc = subprocess.Popen( randgen_cmd
38
, cwd=test_executor.system_manager.randgen_path
39
, env=test_executor.working_environment
40
, stdout = randgen_output
41
, stderr = subprocess.STDOUT
43
randgen_subproc.wait()
44
retcode = randgen_subproc.returncode
45
randgen_output.close()
47
randgen_file = open(randgen_outfile,'r')
48
output = ''.join(randgen_file.readlines())
51
if not test_executor.verbose:
53
return retcode, output