Skip to content

Commit

Permalink
Perform Mon & OSD failure tests in Stretch cluster (#9319)
Browse files Browse the repository at this point in the history
Signed-off-by: Mahesh Shetty <[email protected]>
  • Loading branch information
mashetty330 authored Jul 19, 2024
1 parent bace443 commit 4120623
Show file tree
Hide file tree
Showing 3 changed files with 372 additions and 0 deletions.
44 changes: 44 additions & 0 deletions ocs_ci/ocs/resources/stretchcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
get_mon_pods,
get_mon_pod_id,
get_pod_node,
get_osd_pods,
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -665,3 +666,46 @@ def post_failure_checks(
failure_check_map[type](
start_time, end_time, wait_for_read_completion=wait_for_read_completion
)

def get_mon_pods_in_a_zone(self, zone):
"""
Fetches mon pods in a particular zone
Args:
zone (str): Zone
Returns:
List: mon pods in a zone
"""
nodes_in_zone = [node.name for node in self.get_nodes_in_zone(zone)]
mon_pods = [
Pod(**pod_info)
for pod_info in get_pods_having_label(
label=constants.MON_APP_LABEL, statuses=["Running"]
)
]
mon_pods_in_zone = [
pod for pod in mon_pods if get_pod_node(pod).name in nodes_in_zone
]
return mon_pods_in_zone

def get_osd_pods_in_a_zone(self, zone):
"""
Fetches osd osd pods in particular zone
Args:
zone (str): Zone
Returns:
List: OSD pods in a zone
"""

nodes_in_zone = [node.name for node in self.get_nodes_in_zone(zone)]
osd_pods = get_osd_pods()

osd_pods_in_zone = [
pod for pod in osd_pods if get_pod_node(pod).name in nodes_in_zone
]
return osd_pods_in_zone
83 changes: 83 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7065,6 +7065,15 @@ def finalizer():

@pytest.fixture()
def logwriter_cephfs_many_pvc_factory(request, pvc_factory):
return logwriter_cephfs_many_pvc(request, pvc_factory)


@pytest.fixture(scope="class")
def logwriter_cephfs_many_pvc_class(request, pvc_factory_class):
return logwriter_cephfs_many_pvc(request, pvc_factory_class)


def logwriter_cephfs_many_pvc(request, pvc_factory):
"""
Fixture to create RWX cephfs volume
Expand All @@ -7090,8 +7099,17 @@ def setup_stretch_cluster_project(request, project_factory_session):
return project_factory_session(constants.STRETCH_CLUSTER_NAMESPACE)


@pytest.fixture(scope="class")
def logwriter_workload_class(request, teardown_factory_class):
return setup_logwriter_workload(request, teardown_factory_class)


@pytest.fixture()
def logwriter_workload_factory(request, teardown_factory):
return setup_logwriter_workload(request, teardown_factory)


def setup_logwriter_workload(request, teardown_factory):
"""
Fixture to create logwriter deployment
Expand Down Expand Up @@ -7139,8 +7157,17 @@ def factory(pvc, logwriter_path):
return factory


@pytest.fixture(scope="class")
def logreader_workload_class(request, teardown_factory_class):
return setup_logreader_workload(request, teardown_factory_class)


@pytest.fixture()
def logreader_workload_factory(request, teardown_factory):
return setup_logreader_workload(request, teardown_factory)


def setup_logreader_workload(request, teardown_factory):
def factory(pvc, logreader_path, duration=30):
"""
Args:
Expand Down Expand Up @@ -7187,6 +7214,26 @@ def factory(pvc, logreader_path, duration=30):
return factory


@pytest.fixture(scope="class")
def setup_logwriter_cephfs_workload_class(
request,
setup_stretch_cluster_project,
pvc_factory_class,
logwriter_cephfs_many_pvc_class,
logwriter_workload_class,
logreader_workload_class,
):

return setup_logwriter_cephfs_workload(
request,
setup_stretch_cluster_project,
pvc_factory_class,
logwriter_cephfs_many_pvc_class,
logwriter_workload_class,
logreader_workload_class,
)


@pytest.fixture()
def setup_logwriter_cephfs_workload_factory(
request,
Expand All @@ -7196,6 +7243,25 @@ def setup_logwriter_cephfs_workload_factory(
logwriter_workload_factory,
logreader_workload_factory,
):

return setup_logwriter_cephfs_workload(
request,
setup_stretch_cluster_project,
pvc_factory,
logwriter_cephfs_many_pvc_factory,
logwriter_workload_factory,
logreader_workload_factory,
)


def setup_logwriter_cephfs_workload(
request,
setup_stretch_cluster_project,
pvc_factory,
logwriter_cephfs_many_pvc_factory,
logwriter_workload_factory,
logreader_workload_factory,
):
"""
This fixture will create the RWX cephfs volume and call the logwriter, logreader fixture to do
complete setup
Expand Down Expand Up @@ -7227,9 +7293,26 @@ def factory(read_duration=30):
return factory


@pytest.fixture(scope="class")
def setup_logwriter_rbd_workload_class(
request, setup_stretch_cluster_project, teardown_factory_class
):
return setup_logwriter_rbd_workload(
request, setup_stretch_cluster_project, teardown_factory_class
)


@pytest.fixture()
def setup_logwriter_rbd_workload_factory(
request, setup_stretch_cluster_project, teardown_factory
):
return setup_logwriter_rbd_workload(
request, setup_stretch_cluster_project, teardown_factory
)


def setup_logwriter_rbd_workload(
request, setup_stretch_cluster_project, teardown_factory
):
"""
This fixture will create the RWO RBD volume, create logwriter sts using that volume
Expand Down
Loading

0 comments on commit 4120623

Please sign in to comment.