def complete_active_iteration(self, force_stop=False): logger.info('completea active iteration.') if not self.is_iteration_running(): logger.error('No active iteration found to complete.') return logger.log_result_info_status(self._stc_result_object) self._active_iteration_info = ActiveIterationInfo() self.load_from_stc_object(self._active_iteration_info) self._active_iteration_status = ActiveIterationStatus() self.load_from_stc_object(self._active_iteration_status) if force_stop is True: self._active_iteration_status.exec_status = EnumExecStatus.stopped else: self._active_iteration_status.exec_status = EnumExecStatus.completed self._active_iteration_info._end_time = result_utils.get_current_time_string() result = self.generate_iteration_verdict() if result: self._active_iteration_status.verdict = result['verdict'] self._active_iteration_info.result_file = result['resultFile'] self._active_iteration_info.set_data_class(self._active_iteration_info, EnumDataClass.iteration_result) self._active_iteration_info.set_data_format(self._active_iteration_info, EnumDataFormat.none) else: self._active_iteration_status.verdict = EnumVerdict.none self._active_iteration_info.set_data_class(self._active_iteration_info, EnumDataClass.iteration_result) self._active_iteration_info.set_data_format(self._active_iteration_info, EnumDataFormat.none) self.save_active_iteration_data() self.reset_active_iteration_data() logger.info('completea active iteration completed.')
def add_provider_result_to_root(dict_data): """Add provider result to test object. Try to create one and continue if test does not exist. """ logger.info('Add provider result to root.') # make sure test in created and running. If not do that first. start_test_if_required() test_result = TestResult() dict_data = result_utils.insert_report_group_if_not_defined(dict_data) test_result.add_provider_data(dict_data)
def test_wrap_data_as_single_group(stc, resource_cleanup): data = [] data.append(test_utils.dummy_verify_result_failed) data.append(test_utils.dummy_verify_result_passed) gdata = ru.wrap_data_as_single_group(data) assert gdata is not None assert gdata[RC.TAG] == RC.ALL_GROUPS assert (RC.CHILDREN in gdata) is True gdata = gdata[RC.CHILDREN] assert len(gdata) == 2 assert gdata[0][pc.INFO][pc.REPORT_GROUP] == 'GROUP_1' assert gdata[1][pc.INFO][pc.REPORT_GROUP] == 'SUMMARY' gdata = ru.wrap_data_as_single_group(test_utils.dummy_verify_result_failed) assert gdata is not None assert gdata[RC.TAG] == RC.ALL_GROUPS assert (RC.CHILDREN in gdata) is True gdata = gdata[RC.CHILDREN] assert len(gdata) == 1 assert gdata[0][pc.INFO][pc.REPORT_GROUP] == 'GROUP_1'
def add_provider_result(dict_data): """Add provider result to active result object. It is leaf iterator result object in case of iterative test. Do not throw error if result object does not exist. Try to create one and continue. """ logger.info('Add provider result.') # make sure test in created and running. If not do that first. start_test_if_required() result = iterator_utils.get_active_result_object() logger.debug_result_object_info(result) dict_data = result_utils.insert_report_group_if_not_defined(dict_data) result_obj.add_provider_data(result, dict_data)
def generate_report(self): result_utils.summarize_status(self) parent_itr_info = iterator_utils.get_parent_active_info(self._stc_result_object) self._info.set_data_format(self._info, EnumDataFormat.group) self._info.set_data_class(self._info, EnumDataClass.iteration_report) report = self._info.run_time_data if parent_itr_info and len(parent_itr_info) > 0: report[self._info.dict_name]['parent_iteration_info'] = parent_itr_info report[self._status.dict_name] = self._status.run_time_data report[ResultBase.get_data_dict_name()] = \ result_utils.group_data_using_report_group(self._data) report_name = self.get_report_file_name(parent_itr_info) # add report name to info report[self._info.dict_name]['resultFile'] = report_name result_utils.generate_report_file(report_name, report) # return status status = {} status[Status.get_verdict_dict_name()] = self._status.verdict status[Status.get_verdict_text_dict_name()] = self._status._verdict_text status[IterationInfo.get_result_file_dict_name()] = report_name return status
def start_next_iteration(self, value, iteration_id): logger.info('start next iteration.') # make sure no active iteration running. if self.is_iteration_running(): logger.warning('Complete iteration call missing for previous iteration.') self.complete_active_iteration() self._active_iteration_info = ActiveIterationInfo(value, iteration_id, self._iterator_param) self._active_iteration_info._start_time = result_utils.get_current_time_string() self._active_iteration_status = ActiveIterationStatus(EnumExecStatus.running) self.commit_active_info_status() logger.debug('start next iteration completed.') logger.log_result_info_status(self._stc_result_object)
def save_active_iteration_data(self): """Convert from Active iteration data to Iteration data """ logger.info('Save active iteration data.') child_data = self.get_from_stc_as_dict(self.stc_property_child_iterator_data) if child_data: self._active_iteration_info.set_data_format(self._active_iteration_info, EnumDataFormat.group) result = self._active_iteration_info.run_time_data result[self.get_data_dict_name()] = result_utils.wrap_data_as_single_group(child_data) else: result = self._active_iteration_info.run_time_data result[Status.get_dict_name()] = self._active_iteration_status.run_time_data self.append_stc_object_collection( self.stc_property_completed_data, json.dumps(result, separators=(',', ':'), sort_keys=False)) logger.debug('Save active iteration data completed.')
def complete(self, force_stop): logger.info('Complete - End iterator.') if self.is_iteration_running(): logger.warning('Complete iteration call missing before end iterator.') self.complete_active_iteration(force_stop) self.load_all_iterator_data() if force_stop is True: self._status.exec_status = EnumExecStatus.stopped else: self._status.exec_status = EnumExecStatus.completed self._status.verdict = EnumVerdict.none self._info.set_data_format(self._info, EnumDataFormat.group) self._info.set_data_class(self._info, EnumDataClass.iterator_result) iteratorData = self._info.run_time_data iteratorData[self._status.dict_name] = self._status.run_time_data allData = self.get_from_stc_collection_property_as_dict(self.stc_property_completed_data) iteratorData[self.get_data_dict_name()] = result_utils.wrap_data_as_single_group(allData) self._stc_result_object.MarkDelete() logger.debug('Complete - End iterator completed.') return iteratorData
def test_group_data_using_report_group(stc, resource_cleanup): data = [] gdata = ru.group_data_using_report_group(data) assert gdata is not None assert gdata[RC.TAG] == RC.ALL_GROUPS assert (RC.CHILDREN in gdata) is True assert len(gdata[RC.CHILDREN]) == 0 data = [] data.append(test_utils.result_group_2_3) data.append(test_utils.dummy_verify_result_failed) data.append(test_utils.result_group_2_1) data.append(test_utils.dummy_verify_result_passed) data.append(test_utils.result_group_5) data.append(test_utils.result_group_2_2) gdata = ru.group_data_using_report_group(data) assert gdata is not None assert gdata[RC.TAG] == RC.ALL_GROUPS assert (RC.CHILDREN in gdata) is True assert len(gdata[RC.CHILDREN]) == 4 cdata0 = gdata[RC.CHILDREN][0] cdata1 = gdata[RC.CHILDREN][1] cdata2 = gdata[RC.CHILDREN][2] cdata3 = gdata[RC.CHILDREN][3] assert (pc.DATA in cdata0) is True assert (pc.DATA in cdata1) is True assert (pc.DATA in cdata2) is True assert (pc.DATA in cdata3) is True data0 = cdata0[pc.DATA] data1 = cdata1[pc.DATA] data2 = cdata2[pc.DATA] data3 = cdata3[pc.DATA] assert len(data0[RC.CHILDREN]) == 1 assert len(data1[RC.CHILDREN]) == 1 assert len(data2[RC.CHILDREN]) == 3 assert len(data3[RC.CHILDREN]) == 1 assert data0[RC.TAG] == "Report Group SUMMARY" assert data1[RC.TAG] == "Report Group GROUP_1" assert data2[RC.TAG] == "Report Group GROUP_2" assert data3[RC.TAG] == "Report Group GROUP_5" assert data0[RC.CHILDREN][0][pc.INFO][pc.REPORT_GROUP] == 'SUMMARY' assert data1[RC.CHILDREN][0][pc.INFO][pc.REPORT_GROUP] == 'GROUP_1' assert data2[RC.CHILDREN][0][pc.INFO][pc.REPORT_GROUP] == 'GROUP_2' assert data2[RC.CHILDREN][1][pc.INFO][pc.REPORT_GROUP] == 'GROUP_2' assert data2[RC.CHILDREN][2][pc.INFO][pc.REPORT_GROUP] == 'GROUP_2' assert data3[RC.CHILDREN][0][pc.INFO][pc.REPORT_GROUP] == 'GROUP_5' text0 = test_utils.dummy_verify_result_passed[pc.INFO][RC.NAME] text1 = test_utils.dummy_verify_result_failed[pc.INFO][RC.NAME] text2 = test_utils.result_group_2_3[pc.INFO][RC.NAME] text3 = test_utils.result_group_2_1[pc.INFO][RC.NAME] text4 = test_utils.result_group_2_2[pc.INFO][RC.NAME] text5 = test_utils.result_group_5[pc.INFO][RC.NAME] assert data0[RC.CHILDREN][0][pc.INFO][RC.NAME] == text0 assert data1[RC.CHILDREN][0][pc.INFO][RC.NAME] == text1 assert data2[RC.CHILDREN][0][pc.INFO][RC.NAME] == text2 assert data2[RC.CHILDREN][1][pc.INFO][RC.NAME] == text3 assert data2[RC.CHILDREN][2][pc.INFO][RC.NAME] == text4 assert data3[RC.CHILDREN][0][pc.INFO][RC.NAME] == text5