Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 E2E: be compatible with legacy services #7134

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class SocketIONodeProgressCompleteWaiter:
logger: logging.Logger
product_url: AnyUrl
api_request_context: APIRequestContext
is_service_legacy: bool
_current_progress: dict[NodeProgressType, float] = field(
default_factory=defaultdict
)
Expand Down Expand Up @@ -336,7 +337,12 @@ def __call__(self, message: str) -> bool:

_current_timestamp = datetime.now(UTC)
if _current_timestamp - self._last_poll_timestamp > timedelta(seconds=5):
url = f"https://{self.node_id}.services.{self.get_partial_product_url()}"
if self.is_service_legacy:
url = f"https://{self.get_partial_product_url()}x/{self.node_id}/"
else:
url = (
f"https://{self.node_id}.services.{self.get_partial_product_url()}"
)
response = self.api_request_context.get(url, timeout=1000)
level = logging.DEBUG
if (response.status >= 400) and (response.status not in (502, 503)):
Expand Down Expand Up @@ -431,6 +437,7 @@ def expected_service_running(
timeout: int,
press_start_button: bool,
product_url: AnyUrl,
is_service_legacy: bool,
) -> Generator[ServiceRunning, None, None]:
with log_context(
logging.INFO, msg=f"Waiting for node to run. Timeout: {timeout}"
Expand All @@ -440,6 +447,7 @@ def expected_service_running(
logger=ctx.logger,
product_url=product_url,
api_request_context=page.request,
is_service_legacy=is_service_legacy,
)
service_running = ServiceRunning(iframe_locator=None)

Expand Down Expand Up @@ -472,6 +480,7 @@ def wait_for_service_running(
timeout: int,
press_start_button: bool,
product_url: AnyUrl,
is_service_legacy: bool,
) -> FrameLocator:
"""NOTE: if the service was already started this will not work as some of the required websocket events will not be emitted again
In which case this will need further adjutment"""
Expand All @@ -484,6 +493,7 @@ def wait_for_service_running(
logger=ctx.logger,
product_url=product_url,
api_request_context=page.request,
is_service_legacy=is_service_legacy,
)
with websocket.expect_event("framereceived", waiter, timeout=timeout):
if press_start_button:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def wait_for_launched_s4l(
autoscaled: bool,
copy_workspace: bool,
product_url: AnyUrl,
is_service_legacy: bool,
) -> WaitForS4LDict:
with log_context(logging.INFO, "launch S4L") as ctx:
predicate = S4LWaitForWebsocket(logger=ctx.logger)
Expand All @@ -132,6 +133,7 @@ def wait_for_launched_s4l(
+ (_S4L_COPY_WORKSPACE_TIME if copy_workspace else 0),
press_start_button=False,
product_url=product_url,
is_service_legacy=is_service_legacy,
)
s4l_websocket = ws_info.value
ctx.logger.info("acquired S4L websocket!")
Expand Down
12 changes: 12 additions & 0 deletions tests/e2e-playwright/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ def pytest_addoption(parser: pytest.Parser) -> None:
default=None,
help="Service Key",
)
group.addoption(
"--service-is-legacy",
action="store_true",
default=False,
help="Whether service is a legacy service (no sidecar)",
)
group.addoption(
"--template-id",
action="store",
Expand Down Expand Up @@ -260,6 +266,12 @@ def service_key(request: pytest.FixtureRequest) -> str:
return os.environ["SERVICE_KEY"]


@pytest.fixture(scope="session")
def is_service_legacy(request: pytest.FixtureRequest) -> bool:
autoscaled = request.config.getoption("--service-is-legacy")
return TypeAdapter(bool).validate_python(autoscaled)
Comment on lines +271 to +272
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoscaled?



@pytest.fixture(scope="session")
def template_id(request: pytest.FixtureRequest) -> str | None:
if key := request.config.getoption("--template-id"):
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e-playwright/tests/jupyterlabs/test_jupyterlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def test_jupyterlab(
large_file_size: ByteSize,
large_file_block_size: ByteSize,
product_url: AnyUrl,
is_service_legacy: bool,
):
# NOTE: this waits for the jupyter to send message, but is not quite enough
with (
Expand Down Expand Up @@ -101,6 +102,7 @@ def test_jupyterlab(
timeout=_WAITING_FOR_SERVICE_TO_START,
press_start_button=False,
product_url=product_url,
is_service_legacy=is_service_legacy,
)

iframe = page.frame_locator("iframe")
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e-playwright/tests/sim4life/test_sim4life.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test_sim4life(
is_autoscaled: bool,
check_videostreaming: bool,
product_url: AnyUrl,
is_service_legacy: bool,
):
if use_plus_button:
project_data = create_project_from_new_button(service_key)
Expand All @@ -54,6 +55,7 @@ def test_sim4life(
autoscaled=is_autoscaled,
copy_workspace=False,
product_url=product_url,
is_service_legacy=is_service_legacy,
)
s4l_websocket = resp["websocket"]
s4l_iframe = resp["iframe"]
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e-playwright/tests/sim4life/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_template(
is_autoscaled: bool,
check_videostreaming: bool,
product_url: AnyUrl,
is_service_legacy: bool,
):
project_data = create_project_from_template_dashboard(template_id)

Expand All @@ -45,6 +46,7 @@ def test_template(
autoscaled=is_autoscaled,
copy_workspace=True,
product_url=product_url,
is_service_legacy=is_service_legacy,
)
s4l_websocket = resp["websocket"]
s4l_iframe = resp["iframe"]
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e-playwright/tests/tip/test_ti_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def test_classic_ti_plan( # noqa: PLR0915
is_product_lite: bool,
create_tip_plan_from_dashboard: Callable[[str], dict[str, Any]],
product_url: AnyUrl,
is_service_legacy: bool,
):
with log_context(logging.INFO, "Checking 'Access TIP' teaser"):
# click to open and expand
Expand Down Expand Up @@ -145,6 +146,7 @@ def test_classic_ti_plan( # noqa: PLR0915
),
press_start_button=False,
product_url=product_url,
is_service_legacy=is_service_legacy,
)
# NOTE: Sometimes this iframe flicks and shows a white page. This wait will avoid it
page.wait_for_timeout(_ELECTRODE_SELECTOR_FLICKERING_WAIT_TIME)
Expand Down Expand Up @@ -205,6 +207,7 @@ def test_classic_ti_plan( # noqa: PLR0915
),
press_start_button=False,
product_url=product_url,
is_service_legacy=is_service_legacy,
) as service_running:
app_mode_trigger_next_app(page)
ti_iframe = service_running.iframe_locator
Expand Down Expand Up @@ -318,6 +321,7 @@ def test_classic_ti_plan( # noqa: PLR0915
),
press_start_button=False,
product_url=product_url,
is_service_legacy=is_service_legacy,
) as service_running:
app_mode_trigger_next_app(page)
s4l_postpro_iframe = service_running.iframe_locator
Expand Down
Loading