def initCatRawInfo(self): super(Testrun, self).initCatRawInfo() # Initialize root data self._is_valid = True self._test_result_log = None self._test_type = GENERAL self._total_tests = 0 self._failed_tests = 0 self._tester_id = self.getIdFromCatObj('tester') self._workunit_id = self.getIdFromCatObj('workunit') self._deliverable_id = self.getIdFromCatObj('sitedeliverable', 'deliverable') self._machine_ids = self.getIdsFromCatObj('machines', 'machine') self._result = self.getValueFromCatObj('result') self._result_dir = self.getValueFromCatObj('resultsdir') self._start_time = self.getValueFromCatObj('starttime') self._end_time = self.getValueFromCatObj('endtime') if 'PA' in self._result_dir: self._http_result_dir = '%s%s' % (CAT_PA_RESULT_BASE, self._result_dir) else: self._http_result_dir = '%s%s' % (CAT_WDC_RESULT_BASE, self._result_dir) if self._result: self._run_time = getExecutionTime(self._start_time, self._end_time, DATE_FORMAT_CAT) if self._result == RESULT_INVALID_INFRA: self._result = RESULT_INVALID else: self._result = KW_STILL_RUNNING self._run_time = KW_STILL_RUNNING self._end_time = KW_STILL_RUNNING self._run_time_in_minutes = getTimeDeltaInMinutes(self._run_time) self._ignored = self.getValueFromCatObj('ignored') self._triage_time = self.getValueFromCatObj('triagetime') self._bug_objs = self._catObj['bugs'] self._ticket_objs = self._catObj['helpnows'] self._need_triage = False if self._run_time != KW_STILL_RUNNING and self._result != RESULT_PASS: if not self._triage_time: self._need_triage = True for sub_id in [self._workunit_id, self._deliverable_id]: if sub_id is None: # If sub id is None, this testrun is invalid as its RestAPI # information is not entire self._is_valid = False return # Initialize sub data Testrun._addSubData(Workunit, self._workunit_id) Testrun._addSubData(Deliverable, self._deliverable_id) for machine_id in self._machine_ids: Testrun._addSubData(Machine, machine_id) for bug_obj in self._bug_objs: Testrun._addSubData('bug_obj', bug_obj['id'], bug_obj) for ticket_obj in self._ticket_objs: Testrun._addSubData('ticket_obj', ticket_obj['id'], ticket_obj)
def getBuildType(self): assert (self.isFullyInitialzied()) return self._bldType """Below code is for test purpose """ if __name__ == '__main__': from Common.cat.lib.catApi import getTotalQueryRequestTimes from Common.utils.commonUtil import getCurrentDate, getExecutionTime start = getCurrentDate() builderIds = [105, 107, 3107, 2216] builderDatas = [] for builderId in builderIds: print('Working for builder %s' % builderId) builderData = Builder(builderId) builderDatas.append(builderData) builderData.initCatRawInfo() Builder.initSubDataMap() for builder in builderDatas: builder.initReadableInfo() #print(builder.getDetailedData()) print(builder.getBranchName()) end = getCurrentDate() print('Cost Time: %s' % getExecutionTime(start, end)) print("Total CAT request: %s" % getTotalQueryRequestTimes())
printOutput(queryCatInfo('builder', {'id': '107'}), 'CAT Builder Info') printOutput(queryCatInfo('machine', {'id': '3196'}), 'CAT Machine Info') data = queryCatInfo('testrun', filterMap={'deliverables__build__branch__in': 'vmcore-main', 'area__id__in': '2'}, orderBy='-endtime') printOutput(data, 'CAT testrun info from CAT without limited') data = queryCatInfo('testrun', filterMap={'deliverables__build__branch__in': 'vmcore-main', 'area__id__in': '13'}, orderBy='-endtime', limitDay=3, limit=200) printOutput(data, 'CAT testrun info with limitDay=3, limit=200') data = queryCatInfo('testrun', filterMap={'deliverables__build__branch__in': 'vmcore-main', 'area__id__in': '13'}, orderBy='-endtime', limitDay=1, limit=500) printOutput(data, 'CAT testrun info with limitDay=1, limit=500 ') printOutput(queryCatInfo('testrun', filterMap={'deliverables__id__in': '7353360'}), 'Query testrun info with default limit number') printOutput(queryCatInfo('testrun', filterMap={'deliverables__id__in': '7353360'}, total=True), 'Query all testruns info') printOutput(queryCatInfo('machine', {'id': 0}), "Negative Test: Object Not Exist") end = getCurrentDate() print getExecutionTime(start, end)