118
def handle_system_reqs(self):
119
""" We check our test case and see what we need to do
120
system-wise to get ready. This is likely to be
121
mode-dependent and this is just a placeholder
126
self.process_environment_reqs()
127
self.process_symlink_reqs()
128
self.process_master_sh()
131
def process_master_sh(self):
132
""" We do what we need to if we have a master.sh file """
133
if self.current_testcase.master_sh:
134
retcode, output = self.system_manager.execute_cmd("/bin/sh %s" %(self.current_testcase.master_sh))
136
self.logging.info("retcode: %retcode")
137
self.logging.info("%output")
139
def process_environment_reqs(self):
140
""" We generate the ENV vars we need set
141
and then ask systemManager to do so
144
env_reqs = { 'DRIZZLETEST_VARDIR': self.master_server.vardir
145
, 'DRIZZLE_TMP_DIR': self.master_server.tmpdir
146
, 'MASTER_MYSOCK': self.master_server.socket_file
147
, 'MASTER_MYPORT': str(self.master_server.master_port)
148
, 'MC_PORT': str(self.master_server.mc_port)
149
, 'PBMS_PORT': str(self.master_server.pbms_port)
150
, 'RABBITMQ_NODE_PORT': str(self.master_server.rabbitmq_node_port)
151
, 'DRIZZLE_TCP_PORT': str(self.master_server.drizzle_tcp_port)
152
, 'EXE_DRIZZLE': self.master_server.drizzle_client
153
, 'MASTER_SERVER_SLAVE_CONFIG' : self.master_server.slave_config_file
154
, 'DRIZZLE_DUMP': "%s --no-defaults -uroot -p%d" %( self.master_server.drizzledump
155
, self.master_server.master_port)
156
, 'DRIZZLE_SLAP': "%s -uroot -p%d" %( self.master_server.drizzleslap
157
, self.master_server.master_port)
158
, 'DRIZZLE_IMPORT': "%s -uroot -p%d" %( self.master_server.drizzleimport
159
, self.master_server.master_port)
160
, 'DRIZZLE': "%s -uroot -p%d" %( self.master_server.drizzle_client
161
, self.master_server.master_port)
162
, 'DRIZZLE_BASEDIR' : self.system_manager.code_tree.basedir
163
, 'DRIZZLE_TRX_READER' : self.system_manager.code_tree.drizzle_trx_reader
164
, 'DRIZZLE_TEST_WORKDIR' : self.system_manager.workdir
168
self.working_environment = self.system_manager.create_working_environment(env_reqs)
171
def process_symlink_reqs(self):
172
""" Create any symlinks we may need """
175
self.system_manager.create_symlinks(needed_symlinks)
178
class crashmeTestExecutor(sqlbenchTestExecutor):
179
""" crashme-specific variant of sqlbench executor """
181
def execute_testCase (self):
182
""" Execute a crashme testCase
185
test_execution.testExecutor.execute_testCase(self)
188
self.prepare_config()
191
self.execute_crashme()
194
self.current_test_status = self.process_crashme_output()
195
self.set_server_status(self.current_test_status)
196
self.server_manager.reset_servers(self.name)
198
def prepare_config(self):
199
""" Create the config file crash-me needs to execute """
201
output_filename= "%s/drizzle.cfg" % (self.system_manager.workdir)
203
# remove the existing configuration file to start fresh
204
if os.path.exists(output_filename):
205
logging.info("Removing %s" % output_filename)
206
os.remove(output_filename)
208
output_file= open(output_filename,"w")
209
# don't support '+' for concatenation
210
output_file.writelines("func_extra_concat_as_+=no\n")
211
# new boost libraries are causing us to put these limits in, needs investigation
212
output_file.writelines("max_text_size=1048576\n")
213
output_file.writelines("where_string_size=1048576\n")
214
output_file.writelines("select_string_size=1048576\n")
218
def execute_crashme(self):
219
""" Execute the commandline and return the result.
220
We use subprocess as we can pass os.environ dicts and whatnot
224
output_filename= "%s/drizzle.cfg" % (self.system_manager.workdir)
225
testcase_name = self.current_testcase.fullname
226
self.time_manager.start(testcase_name,'test')
227
crashme_outfile = os.path.join(self.logdir,'crashme.out')
228
crashme_output = open(crashme_outfile,'w')
229
crashme_cmd = self.current_testcase.test_command + " --config-file=%s" %(output_filename)
230
self.logging.info("Executing crash-me: %s" %(crashme_cmd))
232
crashme_subproc = subprocess.Popen( crashme_cmd
234
, cwd=os.path.join(self.system_manager.testdir, 'sql-bench')
235
, env=self.working_environment
236
, stdout = crashme_output
237
, stderr = subprocess.STDOUT
239
crashme_subproc.wait()
240
retcode = crashme_subproc.returncode
241
execution_time = int(self.time_manager.stop(testcase_name)*1000) # millisec
243
crashme_output.close()
244
crashme_file = open(crashme_outfile,'r')
245
output = ''.join(crashme_file.readlines())
247
self.logging.debug(output)
251
self.logging.debug("crashme_retcode: %d" %(retcode))
252
self.current_test_retcode = retcode
253
self.current_test_output = output
254
self.current_test_exec_time = execution_time
256
def process_crashme_output(self):
257
if self.current_test_retcode == 0:
258
infile_name = self.current_test_output.split('\n')[3].split(':')[1].strip()
259
inf= open(infile_name, "r")
260
inlines= inf.readlines()
262
in_error_section = False
263
# crash-me is quite chatty and we don't normally want to sift
264
# through ALL of that stuff. We do allow seeing it via --verbose
266
self.current_test_output = ''
267
for inline in inlines:
268
if in_error_section and not inline.strip().startswith('#'):
269
in_error_section = False
270
if '=error' in inline:
272
in_error_section= True
274
self.current_test_output += inline