Пример #1
0
def queryTask(config, device_id, project_code, test_type, branch):
    try:
        with rabbitpy.Connection('amqp://{}:{}@{}:{}/%2F'.format(
                g_username, g_password, config["rabbitMQ_address"],
                config["rabbitMQ_port"])) as conn:
            with conn.channel() as channel:
                # dedicated queue would be consumed firstly
                q = rabbitpy.Queue(channel, device_id)
                q.durable = True
                q.declare()
                if q.__len__() > 0:
                    msg = q.get()
                    msg.ack()
                    return json.loads(msg.body)

                # common queue would be consumed according to priority
                for t in test_type:
                    for b in branch:
                        q = rabbitpy.Queue(
                            channel, '{}_{}_{}'.format(project_code, b, t))
                        q.durable = True
                        q.declare()
                        if q.__len__() > 0:
                            msg = q.get()
                            msg.ack()
                            return json.loads(msg.body)
    except:
        LOGGER.critical(traceback.format_exc())
        return None
Пример #2
0
 def is_new_bug(self, work, run):
     try:
         # one run could contain multiple run results, due to failrerun functionality
         log_cur = self.log_structure(work, self.error_log)
         b_new, pretty_result = self._is_new_bug(log_cur, work, run)
         LOGGER.info('{} is {}'.format(work.name, pretty_result))
         return b_new
     except:
         LOGGER.critical(traceback.format_exc())
         return True
Пример #3
0
 def __get_ip_address():
     ip_address = None
     get_ip_process = subprocess.Popen('ipconfig -all',
                                       stdout=subprocess.PIPE)
     tmp_output = get_ip_process.communicate()[0]
     search_result = re.search(
         'IPv4 Address(. )*: (\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})',
         tmp_output)
     if search_result is not None:
         ip_address = search_result.group(2)
     else:
         ip_address = 'localhost'
         LOGGER.critical(
             'ERROR! Cannot find host IP!!!, using LOCALHOST')
     return ip_address
Пример #4
0
def getMergeSlotInfo(change_id, bundle_id_list):
    LOGGER.critical("change id: {}".format(change_id))
    _d = dict()
    _d["change_id"] = change_id
    if '/' in change_id:
        change_id = change_id.split('/')[0]

    query_url = "https://sample.com/a/changes/%s/detail/?o=CURRENT_REVISION&o=CURRENT_COMMIT" % change_id
    rc = gerritRequest(query_url)
    _d["subject"] = rc['subject']
    if 'Merge' in rc['subject']:
        _ls = rc["revisions"][rc["revisions"].keys()[0]]["commit"]["parents"]
        for _i in _ls:
            print _i["subject"], _i["commit"]
            if isMergeSlot(_i["subject"]):
                getParentInfo(str(_i["commit"]), bundle_id_list, _d, True)
            else:
                getParentInfo(str(_i["commit"]), bundle_id_list, _d, False)

        bundle_id_list.append(_d)
    return
Пример #5
0
    def __init__(self, scenario, dut):
        self.scenario_name = scenario.scenario_name
        self.project_code = dut.project_code
        # self.platform = dut.platform # whether use the one of scenario?
        self.platform = scenario.platform
        self.sub_platform = dut.sub_platform
        self.subversion = scenario.subversion
        self.build = dut.task_variable.get("build", "NA")
        self.component = dut.task_variable.get("component", "NA")
        if self.build == 'NA':
            self.build = dut.task_variable.get("Build_No_Variable", "NA")

        self.patch = dut.task_variable.get("patchset", "NA")
        self.manifest_id = dut.task_variable.get("manifest_id", "NA")

        if self.manifest_id != 'NA':
            self.gerrit_link = 'https://icggerrit.corp.sample.com/#/x/hydra-ci/iset/manifestvotes&manifest_id='.format(
                self.manifest_id)
        elif self.patch != 'NA':
            self.gerrit_link = 'https://icggerrit.corp.sample.com/#/c/{}/'.format(
                self.patch)
        else:
            self.gerrit_link = 'NA'

        self.owner = dut.task_variable.get("owner", "NA")
        self.author_email = dut.task_variable.get("author_email", "")
        if self.author_email:
            scenario.mail_list.append(self.author_email)

        if dut.task_variable.get("email", ""):
            scenario.mail_list.append(dut.task_variable["email"])

        self.os = dut.task_variable.get("os", "NA")
        self.test_type = scenario.test_type
        self.report_ww = dut.task_variable.get(
            "report_ww", "NA")  # [year, ww, stackIndex, 2018WW2_0]
        self.fail_case_list = []
        self.bCancelled = False
        self.bEnv_failure = False
        self.cases = []
        self.server_config = dut.server_config
        self.dut_name = dut.dut_name
        self.dut_ip = dut.dut_ip
        self.total_count = 0
        self.non_gating_count = 0
        self.fail_count = 0
        self.pass_count = 0
        self.not_run_count = 0
        self.repeat_pass_count = 0
        self.start_time = time.ctime(
            dut.task_variable.get("start", time.time()))
        self.finish_time = time.ctime(
            dut.task_variable.get("finish", time.time()))
        self.patch_detail = 'NA'
        self.subject = 'NA'
        self.email = 'NA'
        self.artifacts_path = 'NA'
        self.dut_info = ''
        self.log_path = scenario.base_log_path if scenario.base_log_path else WIN_LOG_ROOT_PATH
        self.merge_slot_info = []
        self.merge_slot_info_str = ''
        self.user = dut.task_variable.get(
            "username", "NA") + ';' + dut.task_variable.get("killer", "")
        self.run_id = str(uuid.uuid1()).split('-')[0]

        html_path = '{}_{}_{}_{}.html'.format(self.build, self.dut_name,
                                              self.scenario_name,
                                              dut.task_variable['UUID'])
        self.html_full_path = os.path.join(
            dut.server_config["base_share_path"], 'html', html_path)

        try:
            self.critical_issues = repr(
                scenario.bsod_dict) if scenario.bsod_dict else ''
        except:
            LOGGER.critical(traceback.format_exc())

        try:
            _t = dut.staf_handle.get_dut_info(dut)
            if _t:
                for key, value in _t.items():
                    self.dut_info += "{} : {} </br>".format(key, value)
        except:
            LOGGER.error(traceback.format_exc())

        try:
            self.fecthPatchInfo()
        except:
            LOGGER.error(traceback.format_exc())

        _last_cmd = ''

        if dut.task_variable.get("Interval_Cancel", False):
            self.bCancelled = True

        for case in scenario.cases():
            self.total_count += 1
            # self.cases.append(case)
            case.pretty_result = case.result()

            if case.pretty_result == 'running':
                case.pretty_result = 'fail'

            if case.pretty_result == 'fail' and case.gating:
                self.fail_count += 1
                self.fail_case_list.append(case.name)