-
Notifications
You must be signed in to change notification settings - Fork 63
ModelCatalog: update default tests to reflect expected behavior #578
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 57 additions & 17 deletions
74
tests/model_registry/model_catalog/test_default_model_catalog.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,87 @@ | ||
| import pytest | ||
| import yaml | ||
| from kubernetes.dynamic import DynamicClient | ||
|
|
||
| from ocp_resources.model_registry_modelregistry_opendatahub_io import ModelRegistry | ||
| from ocp_resources.deployment import Deployment | ||
| from simple_logger.logger import get_logger | ||
| from typing import Self | ||
| from typing import Self, Any | ||
|
|
||
| from ocp_resources.pod import Pod | ||
| from ocp_resources.config_map import ConfigMap | ||
| from tests.model_registry.model_catalog.utils import validate_model_catalog_enabled, execute_get_command | ||
| from ocp_resources.route import Route | ||
| from ocp_resources.service import Service | ||
| from tests.model_registry.model_catalog.utils import ( | ||
| validate_model_catalog_enabled, | ||
| execute_get_command, | ||
| validate_model_catalog_resource, | ||
| validate_default_catalog, | ||
| ) | ||
|
|
||
| LOGGER = get_logger(name=__name__) | ||
|
|
||
|
|
||
| @pytest.mark.usefixtures( | ||
| "updated_dsc_component_state_scope_session", | ||
| "model_registry_namespace", | ||
| "model_registry_metadata_db_resources", | ||
| ) | ||
| class TestModelCatalog: | ||
| def test_config_map_not_created(self: Self, catalog_config_map: ConfigMap): | ||
| # Check that the default configmaps does not exist, when model registry is not created | ||
| assert not catalog_config_map.exists | ||
|
|
||
| @pytest.mark.smoke | ||
| def test_config_map_exists(self: Self, model_registry_instance: ModelRegistry, catalog_config_map: ConfigMap): | ||
| # Check that the default configmaps is created when model registry is enabled. | ||
| def test_config_map_exists(self: Self, catalog_config_map: ConfigMap): | ||
| # Check that the default configmaps is created when model registry is | ||
| # enabled on data science cluster. | ||
| assert catalog_config_map.exists, f"{catalog_config_map.name} does not exist" | ||
| models = yaml.safe_load(catalog_config_map.instance.data["sources.yaml"])["catalogs"] | ||
| assert not models, f"Expected no default models to be present. Actual: {models}" | ||
| catalogs = yaml.safe_load(catalog_config_map.instance.data["sources.yaml"])["catalogs"] | ||
| assert catalogs | ||
| assert len(catalogs) == 1, f"{catalog_config_map.name} should have 1 catalog" | ||
| validate_default_catalog(default_catalog=catalogs[0]) | ||
|
|
||
| def test_operator_pod_enabled_model_catalog( | ||
| self: Self, model_registry_instance: ModelRegistry, model_registry_operator_pod: Pod | ||
| @pytest.mark.parametrize( | ||
| "resource_name", | ||
| [ | ||
| pytest.param( | ||
| Deployment, | ||
| id="test_model_catalog_deployment_resource", | ||
| ), | ||
| pytest.param( | ||
| Route, | ||
| id="test_model_catalog_route_resource", | ||
| ), | ||
| pytest.param( | ||
| Service, | ||
| id="test_model_catalog_service_resource", | ||
| ), | ||
| pytest.param( | ||
| Pod, | ||
| id="test_model_catalog_pod_resource", | ||
| ), | ||
| ], | ||
| ) | ||
| def test_model_catalog_resources_exists( | ||
| self: Self, admin_client: DynamicClient, model_registry_namespace: str, resource_name: Any | ||
| ): | ||
| validate_model_catalog_resource( | ||
| kind=resource_name, admin_client=admin_client, namespace=model_registry_namespace | ||
| ) | ||
|
|
||
| def test_operator_pod_enabled_model_catalog(self: Self, model_registry_operator_pod: Pod): | ||
| assert validate_model_catalog_enabled(pod=model_registry_operator_pod) | ||
|
|
||
| def test_model_catalog_no_custom_catalog( | ||
| self, | ||
| model_registry_instance: ModelRegistry, | ||
| model_catalog_rest_url: list[str], | ||
| model_registry_rest_headers: dict[str, str], | ||
| ): | ||
| """ | ||
| Validate sources api for model catalog | ||
| """ | ||
| result = execute_get_command( | ||
| url=f"{model_catalog_rest_url[0]}sources", | ||
| headers=model_registry_rest_headers, | ||
| )["items"] | ||
| assert not result, f"Expected no custom models to be present. Actual: {result}" | ||
| assert result | ||
| assert len(result) == 1, f"Expected no custom models to be present. Actual: {result}" | ||
|
|
||
| def test_default_config_map_not_present(self: Self, model_registry_namespace: str): | ||
| # RHOAIENG-33246: Introduced a new configmap. It should be removed before 2.25 release | ||
| # This test is temporary. So not parameterizing it. | ||
| cfg_map = ConfigMap(name="default-model-catalog", namespace=model_registry_namespace) | ||
| assert not cfg_map.exists, f"{cfg_map.name} should not exist" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.