def _verifyStats(self, category, success=0, failure=0, retry=0):
    """Verify that the given category has the specified values collected."""
    stats_success, stats_failure, stats_retry = retry_stats.CategoryStats(
        category)

    self.assertEqual(stats_success, success)
    self.assertEqual(stats_failure, failure)
    self.assertEqual(stats_retry, retry)
Beispiel #2
0
def ReportResults(symbols, failed_list):
    """Log a summary of the symbol uploading.

  This has the side effect of fully consuming the symbols iterator.

  Args:
    symbols: An iterator of SymbolFiles to be uploaded.
    failed_list: A filename at which to write out a list of our failed uploads.

  Returns:
    The number of symbols not uploaded.
  """
    upload_failures = []
    result_counts = {
        SymbolFile.INITIAL: 0,
        SymbolFile.UPLOADED: 0,
        SymbolFile.DUPLICATE: 0,
        SymbolFile.ERROR: 0,
    }

    for s in symbols:
        result_counts[s.status] += 1
        if s.status in [SymbolFile.INITIAL, SymbolFile.ERROR]:
            upload_failures.append(s)

    # Report retry numbers.
    _, _, retries = retry_stats.CategoryStats(UPLOAD_STATS)
    if retries:
        logging.warning('%d upload retries performed.', retries)

    logging.info('Uploaded %(uploaded)d, Skipped %(duplicate)d duplicates.',
                 result_counts)

    if result_counts[SymbolFile.ERROR]:
        logging.PrintBuildbotStepWarnings()
        logging.warning('%d non-recoverable upload errors',
                        result_counts[SymbolFile.ERROR])

    if result_counts[SymbolFile.INITIAL]:
        logging.PrintBuildbotStepWarnings()
        logging.warning(
            '%d upload(s) were skipped because of excessive errors',
            result_counts[SymbolFile.INITIAL])

    if failed_list is not None:
        with open(failed_list, 'w') as fl:
            for s in upload_failures:
                fl.write('%s\n' % s.display_path)

    return result_counts[SymbolFile.INITIAL] + result_counts[SymbolFile.ERROR]