-
Notifications
You must be signed in to change notification settings - Fork 64
test(maas): add MaaS API and controller component health tests #1170
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
dbasunag
merged 10 commits into
opendatahub-io:main
from
SB159:feature/maas-component-health
Mar 5, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0c8e1c6
test(maas): add MaaS API and controller component health tests
SB159 73975ba
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f639f16
Merge branch 'main' into feature/maas-component-health
dbasunag 9456aab
test(maas): address review comments
SB159 2e56e17
test(maas): fix flake8 issues
SB159 fb60651
test(maas): resolve merge conflicts
SB159 4f42e4d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 32fef2e
test(maas): fix coderabit comment
SB159 495dd12
Merge branch 'main' into feature/maas-component-health
dbasunag 2f8cdbd
Merge branch 'main' into feature/maas-component-health
dbasunag 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
66 changes: 66 additions & 0 deletions
66
...ving/model_server/maas_billing/maas_subscription/component_health/test_maas_api_health.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 |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import pytest | ||
| from kubernetes.dynamic import DynamicClient | ||
| from ocp_resources.data_science_cluster import DataScienceCluster | ||
| from ocp_resources.deployment import Deployment | ||
| from pytest_testconfig import config as py_config | ||
| from simple_logger.logger import get_logger | ||
|
|
||
| from utilities.constants import DscComponents | ||
| from utilities.general import wait_for_pods_running | ||
|
|
||
| LOGGER = get_logger(name=__name__) | ||
|
|
||
|
|
||
| @pytest.mark.component_health | ||
| @pytest.mark.usefixtures("maas_controller_enabled_latest") | ||
| class TestMaaSApiComponentHealth: | ||
| def test_maas_management_state( | ||
| self, | ||
| dsc_resource: DataScienceCluster, | ||
| ) -> None: | ||
| """Verify modelsAsService managementState is MANAGED in DSC.""" | ||
| assert ( | ||
| dsc_resource.instance.spec.components[DscComponents.KSERVE].modelsAsService.managementState | ||
| == DscComponents.ManagementState.MANAGED | ||
| ) | ||
|
|
||
| def test_maas_condition_in_dsc( | ||
| self, | ||
| dsc_resource: DataScienceCluster, | ||
| ) -> None: | ||
| """Verify ModelsAsServiceReady condition is True in DSC.""" | ||
| for condition in dsc_resource.instance.status.conditions: | ||
| if condition.type == "ModelsAsServiceReady": | ||
| assert condition.status == "True" | ||
| break | ||
| else: | ||
| pytest.fail("ModelsAsServiceReady condition not found in DSC") | ||
|
|
||
| def test_maas_api_deployment_available( | ||
| self, | ||
| admin_client: DynamicClient, | ||
| ) -> None: | ||
| """Verify maas-api deployment Available=True.""" | ||
| applications_namespace = py_config["applications_namespace"] | ||
|
|
||
| maas_api_deployment = Deployment( | ||
| client=admin_client, | ||
| name="maas-api", | ||
| namespace=applications_namespace, | ||
| ensure_exists=True, | ||
| ) | ||
| maas_api_deployment.wait_for_condition( | ||
| condition="Available", | ||
| status="True", | ||
| timeout=120, | ||
| ) | ||
|
|
||
| def test_maas_api_pods_health( | ||
| self, | ||
| admin_client: DynamicClient, | ||
| ) -> None: | ||
| """Verify maas-api pods are Running/Ready.""" | ||
| applications_namespace = py_config["applications_namespace"] | ||
| LOGGER.info(f"Checking maas-api pods in namespace {applications_namespace}") | ||
|
|
||
| wait_for_pods_running(admin_client=admin_client, namespace_name=applications_namespace) |
97 changes: 97 additions & 0 deletions
97
...del_server/maas_billing/maas_subscription/component_health/test_maas_controller_health.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 |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import pytest | ||
| from kubernetes.dynamic import DynamicClient | ||
| from ocp_resources.custom_resource_definition import CustomResourceDefinition | ||
| from ocp_resources.data_science_cluster import DataScienceCluster | ||
| from ocp_resources.deployment import Deployment | ||
| from pytest_testconfig import config as py_config | ||
| from simple_logger.logger import get_logger | ||
|
|
||
| from utilities.constants import ApiGroups | ||
| from utilities.general import wait_for_pods_running | ||
|
|
||
| LOGGER = get_logger(name=__name__) | ||
|
|
||
|
|
||
| @pytest.mark.component_health | ||
| @pytest.mark.usefixtures("maas_controller_enabled_latest") | ||
| class TestMaaSController: | ||
| def test_maas_condition_in_dsc( | ||
| self, | ||
| dsc_resource: DataScienceCluster, | ||
| ) -> None: | ||
| """Verify ModelsAsServiceReady condition is True in DSC (MR-style loop + break + else fail).""" | ||
| for condition in dsc_resource.instance.status.conditions: | ||
| if condition.type == "ModelsAsServiceReady": | ||
| assert condition.status == "True" | ||
| break | ||
| else: | ||
| pytest.fail("ModelsAsServiceReady condition not found in DSC") | ||
|
|
||
| def test_maas_controller_crds_exist( | ||
| self, | ||
| admin_client: DynamicClient, | ||
| ) -> None: | ||
| """Verify MaaS controller CRDs exist (no CustomResourceDefinition.get usage).""" | ||
| expected_crd_names = ( | ||
| f"maasmodels.{ApiGroups.MAAS_IO}", | ||
| f"maasauthpolicies.{ApiGroups.MAAS_IO}", | ||
| f"maassubscriptions.{ApiGroups.MAAS_IO}", | ||
| ) | ||
| missing_crds = [] | ||
| for crd_name in expected_crd_names: | ||
| crd_resource = CustomResourceDefinition( | ||
| client=admin_client, | ||
| name=crd_name, | ||
| ensure_exists=True, | ||
| ) | ||
| if not crd_resource.exists: | ||
| missing_crds.append(crd_name) | ||
|
|
||
| assert not missing_crds, f"Missing expected CRDs: {', '.join(missing_crds)}" | ||
|
|
||
| def test_maas_controller_deployment_available( | ||
| self, | ||
| admin_client: DynamicClient, | ||
| ) -> None: | ||
| """Verify maas-controller Deployment is Available.""" | ||
| applications_namespace = py_config["applications_namespace"] | ||
|
|
||
| controller_deployment = Deployment( | ||
| client=admin_client, | ||
| name="maas-controller", | ||
| namespace=applications_namespace, | ||
| ensure_exists=True, | ||
| ) | ||
| controller_deployment.wait_for_condition( | ||
| condition="Available", | ||
| status="True", | ||
| timeout=120, | ||
| ) | ||
|
|
||
| def test_maas_controller_pods_health( | ||
| self, | ||
| admin_client: DynamicClient, | ||
| ) -> None: | ||
| """Verify maas-controller pods are Running.""" | ||
| applications_namespace = py_config["applications_namespace"] | ||
| LOGGER.info(f"Testing Pods in namespace {applications_namespace} for MaaS Controller health") | ||
| wait_for_pods_running(admin_client=admin_client, namespace_name=applications_namespace) | ||
|
SB159 marked this conversation as resolved.
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "resource_fixture, kind_label", | ||
| [ | ||
| ("maas_model_tinyllama_free", "MaaSModel"), | ||
| ("maas_auth_policy_tinyllama_free", "MaaSAuthPolicy"), | ||
| ("maas_subscription_tinyllama_free", "MaaSSubscription"), | ||
| ], | ||
| ) | ||
| def test_maas_subscription_stack_ready_for_free_model( | ||
|
SB159 marked this conversation as resolved.
|
||
| self, | ||
| request: pytest.FixtureRequest, | ||
| resource_fixture: str, | ||
| kind_label: str, | ||
| ) -> None: | ||
| """Verify the MaaS subscription flow objects are created and Ready.""" | ||
| resource = request.getfixturevalue(argname=resource_fixture) | ||
| LOGGER.info(f"Checking {kind_label} {resource.name} is Ready") | ||
| resource.wait_for_condition(condition="Ready", status="True", timeout=300) | ||
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.