Skip to content

Commit

Permalink
Fixes issue:8631: Update the steps of test case to get rgw_alerts (#1…
Browse files Browse the repository at this point in the history
…0407)

* Fixes issue:8631: Update the steps of test case to get rgw_alerts

Signed-off-by: Akarsha-rai <[email protected]>
  • Loading branch information
Akarsha-rai committed Sep 9, 2024
1 parent 9c477c0 commit 83f552b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
17 changes: 13 additions & 4 deletions tests/functional/monitoring/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,17 @@ def stop_rgw():
nonlocal rgw_deployments
for rgw_deployment in rgw_deployments:
rgw = rgw_deployment["metadata"]["name"]
logger.info(f"Downscaling deployment {rgw} to 0")
oc.exec_oc_cmd(f"scale --replicas=0 deployment/{rgw}")
logger.info(
f"Updating readiness probe of deployment {rgw} to make rgw pod down"
)
cmd = (
'[{"op": "replace", "path": "/spec/template/spec/containers/0/readinessProbe", '
'"value": {"exec": {"command": ["bash", "-c", "#!/usr/bin/env bash\n\nexit 100"]}}}]'
)
if not oc.patch(resource_name=rgw, params=cmd, format_type="json"):
logger.error(f"Patch command failed to run on deployment {rgw}")
raise CommandFailed
logger.info(f"Succeeded: {cmd} patched on deployment {rgw}")
logger.info(f"Waiting for {run_time} seconds")
time.sleep(run_time)
return rgw_deployments
Expand All @@ -930,8 +939,8 @@ def stop_rgw():
logger.info("Return RGW pods")
for rgw_deployment in rgw_deployments:
rgw = rgw_deployment["metadata"]["name"]
logger.info(f"Upscaling deployment {rgw} to 1")
oc.exec_oc_cmd(f"scale --replicas=1 deployment/{rgw}")
logger.info("To bring the pod running delete the deployment")
oc.delete(resource_name=rgw)

return measured_op

Expand Down
8 changes: 7 additions & 1 deletion tests/functional/monitoring/prometheus/alerts/test_rgw.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
@tier4c
@pytest.mark.polarion_id("OCS-2323")
@pytest.mark.bugzilla("1953615")
@pytest.mark.bugzilla("2218190")
@skipif_managed_service
def test_rgw_unavailable(measure_stop_rgw, threading_lock):
"""
Test that there is appropriate alert when RGW is unavailable and that
this alert is cleared when the RGW interface is back online.
"""

api = prometheus.PrometheusAPI(threading_lock=threading_lock)

# get alerts from time when manager deployment was scaled down
Expand All @@ -38,7 +40,11 @@ def test_rgw_unavailable(measure_stop_rgw, threading_lock):
"Please check Ceph cluster health or RGW connection."
)
else:
target_msg = "Cluster Object Store is in unhealthy state. Please check Ceph cluster health."
target_msg = (
"Cluster Object Store is in unhealthy state or number of ready replicas for "
"Rook Ceph RGW deployments is less than the desired replicas in "
f"namespace:cluster {config.ENV_DATA['cluster_namespace']}:."
)
states = ["pending", "firing"]

prometheus.check_alert_list(
Expand Down

0 comments on commit 83f552b

Please sign in to comment.