]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/standalone/mon/availability.sh: add tests
authorShraddha Agrawal <shraddha.agrawal000@gmail.com>
Thu, 19 Jun 2025 13:01:52 +0000 (18:31 +0530)
committerShraddha Agrawal <shraddha.agrawal000@gmail.com>
Thu, 26 Jun 2025 12:13:41 +0000 (17:43 +0530)
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 <shraddhaag@ibm.com>
(cherry picked from commit c08cf3277fbce6c02e9251b2985cf52ac0dbc165)

qa/standalone/mon/availability.sh

index 0d8f235def28a7e0ae80998ef0b37d8141f71f55..668dd3673356b2ef5f44e77442f888480ddfeef4 100755 (executable)
@@ -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
 }