@@ -156,10 +156,10 @@ class RobustWebSocket:
156156 _num_reconnections : int = 0
157157 auto_reconnect : bool = True
158158
159- def __post_init__ (self ):
159+ def __post_init__ (self ) -> None :
160160 self ._configure_websocket_events ()
161161
162- def _configure_websocket_events (self ):
162+ def _configure_websocket_events (self ) -> None :
163163 with log_context (
164164 logging .INFO ,
165165 msg = "handle websocket message (set to --log-cli-level=DEBUG level if you wanna see all of them)" ,
@@ -172,10 +172,11 @@ def on_framereceived(payload: str | bytes) -> None:
172172 ctx .logger .debug ("⬆️ Frame received: %s" , payload )
173173
174174 def on_close (_ : WebSocket ) -> None :
175- ctx .logger .warning ("⚠️ WebSocket closed." )
176175 if self .auto_reconnect :
177176 ctx .logger .warning ("⚠️ WebSocket closed. Attempting to reconnect..." )
178177 self ._attempt_reconnect (ctx .logger )
178+ else :
179+ ctx .logger .warning ("⚠️ WebSocket closed." )
179180
180181 def on_socketerror (error_msg : str ) -> None :
181182 ctx .logger .error ("❌ WebSocket error: %s" , error_msg )
@@ -448,17 +449,20 @@ def __call__(self, message: str) -> bool:
448449 f"{ json .dumps ({k : round (v , 2 ) for k , v in self ._current_progress .items ()})} " ,
449450 )
450451
451- return self .got_expected_node_progress_types () and all (
452+ progress_completed = self .got_expected_node_progress_types () and all (
452453 round (progress , 1 ) == 1.0
453454 for progress in self ._current_progress .values ()
454455 )
456+ if progress_completed :
457+ self .logger .info ("✅ Service start completed successfully!! ✅" )
455458
456459 time_since_last_progress = datetime .now (UTC ) - self ._last_progress_time
457460 if time_since_last_progress > self .max_idle_timeout :
458461 self .logger .warning (
459462 "⚠️ %s passed since the last received progress message. "
460- "The service might be stuck, or we missed some messages ⚠️" ,
463+ "The service %s might be stuck, or we missed some messages ⚠️" ,
461464 time_since_last_progress ,
465+ self .node_id ,
462466 )
463467 return True
464468
@@ -569,6 +573,9 @@ class ServiceRunning:
569573 iframe_locator : FrameLocator | None
570574
571575
576+ _MIN_TIMEOUT_WAITING_FOR_SERVICE_ENDPOINT : Final [int ] = 30 * SECOND
577+
578+
572579@contextlib .contextmanager
573580def expected_service_running (
574581 * ,
@@ -602,7 +609,10 @@ def expected_service_running(
602609 api_request_context = page .request ,
603610 product_url = product_url ,
604611 is_legacy_service = is_service_legacy ,
605- timeout = min (timeout - int (elapsed_time .total_seconds () * SECOND ), 5 * SECOND ),
612+ timeout = max (
613+ timeout - int (elapsed_time .total_seconds () * SECOND ),
614+ _MIN_TIMEOUT_WAITING_FOR_SERVICE_ENDPOINT ,
615+ ),
606616 )
607617 service_running .iframe_locator = page .frame_locator (
608618 f'[osparc-test-id="iframe_{ node_id } "]'
@@ -640,7 +650,10 @@ def wait_for_service_running(
640650 api_request_context = page .request ,
641651 product_url = product_url ,
642652 is_legacy_service = is_service_legacy ,
643- timeout = min (timeout - int (elapsed_time .total_seconds () * SECOND ), 5 * SECOND ),
653+ timeout = max (
654+ timeout - int (elapsed_time .total_seconds () * SECOND ),
655+ _MIN_TIMEOUT_WAITING_FOR_SERVICE_ENDPOINT ,
656+ ),
644657 )
645658 return page .frame_locator (f'[osparc-test-id="iframe_{ node_id } "]' )
646659
0 commit comments