示例#1
0
def test_metrics_collector_adds_events_when_flushing_accumulated():
    mc = MockMetricsCollector()
    mc.add_event(MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0)
    mc.flush_accumulated()

    assert len(mc.events) == 1
    assert mc.events[0] == (MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0)
示例#2
0
def test_metrics_collector_accumulate_same_events_into_one():
    mc = MockMetricsCollector()
    mc.add_event(MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0)
    mc.add_event(MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 2.0)
    mc.flush_accumulated()

    assert len(mc.events) == 1
    assert mc.events[0] == (MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 5.0)
示例#3
0
def test_metrics_collector_separates_different_events():
    mc = MockMetricsCollector()
    mc.add_event(MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0)
    mc.add_event(MetricsName.BACKUP_ORDERED_BATCH_SIZE, 2.0)
    mc.flush_accumulated()

    assert len(mc.events) == 2
    assert (MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0) in mc.events
    assert (MetricsName.BACKUP_ORDERED_BATCH_SIZE, 2.0) in mc.events
示例#4
0
def test_metrics_collector_resets_accumulated_after_flush():
    mc = MockMetricsCollector()
    mc.add_event(MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0)
    mc.flush_accumulated()
    mc.add_event(MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 2.0)
    mc.flush_accumulated()

    assert len(mc.events) == 2
    assert mc.events[0] == (MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 3.0)
    assert mc.events[1] == (MetricsName.BACKUP_THREE_PC_BATCH_SIZE, 2.0)
def test_metrics_collector_dont_add_events_when_accumulating():
    mc = MockMetricsCollector()

    mc.add_event(gen_metrics_name(), 3.0)

    assert mc.events == []