def run_test(self, test): stime = datetime.now() cmd = self.prepare_run(test) if cmd == None: return 89, stime.strftime("%Y-%m-%d-%H:%M:%S.%f") # open log files self.open_logfile(test) tattr = self.tconfig.get_test_attributes(test) #= returns dict #-- let the user know test is about to start self.logger.debug('Executing {0} on remote node(s)'.format(cmd)) self.logger.info( '{0} started on {1} node(s) at {2}. It might take up to {3}s.'. format(test, len(self.target), stime, tattr['timeout'])) tm = TimeoutManager( self.logger, timedelta(seconds=int(self.mattr['tty_progress_interval'])), timedelta(seconds=int(self.mattr['watch_output_progress']))) if self.mattr['watch_output_progress'] == '0': tm_thread = start_thread(tm.tick_thread) else: tm_thread = start_thread(tm.alert_thread) #-- initiate the timeout manager with known nodes if self.proxy: tm.activity(self.proxy.node) else: for node in self.target: tm.activity(node) #-- let's execute!! proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) threads = [start_thread(self.store_node_stdout, proc.stdout, tm)] threads += [start_thread(self.print_log_stderr, proc.stderr, tm)] proc.wait() for t in threads: t.join() tm.done() while tm_thread.isAlive(): self.logger.debug('Waiting for the timeout manager thread to end.') time.sleep(0.05) etime = datetime.now() self.logger.info( '{0} ended on {1} node(s) at {2}, rc= {3}, elapsed time: {4}'. format(test, len(self.target), etime, proc.returncode, etime - stime)) self.close_logfile() if not self.mgmt_mode or (self.proxy and self.proxy.type == 'mgt'): self.proxy.rc = proc.returncode del tm # delete the TimeoutMamager return 0, stime.strftime("%Y-%m-%d %H:%M:%S.%f")