Skip to content

Commit 355d741

Browse files
🐛 Restrict client version for logstreaming e2e test and don't fail when cleaning up jobs in e2e tests (#146)
* update workflow before publishing python package * fix dependency issue and bump version * point to website in project description * fix broken dependency * improve doc * add github token to download artifacts * ensure only read-access @wvangeit * yet another attempt at downloading artifacts * make sure to use repo that ran the trigger wf * another attempt at fixing * change owner * allow publishing to testpypi also when pr * minor change * revert minor (but breaking) change * minor fix * add debug messages * another debug message * hopefully the final version * final fix * minor fix * move master and tag to individual jobs * add debug messages * dev->post * add python script for determining semantic version * minor changes * minor changes * improve error handling and add version file to artifacts * check if release * minor fix * ensure to enter venv * also when tagging * source venv in publishin workflow * ensure only master * add script for testing 'pure' semver * adapt workflows to new python script * minor change * attempt to evaluate expressions correctly * several fixes to fix tests * ensure repo is checked out in publish workflow * several small fixes * cleanup * debug * minor cleanup * mionr changes * add debug message * minor change * minor change * yet another try * minor change * minor change * minor change * mionr change * minor changes * correct workflow run id * cosmetic change * avoid using gh * change to a single job for publishing * minor cleanup * swap loops in clean up jobs * correction * update server compatibility to new url * minor change to trigger ci * introduce decorator to filter tests based on client version * test if it works * remove file which was wrongly committed * improve doc string * small cleanup * dont fail postprocessing step if deleting a job fails * @pcrespov change name
1 parent 2daeacd commit 355d741

File tree

4 files changed

+63
-31
lines changed

4 files changed

+63
-31
lines changed

clients/python/test/e2e/_utils.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import subprocess
33
from pathlib import Path
4+
from typing import Optional
45

56
import osparc
67
import pytest
@@ -23,15 +24,34 @@ def repo_version() -> Version:
2324
return Version(version_file.read_text())
2425

2526

26-
def requires_dev_features(test):
27+
def skip_if_no_dev_features(test):
2728
if (
2829
Version(osparc.__version__) < repo_version()
2930
or not osparc_dev_features_enabled()
3031
):
3132
return pytest.mark.skip(
3233
(
3334
f"{osparc.__version__=}<{str(repo_version)} "
34-
"or {osparc_dev_features_enabled()=}"
35+
f"or {osparc_dev_features_enabled()=}"
3536
)
3637
)(test)
3738
return test
39+
40+
41+
def skip_if_osparc_version(
42+
*,
43+
at_least: Optional[Version] = None,
44+
at_most: Optional[Version] = None,
45+
exactly: Optional[Version] = None,
46+
):
47+
def _wrapper(test):
48+
osparc_version = Version(osparc.__version__)
49+
if at_least and osparc_version < at_least:
50+
return pytest.mark.skip((f"{osparc_version=}<{at_least}"))(test)
51+
if at_most and osparc_version > at_most:
52+
return pytest.mark.skip((f"{osparc_version=}>{at_most}"))(test)
53+
if exactly and osparc_version != exactly:
54+
return pytest.mark.skip((f"{osparc_version=}!={exactly}"))(test)
55+
return test
56+
57+
return _wrapper

clients/python/test/e2e/ci/e2e/e2e/postprocess.py

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
import typer
1212
from pydantic import PositiveInt
1313
from tenacity import (
14+
RetryError,
1415
Retrying,
1516
retry_if_exception_type,
1617
stop_after_attempt,
1718
stop_after_delay,
1819
)
20+
from urllib3.exceptions import HTTPError as Urllib3HttpError
1921

