Skip to content

Commit

Permalink
test: Fix TEST_scrub_extended_sleep test (corrected test name)
Browse files Browse the repository at this point in the history
Didn't really test extended sleep in original code:
Cause by: 3bfb5c2

Signed-off-by: David Zafman <[email protected]>
  • Loading branch information
dzafman committed Nov 17, 2020
1 parent 0a0ed89 commit 38c3130
Showing 1 changed file with 56 additions and 6 deletions.
62 changes: 56 additions & 6 deletions qa/standalone/scrub/osd-scrub-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,37 @@ function TEST_interval_changes() {
teardown $dir || return 1
}

function TEST_scrub_extented_sleep() {
function TEST_scrub_extended_sleep() {
local dir=$1
local poolname=test
local OSDS=3
local objects=15

TESTDATA="testdata.$$"

DAY=$(date +%w)
# Handle wrap
if [ "$DAY" -ge "4" ];
then
DAY="0"
fi
# Start after 2 days in case we are near midnight
DAY_START=$(expr $DAY + 2)
DAY_END=$(expr $DAY + 3)

setup $dir || return 1
run_mon $dir a --osd_pool_default_size=3 || return 1
run_mgr $dir x || return 1
for osd in $(seq 0 $(expr $OSDS - 1))
do
run_osd $dir $osd --osd_scrub_sleep=0 \
--osd_scrub_extended_sleep=10 \
--osd_scrub_extended_sleep=20 \
--bluestore_cache_autotune=false \
--osd_deep_scrub_randomize_ratio=0.0 \
--osd_scrub_interval_randomize_ratio=0 || return 1
--osd_scrub_interval_randomize_ratio=0 \
--osd_scrub_begin_week_day=$DAY_START \
--osd_scrub_end_week_day=$DAY_END \
|| return 1
done

# Create a pool with a single pg
Expand All @@ -217,14 +230,51 @@ function TEST_scrub_extented_sleep() {
local last_scrub=$(get_last_scrub_stamp $pgid)
ceph tell $pgid scrub || return 1

# Due to the long delay, the scrub should not be done within 3 seconds
for ((i=0; i < 3; i++)); do
# Allow scrub to start extended sleep
PASSED="false"
for ((i=0; i < 15; i++)); do
if grep -q "scrub state.*, sleeping" $dir/osd.${primary}.log
then
PASSED="true"
break
fi
sleep 1
done

# Check that extended sleep was triggered
if [ $PASSED = "false" ];
then
return 1
fi

# release scrub to run after extended sleep finishes
ceph tell osd.$primary config set osd_scrub_begin_week_day 0
ceph tell osd.$primary config set osd_scrub_end_week_day 0

# Due to extended sleep, the scrub should not be done within 20 seconds
# but test up to 10 seconds and make sure it happens by 25 seconds.
count=0
PASSED="false"
for ((i=0; i < 25; i++)); do
count=$(expr $count + 1)
if test "$(get_last_scrub_stamp $pgid)" '>' "$last_scrub" ; then
return 1
# Did scrub run too soon?
if [ $count -lt "10" ];
then
return 1
fi
PASSED="true"
break
fi
sleep 1
done

# Make sure scrub eventually ran
if [ $PASSED = "false" ];
then
return 1
fi

teardown $dir || return 1
}

Expand Down

0 comments on commit 38c3130

Please sign in to comment.