Skip to content

Commit e11d6ce

Browse files
authored
Merge pull request ceph#61812 from ronen-fr/wip-rf-fstab
qa/standalone: do not use /etc/fstab as an always-there bytes source Reviewed-by: Patrick Donnelly <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]> Reviewed-by: Radoslaw Zarzynski <[email protected]>
2 parents 8fae8d0 + 8009a3d commit e11d6ce

File tree

4 files changed

+73
-39
lines changed

4 files changed

+73
-39
lines changed

qa/standalone/ceph-helpers.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,6 +2326,37 @@ function test_get_op_scheduler() {
23262326
teardown $dir || return 1
23272327
}
23282328

2329+
########################################################################
2330+
##
2331+
# Create a temporary file with random data and return its name. The file
2332+
# should be removed by the caller.
2333+
#
2334+
# Example:
2335+
# testdata=$(file_with_random_data 1024)
2336+
#
2337+
# @param the size of the file created in bytes. As in most use cases
2338+
# the size is meaningless, a default (512) is used if not specified
2339+
# @return the name of the file created
2340+
#
2341+
function file_with_random_data() {
2342+
local size_bytes=${1:-512}
2343+
local file=$(mktemp)
2344+
dd if=/dev/urandom of=$file bs=$size_bytes count=1
2345+
printf '%s' "$file"
2346+
}
2347+
2348+
function test_file_with_random_data() {
2349+
local dir=$1
2350+
2351+
setup $dir || return 1
2352+
local file=$(file_with_random_data 4000)
2353+
test -f $file || return 1
2354+
test $(stat -c %s $file) = 4000 || return 1
2355+
rm $file
2356+
teardown $dir || return 1
2357+
}
2358+
2359+
23292360
#######################################################################
23302361

23312362
##

