X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fqa%2Fstandalone%2Fscrub%2Fosd-scrub-snaps.sh;h=cf6f67b6dbe2d1b6d3694b940d182a8de738ea0a;hb=94b1876350060563a6ac95339df15f95fd3ebadc;hp=4c03bdb9efcd1cfd737e20b2ff210f68f87cf000;hpb=4832b6f0acade977670a37c20ff5dbe69e727416;p=ceph.git diff --git a/ceph/qa/standalone/scrub/osd-scrub-snaps.sh b/ceph/qa/standalone/scrub/osd-scrub-snaps.sh index 4c03bdb9e..cf6f67b6d 100755 --- a/ceph/qa/standalone/scrub/osd-scrub-snaps.sh +++ b/ceph/qa/standalone/scrub/osd-scrub-snaps.sh @@ -16,6 +16,10 @@ # source $CEPH_ROOT/qa/standalone/ceph-helpers.sh +# Test development and debugging +# Set to "yes" in order to ignore diff errors and save results to update test +getjson="no" + function run() { local dir=$1 shift @@ -27,23 +31,26 @@ function run() { local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')} for func in $funcs ; do + setup $dir || return 1 $func $dir || return 1 + teardown $dir || return 1 done } function TEST_scrub_snaps() { local dir=$1 local poolname=test + local OBJS=15 + local OSDS=1 TESTDATA="testdata.$$" - setup $dir || return 1 - run_mon $dir a --osd_pool_default_size=1 || return 1 + run_mon $dir a --osd_pool_default_size=$OSDS || return 1 run_mgr $dir x || return 1 - run_osd $dir 0 || return 1 - - create_rbd_pool || return 1 - wait_for_clean || return 1 + for osd in $(seq 0 $(expr $OSDS - 1)) + do + run_osd $dir $osd || return 1 + done # Create a pool with a single pg create_pool $poolname 1 1 @@ -51,11 +58,12 @@ function TEST_scrub_snaps() { poolid=$(ceph osd dump | grep "^pool.*[']test[']" | awk '{ print $2 }') dd if=/dev/urandom of=$TESTDATA bs=1032 count=1 - for i in `seq 1 15` + for i in `seq 1 $OBJS` do rados -p $poolname put obj${i} $TESTDATA done + local primary=$(get_primary $poolname obj1) SNAP=1 rados -p $poolname mksnap snap${SNAP} dd if=/dev/urandom of=$TESTDATA bs=256 count=${SNAP} @@ -97,66 +105,67 @@ function TEST_scrub_snaps() { kill_daemons $dir TERM osd || return 1 - # Don't need to ceph_objectstore_tool function because osd stopped + # Don't need to use ceph_objectstore_tool() function because osd stopped - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj1)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" --force remove + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj1)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" --force remove - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --op list obj5 | grep \"snapid\":2)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" remove + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --op list obj5 | grep \"snapid\":2)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" remove - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --op list obj5 | grep \"snapid\":1)" + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --op list obj5 | grep \"snapid\":1)" OBJ5SAVE="$JSON" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" remove + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" remove - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --op list obj5 | grep \"snapid\":4)" + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --op list obj5 | grep \"snapid\":4)" dd if=/dev/urandom of=$TESTDATA bs=256 count=18 - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" set-bytes $TESTDATA + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" set-bytes $TESTDATA - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj3)" + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj3)" dd if=/dev/urandom of=$TESTDATA bs=256 count=15 - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" set-bytes $TESTDATA + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" set-bytes $TESTDATA - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --op list obj4 | grep \"snapid\":7)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" remove + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --op list obj4 | grep \"snapid\":7)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" remove - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj2)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" rm-attr snapset + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj2)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" rm-attr snapset # Create a clone which isn't in snapset and doesn't have object info JSON="$(echo "$OBJ5SAVE" | sed s/snapid\":1/snapid\":7/)" dd if=/dev/urandom of=$TESTDATA bs=256 count=7 - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" set-bytes $TESTDATA + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" set-bytes $TESTDATA rm -f $TESTDATA - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj6)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" clear-snapset - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj7)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" clear-snapset corrupt - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj8)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" clear-snapset seq - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj9)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" clear-snapset clone_size - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj10)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" clear-snapset clone_overlap - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj11)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" clear-snapset clones - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj12)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" clear-snapset head - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj13)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" clear-snapset snaps - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj14)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" clear-snapset size + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj6)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" clear-snapset + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj7)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" clear-snapset corrupt + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj8)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" clear-snapset seq + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj9)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" clear-snapset clone_size + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj10)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" clear-snapset clone_overlap + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj11)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" clear-snapset clones + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj12)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" clear-snapset head + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj13)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" clear-snapset snaps + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj14)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" clear-snapset size echo "garbage" > $dir/bad - JSON="$(ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal --head --op list obj15)" - ceph-objectstore-tool --data-path $dir/0 --journal-path $dir/0/journal "$JSON" set-attr snapset $dir/bad + JSON="$(ceph-objectstore-tool --data-path $dir/${primary} --head --op list obj15)" + ceph-objectstore-tool --data-path $dir/${primary} "$JSON" set-attr snapset $dir/bad rm -f $dir/bad - run_osd $dir 0 || return 1 - create_rbd_pool || return 1 - wait_for_clean || return 1 + for osd in $(seq 0 $(expr $OSDS - 1)) + do + run_osd $dir $osd || return 1 + done local pgid="${poolid}.0" if ! pg_scrub "$pgid" ; then @@ -172,7 +181,6 @@ function TEST_scrub_snaps() { test $(jq -r '.[0]' $dir/json) = $pgid || return 1 rados list-inconsistent-snapset $pgid > $dir/json || return 1 - test $(jq '.inconsistents | length' $dir/json) = "21" || return 1 local jqfilter='.inconsistents' local sortkeys='import json; import sys ; JSON=sys.stdin.read() ; ud = json.loads(JSON) ; print json.dumps(ud, sort_keys=True, indent=2)' @@ -272,7 +280,7 @@ function TEST_scrub_snaps() { }, { "errors": [ - "oi_attr_missing", + "info_missing", "headless" ], "snap": 7, @@ -280,6 +288,32 @@ function TEST_scrub_snaps() { "nspace": "", "name": "obj5" }, + { + "name": "obj10", + "nspace": "", + "locator": "", + "snap": "head", + "snapset": { + "head_exists": 1, + "snap_context": { + "seq": 1, + "snaps": [ + 1 + ] + }, + "clones": [ + { + "snap": 1, + "size": 1032, + "overlap": "????", + "snaps": [ + 1 + ] + } + ] + }, + "errors": [] + }, { "extra clones": [ 1 @@ -290,7 +324,17 @@ function TEST_scrub_snaps() { "snap": "head", "locator": "", "nspace": "", - "name": "obj11" + "name": "obj11", + "snapset": { + "head_exists": 1, + "snap_context": { + "seq": 1, + "snaps": [ + 1 + ] + }, + "clones": [] + } }, { "errors": [ @@ -299,11 +343,56 @@ function TEST_scrub_snaps() { "snap": "head", "locator": "", "nspace": "", - "name": "obj12" + "name": "obj12", + "snapset": { + "head_exists": 0, + "snap_context": { + "seq": 1, + "snaps": [ + 1 + ] + }, + "clones": [ + { + "snap": 1, + "size": 1032, + "overlap": "[]", + "snaps": [ + 1 + ] + } + ] + } + }, + { + "name": "obj14", + "nspace": "", + "locator": "", + "snap": "head", + "snapset": { + "head_exists": 1, + "snap_context": { + "seq": 1, + "snaps": [ + 1 + ] + }, + "clones": [ + { + "snap": 1, + "size": 1033, + "overlap": "[]", + "snaps": [ + 1 + ] + } + ] + }, + "errors": [] }, { "errors": [ - "ss_attr_corrupted" + "snapset_corrupted" ], "snap": "head", "locator": "", @@ -316,7 +405,7 @@ function TEST_scrub_snaps() { 4 ], "errors": [ - "ss_attr_missing", + "snapset_missing", "extra_clones" ], "snap": "head", @@ -331,7 +420,37 @@ function TEST_scrub_snaps() { "snap": "head", "locator": "", "nspace": "", - "name": "obj3" + "name": "obj3", + "snapset": { + "head_exists": 1, + "snap_context": { + "seq": 3, + "snaps": [ + 3, + 2, + 1 + ] + }, + "clones": [ + { + "snap": 1, + "size": 1032, + "overlap": "[]", + "snaps": [ + 1 + ] + }, + { + "snap": 3, + "size": 256, + "overlap": "[]", + "snaps": [ + 3, + 2 + ] + } + ] + } }, { "missing": [ @@ -343,7 +462,38 @@ function TEST_scrub_snaps() { "snap": "head", "locator": "", "nspace": "", - "name": "obj4" + "name": "obj4", + "snapset": { + "head_exists": 1, + "snap_context": { + "seq": 7, + "snaps": [ + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + }, + "clones": [ + { + "snap": 7, + "size": 1032, + "overlap": "[]", + "snaps": [ + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } + ] + } }, { "missing": [ @@ -360,7 +510,57 @@ function TEST_scrub_snaps() { "snap": "head", "locator": "", "nspace": "", - "name": "obj5" + "name": "obj5", + "snapset": { + "head_exists": 1, + "snap_context": { + "seq": 6, + "snaps": [ + 6, + 5, + 4, + 3, + 2, + 1 + ] + }, + "clones": [ + { + "snap": 1, + "size": 1032, + "overlap": "[]", + "snaps": [ + 1 + ] + }, + { + "snap": 2, + "size": 256, + "overlap": "[]", + "snaps": [ + 2 + ] + }, + { + "snap": 4, + "size": 512, + "overlap": "[]", + "snaps": [ + 4, + 3 + ] + }, + { + "snap": 6, + "size": 1024, + "overlap": "[]", + "snaps": [ + 6, + 5 + ] + } + ] + } }, { "extra clones": [ @@ -372,7 +572,17 @@ function TEST_scrub_snaps() { "snap": "head", "locator": "", "nspace": "", - "name": "obj6" + "name": "obj6", + "snapset": { + "head_exists": 1, + "snap_context": { + "seq": 1, + "snaps": [ + 1 + ] + }, + "clones": [] + } }, { "extra clones": [ @@ -385,16 +595,69 @@ function TEST_scrub_snaps() { "snap": "head", "locator": "", "nspace": "", - "name": "obj7" + "name": "obj7", + "snapset": { + "head_exists": 0, + "snap_context": { + "seq": 0, + "snaps": [] + }, + "clones": [] + } }, { "errors": [ - "snapset_mismatch" + "snapset_error" ], "snap": "head", "locator": "", "nspace": "", - "name": "obj8" + "name": "obj8", + "snapset": { + "head_exists": 1, + "snap_context": { + "seq": 0, + "snaps": [ + 1 + ] + }, + "clones": [ + { + "snap": 1, + "size": 1032, + "overlap": "[]", + "snaps": [ + 1 + ] + } + ] + } + }, + { + "name": "obj9", + "nspace": "", + "locator": "", + "snap": "head", + "snapset": { + "head_exists": 1, + "snap_context": { + "seq": 1, + "snaps": [ + 1 + ] + }, + "clones": [ + { + "snap": 1, + "size": "????", + "overlap": "[]", + "snaps": [ + 1 + ] + } + ] + }, + "errors": [] } ], "epoch": 20 @@ -402,9 +665,13 @@ function TEST_scrub_snaps() { EOF jq "$jqfilter" $dir/json | python -c "$sortkeys" > $dir/csjson - diff ${DIFFCOLOPTS} $dir/checkcsjson $dir/csjson || return 1 + diff ${DIFFCOLOPTS} $dir/checkcsjson $dir/csjson || test $getjson = "yes" || return 1 + if test $getjson = "yes" + then + jq '.' $dir/json > save1.json + fi - if which jsonschema > /dev/null; + if test "$LOCALRUN" = "yes" && which jsonschema > /dev/null; then jsonschema -i $dir/json $CEPH_ROOT/doc/rados/command/list-inconsistent-snap.json || return 1 fi @@ -455,15 +722,13 @@ EOF for err_string in "${err_strings[@]}" do - if ! grep "$err_string" $dir/osd.0.log > /dev/null; + if ! grep "$err_string" $dir/osd.${primary}.log > /dev/null; then echo "Missing log message '$err_string'" ERRORS=$(expr $ERRORS + 1) fi done - teardown $dir || return 1 - if [ $ERRORS != "0" ]; then echo "TEST FAILED WITH $ERRORS ERRORS"