Skip to content

Commit

Permalink
integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav1dde committed Aug 5, 2024
1 parent 69d4d24 commit de417cc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
7 changes: 5 additions & 2 deletions relay-server/src/services/metrics/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,16 @@ impl AggregatorService {
config: AggregatorServiceConfig,
receiver: Option<Recipient<FlushBuckets, NoResponse>>,
) -> Self {
let aggregator = aggregator::Aggregator::named(name, config.aggregator);
Self {
receiver,
state: AggregatorState::Running,
max_total_bucket_bytes: config.max_total_bucket_bytes,
aggregator: aggregator::Aggregator::named(name, config.aggregator),
flush_interval_ms: config.flush_interval_ms,
can_accept_metrics: Arc::new(AtomicBool::new(true)),
can_accept_metrics: Arc::new(AtomicBool::new(
!aggregator.totals_cost_exceeded(config.max_total_bucket_bytes),
)),
aggregator,
}
}

Expand Down
23 changes: 23 additions & 0 deletions tests/integration/test_healthchecks.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,29 @@ def test_readiness_depends_on_aggregator_being_full(mini_sentry, relay):
assert response.status_code == 503


def test_readiness_depends_on_aggregator_being_full_after_metrics(mini_sentry, relay):
relay = relay(
mini_sentry,
{"aggregator": {"max_total_bucket_bytes": 1}},
)

metrics_payload = f"transactions/foo:42|c\ntransactions/bar:17|c"
relay.send_metrics(42, metrics_payload)

for _ in range(100):
response = wait_get(relay, "/api/relay/healthcheck/ready/")
print(response, response.status_code)
if response.status_code == 503:
error = str(mini_sentry.test_failures.pop())
assert "Health check probe 'aggregator'" in error
error = str(mini_sentry.test_failures.pop())
assert "aggregator limit exceeded" in error
return
time.sleep(0.1)

assert False, "health check never failed"


def test_readiness_disk_spool(mini_sentry, relay):
try:
temp = tempfile.mkdtemp()
Expand Down

0 comments on commit de417cc

Please sign in to comment.