@@ -491,25 +491,44 @@ function generateK8sEventLogs(count: number = 20): string {
491491 return rows . join ( ',\n' ) ;
492492}
493493
494- const CLICKHOUSE_READY_TIMEOUT_SECONDS = 30 ;
494+ // CI can be slower, so use a longer timeout
495+ const CLICKHOUSE_READY_TIMEOUT_SECONDS = parseInt (
496+ process . env . E2E_CLICKHOUSE_READY_TIMEOUT || '60' ,
497+ 10 ,
498+ ) ;
495499
496500async function waitForClickHouse (
497501 client : ReturnType < typeof createClickHouseClient > ,
498502) : Promise < void > {
499503 console . log ( ' Waiting for ClickHouse to be ready...' ) ;
504+ console . log (
505+ ` Attempting connection to: ${ DEFAULT_CONFIG . host } (user: ${ DEFAULT_CONFIG . user } )` ,
506+ ) ;
507+
508+ let lastError : Error | null = null ;
500509
501510 for ( let attempt = 0 ; attempt < CLICKHOUSE_READY_TIMEOUT_SECONDS ; attempt ++ ) {
502511 try {
503512 await client . query ( 'SELECT 1' ) ;
504513 console . log ( ' ClickHouse is ready' ) ;
505514 return ;
506- } catch {
515+ } catch ( error ) {
516+ lastError = error instanceof Error ? error : new Error ( String ( error ) ) ;
517+ if ( attempt % 5 === 0 ) {
518+ // Log every 5 seconds
519+ console . log (
520+ ` Still waiting... (${ attempt } /${ CLICKHOUSE_READY_TIMEOUT_SECONDS } s)` ,
521+ ) ;
522+ }
507523 await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
508524 }
509525 }
510526
527+ console . error ( ' Last connection error:' , lastError ?. message ) ;
511528 throw new Error (
512- `ClickHouse not ready after ${ CLICKHOUSE_READY_TIMEOUT_SECONDS } seconds` ,
529+ `ClickHouse not ready after ${ CLICKHOUSE_READY_TIMEOUT_SECONDS } seconds. ` +
530+ `Host: ${ DEFAULT_CONFIG . host } . ` +
531+ `Last error: ${ lastError ?. message || 'Unknown' } ` ,
513532 ) ;
514533}
515534
0 commit comments