Skip to content

Commit 6160bad

Browse files
authored
🎨E2E: add --service_version option (#7083)
1 parent 2415e78 commit 6160bad

File tree

6 files changed

+86
-25
lines changed

6 files changed

+86
-25
lines changed

tests/e2e-playwright/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ $(SLEEPERS_INPUT_FILE) $(JUPYTER_LAB_INPUT_FILE) $(CLASSIC_TIP_INPUT_FILE) $(S4L
161161
if [ "$@" = "$(JUPYTER_LAB_INPUT_FILE)" ]; then \
162162
read -p "Enter the size of the large file (human readable form e.g. 3Gib): " LARGE_FILE_SIZE; \
163163
echo "--service-key=jupyter-math --large-file-size=$$LARGE_FILE_SIZE" >> $@; \
164+
read -p "Enter the service version (default to latest): " SERVICE_VERSION; \
165+
if [ -z "$$SERVICE_VERSION" ]; then \
166+
echo "No service version specified, using default."; \
167+
else \
168+
echo "--service-version=$$SERVICE_VERSION" >> $@; \
169+
fi; \
164170
elif [ "$@" = "$(S4L_INPUT_FILE)" ]; then \
165171
read -p "Do you want to check the videostreaming ? (requires to run with chrome/msedge) [y/n]: " VIDEOSTREAM; \
166172
if [ "$$VIDEOSTREAM" = "y" ]; then \
@@ -173,6 +179,12 @@ $(SLEEPERS_INPUT_FILE) $(JUPYTER_LAB_INPUT_FILE) $(CLASSIC_TIP_INPUT_FILE) $(S4L
173179
else \
174180
read -p "Enter the service key: " SERVICE_KEY; \
175181
echo "--service-key=$$SERVICE_KEY" >> $@; \
182+
read -p "Enter the service version (default to latest): " SERVICE_VERSION; \
183+
if [ -z "$$SERVICE_VERSION" ]; then \
184+
echo "No service version specified, using default."; \
185+
else \
186+
echo "--service-version=$$SERVICE_VERSION" >> $@; \
187+
fi; \
176188
fi; \
177189
elif [ "$@" = "$(SLEEPERS_INPUT_FILE)" ]; then \
178190
read -p "Enter the number of sleepers: " NUM_SLEEPERS; \

tests/e2e-playwright/tests/conftest.py

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ def pytest_addoption(parser: pytest.Parser) -> None:
112112
default=False,
113113
help="Whether service is a legacy service (no sidecar)",
114114
)
115+
group.addoption(
116+
"--service-version",
117+
action="store",
118+
type=str,
119+
default=None,
120+
help="The service version option defines a service specific version",
121+
)
115122
group.addoption(
116123
"--template-id",
117124
action="store",
@@ -272,6 +279,14 @@ def is_service_legacy(request: pytest.FixtureRequest) -> bool:
272279
return TypeAdapter(bool).validate_python(autoscaled)
273280

274281

282+
@pytest.fixture(scope="session")
283+
def service_version(request: pytest.FixtureRequest) -> str | None:
284+
if key := request.config.getoption("--service-version"):
285+
assert isinstance(key, str)
286+
return key
287+
return None
288+
289+
275290
@pytest.fixture(scope="session")
276291
def template_id(request: pytest.FixtureRequest) -> str | None:
277292
if key := request.config.getoption("--template-id"):
@@ -438,23 +453,42 @@ def _open_with_resources(page: Page, *, click_it: bool):
438453
return open_with_resources_button
439454

440455

456+
def _select_service_version(page: Page, *, version: str) -> None:
457+
try:
458+
# since https://github.com/ITISFoundation/osparc-simcore/pull/7060
459+
with log_context(logging.INFO, msg=f"selecting version {version}"):
460+
page.get_by_test_id("serviceSelectBox").click(timeout=5 * SECOND)
461+
with page.expect_response(
462+
re.compile(r"/catalog/services/.+/resources"), timeout=1.5 * 5 * SECOND
463+
):
464+
page.get_by_test_id(f"serviceVersionItem_{version}").click(
465+
timeout=5 * SECOND
466+
)
467+
except TimeoutError:
468+
# we try the non robust way
469+
page.get_by_label("Version").select_option(version)
470+
471+
441472
@pytest.fixture
442473
def create_new_project_and_delete(
443474
page: Page,
444475
log_in_and_out: RestartableWebSocket,
445476
is_product_billable: bool,
446477
api_request_context: APIRequestContext,
447478
product_url: AnyUrl,
448-
) -> Iterator[Callable[[tuple[RunningState], bool], dict[str, Any]]]:
479+
) -> Iterator[
480+
Callable[[tuple[RunningState], bool, str | None, str | None], dict[str, Any]]
481+
]:
449482
"""The first available service currently displayed in the dashboard will be opened
450483
NOTE: cannot be used multiple times or going back to dashboard will fail!!
451484
"""
452485
created_project_uuids = []
453486

454487
def _(
455-
expected_states: tuple[RunningState] = (RunningState.NOT_STARTED,),
456-
press_open: bool = True,
457-
template_id: str | None = None,
488+
expected_states: tuple[RunningState],
489+
press_open: bool,
490+
template_id: str | None,
491+
service_version: str | None,
458492
) -> dict[str, Any]:
459493
assert (
460494
len(created_project_uuids) == 0
@@ -527,6 +561,8 @@ def wait_for_done(response):
527561
# not expected in the sim4life context though
528562
...
529563
else:
564+
if service_version is not None:
565+
_select_service_version(page, version=service_version)
530566
open_button.click()
531567
if is_product_billable:
532568
_open_with_resources(page, click_it=True)
@@ -618,7 +654,9 @@ def find_and_start_service_in_dashboard(
618654
page: Page,
619655
) -> Callable[[ServiceType, str, str | None], None]:
620656
def _(
621-
service_type: ServiceType, service_name: str, service_key_prefix: str | None
657+
service_type: ServiceType,
658+
service_name: str,
659+
service_key_prefix: str | None,
622660
) -> None:
623661
with log_context(logging.INFO, f"Finding {service_name=} in dashboard"):
624662
page.get_by_test_id("servicesTabBtn").click()
@@ -638,45 +676,54 @@ def _(
638676
def create_project_from_new_button(
639677
start_study_from_plus_button: Callable[[str], None],
640678
create_new_project_and_delete: Callable[
641-
[tuple[RunningState], bool], dict[str, Any]
679+
[tuple[RunningState], bool, str | None, str | None], dict[str, Any]
642680
],
643681
) -> Callable[[str], dict[str, Any]]:
644682
def _(plus_button_test_id: str) -> dict[str, Any]:
645683
start_study_from_plus_button(plus_button_test_id)
646684
expected_states = (RunningState.UNKNOWN,)
647-
return create_new_project_and_delete(expected_states, False)
685+
return create_new_project_and_delete(expected_states, False, None, None)
648686

649687
return _
650688

651689

652690
@pytest.fixture
653691
def create_project_from_template_dashboard(
654692
find_and_click_template_in_dashboard: Callable[[str], None],
655-
create_new_project_and_delete: Callable[[tuple[RunningState]], dict[str, Any]],
656-
) -> Callable[[ServiceType, str, str | None], dict[str, Any]]:
693+
create_new_project_and_delete: Callable[
694+
[tuple[RunningState], bool, str | None, str | None], dict[str, Any]
695+
],
696+
) -> Callable[[str], dict[str, Any]]:
657697
def _(template_id: str) -> dict[str, Any]:
658698
find_and_click_template_in_dashboard(template_id)
659699
expected_states = (RunningState.UNKNOWN,)
660-
return create_new_project_and_delete(expected_states, True, template_id)
700+
return create_new_project_and_delete(expected_states, True, template_id, None)
661701

662702
return _
663703

664704

665705
@pytest.fixture
666706
def create_project_from_service_dashboard(
667707
find_and_start_service_in_dashboard: Callable[[ServiceType, str, str | None], None],
668-
create_new_project_and_delete: Callable[[tuple[RunningState]], dict[str, Any]],
669-
) -> Callable[[ServiceType, str, str | None], dict[str, Any]]:
708+
create_new_project_and_delete: Callable[
709+
[tuple[RunningState], bool, str | None, str | None], dict[str, Any]
710+
],
711+
) -> Callable[[ServiceType, str, str | None, str | None], dict[str, Any]]:
670712
def _(
671-
service_type: ServiceType, service_name: str, service_key_prefix: str | None
713+
service_type: ServiceType,
714+
service_name: str,
715+
service_key_prefix: str | None,
716+
service_version: str | None,
672717
) -> dict[str, Any]:
673718
find_and_start_service_in_dashboard(
674719
service_type, service_name, service_key_prefix
675720
)
676721
expected_states = (RunningState.UNKNOWN,)
677722
if service_type is ServiceType.COMPUTATIONAL:
678723
expected_states = (RunningState.NOT_STARTED,)
679-
return create_new_project_and_delete(expected_states, True)
724+
return create_new_project_and_delete(
725+
expected_states, True, None, service_version
726+
)
680727

681728
return _
682729

tests/e2e-playwright/tests/jupyterlabs/test_jupyterlab.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ def test_jupyterlab(
6464
page: Page,
6565
log_in_and_out: RestartableWebSocket,
6666
create_project_from_service_dashboard: Callable[
67-
[ServiceType, str, str | None], dict[str, Any]
67+
[ServiceType, str, str | None, str | None], dict[str, Any]
6868
],
6969
service_key: str,
70+
service_version: str | None,
7071
large_file_size: ByteSize,
7172
large_file_block_size: ByteSize,
7273
product_url: AnyUrl,
@@ -86,7 +87,7 @@ def test_jupyterlab(
8687
),
8788
):
8889
project_data = create_project_from_service_dashboard(
89-
ServiceType.DYNAMIC, service_key, None
90+
ServiceType.DYNAMIC, service_key, None, service_version
9091
)
9192
assert "workbench" in project_data, "Expected workbench to be in project data!"
9293
assert isinstance(

tests/e2e-playwright/tests/sim4life/test_sim4life.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
def test_sim4life(
2424
page: Page,
2525
create_project_from_service_dashboard: Callable[
26-
[ServiceType, str, str | None], dict[str, Any]
26+
[ServiceType, str, str | None, str | None], dict[str, Any]
2727
],
2828
create_project_from_new_button: Callable[[str], dict[str, Any]],
2929
log_in_and_out: RestartableWebSocket,
3030
service_key: str,
31+
service_version: str | None,
3132
use_plus_button: bool,
3233
is_autoscaled: bool,
3334
check_videostreaming: bool,
@@ -38,7 +39,7 @@ def test_sim4life(
3839
project_data = create_project_from_new_button(service_key)
3940
else:
4041
project_data = create_project_from_service_dashboard(
41-
ServiceType.DYNAMIC, service_key, None
42+
ServiceType.DYNAMIC, service_key, None, service_version
4243
)
4344

4445
assert "workbench" in project_data, "Expected workbench to be in project data!"

tests/e2e-playwright/tests/sleepers/test_sleepers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
_WAITING_FOR_CLUSTER_MAX_WAITING_TIME: Final[int] = 5 * MINUTE
3838
_WAITING_FOR_STARTED_MAX_WAITING_TIME: Final[int] = 5 * MINUTE
3939
_WAITING_FOR_SUCCESS_MAX_WAITING_TIME_PER_SLEEPER: Final[int] = 1 * MINUTE
40-
_WAITING_FOR_FILE_NAMES_MAX_WAITING_TIME: Final[
41-
datetime.timedelta
42-
] = datetime.timedelta(seconds=30)
40+
_WAITING_FOR_FILE_NAMES_MAX_WAITING_TIME: Final[datetime.timedelta] = (
41+
datetime.timedelta(seconds=30)
42+
)
4343
_WAITING_FOR_FILE_NAMES_WAIT_INTERVAL: Final[datetime.timedelta] = datetime.timedelta(
4444
seconds=1
4545
)
@@ -82,14 +82,14 @@ def test_sleepers(
8282
page: Page,
8383
log_in_and_out: RestartableWebSocket,
8484
create_project_from_service_dashboard: Callable[
85-
[ServiceType, str, str | None], dict[str, Any]
85+
[ServiceType, str, str | None, str | None], dict[str, Any]
8686
],
8787
start_and_stop_pipeline: Callable[..., SocketIOEvent],
8888
num_sleepers: int,
8989
input_sleep_time: int | None,
9090
):
9191
project_data = create_project_from_service_dashboard(
92-
ServiceType.COMPUTATIONAL, "sleeper", "itis"
92+
ServiceType.COMPUTATIONAL, "sleeper", "itis", None
9393
)
9494

9595
# we are now in the workbench

tests/e2e-playwright/tests/tip/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def _(
2727
def create_tip_plan_from_dashboard(
2828
find_and_start_tip_plan_in_dashboard: Callable[[str], None],
2929
create_new_project_and_delete: Callable[
30-
[tuple[RunningState], bool], dict[str, Any]
30+
[tuple[RunningState], bool, str | None, str | None], dict[str, Any]
3131
],
3232
) -> Callable[[str], dict[str, Any]]:
3333
def _(plan_name_test_id: str) -> dict[str, Any]:
3434
find_and_start_tip_plan_in_dashboard(plan_name_test_id)
3535
expected_states = (RunningState.UNKNOWN,)
36-
return create_new_project_and_delete(expected_states, press_open=False)
36+
return create_new_project_and_delete(expected_states, False, None, None)
3737

3838
return _

0 commit comments

Comments
 (0)