Example #1
0
 def testDownloadProtoTrace(self):
   url = trace_downloader.HTML_URL_PREFIX + 'foo/bar/trace.html'
   self._cs_exists.side_effect = lambda x, y: y == 'foo/bar/trace.pb.gz'
   trace_path = trace_downloader.DownloadProtoTrace(url)
   self._cs_get.assert_called_once()
   self.assertEqual(
       trace_path,
       os.path.join(trace_downloader.DEFAULT_TRACE_DIR, 'foo_bar_trace.pb.gz'))
def ValidateTBMv3Metric(args):
    reader = csv.DictReader(open(args.trace_links_csv_path))
    debug_info_for_failed_comparisons = []

    for trace_info in reader:
        bot = trace_info['Bot']
        benchmark = trace_info['Benchmark']
        html_trace_url = trace_info['Trace Link']
        html_trace = trace_downloader.DownloadHtmlTrace(
            html_trace_url, download_dir=args.traces_dir)
        proto_trace = trace_downloader.DownloadProtoTrace(
            html_trace_url, download_dir=args.traces_dir)
        tbmv3_out_filename = RunTBMv3Metric(args.tbmv3_name, proto_trace,
                                            args.traces_dir,
                                            args.trace_processor_path)
        tbmv3_metric = CalculateTBMv3Metric(args.tbmv3_histogram,
                                            tbmv3_out_filename)
        tbmv2_out_filename = RunTBMv2Metric(args.tbmv2_name, html_trace,
                                            args.traces_dir)
        tbmv2_metric = CalculateTBMv2Metric(args.tbmv2_histogram,
                                            tbmv2_out_filename)
        if len(tbmv2_metric) == 0:
            logging.warning(
                'TBMv2 metric is empty for bot: %s, benchmark: %s' %
                (bot, benchmark))
        if len(tbmv3_metric) == 0:
            logging.warning(
                'TBMv3 metric is empty for bot: %s, benchmark: %s' %
                (bot, benchmark))
        if tbmv3_metric != tbmv2_metric:
            logging.warning(
                'TBMv3 differs from TBMv2 for bot: %s, benchmark: %s' %
                (bot, benchmark))
            debug_info_for_failed_comparisons.append({
                'tbmv3 json': tbmv3_out_filename,
                'tbmv2 json': tbmv2_out_filename,
                'html trace': html_trace,
                'proto trace': proto_trace,
                'bot': bot,
                'benchmark': benchmark
            })
    if len(debug_info_for_failed_comparisons) == 0:
        print 'SUCCESS!'
        return 0
    print 'TBMv3 validation failed for traces:'
    for filenames in debug_info_for_failed_comparisons:
        print(('\tBot: {bot}\n\tBenchmark: {benchmark}\n'
               '\ttbmv3 json: {tbmv3 json}\n\ttbmv2 json: {tbmv2 json}\n'
               '\thtml trace: {html trace}\n\tproto trace: {proto trace}\n'
               ).format(**filenames))
    return 1
Example #3
0
def CreateTraceInfoFromCsvRow(row, traces_dir):
    message = 'Fetching traces...'
    PrintNoLn(message)
    html_trace_url = row['Trace Link']
    html_trace = trace_downloader.DownloadHtmlTrace(html_trace_url,
                                                    download_dir=traces_dir)
    proto_trace = trace_downloader.DownloadProtoTrace(html_trace_url,
                                                      download_dir=traces_dir)

    trace_info = TraceInfo(html_trace, proto_trace)
    trace_info.trace_metadata = {
        'Bot': row['Bot'],
        'Benchmark': row['Benchmark'],
        'Cloud Trace URL': html_trace_url
    }
    CursorErase(len(message))
    return trace_info
def Main():
    logging.basicConfig(level=logging.WARN)
    parser = argparse.ArgumentParser(
        description='Downloads the proto trace for an cloud storage html '
        'trace url.')
    parser.add_argument('html_trace_url',
                        type=str,
                        help='Looks like %s' % EXAMPLE_TRACE)
    parser.add_argument('--download-dir',
                        type=str,
                        default=trace_downloader.DEFAULT_TRACE_DIR,
                        help='Directory to download the traces to.')
    args = parser.parse_args()
    if args.html_trace_url.endswith('/'):
        raise Exception('This is a directory, not a file url')
    path = trace_downloader.DownloadProtoTrace(args.html_trace_url,
                                               download_dir=args.download_dir)
    print('Downloaded to %s' % os.path.relpath(path))