示例#1
0
def ProcessTestResult(test_result, upload_bucket, results_label,
                      run_identifier, test_suite_start, should_compute_metrics,
                      max_num_values, test_path_format, trace_processor_path,
                      enable_tbmv3, fetch_power_profile):
    ConvertProtoTraces(test_result, trace_processor_path)
    AggregateTBMv2Traces(test_result)
    if enable_tbmv3:
        AggregateTBMv3Traces(test_result)
    if upload_bucket is not None:
        UploadArtifacts(test_result, upload_bucket, run_identifier)

    if should_compute_metrics:
        test_result['_histograms'] = histogram_set.HistogramSet()
        compute_metrics.ComputeTBMv2Metrics(test_result)
        if enable_tbmv3:
            compute_metrics.ComputeTBMv3Metrics(test_result,
                                                trace_processor_path,
                                                fetch_power_profile)
        ExtractMeasurements(test_result)
        num_values = len(test_result['_histograms'])
        if max_num_values is not None and num_values > max_num_values:
            logging.error('%s produced %d values, but only %d are allowed.',
                          test_result['testPath'], num_values, max_num_values)
            util.SetUnexpectedFailure(test_result)
            del test_result['_histograms']
        else:
            AddDiagnosticsToHistograms(test_result, test_suite_start,
                                       results_label, test_path_format)
示例#2
0
def _RunMetric(test_result, metrics):
    html_trace = test_result['outputArtifacts'][HTML_TRACE_NAME]
    html_local_path = html_trace['filePath']
    html_remote_url = html_trace.get('viewUrl')

    # The timeout needs to be coordinated with the Swarming IO timeout for the
    # task that runs this code. If this timeout is longer or close in length
    # to the swarming IO timeout then we risk being forcibly killed for not
    # producing any output. Note that this could be fixed by periodically
    # outputting logs while waiting for metrics to be calculated.
    TEN_MINUTES = 60 * 10
    mre_result = metric_runner.RunMetricOnSingleTrace(
        html_local_path,
        metrics,
        canonical_url=html_remote_url,
        timeout=TEN_MINUTES,
        extra_import_options={'trackDetailedModelStats': True})

    if mre_result.failures:
        util.SetUnexpectedFailure(test_result)
        for f in mre_result.failures:
            logging.error('Failure recorded for test %s: %s',
                          test_result['testPath'], f)

    return mre_result.pairs.get('histograms', [])
示例#3
0
def ComputeTBMv2Metrics(test_result):
    """Compute metrics on aggregated traces in parallel.

  For each test run that has an aggregate trace and some TBMv2 metrics listed
  in its tags, compute the metrics and return the list of all resulting
  histograms.
  """
    artifacts = test_result.get('outputArtifacts', {})

    if test_result['status'] == 'SKIP':
        return

    metrics = [
        tag['value'] for tag in test_result.get('tags', [])
        if tag['key'] == 'tbmv2'
    ]
    if not metrics:
        logging.debug('%s: No TBMv2 metrics specified.',
                      test_result['testPath'])
        return

    if HTML_TRACE_NAME not in artifacts:
        util.SetUnexpectedFailure(test_result)
        logging.error('%s: No traces to compute metrics on.',
                      test_result['testPath'])
        return

    trace_size_in_mib = (
        os.path.getsize(artifacts[HTML_TRACE_NAME]['filePath']) / (2**20))
    # Bails out on traces that are too big. See crbug.com/812631 for more
    # details.
    if trace_size_in_mib > 400:
        util.SetUnexpectedFailure(test_result)
        logging.error('%s: Trace size is too big: %s MiB',
                      test_result['testPath'], trace_size_in_mib)
        return

    start = time.time()
    test_result['_histograms'].ImportDicts(_RunMetric(test_result, metrics))
    logging.info('%s: Computing TBMv2 metrics took %.3f seconds.' %
                 (test_result['testPath'], time.time() - start))
示例#4
0
def ComputeTBMv2Metrics(test_result):
    """Compute metrics on aggregated traces in parallel.

  For each test run that has an aggregate trace and some TBMv2 metrics listed
  in its tags, compute the metrics and return the list of all resulting
  histograms. Note: the order of histograms in the results may be different
  from the order of tests in intermediate_results.
  """
    artifacts = test_result.get('outputArtifacts', {})
    # TODO(crbug.com/981349): If metrics have already been computed in
    # Telemetry, we read it from the file. Remove this branch after Telemetry
    # does not compute metrics anymore.
    if HISTOGRAM_DICTS_FILE in artifacts:
        with open(artifacts[HISTOGRAM_DICTS_FILE]['filePath']) as f:
            test_result['_histograms'].ImportDicts(json.load(f))
        del artifacts[HISTOGRAM_DICTS_FILE]
        return

    if test_result['status'] == 'SKIP':
        return

    if (HTML_TRACE_NAME not in artifacts
            or not any(tag['key'] == 'tbmv2'
                       for tag in test_result.get('tags', []))):
        return

    trace_size_in_mib = (
        os.path.getsize(artifacts[HTML_TRACE_NAME]['filePath']) / (2**20))
    # Bails out on traces that are too big. See crbug.com/812631 for more
    # details.
    # TODO(crbug.com/1010041): Return a non-zero exit code in this case.
    if trace_size_in_mib > 400:
        util.SetUnexpectedFailure(test_result)
        logging.error('%s: Trace size is too big: %s MiB',
                      test_result['testPath'], trace_size_in_mib)
        return

    test_result['_histograms'].ImportDicts(_RunMetric(test_result))