Пример #1
0
  def test_cumulative_distribution_metric_geometric(self):
    """Test _CumulativeDistributionMetric with geometric bucketer."""
    # Buckets:
    #   [-Inf, 1)
    #   [1, 2)
    #   [2, 4)
    #   [4, 8)
    #   [8, 16)
    #   [16, 32)
    #   [32, 64)
    #   [64, Inf)
    metric = monitor.CumulativeDistributionMetric(
        'name',
        description='test metric',
        bucketer=monitor.GeometricBucketer(
            scale=1.0, growth_factor=2, num_finite_buckets=6),
        field_spec=None)

    metric.add(0)
    metric.add(1)
    metric.add(2)
    metric.add(3)
    metric.add(12)
    metric.add(17)
    metric.add(31)
    metric.add(32.1)
    metric.add(40)
    metric.add(64.1)
    result = monitor.metrics_store().get(metric, None).value

    self.assertListEqual([
        1,
        1,
        2,
        0,
        1,
        2,
        2,
        1,
    ], result.buckets)
Пример #2
0
  def test_cumulative_distribution_metric_fixed(self):
    """Test _CumulativeDistributionMetric with fixed bucketer."""
    # Buckets:
    #   [-Inf, 0.1)
    #   [0.1, 0.2)
    #   [0.2, 0.3)
    #   ...
    #   [1.0, Inf)
    metric = monitor.CumulativeDistributionMetric(
        'name',
        description='test metric',
        bucketer=monitor.FixedWidthBucketer(width=0.1, num_finite_buckets=10),
        field_spec=None)

    metric.add(-1)
    metric.add(0.05)
    metric.add(0.1)
    metric.add(0.15)
    metric.add(0.3)
    metric.add(0.75)
    metric.add(1)
    metric.add(2)

    result = monitor.metrics_store().get(metric, None).value

    self.assertListEqual([
        1,
        1,
        2,
        1,
        0,
        0,
        0,
        0,
        1,
        0,
        0,
        2,
    ], result.buckets)
JOB_TOTAL_FUZZ_TIME = monitor.CounterMetric(
    'task/fuzz/job/total_time',
    description=('The total fuzz time in seconds '
                 '(grouped by job)'),
    field_spec=[
        monitor.StringField('job'),
        monitor.BooleanField('timeout'),
    ],
)

FUZZER_TESTCASE_COUNT_RATIO = monitor.CumulativeDistributionMetric(
    'task/fuzz/fuzzer/testcase_count_ratio',
    bucketer=monitor.FixedWidthBucketer(width=0.05, num_finite_buckets=20),
    description=('Distribution of fuzz task\'s generated testcase '
                 'counts divided by expected testcase counts '
                 '(grouped by fuzzers)'),
    field_spec=[
        monitor.StringField('fuzzer'),
    ],
)

# Global log_error count.
LOG_ERROR_COUNT = monitor.CounterMetric(
    'errors/count',
    description='Error count.',
    field_spec=[
        monitor.StringField('task_name'),
    ])

# Untrusted host metrics.
HOST_INCONSISTENT_COUNT = monitor.CounterMetric(
Пример #4
0
 def test_cumulative_distribution_metric_failure(self):
   self.mock.check_module_loaded.return_value = False
   counter = monitor.CumulativeDistributionMetric(
       'd', 'desc', bucketer=None, field_spec=None)
   counter.add(10)
   self.assertIsInstance(counter, monitor._MockMetric)
Пример #5
0
 def test_cumulative_distribution_metric_success(self):
   self.assertIsInstance(
       monitor.CumulativeDistributionMetric(
           'd', 'desc', bucketer=None, field_spec=None),
       monitor._CumulativeDistributionMetric)