test: bound the ClickHouse availability probe and report why it failed - #113
Conversation
The integration suite decides whether ClickHouse is reachable by running a single probe query with no deadline. An unreachable host normally refuses the connection immediately, but a half-started server can accept the socket and never answer; the probe would then block the suite's beforeAll indefinitely and the file would surface as a wall of per-test timeouts naming neither ClickHouse nor the URL it tried. The probe now carries an explicit 10s deadline, so an unanswered connection resolves to a definite "unavailable" verdict instead of hanging. It also returns the reason it failed, and the required-service error repeats that reason alongside the URL, so a CI failure says whether the service refused the connection, timed out, or answered incorrectly. Behaviour is otherwise unchanged: with ClickHouse reachable every test runs as before, and when it is absent without the service being required the suite still skips rather than failing, so a developer with no local ClickHouse is unaffected.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 58 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Comment |
Problem
test/clickhouse-schema.integration.test.tsdecides whether ClickHouse is reachable with a single probe query that has no deadline.An unreachable host normally refuses the connection immediately, so this usually resolves fast. But a half-started server can accept the socket and never answer. In that case the probe blocks the suite's
beforeAllindefinitely, and the file surfaces as a wall of per-test timeouts that name neither ClickHouse nor the URL that was tried — the reader has to guess that the database was the problem at all.Change
The probe now carries an explicit 10s deadline via
AbortSignal.timeout, so an unanswered connection resolves to a definite "unavailable" verdict instead of hanging.It also returns why it failed, and the required-service error repeats that reason next to the URL. A CI failure now distinguishes "the service refused the connection" from "it timed out" from "it answered incorrectly":
Nothing else changes. With ClickHouse reachable, all twelve tests run exactly as before. With it absent and
CLICKHOUSE_REQUIREDunset, the suite still skips rather than failing, so a developer without a local ClickHouse is unaffected.Scope — what this does NOT do
This does not fix the intermittent timeouts occasionally seen in this file on CI. Those are a separate, unrelated failure: a ClickHouse HTTP request occasionally never receives its response, and the client's own 30s
request_timeoutis not enforced in this runtime, so the request hangs and whichever test owns it dies at the default per-test timeout. That is being tracked separately.This PR is deliberately not an attempt at that. It hardens a different path — service genuinely unreachable — which today would hang rather than fail cleanly. It is worth doing on its own merits, and it is not evidence that the intermittent failure is addressed.
Verification
Run against a real
clickhouse-server:24.8, on a fresh instance:ECONNREFUSEDtsc --noEmitclean,biome lintclean. One file, 27 insertions / 7 deletions.