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

pydantic2 migration made integration tests green #6719

Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
cdd69d9
fixed integration tests for simcore-sdk
Nov 14, 2024
cd6db0b
added missing dependency
Nov 14, 2024
10b28a7
fixed prod.txt
Nov 14, 2024
941039c
fixed library name
Nov 14, 2024
ffb95f1
fixed broken validator
Nov 14, 2024
17798cc
fixed broken tests
Nov 14, 2024
f3bf668
disable opentelementry for testing stacks
Nov 14, 2024
732d5f9
fixed conftest
Nov 14, 2024
657075c
fixed broken test
Nov 14, 2024
d0ba06a
refactor
Nov 14, 2024
71f10c5
fixed integration tests for osparc-gateway-server
Nov 14, 2024
7b3c820
refactor
Nov 14, 2024
ff307d6
Merge remote-tracking branch 'upstream/pydantic_v2_migration_do_not_s…
Nov 14, 2024
838bc84
added missing imports
Nov 14, 2024
4b8dc22
fix url
giancarloromeo Nov 14, 2024
8a22850
fixed pydanticv1 issue
Nov 14, 2024
88d43e4
fixed test
Nov 14, 2024
5c7fc53
Merge branch 'pr-osparc-pydantic2-integration-libraries2' of github.c…
Nov 14, 2024
964b515
fixed routes
Nov 14, 2024
dbc9f5b
fixed patch
Nov 14, 2024
9efe3b9
fixed union parsing
Nov 14, 2024
e283d7e
remove assert
Nov 14, 2024
06071a6
aiodocker format
Nov 14, 2024
a34dfdd
fix url type
giancarloromeo Nov 14, 2024
ba57a0e
fix urls
giancarloromeo Nov 14, 2024
1914139
deprecating legacy url
Nov 15, 2024
777b469
Merge branch 'pr-osparc-pydantic2-integration-libraries2' of github.c…
Nov 15, 2024
188f97c
removed LegacyUrl
Nov 15, 2024
a66bc5e
using newer version
Nov 15, 2024
3bcd09e
fixed broken test
Nov 15, 2024
2daf0ca
bump service version
Nov 15, 2024
d48271c
Merge remote-tracking branch 'upstream/pydantic_v2_migration_do_not_s…
Nov 15, 2024
ddaa28b
fixed typing
Nov 15, 2024
48c0058
bumped service versions
Nov 15, 2024
2558636
fixed typing warnings
Nov 15, 2024
871c27b
added missing packages
Nov 15, 2024
e2fc69b
fixed missing package
Nov 15, 2024
00f906b
attempt to avoid flaky test
Nov 15, 2024
b968a23
refactor and migrated to yarl
Nov 15, 2024
30dab5e
pylint
Nov 15, 2024
08f3c52
revert flaky test
Nov 15, 2024
3cb8af8
added missing
Nov 15, 2024
a7a3257
Merge remote-tracking branch 'upstream/pydantic_v2_migration_do_not_s…
Nov 18, 2024
8e6175d
reverting
Nov 18, 2024
6bdc21a
renaming
Nov 18, 2024
d34318d
service owner is None by default if not found
Nov 18, 2024
c30b583
fixed warnings in tests
Nov 18, 2024
8ce43ab
revert
Nov 18, 2024
0e52fdd
pylint
Nov 18, 2024
e2fe840
pylint
Nov 18, 2024
ac299de
mypy fixes adding access_rights
Nov 18, 2024
f75fb75
fixed broken tests
Nov 18, 2024
819cee6
updated description
Nov 18, 2024
c369d3e
Merge remote-tracking branch 'upstream/pydantic_v2_migration_do_not_s…
Nov 18, 2024
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
4 changes: 4 additions & 0 deletions packages/pytest-simcore/src/pytest_simcore/docker_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def env_file_for_testing(
file=fh,
)
for key, value in sorted(testing_environ_vars.items()):
# ensure OpenTelemetry is not enabled
if key.startswith("TRACING_") or key.endswith("_TRACING"):
GitHK marked this conversation as resolved.
Show resolved Hide resolved
continue

# NOTE: python-dotenv parses JSON encoded strings correctly, but
# writing them back shows an issue. if the original ENV is something like MY_ENV='{"correct": "encodedjson"}'
# it goes to MY_ENV={"incorrect": "encodedjson"}!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,24 @@ async def storage_service(
) -> URL:
await wait_till_storage_responsive(storage_endpoint)

def correct_ip(url: AnyUrl):
def _replace_storage_endpoint(url: str) -> str:
url_obj = TypeAdapter(AnyUrl).validate_python(url)
assert storage_endpoint.host is not None
assert storage_endpoint.port is not None

