Skip to content

Commit a732785

Browse files
authored
feat: Separate out cluster, operator and component health checks (#1133)
* feat: Separate out cluster, operator and component health checks * fix: Addressed review comments
1 parent 99ed02d commit a732785

7 files changed

Lines changed: 61 additions & 41 deletions

File tree

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ markers =
2121
ocp_interop: Interop testing with Openshift.
2222
downstream_only: Tests that are specific to downstream
2323
cluster_health: Tests that verifies that cluster is healthy to begin testing
24+
operator_health: Tests that verifies that OpenDataHub/RHOAI operators are healthy and functioning correctly
25+
component_health: Tests that verifies that OpenDataHub/RHOAI components are healthy and functioning correctly
2426
skip_must_gather: Tests that does not require must-gather for triaging
2527
install: Tests that are relevant for install scenario. To be used with upgrade marker, to indicate tests that are valid for both install and upgrade
2628

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,15 @@
11
import pytest
2-
from kubernetes.dynamic import DynamicClient
3-
from ocp_resources.data_science_cluster import DataScienceCluster
4-
from ocp_resources.dsc_initialization import DSCInitialization
52
from ocp_resources.node import Node
63
from ocp_utilities.infra import assert_nodes_in_healthy_condition, assert_nodes_schedulable
7-
from utilities.general import wait_for_pods_running
8-
from utilities.infra import wait_for_dsci_status_ready, wait_for_dsc_status_ready
9-
from pytest_testconfig import config as py_config
104
from simple_logger.logger import get_logger
115

126
LOGGER = get_logger(name=__name__)
137

148

159
@pytest.mark.cluster_health
16-
def test_cluster_node_healthy(nodes: list[Node]):
10+
def test_cluster_node_healthy(nodes: list[Node]) -> None:
11+
"""
12+
Tests if the cluster nodes are healthy
13+
"""
1714
assert_nodes_in_healthy_condition(nodes=nodes, healthy_node_condition_type={"KubeletReady": "True"})
1815
assert_nodes_schedulable(nodes=nodes)
19-
20-
21-
@pytest.mark.cluster_health
22-
def test_data_science_cluster_initialization_healthy(dsci_resource: DSCInitialization):
23-
wait_for_dsci_status_ready(dsci_resource=dsci_resource)
24-
25-
26-
@pytest.mark.cluster_health
27-
def test_data_science_cluster_healthy(dsc_resource: DataScienceCluster):
28-
wait_for_dsc_status_ready(dsc_resource=dsc_resource)
29-
30-
31-
@pytest.mark.parametrize(
32-
"namespace_name",
33-
[
34-
pytest.param(
35-
py_config["operator_namespace"],
36-
id="test_operator_namespace_pod_healthy",
37-
),
38-
pytest.param(
39-
py_config["applications_namespace"],
40-
id="test_application_namespace_pod_healthy",
41-
),
42-
],
43-
)
44-
@pytest.mark.cluster_health
45-
def test_pods_cluster_healthy(admin_client: DynamicClient, namespace_name: str):
46-
LOGGER.info(f"Testing Pods in namespace {namespace_name} for cluster health")
47-
wait_for_pods_running(admin_client=admin_client, namespace_name=namespace_name)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import pytest
2+
from kubernetes.dynamic import DynamicClient
3+
from ocp_resources.data_science_cluster import DataScienceCluster
4+
from ocp_resources.dsc_initialization import DSCInitialization
5+
from utilities.general import wait_for_pods_running
6+
from utilities.infra import wait_for_dsci_status_ready, wait_for_dsc_status_ready
7+
from pytest_testconfig import config as py_config
8+
from simple_logger.logger import get_logger
9+
10+
LOGGER = get_logger(name=__name__)
11+
12+
13+
@pytest.mark.operator_health
14+
def test_data_science_cluster_initialization_healthy(dsci_resource: DSCInitialization) -> None:
15+
"""
16+
Checks if a data science cluster initialization is healthy
17+
"""
18+
wait_for_dsci_status_ready(dsci_resource=dsci_resource)
19+
20+
21+
@pytest.mark.operator_health
22+
def test_data_science_cluster_healthy(dsc_resource: DataScienceCluster) -> None:
23+
"""
24+
Checks if a data science cluster is healthy
25+
"""
26+
wait_for_dsc_status_ready(dsc_resource=dsc_resource)
27+
28+
29+
@pytest.mark.parametrize(
30+
"namespace_name",
31+
[
32+
pytest.param(
33+
py_config["operator_namespace"],
34+
id="test_operator_namespace_pod_healthy",
35+
),
36+
pytest.param(
37+
py_config["applications_namespace"],
38+
id="test_application_namespace_pod_healthy",
39+
),
40+
],
41+
)
42+
@pytest.mark.operator_health
43+
def test_pods_cluster_healthy(admin_client: DynamicClient, namespace_name: str) -> None:
44+
"""
45+
Checks if pods in a given namespace are all healthy
46+
"""
47+
LOGGER.info(f"Testing Pods in namespace {namespace_name} for cluster health")
48+
wait_for_pods_running(admin_client=admin_client, namespace_name=namespace_name)
File renamed without changes.
File renamed without changes.

tests/model_registry/cluster_health/test_mr_health_check.py renamed to tests/model_registry/component_health/test_mr_health_check.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@
1313
LOGGER = get_logger(name=__name__)
1414

1515

16-
@pytest.mark.cluster_health
16+
@pytest.mark.component_health
1717
class TestMrDefault:
18-
def test_mr_management_state(self, dsc_resource: DataScienceCluster):
18+
def test_mr_management_state(self, dsc_resource: DataScienceCluster) -> None:
1919
"""Verify MODELREGISTRY managementState is MANAGED in DSC."""
2020
assert (
2121
dsc_resource.instance.spec.components[DscComponents.MODELREGISTRY].managementState
2222
== DscComponents.ManagementState.MANAGED
2323
)
2424

25-
def test_mr_namespace_exists_and_active(self, admin_client: DynamicClient, dsc_resource: DataScienceCluster):
25+
def test_mr_namespace_exists_and_active(
26+
self, admin_client: DynamicClient, dsc_resource: DataScienceCluster
27+
) -> None:
2628
"""Verify MR namespace exists and is in Active state."""
2729
namespace = Namespace(
2830
client=admin_client,
@@ -32,7 +34,7 @@ def test_mr_namespace_exists_and_active(self, admin_client: DynamicClient, dsc_r
3234
assert namespace.instance.status.phase == Namespace.Status.ACTIVE
3335
assert namespace.instance.metadata.name == py_config["model_registry_namespace"]
3436

35-
def test_mr_condition_in_dsc(self, dsc_resource: DataScienceCluster):
37+
def test_mr_condition_in_dsc(self, dsc_resource: DataScienceCluster) -> None:
3638
"""Verify MR ready condition is True in DSC."""
3739
for condition in dsc_resource.instance.status.conditions:
3840
if condition.type == DscComponents.COMPONENT_MAPPING[DscComponents.MODELREGISTRY]:
@@ -41,7 +43,7 @@ def test_mr_condition_in_dsc(self, dsc_resource: DataScienceCluster):
4143
else:
4244
pytest.fail("MR ready condition not found in DSC")
4345

44-
@pytest.mark.cluster_health
46+
@pytest.mark.component_health
4547
def test_mr_pods_health(self, admin_client: DynamicClient):
4648
namespace = py_config["model_registry_namespace"]
4749
LOGGER.info(f"Testing Pods in namespace {namespace} for cluster health")

tests/model_registry/cluster_health/test_mr_operator_health.py renamed to tests/model_registry/component_health/test_mr_operator_health.py

File renamed without changes.

0 commit comments

Comments
 (0)