Skip to content

Commit

Permalink
Review fix - test_ceph_osd_slow_ops_alert 4.13 (#8655)
Browse files Browse the repository at this point in the history
* review fix from #8600

Signed-off-by: Daniel Osypenko <[email protected]>
  • Loading branch information
DanielOsypenko authored Oct 20, 2023
1 parent 206f5ea commit 021f904
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 39 deletions.
16 changes: 0 additions & 16 deletions ocs_ci/ocs/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -3051,22 +3051,6 @@ def get_mds_standby_replay_info():
}


def set_osd_op_complaint_time(osd_op_complaint_time_val: float) -> dict:
"""
Set osd_op_complaint_time to the given value
Args:
osd_op_complaint_time_val (float): Value in seconds to set osd_op_complaint_time to
Returns:
dict: output of the command
"""
ct_pod = pod.get_ceph_tools_pod()
return ct_pod.exec_ceph_cmd(
f"ceph config set osd osd_op_complaint_time {osd_op_complaint_time_val}"
)


def get_full_ratio_from_osd_dump():
"""
Get the full ratio value from osd map
Expand Down
32 changes: 32 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6468,3 +6468,35 @@ def teardown():
request.addfinalizer(teardown)

return mot_obj


@pytest.fixture()
def set_osd_op_complaint_time(request, reduced_osd_complaint_time: float) -> dict:
"""
Set osd_op_complaint_time to the given value
Args:
request: Pytest request object
reduced_osd_complaint_time (float): Value in seconds to set osd_op_complaint_time to
Returns:
dict: output of the command
"""
ct_pod = get_ceph_tools_pod()
cmd_status = ct_pod.exec_ceph_cmd(
f"ceph config set osd osd_op_complaint_time {reduced_osd_complaint_time}"
)

def finalizer():
"""
Set default values for:
osd_op_complaint_time=30.000000
"""
# set the osd_op_complaint_time to selected monitor back to default value
ct_pod.exec_ceph_cmd(
f"ceph config set osd osd_op_complaint_time {constants.DEFAULT_OSD_OP_COMPLAINT_TIME}"
)

request.addfinalizer(finalizer)

return cmd_status
42 changes: 19 additions & 23 deletions tests/manage/monitoring/test_workload_with_distruptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
from ocs_ci.ocs.cluster import (
CephCluster,
get_percent_used_capacity,
set_osd_op_complaint_time,
get_full_ratio_from_osd_dump,
)
from ocs_ci.ocs.fiojob import get_timeout
Expand Down Expand Up @@ -186,14 +185,27 @@ def test_workload_with_checksum_verify(

class TestCephOSDSlowOps(object):
@pytest.fixture(scope="function")
def setup(self, request, pod_factory, multi_pvc_factory):
def setup(self, request, pod_factory, multi_pvc_factory, set_osd_op_complaint_time):
"""
Set preconditions to trigger CephOSDSlowOps
"""
self.test_pass = None
reduced_osd_complaint_time = 0.1
self.pod_objs = []

set_osd_op_complaint_time(reduced_osd_complaint_time)
def finalizer_delete_resources():
"""
Delete resources created during the test
"""

# delete resources
for pod_obj in self.pod_objs:
pod_obj.delete()
pod_obj.delete(wait=True)

for pvc_obj in self.pvc_objs:
pvc_obj.delete(wait=True)

request.addfinalizer(finalizer_delete_resources)

ceph_cluster = CephCluster()

Expand Down Expand Up @@ -222,7 +234,6 @@ def setup(self, request, pod_factory, multi_pvc_factory):
num_of_pvc=num_of_load_objs,
wait_each=True,
)
self.pod_objs = []

for pvc_obj in self.pvc_objs:
pod_obj = pod_factory(
Expand All @@ -240,27 +251,12 @@ def setup(self, request, pod_factory, multi_pvc_factory):

self.start_workload_time = time.perf_counter()

def finalizer():
"""
Set default values for:
osd_op_complaint_time=30.000000
"""
# set the osd_op_complaint_time to selected monitor back to default value
set_osd_op_complaint_time(constants.DEFAULT_OSD_OP_COMPLAINT_TIME)

# delete resources
for pod_obj in self.pod_objs:
pod_obj.delete()
pod_obj.delete(wait=True)

for pvc_obj in self.pvc_objs:
pvc_obj.delete(wait=True)

request.addfinalizer(finalizer)

@tier3
@pytest.mark.polarion_id("OCS-5158")
@blue_squad
@pytest.mark.parametrize(
argnames=["reduced_osd_complaint_time"], argvalues=[pytest.param(0.1)]
)
def test_ceph_osd_slow_ops_alert(self, setup):
"""
Test to verify bz #1966139, more info about Prometheus alert - #1885441
Expand Down

0 comments on commit 021f904

Please sign in to comment.