return AnyUrl.build(
scheme=url.scheme,
storage_endpoint_url = AnyUrl.build(
scheme=url_obj.scheme,
host=storage_endpoint.host,
port=f"{storage_endpoint.port}",
path=url.path,
query=url.query,
port=storage_endpoint.port,
path=url_obj.path.lstrip("/"),
query=url_obj.query,
)
return f"{storage_endpoint_url}"
GitHK marked this conversation as resolved.
Show resolved Hide resolved

# NOTE: Mock to ensure container IP agrees with host IP when testing
mocker.patch(
"simcore_sdk.node_ports_common._filemanager._get_https_link_if_storage_secure",
correct_ip,
_replace_storage_endpoint,
)

return storage_endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ async def _complete_upload(
:rtype: ETag
"""
async with session.post(
_get_https_link_if_storage_secure(str(upload_completion_link)),
_get_https_link_if_storage_secure(f"{upload_completion_link}"),
json=jsonable_encoder(FileUploadCompletionBody(parts=parts)),
auth=get_basic_auth(),
) as resp:
resp.raise_for_status()
# now poll for state
file_upload_complete_response = TypeAdapter(Envelope[FileUploadCompleteResponse]).validate_python(
await resp.json()
)
file_upload_complete_response = TypeAdapter(
Envelope[FileUploadCompleteResponse]
).validate_python(await resp.json())
assert file_upload_complete_response.data # nosec
state_url = _get_https_link_if_storage_secure(
str(file_upload_complete_response.data.links.state)
f"{file_upload_complete_response.data.links.state}"
)
_logger.info("completed upload of %s", f"{len(parts)} parts, received {state_url}")

Expand All @@ -96,9 +96,9 @@ async def _complete_upload(
with attempt:
async with session.post(state_url, auth=get_basic_auth()) as resp:
resp.raise_for_status()
future_enveloped = TypeAdapter(Envelope[FileUploadCompleteFutureResponse]).validate_python(
await resp.json()
)
future_enveloped = TypeAdapter(
Envelope[FileUploadCompleteFutureResponse]
).validate_python(await resp.json())
assert future_enveloped.data # nosec
if future_enveloped.data.state == FileUploadCompleteState.NOK:
msg = "upload not ready yet"
Expand Down Expand Up @@ -142,7 +142,8 @@ async def _abort_upload(
# abort the upload correctly, so it can revert back to last version
try:
async with session.post(
_get_https_link_if_storage_secure(str(abort_upload_link)), auth=get_basic_auth()
_get_https_link_if_storage_secure(f"{abort_upload_link}"),
auth=get_basic_auth(),
) as resp:
resp.raise_for_status()
except ClientError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ async def __call__(self, logs: str) -> None:
with log_catch(_logger, reraise=False):
rclone_message: _RCloneSyncMessages = TypeAdapter(
_RCloneSyncMessages
).validate_strings(
logs,
)
).validate_json(logs)

if isinstance(rclone_message, _RCloneSyncTransferringMessage):
await self.progress_bar.set_(rclone_message.stats.bytes)
Expand Down
4 changes: 2 additions & 2 deletions packages/simcore-sdk/tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def project_id(user_id: int, postgres_db: sa.engine.Engine) -> Iterable[str]:

@pytest.fixture(scope="module")
def node_uuid() -> NodeIDStr:
return NodeIDStr(f"{uuid4()}")
return TypeAdapter(NodeIDStr).validate_python(f"{uuid4()}")


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -156,7 +156,7 @@ async def _create(file_path: Path) -> dict[str, Any]:
"Content-Type": "application/binary",
}
async with session.put(
link, data=file_path.read_bytes(), headers=extra_hdr
f"{link}", data=file_path.read_bytes(), headers=extra_hdr
) as resp:
resp.raise_for_status()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,24 @@ async def simcore_storage_service(mocker: MockerFixture, app: FastAPI) -> None:
storage_host: Final[str] | None = os.environ.get("STORAGE_HOST")
storage_port: Final[str] | None = os.environ.get("STORAGE_PORT")

def correct_ip(url: AnyUrl):

def _replace_storage_endpoint(url: str) -> str:
url_obj = TypeAdapter(AnyUrl).validate_python(url)
assert storage_host is not None
assert storage_port is not None

return AnyUrl.build(
scheme=url.scheme,
storage_endpoint_url = AnyUrl.build(
scheme=url_obj.scheme,
host=storage_host,
port=storage_port,
path=url.path,
query=url.query,
port=int(storage_port),
path=url_obj.path.lstrip("/"),
query=url_obj.query,
)
return f"{storage_endpoint_url}"

# NOTE: Mock to ensure container IP agrees with host IP when testing
mocker.patch(
"simcore_sdk.node_ports_common._filemanager._get_https_link_if_storage_secure",
correct_ip,
_replace_storage_endpoint,
GitHK marked this conversation as resolved.
Show resolved Hide resolved
)


Expand Down
1 change: 1 addition & 0 deletions services/storage/requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

# installs this repo's packages
simcore-aws-library @ ../../packages/aws-library/
simcore-common-library @ ../../packages/common-library/
GitHK marked this conversation as resolved.
Show resolved Hide resolved
simcore-models-library @ ../../packages/models-library/
simcore-postgres-database @ ../../packages/postgres-database/
simcore-service-library[aiohttp] @ ../../packages/service-library
Expand Down
2 changes: 1 addition & 1 deletion services/storage/src/simcore_service_storage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def convert_from_lower_case(cls, v: str) -> str:
def when_directory_force_link_type_and_file_size(cls, data: Any) -> Any:
assert isinstance(data, dict)

if bool(data.get("is_directory", False)) is True:
if TypeAdapter(bool).validate_python(data.get("is_directory", "false")):
sanderegg marked this conversation as resolved.
Show resolved Hide resolved
# sets directory size by default to undefined
if int(data.get("file_size", -1)) < 0:
data["file_size"] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class RRIDEntry(BaseModel):

class TSREntry(BaseModel):
references: list[str]
target_level: int | None # max value allowed
current_level: int | None # current selection
target_level: int | None = None # max value allowed
current_level: int | None = None # current selection
GitHK marked this conversation as resolved.
Show resolved Hide resolved


class CodeDescriptionModel(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
from simcore_service_webserver.projects.models import ProjectDict
from yarl import URL

pytest_simcore_core_services_selection = ["migration", "postgres", "redis", "rabbit"]
pytest_simcore_core_services_selection = [
"migration",
"postgres",
"redis",
"rabbit",
]

_logger = logging.getLogger(__name__)

Expand Down
Loading