|
8 | 8 | from enum import Enum, unique |
9 | 9 | from typing import Any, Final |
10 | 10 |
|
11 | | -from playwright.sync_api import FrameLocator, Page, Request, WebSocket |
| 11 | +from playwright.sync_api import FrameLocator, Page, Request |
| 12 | +from playwright.sync_api import TimeoutError as PlaywrightTimeoutError |
| 13 | +from playwright.sync_api import WebSocket |
12 | 14 | from pytest_simcore.helpers.logging_tools import log_context |
13 | 15 |
|
14 | 16 | SECOND: Final[int] = 1000 |
@@ -194,6 +196,7 @@ def __call__(self, message: str) -> None: |
194 | 196 | class SocketIONodeProgressCompleteWaiter: |
195 | 197 | node_id: str |
196 | 198 | logger: logging.Logger |
| 199 | + _last_call_return: bool = False |
197 | 200 | _current_progress: dict[NodeProgressType, float] = field( |
198 | 201 | default_factory=defaultdict |
199 | 202 | ) |
@@ -226,20 +229,19 @@ def __call__(self, message: str) -> bool: |
226 | 229 | f"{json.dumps({k:round(v,1) for k,v in self._current_progress.items()})}", |
227 | 230 | ) |
228 | 231 |
|
229 | | - return all( |
| 232 | + self._last_call_return = all( |
230 | 233 | progress_type in self._current_progress |
231 | 234 | for progress_type in NodeProgressType.required_types_for_started_service() |
232 | 235 | ) and all( |
233 | 236 | round(progress, 1) == 1.0 |
234 | 237 | for progress in self._current_progress.values() |
235 | 238 | ) |
236 | | - |
| 239 | + return self._last_call_return |
| 240 | + self._last_call_return = False |
237 | 241 | return False |
238 | 242 |
|
239 | | - def is_progress_succesfully_finished(self) -> bool: |
240 | | - return all( |
241 | | - round(progress, 1) == 1.0 for progress in self._current_progress.values() |
242 | | - ) |
| 243 | + def get_last_call_return(self): |
| 244 | + return self._last_call_return |
243 | 245 |
|
244 | 246 | def get_current_progress(self): |
245 | 247 | return self._current_progress.values() |
@@ -340,17 +342,18 @@ def expected_service_running( |
340 | 342 | with websocket.expect_event("framereceived", waiter, timeout=timeout): |
341 | 343 | if press_start_button: |
342 | 344 | _trigger_service_start(page, node_id) |
343 | | - except TimeoutError: |
344 | | - if waiter.is_progress_succesfully_finished() is False: |
| 345 | + |
| 346 | + yield service_running |
| 347 | + |
| 348 | + except PlaywrightTimeoutError: |
| 349 | + if waiter.get_last_call_return() is False: |
345 | 350 | ctx.logger.warning( |
346 | | - "⚠️ Progress bar didn't receive 100 percent: %s ⚠️", # https://github.com/ITISFoundation/osparc-simcore/issues/6449 |
| 351 | + "⚠️ Progress bar didn't receive 100 percent: %s ⚠️", # https://github.com/ITISFoundation/osparc-simcore/issues/6449 |
347 | 352 | waiter.get_current_progress(), |
348 | 353 | ) |
349 | 354 | else: |
350 | 355 | raise |
351 | 356 |
|
352 | | - yield service_running |
353 | | - |
354 | 357 | service_running.iframe_locator = page.frame_locator( |
355 | 358 | f'[osparc-test-id="iframe_{node_id}"]' |
356 | 359 | ) |
|
0 commit comments