2022
from ._models import Artifacts, ClientSettings, PytestIniFile, ServerSettings
2123
from ._utils import E2eExitCodes, E2eScriptFailure, handle_validation_error
@@ -219,22 +221,34 @@ def clean_up_jobs(artifacts_dir: Path, retry_minutes: Optional[PositiveInt] = No
219221
msg = "Cleaning up jobs for user: "
220222
msg += f"\n{server_config.model_dump_json(indent=1)}"
221223
typer.echo(msg)
222-
for attempt in Retrying(
223-
retry=retry_if_exception_type(osparc.ApiException),
224-
stop=stop_after_delay(timedelta(minutes=retry_minutes))
225-
if retry_minutes
226-
else stop_after_attempt(1),
227-
):
228-
with attempt:
229-
with osparc.ApiClient(config) as api_client:
230-
solvers_api = osparc.SolversApi(api_client)
231-
assert isinstance(
232-
solvers := solvers_api.list_solvers_releases(), list
233-
)
234-
for solver in solvers:
235-
assert isinstance(solver, osparc.Solver)
236-
assert (id_ := solver.id) is not None
237-
assert (version := solver.version) is not None
238-
for job in solvers_api.jobs(id_, version):
239-
assert isinstance(job, osparc.Job)
240-
solvers_api.delete_job(id_, version, job.id)
224+
try:
225+
for attempt in Retrying(
226+
retry=retry_if_exception_type((osparc.ApiException, Urllib3HttpError)),
227+
stop=stop_after_delay(timedelta(minutes=retry_minutes))
228+
if retry_minutes
229+
else stop_after_attempt(1),
230+
):
231+
with attempt:
232+
with osparc.ApiClient(config) as api_client:
233+
solvers_api = osparc.SolversApi(api_client)
234+
assert isinstance(
235+
solvers := solvers_api.list_solvers_releases(), list
236+
)
237+
for solver in solvers:
238+
assert isinstance(solver, osparc.Solver)
239+
assert (id_ := solver.id) is not None
240+
assert (version := solver.version) is not None
241+
for job in solvers_api.jobs(id_, version):
242+
assert isinstance(job, osparc.Job)
243+
solvers_api.delete_job(id_, version, job.id)
244+
except RetryError as exc:
245+
typer.echo(
246+
typer.style(
247+
(
248+
"Failed when cleaning jobs when encountering "
249+
f"the following exception:\n{exc.last_attempt.exception()}"
250+
),
251+
fg=typer.colors.RED,
252+
bold=True,
253+
)
254+
)

clients/python/test/e2e/test_files_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import osparc
55
import pytest
6-
from _utils import requires_dev_features
6+
from _utils import skip_if_no_dev_features
77
from conftest import _KB
88

99

@@ -19,7 +19,7 @@ def _hash_file(file: Path) -> str:
1919
return sha256.hexdigest()
2020

2121

22-
@requires_dev_features
22+
@skip_if_no_dev_features
2323
def test_upload_file(tmp_file: Path, api_client: osparc.ApiClient) -> None:
2424
"""Test that we can upload a file via the multipart upload"""
2525
tmp_path: Path = tmp_file.parent
@@ -37,7 +37,7 @@ def test_upload_file(tmp_file: Path, api_client: osparc.ApiClient) -> None:
3737
files_api.delete_file(uploaded_file1.id)
3838

3939

40-
@requires_dev_features
40+
@skip_if_no_dev_features
4141
@pytest.mark.parametrize("use_checksum", [True, False])
4242
@pytest.mark.parametrize("use_id", [True, False])
4343
def test_search_files(

clients/python/test/e2e/test_solvers_api.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import json
22

33
import osparc
4-
from _utils import requires_dev_features
4+
from _utils import skip_if_no_dev_features, skip_if_osparc_version
55
from httpx import AsyncClient
6+
from packaging.version import Version
67

78
DEFAULT_TIMEOUT_SECONDS = 10 * 60 # 10 min
89

910

10-
@requires_dev_features
11+
@skip_if_no_dev_features
1112
def test_jobs(api_client: osparc.ApiClient, sleeper: osparc.Solver):
1213
"""Test the jobs method
1314
@@ -48,14 +49,11 @@ def test_jobs(api_client: osparc.ApiClient, sleeper: osparc.Solver):
4849
solvers_api.delete_job(sleeper.id, sleeper.version, elm)
4950

5051

52+
@skip_if_osparc_version(at_least=Version("0.6.5"))
5153
async def test_logstreaming(
5254
api_client: osparc.ApiClient, sleeper: osparc.Solver, async_client: AsyncClient
5355
):
54-
"""Test the log streaming
55-
56-
Args:
57-
configuration (osparc.Configuration): The Configuration
58-
"""
56+
"""Test log streaming"""
5957
solvers_api: osparc.SolversApi = osparc.SolversApi(api_client)
6058
job: osparc.Job = solvers_api.create_job(
6159
sleeper.id, sleeper.version, osparc.JobInputs({"input1": 1.0})

0 commit comments

Comments
 (0)