From 951f10f56e7d895337e2754898ecc79824d5e035 Mon Sep 17 00:00:00 2001 From: Shraddha Agrawal Date: Thu, 19 Jun 2025 18:31:52 +0530 Subject: [PATCH] qa/standalone/mon/availability.sh: add tests This commit adds tests for the new command to clear availability status for a particular pool. The two tests do the following: 1. Checks if availability status is cleared successfully. 2. Checks availability status is not cleared if feature is disabled. Fixes: https://tracker.ceph.com/issues/71495 Signed-off-by: Shraddha Agrawal (cherry picked from commit c08cf3277fbce6c02e9251b2985cf52ac0dbc165) --- qa/standalone/mon/availability.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/qa/standalone/mon/availability.sh b/qa/standalone/mon/availability.sh index 0d8f235def2..668dd367335 100755 --- a/qa/standalone/mon/availability.sh +++ b/qa/standalone/mon/availability.sh @@ -73,6 +73,13 @@ function TEST_availablity_score() { fi sleep 120 + # try clearing availability score: should fail as feature is disabled + CLEAR_SCORE_RESPONSE=$(ceph osd pool clear-availability-status foo) + if [ "$CLEAR_SCORE_RESPONSE" != "" ]; then + echo "Failed: score clear attempted when feature is disabled" + return 1 + fi + # enable feature and check is score updated when it was off ceph config set mon enable_availability_tracking true AVAILABILITY_STATUS=$(ceph osd pool availability-status | grep -w "foo") @@ -125,7 +132,19 @@ function TEST_availablity_score() { echo "Failed: Availability score for the pool did not drop" return 1 fi + UPTIME_DURATION=$(echo "$AVAILABILITY_STATUS" | awk '{print $2}') + UPTIME_SECONDS=$(( ${UPTIME_DURATION%[sm]} * (${UPTIME_DURATION: -1} == "m" ? 60 : 1) )) + # reset availability score for pool foo + ceph osd pool clear-availability-status foo + AVAILABILITY_STATUS=$(ceph osd pool availability-status | grep -w "foo") + NEW_UPTIME_DURATION=$(echo "$AVAILABILITY_STATUS" | awk '{print $2}') + NEW_UPTIME_SECONDS=$(( ${UPTIME_DURATION%[sm]} * (${UPTIME_DURATION: -1} == "m" ? 60 : 1) )) + if [ "$NEW_UPTIME_SECONDS" -gt "$UPTIME_SECONDS" ]; then + echo "Failed: Availability score for the pool did not drop after clearing" + return 1 + fi + echo "TEST PASSED" return 0 } -- 2.39.5