chore(test): replace pointless sleeps in billing quota tests with flush#66371
Draft
gantoine wants to merge 1 commit into
Draft
chore(test): replace pointless sleeps in billing quota tests with flush#66371gantoine wants to merge 1 commit into
gantoine wants to merge 1 commit into
Conversation
The 7 `time.sleep(1)` calls before `update_all_orgs_billing_quotas()` were cargo-culted attempts to wait for ClickHouse ingestion, but `_create_event` only batches into an in-memory cache that `sync_execute` flushes itself in the test environment. Make the flush explicit with `flush_persons_and_events()` and drop the dead `import time`, removing ~7s of real wall-time per run. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
Reviews (1): Last reviewed commit: "chore(test): replace pointless sleeps in..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ee/billing/test/test_quota_limiting.pyhad 7time.sleep(1)calls scattered beforeupdate_all_orgs_billing_quotas(). Each one was a cargo-culted attempt to "wait for ClickHouse ingestion" — but they never did anything useful._create_eventonly appends to an in-memory cache; the actual flush to ClickHouse happens insidesync_execute, which already callsflush_persons_and_events()itself in the test environment. The sleeps just burned ~7s of real wall-time per run (plus added flake risk) for no coverage.Changes
time.sleep(1)with an explicitflush_persons_and_events()(the repo's documented visibility mechanism), making the data-availability intent clear instead of timing-dependent.import time.No assertions changed; this is purely a wall-time / flake fix.
How did you test this code?
I'm an agent. I ran the affected suite locally:
Result: 61 passed; the 2 that "failed" are a pre-existing devbox-only environment mismatch (
SITE_URLresolves to the devbox host, so theinstancegroup assertion expectshttp://localhost:8010). They fail identically on unmodifiedmaster, and pass when run withSITE_URL=http://localhost:8010(full suite green, 63/63). Critically, thecurrent_usage == 109assertion (99 base + 10 created events) passes, proving the explicit flush makes the events visible exactly as the sleep was meant to.🤖 Agent context
Autonomy: Fully autonomous
Part of a monorepo test-suite cleanup targeting high CI-wall-time tests. Before changing anything I traced
sync_execute(posthog/clickhouse/client/execute.py) and confirmed it callsflush_persons_and_events()inTESTmode, so the sleeps were provably redundant. No skills were required for this one (pure test-timing fix). Tool: Claude Code (Opus 4.8).Requesting review from: Billing