Skip to content

Commit 50c2f07

Browse files
committed
qa/standalone/scrub: fix osd-scrub-repair()
following changes to 'scrub while recovering' logic, the 'what type of scrubs are allowed to run when recovering' tests were broken, and are now fixed. Signed-off-by: Ronen Friedman <[email protected]>
1 parent b657f9f commit 50c2f07

File tree

1 file changed

+73
-13
lines changed

1 file changed

+73
-13
lines changed

qa/standalone/scrub/osd-scrub-repair.sh

Lines changed: 73 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,30 @@ function TEST_corrupt_and_repair_replicated() {
107107
corrupt_and_repair_one $dir $poolname $(get_primary $poolname SOMETHING) || return 1
108108
}
109109

110+
#
111+
# Allow operator-initiated scrubs to be scheduled even when some recovering is still
112+
# undergoing on the same OSD
113+
#
114+
function TEST_allow_oper_initiated_scrub_during_recovery() {
115+
local dir=$1
116+
local -A cluster_conf=(
117+
['osds_num']="2"
118+
['pgs_in_pool']="4"
119+
['pool_name']="nopool"
120+
['pool_default_size']="2"
121+
['extras']="--osd_scrub_during_recovery=false \
122+
--osd_debug_pretend_recovery_active=true"
123+
)
124+
125+
standard_scrub_cluster $dir cluster_conf
126+
local poolname=rbd
127+
create_rbd_pool || return 1
128+
wait_for_clean || return 1
129+
130+
add_something $dir $poolname || return 1
131+
oper_scrub_and_schedule $dir $poolname $(get_not_primary $poolname SOMETHING) || return 1
132+
}
133+
110134
#
111135
# Allow repair to be scheduled when some recovering is still undergoing on the same OSD
112136
#
@@ -117,10 +141,8 @@ function TEST_allow_repair_during_recovery() {
117141
run_mon $dir a --osd_pool_default_size=2 || return 1
118142
run_mgr $dir x || return 1
119143
run_osd $dir 0 --osd_scrub_during_recovery=false \
120-
--osd_repair_during_recovery=true \
121144
--osd_debug_pretend_recovery_active=true || return 1
122145
run_osd $dir 1 --osd_scrub_during_recovery=false \
123-
--osd_repair_during_recovery=true \
124146
--osd_debug_pretend_recovery_active=true || return 1
125147
create_rbd_pool || return 1
126148
wait_for_clean || return 1
@@ -132,25 +154,62 @@ function TEST_allow_repair_during_recovery() {
132154
#
133155
# Skip non-repair scrub correctly during recovery
134156
#
157+
# Note: forgoing the automatic creation of a pool in standard_scrub_cluster as
158+
# the test requires a specific RBD pool.
135159
function TEST_skip_non_repair_during_recovery() {
136160
local dir=$1
137-
local poolname=rbd
161+
local -A cluster_conf=(
162+
['osds_num']="2"
163+
['pgs_in_pool']="4"
164+
['pool_name']="nopool"
165+
['pool_default_size']="2"
166+
['extras']="--osd_scrub_during_recovery=false --osd_debug_pretend_recovery_active=true"
167+
)
138168

139-
run_mon $dir a --osd_pool_default_size=2 || return 1
140-
run_mgr $dir x || return 1
141-
run_osd $dir 0 --osd_scrub_during_recovery=false \
142-
--osd_repair_during_recovery=true \
143-
--osd_debug_pretend_recovery_active=true || return 1
144-
run_osd $dir 1 --osd_scrub_during_recovery=false \
145-
--osd_repair_during_recovery=true \
146-
--osd_debug_pretend_recovery_active=true || return 1
169+
standard_scrub_cluster $dir cluster_conf
170+
local poolname=rbd
147171
create_rbd_pool || return 1
148172
wait_for_clean || return 1
149173

150174
add_something $dir $poolname || return 1
151175
scrub_and_not_schedule $dir $poolname $(get_not_primary $poolname SOMETHING) || return 1
152176
}
153177

178+
179+
function oper_scrub_and_schedule() {
180+
local dir=$1
181+
local poolname=$2
182+
local osd=$3
183+
184+
#
185+
# 1) start an operator-initiated scrub
186+
#
187+
local pg=$(get_pg $poolname SOMETHING)
188+
local last_scrub=$(get_last_scrub_stamp $pg)
189+
ceph tell $pg scrub
190+
191+
#
192+
# 2) Assure the scrub was executed
193+
#
194+
sleep 3
195+
for ((i=0; i < 3; i++)); do
196+
if test "$(get_last_scrub_stamp $pg)" '>' "$last_scrub" ; then
197+
break
198+
fi
199+
if test "$(get_last_scrub_stamp $pg)" '==' "$last_scrub" ; then
200+
return 1
201+
fi
202+
sleep 1
203+
done
204+
205+
#
206+
# 3) Access to the file must OK
207+
#
208+
objectstore_tool $dir $osd SOMETHING list-attrs || return 1
209+
rados --pool $poolname get SOMETHING $dir/COPY || return 1
210+
diff $dir/ORIGINAL $dir/COPY || return 1
211+
}
212+
154213
function scrub_and_not_schedule() {
155214
local dir=$1
156215
local poolname=$2
@@ -166,6 +225,7 @@ function scrub_and_not_schedule() {
166225
#
167226
# 2) Assure the scrub is not scheduled
168227
#
228+
sleep 3
169229
for ((i=0; i < 3; i++)); do
170230
if test "$(get_last_scrub_stamp $pg)" '>' "$last_scrub" ; then
171231
return 1
@@ -218,9 +278,9 @@ function corrupt_and_repair_two() {
218278

219279
#
220280
# 1) add an object
221-
# 2) remove the corresponding file from a designated OSD
281+
# 2) remove the corresponding object from a designated OSD
222282
# 3) repair the PG
223-
# 4) check that the file has been restored in the designated OSD
283+
# 4) check that the object has been restored in the designated OSD
224284
#
225285
function corrupt_and_repair_one() {
226286
local dir=$1

0 commit comments

Comments
 (0)