Example #1
0
def get_job_results(proxy, job_id, test_suite, test_case):
    # Look for infrastructure errors and retry if we see them.
    results_yaml = _call_proxy(proxy.results.get_testjob_results_yaml, job_id)
    results = yaml.load(results_yaml, Loader=loader(False))
    for res in results:
        metadata = res['metadata']
        if not 'result' in metadata or metadata['result'] != 'fail':
            continue
        if 'error_type' in metadata and metadata[
                'error_type'] == "Infrastructure":
            print_log(
                "LAVA job {} failed with Infrastructure Error. Retry.".format(
                    job_id))
            return False
        if 'case' in metadata and metadata['case'] == "validate":
            print_log(
                "LAVA job {} failed validation (possible download error). Retry."
                .format(job_id))
            return False

    results_yaml = _call_proxy(proxy.results.get_testcase_results_yaml, job_id,
                               test_suite, test_case)
    results = yaml.load(results_yaml, Loader=loader(False))
    if not results:
        fatal_err("LAVA: no result for test_suite '{}', test_case '{}'".format(
            test_suite, test_case))

    print_log("LAVA: result for test_suite '{}', test_case '{}': {}".format(
        test_suite, test_case, results[0]['result']))
    if results[0]['result'] != 'pass':
        fatal_err("FAIL")

    return True
Example #2
0
def follow_job_execution(proxy, job_id):
    line_count = 0
    finished = False
    last_time_logs = datetime.now()
    while not finished:
        (finished, data) = _call_proxy(proxy.scheduler.jobs.logs, job_id, line_count)
        logs = yaml.load(str(data), Loader=loader(False))
        if logs:
            # Reset the timeout
            last_time_logs = datetime.now()
            for line in logs:
                print("{} {}".format(line["dt"], line["msg"]))

            line_count += len(logs)

        else:
            time_limit = timedelta(minutes=DEVICE_HANGING_TIMEOUT_MIN)
            if datetime.now() - last_time_logs > time_limit:
                print_log("LAVA job {} doesn't advance (machine got hung?). Retry.".format(job_id))
                return False

        # `proxy.scheduler.jobs.logs` does not block, even when there is no
        # new log to be fetched. To avoid dosing the LAVA dispatcher
        # machine, let's add a sleep to save them some stamina.
        time.sleep(LOG_POLLING_TIME_SEC)

    return True
Example #3
0
 def _load_log_from_data(self, data) -> list[str]:
     lines = []
     # When there is no new log data, the YAML is empty
     if loaded_lines := yaml.load(str(data), Loader=loader(False)):
         lines = loaded_lines
         # If we had non-empty log data, we can assure that the device is alive.
         self.heartbeat()
         self.last_log_line += len(lines)
Example #4
0
def follow_job_execution(proxy, job_id):
    line_count = 0
    finished = False
    while not finished:
        (finished, data) = _call_proxy(proxy.scheduler.jobs.logs, job_id,
                                       line_count)
        logs = yaml.load(str(data), Loader=loader(False))
        if logs:
            for line in logs:
                print("{} {}".format(line["dt"], line["msg"]))

            line_count += len(logs)
Example #5
0
def find_lava_error(job) -> None:
    # Look for infrastructure errors and retry if we see them.
    results_yaml = _call_proxy(job.proxy.results.get_testjob_results_yaml,
                               job.job_id)
    results = yaml.load(results_yaml, Loader=loader(False))
    for res in results:
        metadata = res["metadata"]
        find_exception_from_metadata(metadata, job.job_id)

    # If we reach this far, it means that the job ended without hwci script
    # result and no LAVA infrastructure problem was found
    job.status = "fail"
Example #6
0
def get_job_results(proxy, job_id, test_suite):
    # Look for infrastructure errors and retry if we see them.
    results_yaml = _call_proxy(proxy.results.get_testjob_results_yaml, job_id)
    results = yaml.load(results_yaml, Loader=loader(False))
    for res in results:
        metadata = res["metadata"]
        find_exception_from_metadata(metadata, job_id)

    results_yaml = _call_proxy(proxy.results.get_testsuite_results_yaml,
                               job_id, test_suite)
    results: list = yaml.load(results_yaml, Loader=loader(False))
    if not results:
        raise MesaCIException(f"LAVA: no result for test_suite '{test_suite}'")

    for metadata in results:
        test_case = metadata["name"]
        result = metadata["metadata"]["result"]
        print_log(f"LAVA: result for test_suite '{test_suite}', "
                  f"test_case '{test_case}': {result}")
        if result != "pass":
            return False

    return True
Example #7
0
 def _load_log_from_data(self, data) -> list[str]:
     lines = []
     # When there is no new log data, the YAML is empty
     if loaded_lines := yaml.load(str(data), Loader=loader(False)):
         lines = loaded_lines
         self.last_log_line += len(lines)