Skip to content

Commit c08cf32

Browse files
committed
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 <[email protected]>
1 parent f6aed0b commit c08cf32

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

qa/standalone/mon/availability.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ function TEST_availablity_score() {
7373
fi
7474
sleep 120
7575

76+
# try clearing availability score: should fail as feature is disabled
77+
CLEAR_SCORE_RESPONSE=$(ceph osd pool clear-availability-status foo)
78+
if [ "$CLEAR_SCORE_RESPONSE" != "" ]; then
79+
echo "Failed: score clear attempted when feature is disabled"
80+
return 1
81+
fi
82+
7683
# enable feature and check is score updated when it was off
7784
ceph config set mon enable_availability_tracking true
7885
AVAILABILITY_STATUS=$(ceph osd pool availability-status | grep -w "foo")
@@ -125,7 +132,19 @@ function TEST_availablity_score() {
125132
echo "Failed: Availability score for the pool did not drop"
126133
return 1
127134
fi
135+
UPTIME_DURATION=$(echo "$AVAILABILITY_STATUS" | awk '{print $2}')
136+
UPTIME_SECONDS=$(( ${UPTIME_DURATION%[sm]} * (${UPTIME_DURATION: -1} == "m" ? 60 : 1) ))
128137

138+
# reset availability score for pool foo
139+
ceph osd pool clear-availability-status foo
140+
AVAILABILITY_STATUS=$(ceph osd pool availability-status | grep -w "foo")
141+
NEW_UPTIME_DURATION=$(echo "$AVAILABILITY_STATUS" | awk '{print $2}')
142+
NEW_UPTIME_SECONDS=$(( ${UPTIME_DURATION%[sm]} * (${UPTIME_DURATION: -1} == "m" ? 60 : 1) ))
143+
if [ "$NEW_UPTIME_SECONDS" -gt "$UPTIME_SECONDS" ]; then
144+
echo "Failed: Availability score for the pool did not drop after clearing"
145+
return 1
146+
fi
147+
129148
echo "TEST PASSED"
130149
return 0
131150
}

0 commit comments

Comments
 (0)