Repository navigation
test(usage): wait for schema readiness before E2E queries - #13506
Conversation
Greptile SummaryThis PR stabilizes usage-query E2E tests by waiting for the authenticated usage health endpoint to report schema readiness before running the existing query assertions.
Confidence Score: 5/5The PR appears safe to merge because the readiness probe matches the health endpoint contract and preserves existing test behavior. No blocking or actionable new issue remains; temporary not-ready responses are retried within the established eventual-assertion helper, while disabled usage configurations continue to skip the affected tests. Important Files Changed
Reviews (3): Last reviewed commit: "Merge branch 'main' into fix/usage-e2e-s..." | Re-trigger Greptile |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Summary
/health/usagebefore the six usage-query E2E tests run.assertEventuallyhelper (60-second timeout, 500ms polling) and reuse onehealth.readkey across probes.Root cause
Failing PostgreSQL (dedicated) / Usage job
All six failures were HTTP 503 instead of the expected 200/400. The API was serving requests while ClickHouse initialization was still retrying (
Usage schema setup failed. Retrying (1/2)...). Usage routes correctly returnedgeneral_usage_not_readyduring that window. HTTP/health/versionreadiness does not guarantee that the usage schema exists.The usage health endpoint checks the event, gauge, and daily schema through the real storage connection. Polling it establishes the test prerequisite without retrying the requests/assertions under test, adding an unconditional sleep, or changing application startup behavior.
Local E2E verification
Ran against an isolated Docker stack with dedicated PostgreSQL, Redis, ClickHouse 26.4.3, and the real API/worker. Source and locked Composer dependencies were from
mainat6c9ce08306plus this test-only change.Usage storage must be ready before testing usage queries_APP_USAGE_STATS=disabledon API and test process, ClickHouse stoppedgit diff --checkCommands used for the suites:
Cold-start verification used only disposable project-scoped containers/volumes: remove the test ClickHouse container/volume, restart the API, start ClickHouse after 8 seconds, and launch the suite as soon as API health passes. The baseline ran the unchanged test file from
HEAD; the fixed runs used this branch. No production code was patched or mocked.Local runtime: ARM64 PHP 8.5.9 (CI used PHP 8.5.10). The cached development image has MongoDB extension 2.3.3 rather than the lockfile's required 2.1.x, so dependency installation used
--ignore-platform-req=ext-mongodb; MongoDB was not used in these PostgreSQL tests.