return dt_utils.exec_cmd(cmd, cls.logger, exit_on_error)
@classmethod
- def pre_copy(cls, container_id, src_path, dest_path, exit_on_error=False):
- if src_path == "" or dest_path == "":
+ def pre_copy(cls, container_id, src_path, dest_path,
+ exit_on_error=False):
+ if not src_path or not dest_path:
return (1, 'src_path or dest_path is empty')
- cmd = 'sudo docker cp %s %s:%s' % (src_path, container_id, dest_path)
- cls.logger.debug('execute cmd %s', cmd)
- return dt_utils.exec_cmd(cmd, cls.logger, exit_on_error)
+ cmd = 'cp %s %s' % (src_path, dest_path)
+ return cls.exec_cmd(container_id, cmd, exit_on_error)
'details': {"timestart": timestart,
"duration": testcase_duration,
"tests": '', "failures": ''}}
- elif 'tempest' in testcase_name:
+ elif testcase_name in dt_cfg.dovetail_config['functest_testsuite']:
file_path = \
os.path.join(dovetail_config['result_dir'],
- dovetail_config[self.type]['result']['tp_path'])
+ dovetail_config[self.type]['result']['file_path'])
if not os.path.exists(file_path):
self.logger.info('result file not found: %s', file_path)
return None
- with open(file_path, 'r') as myfile:
- output = myfile.read()
-
- match = re.findall('(.*?)[. ]*fail ', output)
- if match:
- error_logs = " ".join(match)
- else:
- error_logs = ""
- match = re.findall('(.*?)[. ]*skip:', output)
- if match:
- skipped = " ".join(match)
- else:
- skipped = ""
+ tests = 0
+ failed_num = 0
+ error_case = ''
+ skipped_case = ''
+ with open(file_path, 'r') as f:
+ for jsonfile in f:
+ try:
+ data = json.loads(jsonfile)
+ if testcase_name == data['case_name']:
+ criteria = data['details']['status']
+ timestart = data['details']['timestart']
+ testcase_duration = data['details']['duration']
+ tests = data['details']['tests']
+ failed_num = data['details']['failures']
+ error_case = data['details']['errors']
+ skipped_case = data['details']['skipped']
+ except Exception:
+ continue
- match = re.findall(' - Failures: (\d*)', output)
- if match:
- failed_num = int(match[0])
- else:
- failed_num = 0
- if failed_num == 0:
- criteria = 'PASS'
-
- match = re.findall('Ran: (\d*) tests in (\d*)\.\d* sec.', output)
- num_tests, dur_sec_int = match[0]
- json_results = {'criteria': criteria, 'details': {"timestart": '',
- "duration": int(dur_sec_int),
- "tests": int(num_tests), "failures": failed_num,
- "errors": error_logs,
- "skipped": skipped}}
+ json_results = {'criteria': criteria,
+ 'details': {"timestart": timestart,
+ "duration": testcase_duration,
+ "tests": tests,
+ "failures": failed_num,
+ "errors": error_case,
+ "skipped": skipped_case}}
self.logger.debug('Results: %s', str(json_results))
return json_results
dest_path = self.testcase.pre_copy_dest_path()
if dest_path:
- src_path = self.testcase.mk_src_file()
- ret, msg = Container.pre_copy(container_id, src_path, dest_path)
-
+ self.testcase.mk_src_file()
+ src_path = self.testcase.pre_copy_src_path(self.type)
+ ret, msg = Container.pre_copy(container_id, src_path,
+ dest_path)
if not self.testcase.prepared():
prepare_failed = False
cmds = self.testcase.pre_condition()