Beispiel #1
0
 def __getVmkernelLogs(self):
     """Get all vmkernel logs in rootDir
   """
     dirInfo = urlOpen(self._rootDir)
     vmkernelRe = r'<a href=.*>(.*?vmkernel.log)</a>'
     vmkernel_names = re.findall(vmkernelRe, dirInfo, re.MULTILINE)
     for vmkernel_name in vmkernel_names:
         self._vmkernel_logs.append('%s%s' % (self._rootDir, vmkernel_name))
Beispiel #2
0
    def __init__(self, root_dir):
        """Init TestInfo instance, raise exception if file not exist
      """
        self._testinfo_csv_url = os.path.join(root_dir, 'testinfo.csv')
        try:
            self._testinfo = urlOpen(self._testinfo_csv_url, True)
        except:
            raise Exception("Failed to find %s" % self._testinfo_csv_url)

        self._test_result_list = []
        self._non_passed_test_result_list = []
        self._total_tests = 0
        self._failed_tests = 0
Beispiel #3
0
    def parserVmkernelLog(self):
        """Parser vmkernel log, restore useful log
      """
        logger.info("Parsering vmkernel log from %s" % self._rootDir)
        self.__getVmkernelLogs()
        if not self._vmkernel_logs:
            raise Exception("Cannot find *-vmkernel.log in %s" % self._rootDir)

        for vmkernel_log_path in self._vmkernel_logs:
            vmkernel_log = urlOpen(vmkernel_log_path)
            scriptStartedRe = '%s%s\s(.*?)$' % (
                VMKERNEL_LOG_WITH_MATCH_TS_FORMAT_RE, self.TESTESX_START)
            scriptStartedLogs = re.findall(scriptStartedRe, vmkernel_log,
                                           re.DOTALL | re.MULTILINE)

            scriptFinishedRe = '%s%s\s(.*?)$' % (
                VMKERNEL_LOG_WITH_MATCH_TS_FORMAT_RE, self.TESTESX_FINISH)
            scriptFinishedLogs = re.findall(scriptFinishedRe, vmkernel_log,
                                            re.DOTALL | re.MULTILINE)

            for ts, scriptName in scriptStartedLogs:
                info = ExecutionInfo(vmkernel_log_path, scriptName)
                info.updateStartTime(ts)
                self._script_executioninfo_dict[scriptName] = info

            for ts, scriptName in scriptFinishedLogs:
                try:
                    info = self._script_executioninfo_dict[scriptName]
                    info.updateFinishTime(ts)
                except:
                    info = ExecutionInfo(vmkernel_log_path, scriptName)
                    info.updateStartTime('N/A')
                    info.updateFinishTime(ts)
                    self._script_executioninfo_dict[scriptName] = info

        self._script_info_list = self._script_executioninfo_dict.values()
        self._script_info_list = sorted(
            self._script_info_list,
            key=lambda ExecutionInfo: ExecutionInfo._start_time)

        for script_info in self._script_info_list:
            hostName = script_info.getHostName()
            if hostName not in self._host_scripts_dict:
                self._host_scripts_dict[hostName] = []

            self._host_scripts_dict[hostName].append(script_info.getValue())
Beispiel #4
0
    def __init__(self, root_dir):
        """Init TestesxLog instance,
      exception will be raised out if testesx_url doesn't exist
      """
        self._testesx_url = os.path.join(root_dir, TESTESX_DIR, TESTESX_LOG)
        try:
            self._testesx_log = urlOpen(self._testesx_url, True)
        except:
            raise Exception("Failed to find testesx.log in %s" %
                            self._testesx_url)

        self._esx_hostlog_dict = {}
        self._total_line_level_logs = []
        self._test_result_list = []
        self._nimbus = False
        self._total_tests = 0
        self._failed_tests = 0
Beispiel #5
0
    def _parserTestLog(self):
        """Parser test log
      """
        self.__initScriptLocation()
        if self._script_log == NOT_AVALIABLE:
            # Skip parser test log if it's not available
            return

        log_content = urlOpen(self._script_log)
        if not log_content:
            self._scriptInfo.setLogInfo(LOG_FILE_EMPTY)
            return

        log_content_splitted = log_content.split('\n')
        if len(log_content_splitted) <= LINE_LIMIT_FOR_TOTAL_LOG:
            self._scriptInfo.setLogInfo(log_content, totalLog=True)
            return

        self._parserMajorLog(log_content)
Beispiel #6
0
def queryCatInfo(nameSpace, filterMap, orderBy=None,
                 limitDay=None, limit=None, apiVersion=DEFAULT_QUERY_VERSION):
   """Query objs from CAT

   @namespace:  CAT base query info
   @filterMap:  CAT RestAPI filter info
   @orderBy:    CAT query objs order
   @limitDay:   The limit latest days of query objs
   @limit:      The limit number of query objs.
                If limit is None, retrieve all CAT objects based on request
   @apiVersion: The CAT Rest API version, default is v2.0

   @return: A list of CAT Objs, [jsonObjs]

   eg. restAPI URL:
   'https://cat-api.eng.vmware.com/api/v2.0/testrun/?format=json&tester=222
    &limit=10&order_by=-endtime'

   Function Usage:
   queryCatInfo(nameSpace=testrun, filterMap={'tester': 222}, limit=10)
   """

   url = __genCatRequestUrl(nameSpace, filterMap, orderBy, limitDay,
                            limit, apiVersion)
   try:
      return_objects = []
      while True:
         request = urlOpen(url, True, retry=3)
         return_data = json.loads(request)
         next_url = return_data['meta']['next']
         return_objects.extend(return_data['objects'])
         if not next_url:
            break
         elif limit is not None:
            break
         else:
            url = '%s%s' % (CAT_API_URL_BASE, next_url)
      return return_objects
   except Exception as e:
      logger.error("RESTAPI Query action failed. URL: %s\nError Info: %s",
                   url, e)
Beispiel #7
0
    def __initScriptLocation(self):
        try:
            script_dir_info = urlOpen(self._scriptDir)
        except:
            raise Exception("Script log dir %s not exist" % self._scriptDir)

        try:
            report = re.findall(r'<a href=.*>(.*?.tar.gz)</a>',
                                script_dir_info, re.MULTILINE)[0]
            self._bug_report = os.path.join(self._scriptDir, report)
        except:
            self._bug_report = NOT_AVALIABLE

        try:
            scriptlog = re.findall(r'<a href=.*>(.*?.log)</a>',
                                   script_dir_info, re.MULTILINE)[0]
            self._script_log = os.path.join(self._scriptDir, scriptlog)
        except:
            self._script_log = NOT_AVALIABLE

        self._scriptInfo.setBugReport(self._bug_report)
        self._scriptInfo.setBugReport(self._script_log)