qa/standalone/osd/divergent-priors.sh

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ function run() {
5656
function TEST_divergent() {
5757
local dir=$1
5858

59-
# something that is always there
60-
local dummyfile='/etc/fstab'
61-
local dummyfile2='/etc/resolv.conf'
62-
59+
local dummyfile=$(file_with_random_data)
6360
local num_osds=3
6461
local osds="$(seq 0 $(expr $num_osds - 1))"
6562
run_mon $dir a || return 1
@@ -96,7 +93,7 @@ function TEST_divergent() {
9693
# write a bunch of objects
9794
for i in $(seq 1 $testobjects)
9895
do
99-
rados -p $poolname put existing_$i $dummyfile
96+
rados -p $poolname put existing_$i $dummyfile || return 1
10097
done
10198

10299
WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean
@@ -153,7 +150,8 @@ function TEST_divergent() {
153150
objname="existing_$(expr $DIVERGENT_WRITE + $DIVERGENT_REMOVE)"
154151
echo "writing non-divergent object $objname"
155152
ceph pg dump pgs
156-
rados -p $poolname put $objname $dummyfile2
153+
# a second object (using a different size, for good measure)
154+
dd if=/dev/urandom bs=1000 count=1 | rados -p "$poolname" put "$objname" - || return 1
157155

158156
# ensure no recovery of up osds first
159157
echo 'delay recovery'
@@ -220,16 +218,17 @@ function TEST_divergent() {
220218
fi
221219
echo "success"
222220

221+
rm -f $dummyfile
223222
delete_pool $poolname
224223
kill_daemons $dir || return 1
225224
}
226225

227226
function TEST_divergent_ec() {
228227
local dir=$1
229228

230-
# something that is always there
231-
local dummyfile='/etc/fstab'
232-
local dummyfile2='/etc/resolv.conf'
229+
local dummyfile=$(file_with_random_data)
230+
# a second object, different in size and contents
231+
local dummyfile2=$(file_with_random_data 1000)
233232

234233
local num_osds=3
235234
local osds="$(seq 0 $(expr $num_osds - 1))"
@@ -265,7 +264,7 @@ function TEST_divergent_ec() {
265264
# write a bunch of objects
266265
for i in $(seq 1 $testobjects)
267266
do
268-
rados -p $poolname put existing_$i $dummyfile
267+
rados -p $poolname put existing_$i $dummyfile || return 1
269268
done
270269

271270
WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean
@@ -322,7 +321,8 @@ function TEST_divergent_ec() {
322321
objname="existing_$(expr $DIVERGENT_WRITE + $DIVERGENT_REMOVE)"
323322
echo "writing non-divergent object $objname"
324323
ceph pg dump pgs
325-
rados -p $poolname put $objname $dummyfile2
324+
rados -p $poolname put $objname $dummyfile2 || return 1
325+
rm -f $dummyfile2
326326

327327
WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean
328328

@@ -366,6 +366,7 @@ function TEST_divergent_ec() {
366366
echo 'wait for peering'
367367
ceph pg dump pgs
368368
rados -p $poolname put foo $dummyfile
369+
rm -f $dummyfile
369370

370371
echo "killing divergent $divergent"
371372
ceph pg dump pgs
@@ -420,9 +421,9 @@ function TEST_divergent_ec() {
420421
function TEST_divergent_2() {
421422
local dir=$1
422423

423-
# something that is always there
424-
local dummyfile='/etc/fstab'
425-
local dummyfile2='/etc/resolv.conf'
424+
local dummyfile=$(file_with_random_data)
425+
# a second object, different in size and contents
426+
local dummyfile2=$(file_with_random_data 1000)
426427

427428
local num_osds=3
428429
local osds="$(seq 0 $(expr $num_osds - 1))"
@@ -460,7 +461,7 @@ function TEST_divergent_2() {
460461
# write a bunch of objects
461462
for i in $(seq 1 $testobjects)
462463
do
463-
rados -p $poolname put existing_$i $dummyfile
464+
rados -p $poolname put existing_$i $dummyfile || return 1
464465
done
465466

466467
WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean
@@ -528,7 +529,8 @@ function TEST_divergent_2() {
528529
objname="existing_$(expr $DIVERGENT_WRITE + $DIVERGENT_REMOVE)"
529530
echo "writing non-divergent object $objname"
530531
ceph pg dump pgs
531-
rados -p $poolname put $objname $dummyfile2
532+
rados -p $poolname put $objname $dummyfile2 || return 1
533+
rm -f $dummyfile2
532534

533535
WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean
534536

@@ -560,7 +562,8 @@ function TEST_divergent_2() {
560562
ceph pg dump pgs
561563
echo 'wait for peering'
562564
ceph pg dump pgs
563-
rados -p $poolname put foo $dummyfile
565+
rados -p $poolname put foo $dummyfile || return 1
566+
rm -f $dummyfile
564567

565568
# At this point the divergent_priors should have been detected
566569

@@ -617,7 +620,6 @@ function TEST_divergent_2() {
617620
echo "success"
618621

619622
rm $dir/$expfile
620-
621623
delete_pool $poolname
622624
kill_daemons $dir || return 1
623625
}
@@ -627,9 +629,9 @@ function TEST_divergent_2() {
627629
function TEST_divergent_3() {
628630
local dir=$1
629631

630-
# something that is always there
631-
local dummyfile='/etc/fstab'
632-
local dummyfile2='/etc/resolv.conf'
632+
local dummyfile=$(file_with_random_data)
633+
# a second file (using a different size, for good measure)
634+
local dummyfile2=$(file_with_random_data 1000)
633635

634636
local num_osds=3
635637
local osds="$(seq 0 $(expr $num_osds - 1))"
@@ -685,7 +687,7 @@ function TEST_divergent_3() {
685687
# write a bunch of objects
686688
for i in $(seq 1 $testobjects)
687689
do
688-
rados -p $poolname put existing_$i $dummyfile
690+
rados -p $poolname put existing_$i $dummyfile || return 1
689691
done
690692

691693
WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean
@@ -753,7 +755,7 @@ function TEST_divergent_3() {
753755
objname="existing_$(expr $DIVERGENT_WRITE + $DIVERGENT_REMOVE)"
754756
echo "writing non-divergent object $objname"
755757
ceph pg dump pgs
756-
rados -p $poolname put $objname $dummyfile2
758+
rados -p $poolname put $objname $dummyfile2 || return 1
757759

758760
WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean
759761

@@ -786,6 +788,8 @@ function TEST_divergent_3() {
786788
echo 'wait for peering'
787789
ceph pg dump pgs
788790
rados -p $poolname put foo $dummyfile
791+
rm -f $dummyfile
792+
rm -f $dummyfile2
789793

790794
# At this point the divergent_priors should have been detected
791795

@@ -842,7 +846,6 @@ function TEST_divergent_3() {
842846
echo "success"
843847

844848
rm $dir/$expfile
845-
846849
delete_pool $poolname
847850
kill_daemons $dir || return 1
848851
}

qa/standalone/osd/repeer-on-acting-back.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ function run() {
4646

4747
function TEST_repeer_on_down_acting_member_coming_back() {
4848
local dir=$1
49-
local dummyfile='/etc/fstab'
5049

5150
local num_osds=6
5251
local osds="$(seq 0 $(expr $num_osds - 1))"
@@ -72,11 +71,13 @@ function TEST_repeer_on_down_acting_member_coming_back() {
7271
wait_for_clean || return 1
7372

7473
echo "writing initial objects"
74+
local dummyfile=$(file_with_random_data)
7575
# write a bunch of objects
7676
for i in $(seq 1 $testobjects)
7777
do
78-
rados -p $poolname put existing_$i $dummyfile
78+
rados -p $poolname put existing_$i $dummyfile || return 1
7979
done
80+
rm -f $dummyfile
8081

8182
WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean
8283

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ function TEST_scrub_test() {
5454
local OSDS=3
5555
local objects=15
5656

57-
TESTDATA="testdata.$$"
58-
5957
run_mon $dir a --osd_pool_default_size=3 || return 1
6058
run_mgr $dir x --mgr_stats_period=1 || return 1
6159
local ceph_osd_args="--osd-scrub-interval-randomize-ratio=0 --osd-deep-scrub-randomize-ratio=0 "
@@ -71,12 +69,12 @@ function TEST_scrub_test() {
7169
wait_for_clean || return 1
7270
poolid=$(ceph osd dump | grep "^pool.*[']${poolname}[']" | awk '{ print $2 }')
7371

74-
dd if=/dev/urandom of=$TESTDATA bs=1032 count=1
72+
local testdata_file=$(file_with_random_data 1032)
7573
for i in `seq 1 $objects`
7674
do
77-
rados -p $poolname put obj${i} $TESTDATA
75+
rados -p $poolname put obj${i} $testdata_file || return 1
7876
done
79-
rm -f $TESTDATA
77+
rm -f $testdata_file
8078

8179
local primary=$(get_primary $poolname obj1)
8280
local otherosd=$(get_not_primary $poolname obj1)
@@ -87,10 +85,9 @@ function TEST_scrub_test() {
8785
local anotherosd="2"
8886
fi
8987

90-
CORRUPT_DATA="corrupt-data.$$"
91-
dd if=/dev/urandom of=$CORRUPT_DATA bs=512 count=1
92-
objectstore_tool $dir $anotherosd obj1 set-bytes $CORRUPT_DATA
93-
rm -f $CORRUPT_DATA
88+
local corrupt_data_file=$(file_with_random_data 512)
89+
objectstore_tool $dir $anotherosd obj1 set-bytes $corrupt_data_file || return 1
90+
rm -f $corrupt_data_file
9491

9592
local pgid="${poolid}.0"
9693
pg_deep_scrub "$pgid" || return 1
@@ -694,7 +691,7 @@ function wait_initial_scrubs() {
694691
ceph tell osd.* config set osd_scrub_min_interval 7200
695692
ceph tell osd.* config set osd_deep_scrub_interval 14400
696693
ceph tell osd.* config set osd_max_scrubs 32
697-
ceph tell osd.* config set osd_scrub_sleep 0
694+
ceph tell osd.* config set osd_scrub_sleep 1
698695
ceph tell osd.* config set osd_shallow_scrub_chunk_max 10
699696
ceph tell osd.* config set osd_scrub_chunk_max 10
700697

@@ -709,8 +706,8 @@ function wait_initial_scrubs() {
709706

710707
tout=20
711708
while [ $tout -gt 0 ] ; do
712-
sleep 0.5
713-
(( extr_dbg >= 2 )) && ceph pg dump pgs --format=json-pretty | \
709+
sleep 1
710+
(( extr_dbg >= 1 )) && ceph pg dump pgs --format=json-pretty | \
714711
jq '.pg_stats | map(select(.last_scrub_duration == 0)) | map({pgid: .pgid, last_scrub_duration: .last_scrub_duration})'
715712
not_done=$(ceph pg dump pgs --format=json-pretty | \
716713
jq '.pg_stats | map(select(.last_scrub_duration == 0)) | map({pgid: .pgid, last_scrub_duration: .last_scrub_duration})' | wc -l )
@@ -722,6 +719,8 @@ function wait_initial_scrubs() {
722719
echo "Still waiting for $not_done PGs to finish initial scrubs (timeout $tout)"
723720
tout=$((tout - 1))
724721
done
722+
ceph pg dump pgs --format=json-pretty | \
723+
jq '.pg_stats | map(select(.last_scrub_duration == 0)) | map({pgid: .pgid, last_scrub_duration: .last_scrub_duration})'
725724
(( tout == 0 )) && return 1
726725
return 0
727726
}
@@ -749,7 +748,7 @@ function TEST_abort_periodic_for_operator() {
749748
)
750749
local extr_dbg=1 # note: 3 and above leave some temp files around
751750

752-
standard_scrub_wpq_cluster "$dir" cluster_conf 3 || return 1
751+
standard_scrub_wpq_cluster "$dir" cluster_conf 2 || return 1
753752
local poolid=${cluster_conf['pool_id']}
754753
local poolname=${cluster_conf['pool_name']}
755754
echo "Pool: $poolname : $poolid"

0 commit comments

Comments
 (0)