From: Ronen Friedman Date: Thu, 13 Feb 2025 16:53:53 +0000 (-0600) Subject: qa/standalone: do not use /etc/fstab as an always-there bytes source X-Git-Tag: v20.0.0~101^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F61812%2Fhead;p=ceph.git qa/standalone: do not use /etc/fstab as an always-there bytes source Multiple tests use /etc/fstab when a small data file is required as input. After all, as some comments say: # something that is always there Alas - it's not always there. Not in containers. Replacing with a newly-created temporary file filled with random bytes. For completeness - replacing similar references to /etc/resolv.conf (as a source for random objects) in the standalone tests, too. Signed-off-by: Ronen Friedman --- diff --git a/qa/standalone/ceph-helpers.sh b/qa/standalone/ceph-helpers.sh index 72d70ca7ad5..0fc1182bd1e 100755 --- a/qa/standalone/ceph-helpers.sh +++ b/qa/standalone/ceph-helpers.sh @@ -2326,6 +2326,37 @@ function test_get_op_scheduler() { teardown $dir || return 1 } +######################################################################## +## +# Create a temporary file with random data and return its name. The file +# should be removed by the caller. +# +# Example: +# testdata=$(file_with_random_data 1024) +# +# @param the size of the file created in bytes. As in most use cases +# the size is meaningless, a default (512) is used if not specified +# @return the name of the file created +# +function file_with_random_data() { + local size_bytes=${1:-512} + local file=$(mktemp) + dd if=/dev/urandom of=$file bs=$size_bytes count=1 + printf '%s' "$file" +} + +function test_file_with_random_data() { + local dir=$1 + + setup $dir || return 1 + local file=$(file_with_random_data 4000) + test -f $file || return 1 + test $(stat -c %s $file) = 4000 || return 1 + rm $file + teardown $dir || return 1 +} + + ####################################################################### ## diff --git a/qa/standalone/osd/divergent-priors.sh b/qa/standalone/osd/divergent-priors.sh index 40d72544d1b..d430e5b6149 100755 --- a/qa/standalone/osd/divergent-priors.sh +++ b/qa/standalone/osd/divergent-priors.sh @@ -56,10 +56,7 @@ function run() { function TEST_divergent() { local dir=$1 - # something that is always there - local dummyfile='/etc/fstab' - local dummyfile2='/etc/resolv.conf' - + local dummyfile=$(file_with_random_data) local num_osds=3 local osds="$(seq 0 $(expr $num_osds - 1))" run_mon $dir a || return 1 @@ -96,7 +93,7 @@ function TEST_divergent() { # write a bunch of objects for i in $(seq 1 $testobjects) do - rados -p $poolname put existing_$i $dummyfile + rados -p $poolname put existing_$i $dummyfile || return 1 done WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean @@ -153,7 +150,8 @@ function TEST_divergent() { objname="existing_$(expr $DIVERGENT_WRITE + $DIVERGENT_REMOVE)" echo "writing non-divergent object $objname" ceph pg dump pgs - rados -p $poolname put $objname $dummyfile2 + # a second object (using a different size, for good measure) + dd if=/dev/urandom bs=1000 count=1 | rados -p "$poolname" put "$objname" - || return 1 # ensure no recovery of up osds first echo 'delay recovery' @@ -220,6 +218,7 @@ function TEST_divergent() { fi echo "success" + rm -f $dummyfile delete_pool $poolname kill_daemons $dir || return 1 } @@ -227,9 +226,9 @@ function TEST_divergent() { function TEST_divergent_ec() { local dir=$1 - # something that is always there - local dummyfile='/etc/fstab' - local dummyfile2='/etc/resolv.conf' + local dummyfile=$(file_with_random_data) + # a second object, different in size and contents + local dummyfile2=$(file_with_random_data 1000) local num_osds=3 local osds="$(seq 0 $(expr $num_osds - 1))" @@ -265,7 +264,7 @@ function TEST_divergent_ec() { # write a bunch of objects for i in $(seq 1 $testobjects) do - rados -p $poolname put existing_$i $dummyfile + rados -p $poolname put existing_$i $dummyfile || return 1 done WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean @@ -322,7 +321,8 @@ function TEST_divergent_ec() { objname="existing_$(expr $DIVERGENT_WRITE + $DIVERGENT_REMOVE)" echo "writing non-divergent object $objname" ceph pg dump pgs - rados -p $poolname put $objname $dummyfile2 + rados -p $poolname put $objname $dummyfile2 || return 1 + rm -f $dummyfile2 WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean @@ -366,6 +366,7 @@ function TEST_divergent_ec() { echo 'wait for peering' ceph pg dump pgs rados -p $poolname put foo $dummyfile + rm -f $dummyfile echo "killing divergent $divergent" ceph pg dump pgs @@ -420,9 +421,9 @@ function TEST_divergent_ec() { function TEST_divergent_2() { local dir=$1 - # something that is always there - local dummyfile='/etc/fstab' - local dummyfile2='/etc/resolv.conf' + local dummyfile=$(file_with_random_data) + # a second object, different in size and contents + local dummyfile2=$(file_with_random_data 1000) local num_osds=3 local osds="$(seq 0 $(expr $num_osds - 1))" @@ -460,7 +461,7 @@ function TEST_divergent_2() { # write a bunch of objects for i in $(seq 1 $testobjects) do - rados -p $poolname put existing_$i $dummyfile + rados -p $poolname put existing_$i $dummyfile || return 1 done WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean @@ -528,7 +529,8 @@ function TEST_divergent_2() { objname="existing_$(expr $DIVERGENT_WRITE + $DIVERGENT_REMOVE)" echo "writing non-divergent object $objname" ceph pg dump pgs - rados -p $poolname put $objname $dummyfile2 + rados -p $poolname put $objname $dummyfile2 || return 1 + rm -f $dummyfile2 WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean @@ -560,7 +562,8 @@ function TEST_divergent_2() { ceph pg dump pgs echo 'wait for peering' ceph pg dump pgs - rados -p $poolname put foo $dummyfile + rados -p $poolname put foo $dummyfile || return 1 + rm -f $dummyfile # At this point the divergent_priors should have been detected @@ -617,7 +620,6 @@ function TEST_divergent_2() { echo "success" rm $dir/$expfile - delete_pool $poolname kill_daemons $dir || return 1 } @@ -627,9 +629,9 @@ function TEST_divergent_2() { function TEST_divergent_3() { local dir=$1 - # something that is always there - local dummyfile='/etc/fstab' - local dummyfile2='/etc/resolv.conf' + local dummyfile=$(file_with_random_data) + # a second file (using a different size, for good measure) + local dummyfile2=$(file_with_random_data 1000) local num_osds=3 local osds="$(seq 0 $(expr $num_osds - 1))" @@ -685,7 +687,7 @@ function TEST_divergent_3() { # write a bunch of objects for i in $(seq 1 $testobjects) do - rados -p $poolname put existing_$i $dummyfile + rados -p $poolname put existing_$i $dummyfile || return 1 done WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean @@ -753,7 +755,7 @@ function TEST_divergent_3() { objname="existing_$(expr $DIVERGENT_WRITE + $DIVERGENT_REMOVE)" echo "writing non-divergent object $objname" ceph pg dump pgs - rados -p $poolname put $objname $dummyfile2 + rados -p $poolname put $objname $dummyfile2 || return 1 WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean @@ -786,6 +788,8 @@ function TEST_divergent_3() { echo 'wait for peering' ceph pg dump pgs rados -p $poolname put foo $dummyfile + rm -f $dummyfile + rm -f $dummyfile2 # At this point the divergent_priors should have been detected @@ -842,7 +846,6 @@ function TEST_divergent_3() { echo "success" rm $dir/$expfile - delete_pool $poolname kill_daemons $dir || return 1 } diff --git a/qa/standalone/osd/repeer-on-acting-back.sh b/qa/standalone/osd/repeer-on-acting-back.sh index af406ef926b..c4d261f0489 100755 --- a/qa/standalone/osd/repeer-on-acting-back.sh +++ b/qa/standalone/osd/repeer-on-acting-back.sh @@ -46,7 +46,6 @@ function run() { function TEST_repeer_on_down_acting_member_coming_back() { local dir=$1 - local dummyfile='/etc/fstab' local num_osds=6 local osds="$(seq 0 $(expr $num_osds - 1))" @@ -72,11 +71,13 @@ function TEST_repeer_on_down_acting_member_coming_back() { wait_for_clean || return 1 echo "writing initial objects" + local dummyfile=$(file_with_random_data) # write a bunch of objects for i in $(seq 1 $testobjects) do - rados -p $poolname put existing_$i $dummyfile + rados -p $poolname put existing_$i $dummyfile || return 1 done + rm -f $dummyfile WAIT_FOR_CLEAN_TIMEOUT=20 wait_for_clean diff --git a/qa/standalone/scrub/osd-scrub-test.sh b/qa/standalone/scrub/osd-scrub-test.sh index 385479258f2..3e4664d3138 100755 --- a/qa/standalone/scrub/osd-scrub-test.sh +++ b/qa/standalone/scrub/osd-scrub-test.sh @@ -54,8 +54,6 @@ function TEST_scrub_test() { local OSDS=3 local objects=15 - TESTDATA="testdata.$$" - run_mon $dir a --osd_pool_default_size=3 || return 1 run_mgr $dir x --mgr_stats_period=1 || return 1 local ceph_osd_args="--osd-scrub-interval-randomize-ratio=0 --osd-deep-scrub-randomize-ratio=0 " @@ -71,12 +69,12 @@ function TEST_scrub_test() { wait_for_clean || return 1 poolid=$(ceph osd dump | grep "^pool.*[']${poolname}[']" | awk '{ print $2 }') - dd if=/dev/urandom of=$TESTDATA bs=1032 count=1 + local testdata_file=$(file_with_random_data 1032) for i in `seq 1 $objects` do - rados -p $poolname put obj${i} $TESTDATA + rados -p $poolname put obj${i} $testdata_file || return 1 done - rm -f $TESTDATA + rm -f $testdata_file local primary=$(get_primary $poolname obj1) local otherosd=$(get_not_primary $poolname obj1) @@ -87,10 +85,9 @@ function TEST_scrub_test() { local anotherosd="2" fi - CORRUPT_DATA="corrupt-data.$$" - dd if=/dev/urandom of=$CORRUPT_DATA bs=512 count=1 - objectstore_tool $dir $anotherosd obj1 set-bytes $CORRUPT_DATA - rm -f $CORRUPT_DATA + local corrupt_data_file=$(file_with_random_data 512) + objectstore_tool $dir $anotherosd obj1 set-bytes $corrupt_data_file || return 1 + rm -f $corrupt_data_file local pgid="${poolid}.0" pg_deep_scrub "$pgid" || return 1 @@ -694,7 +691,7 @@ function wait_initial_scrubs() { ceph tell osd.* config set osd_scrub_min_interval 7200 ceph tell osd.* config set osd_deep_scrub_interval 14400 ceph tell osd.* config set osd_max_scrubs 32 - ceph tell osd.* config set osd_scrub_sleep 0 + ceph tell osd.* config set osd_scrub_sleep 1 ceph tell osd.* config set osd_shallow_scrub_chunk_max 10 ceph tell osd.* config set osd_scrub_chunk_max 10 @@ -709,8 +706,8 @@ function wait_initial_scrubs() { tout=20 while [ $tout -gt 0 ] ; do - sleep 0.5 - (( extr_dbg >= 2 )) && ceph pg dump pgs --format=json-pretty | \ + sleep 1 + (( extr_dbg >= 1 )) && ceph pg dump pgs --format=json-pretty | \ jq '.pg_stats | map(select(.last_scrub_duration == 0)) | map({pgid: .pgid, last_scrub_duration: .last_scrub_duration})' not_done=$(ceph pg dump pgs --format=json-pretty | \ 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() { echo "Still waiting for $not_done PGs to finish initial scrubs (timeout $tout)" tout=$((tout - 1)) done + ceph pg dump pgs --format=json-pretty | \ + jq '.pg_stats | map(select(.last_scrub_duration == 0)) | map({pgid: .pgid, last_scrub_duration: .last_scrub_duration})' (( tout == 0 )) && return 1 return 0 } @@ -749,7 +748,7 @@ function TEST_abort_periodic_for_operator() { ) local extr_dbg=1 # note: 3 and above leave some temp files around - standard_scrub_wpq_cluster "$dir" cluster_conf 3 || return 1 + standard_scrub_wpq_cluster "$dir" cluster_conf 2 || return 1 local poolid=${cluster_conf['pool_id']} local poolname=${cluster_conf['pool_name']} echo "Pool: $poolname : $poolid"