Skip to content

Commit d235084

Browse files
authored
✨E2E: Added initial skeleton for testing MMUX services in E2E tests (#8301)
1 parent 3a35a33 commit d235084

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

tests/e2e-playwright/Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ SLEEPERS_INPUT_FILE := .e2e-playwright-sleepers-env.txt
139139
S4L_INPUT_FILE := .e2e-playwright-sim4life-env.txt
140140
JUPYTER_LAB_INPUT_FILE := .e2e-playwright-jupyterlab-env.txt
141141
CLASSIC_TIP_INPUT_FILE := .e2e-playwright-classictip-env.txt
142+
RSM_INPUT_FILE := .e2e-playwright-rsm-env.txt
142143

143144
# Prompt the user for input and store it into variables
144-
$(SLEEPERS_INPUT_FILE) $(JUPYTER_LAB_INPUT_FILE) $(CLASSIC_TIP_INPUT_FILE) $(S4L_INPUT_FILE):
145+
$(SLEEPERS_INPUT_FILE) $(JUPYTER_LAB_INPUT_FILE) $(CLASSIC_TIP_INPUT_FILE) $(S4L_INPUT_FILE) $(RSM_INPUT_FILE):
145146
@read -p "Enter your product URL: " PRODUCT_URL; \
146147
read -p "Is the product billable [y/n]: " BILLABLE; \
147148
read -p "Is the product lite [y/n]: " IS_LITE; \
@@ -189,6 +190,20 @@ $(SLEEPERS_INPUT_FILE) $(JUPYTER_LAB_INPUT_FILE) $(CLASSIC_TIP_INPUT_FILE) $(S4L
189190
elif [ "$@" = "$(SLEEPERS_INPUT_FILE)" ]; then \
190191
read -p "Enter the number of sleepers: " NUM_SLEEPERS; \
191192
echo "--num-sleepers=$$NUM_SLEEPERS" >> $@; \
193+
elif [ "$@" = "$(RSM_INPUT_FILE)" ]; then \
194+
read -p "Enter the service key (default to mmux-vite-app-sumo-write): " SERVICE_KEY; \
195+
if [ -z "$$SERVICE_KEY" ]; then \
196+
echo "No service key specified, using default."; \
197+
echo "--service-key=mmux-vite-app-sumo-write" >> $@; \
198+
else \
199+
echo "--service-key=$$SERVICE_KEY" >> $@; \
200+
fi; \
201+
read -p "Enter the service version (default to latest): " SERVICE_VERSION; \
202+
if [ -z "$$SERVICE_VERSION" ]; then \
203+
echo "No service version specified, using default."; \
204+
else \
205+
echo "--service-version=$$SERVICE_VERSION" >> $@; \
206+
fi; \
192207
fi
193208

194209
# Run the tests
@@ -202,7 +217,10 @@ test-jupyterlab-anywhere: _check_venv_active $(JUPYTER_LAB_INPUT_FILE) ## run ju
202217
@$(call run_test, $(JUPYTER_LAB_INPUT_FILE), tests/jupyterlabs/test_jupyterlab.py)
203218

204219
test-tip-anywhere: _check_venv_active $(CLASSIC_TIP_INPUT_FILE) ## run classic tip test and cache settings
205-
$(call run_test, $(CLASSIC_TIP_INPUT_FILE), tests/tip/test_ti_plan.py)
220+
@$(call run_test, $(CLASSIC_TIP_INPUT_FILE), tests/tip/test_ti_plan.py)
221+
222+
test-response-surface-modeling-anywhere: _check_venv_active $(RSM_INPUT_FILE) ## run response surface modeling test and cache settings
223+
@$(call run_test, $(RSM_INPUT_FILE), tests/metamodeling/test_response_surface_modeling.py)
206224

207225
# Define the common test running function
208226
define run_test

tests/e2e-playwright/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ def _(
749749
expected_states,
750750
True,
751751
None,
752-
service_version, # noqa: FBT003
752+
service_version,
753753
)
754754

755755
return _
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import logging
2+
import re
3+
from collections.abc import Callable
4+
from typing import Any, Final
5+
6+
from playwright.sync_api import Page
7+
from pydantic import AnyUrl
8+
from pytest_simcore.helpers.logging_tools import log_context
9+
from pytest_simcore.helpers.playwright import (
10+
MINUTE,
11+
RobustWebSocket,
12+
ServiceType,
13+
wait_for_service_running,
14+
)
15+
16+
_WAITING_FOR_SERVICE_TO_START: Final[int] = 5 * MINUTE
17+
_DEFAULT_RESPONSE_TO_WAIT_FOR: Final[re.Pattern] = re.compile(
18+
r"/flask/list_function_job_collections_for_functionid"
19+
)
20+
21+
22+
def test_response_surface_modeling(
23+
page: Page,
24+
create_project_from_service_dashboard: Callable[
25+
[ServiceType, str, str | None, str | None], dict[str, Any]
26+
],
27+
log_in_and_out: RobustWebSocket,
28+
service_key: str,
29+
service_version: str | None,
30+
product_url: AnyUrl,
31+
is_service_legacy: bool,
32+
):
33+
with (
34+
log_context(
35+
logging.INFO,
36+
f"Waiting for {service_key} to be responsive (waiting for {_DEFAULT_RESPONSE_TO_WAIT_FOR})",
37+
),
38+
page.expect_response(
39+
_DEFAULT_RESPONSE_TO_WAIT_FOR, timeout=_WAITING_FOR_SERVICE_TO_START
40+
),
41+
):
42+
project_data = create_project_from_service_dashboard(
43+
ServiceType.DYNAMIC, service_key, None, service_version
44+
)
45+
assert "workbench" in project_data, "Expected workbench to be in project data!"
46+
assert isinstance(
47+
project_data["workbench"], dict
48+
), "Expected workbench to be a dict!"
49+
node_ids: list[str] = list(project_data["workbench"])
50+
assert len(node_ids) == 1, "Expected 1 node in the workbench!"
51+
52+
wait_for_service_running(
53+
page=page,
54+
node_id=node_ids[0],
55+
websocket=log_in_and_out,
56+
timeout=_WAITING_FOR_SERVICE_TO_START,
57+
press_start_button=False,
58+
product_url=product_url,
59+
is_service_legacy=is_service_legacy,
60+
)

0 commit comments

Comments
 (0)