def test_normal_rate_long_duration(self) -> None: # 1 event/s for 3m, 9m durations histograms = [] for _ in range(6 * 3): hist = DurationsHistogram(bucket_size=10) hist.incr(duration=9 * 60, count=10) histograms.append(hist) durations = BucketedDurationsHistograms(timestamp=0, width=10, histograms=histograms) assert excessive_event_duration(project_id=1, durations=durations)
def test_low_rate_long_duration(self) -> None: # 1 event/m for 3m, 9m durations histograms = [] durations = None for i in range(6 * 3): hist = DurationsHistogram(bucket_size=10) if i % 6 == 0: hist.incr(duration=9 * 60, count=1) histograms.append(hist) durations = BucketedDurationsHistograms(timestamp=0, width=10, histograms=histograms) assert durations is not None assert not excessive_event_duration(project_id=1, durations=durations)
def test_no_durations(self) -> None: durations = BucketedDurationsHistograms( timestamp=0, width=10, histograms=[DurationsHistogram()] * 5 * 6 ) assert not excessive_event_duration(project_id=1, durations=durations)