Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
23753e7
Add api tests stateless
fege Jun 24, 2025
28d329f
Fix github action failures, lint and nox
fege Jun 24, 2025
e81a14a
Add too_slow and remove code to force the model version id
fege Jun 24, 2025
f67b1a8
Add filter_too_much
fege Jun 24, 2025
25ef85b
add hook to avoid Unsatisfiable
fege Jun 25, 2025
7043310
remove variable
fege Jun 25, 2025
631168d
Merge branch 'main' of github.com:fege/model-registry-kubeflow into R…
fege Jun 25, 2025
09d24f9
add artifact_states
fege Jun 26, 2025
1059bf7
Merge branch 'main' of github.com:fege/model-registry-kubeflow into R…
fege Jun 26, 2025
e9ec8e3
Add example to schema
fege Jun 27, 2025
d8210c4
Add example in src
fege Jun 27, 2025
9ff33ce
register strategy for string of int64
fege Jun 27, 2025
b785fcf
sort imports
fege Jun 27, 2025
325f26f
Merge branch 'main' of github.com:fege/model-registry-kubeflow into R…
fege Jun 30, 2025
b686d7b
modify case for problematic endpoints
fege Jun 30, 2025
79e9e21
add more examples
fege Jul 1, 2025
3b8becc
Merge branch 'main' of github.com:fege/model-registry-kubeflow into R…
fege Jul 1, 2025
f9ad748
pin urllib
fege Jul 1, 2025
7374841
Merge branch 'main' of github.com:fege/model-registry-kubeflow into R…
fege Jul 2, 2025
f40a007
exclude problematic endpoints and test with valid data
fege Jul 2, 2025
ed65e4b
Add gha to run the test and mark them with fuzz
fege Jul 3, 2025
29c759f
revert change in Makefile pushed by error
fege Jul 3, 2025
7ca6053
skip test not marked with e2e or fuzz, trigger the fuzz on pr comment
fege Jul 3, 2025
0fa6cdf
trigger with label
fege Jul 3, 2025
d69c88d
correct the label name
fege Jul 3, 2025
063fa94
add types and semplify the if
fege Jul 3, 2025
57d7ecf
do not run e2e if test-fuzz label is added
fege Jul 3, 2025
7abe73c
unpin urllib
fege Jul 3, 2025
47d67ea
modify lock
fege Jul 3, 2025
3454603
fix: remove proc on label
Al-Pragliola Jul 3, 2025
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
1 change: 1 addition & 0 deletions clients/python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
__pycache__/
venv/
.port-forwards.pid
.hypothesis/
2 changes: 2 additions & 0 deletions clients/python/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def tests(session: Session) -> None:
"pytest-asyncio",
"uvloop",
"olot",
"schemathesis",
)
session.run(
"pytest",
Expand All @@ -83,6 +84,7 @@ def e2e_tests(session: Session) -> None:
"boto3",
"olot",
"uvloop",
"schemathesis",
)
try:
session.run(
Expand Down
735 changes: 661 additions & 74 deletions clients/python/poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions clients/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ requests = "^2.32.2"
black = ">=24.4.2,<26.0.0"
types-python-dateutil = "^2.9.0.20240906"
pytest-html = "^4.1.1"
schemathesis = "^4.0.2"

[tool.coverage.run]
branch = true
Expand Down
1 change: 1 addition & 0 deletions clients/python/schemathesis.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
base-url = "${API_HOST}"
13 changes: 13 additions & 0 deletions clients/python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

import pytest
import requests
import schemathesis
import uvloop
from schemathesis.specs.openapi.schemas import BaseOpenAPISchema

from model_registry import ModelRegistry
from model_registry.utils import BackendDefinition, _get_skopeo_backend
Expand Down Expand Up @@ -317,3 +319,14 @@ def mock_override(base_image, dest_dir, params):
skopeo_pull_mock.side_effect = mock_override
skopeo_push_mock.side_effect = mock_override
yield backend, skopeo_pull_mock, skopeo_push_mock, generic_auth_vars

@pytest.fixture(scope="class")
def generated_schema(pytestconfig: pytest.Config ) -> BaseOpenAPISchema:
os.environ["API_HOST"] = REGISTRY_URL
config = schemathesis.config.SchemathesisConfig.from_path(f"{pytestconfig.rootpath}/schemathesis.toml")
schema = schemathesis.openapi.from_url(
url="https://raw.githubusercontent.com/kubeflow/model-registry/main/api/openapi/model-registry.yaml",
config=config,
)
schema.config.output.sanitization.update(enabled=False)
return schema
40 changes: 40 additions & 0 deletions clients/python/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pytest
import schemathesis
from hypothesis import HealthCheck, settings

schema = schemathesis.pytest.from_fixture("generated_schema")


@schema.parametrize()
@settings(
deadline=None,
suppress_health_check=[
HealthCheck.filter_too_much,
]
)
@pytest.mark.e2e
def test_mr_api_stateless(setup_env_user_token, case):
"""Test the Model Registry API endpoints.

This test uses schemathesis to generate and validate API requests
"""

headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {setup_env_user_token}"
}

# We need to ensure valid data
if case.path == "/api/model_registry/v1alpha3/model_versions/{modelversionId}/artifacts":
case.path_parameters["modelversionId"] = "test-model-version-1"

if case.method == "POST":
case.body = {
"artifactType": "model-artifact",
"name": "test-artifact",
"uri": "s3://test-bucket/test-artifact",
"metadata": {}
}
Comment thread
fege marked this conversation as resolved.
Outdated

case.call_and_validate(headers=headers)

Loading