#!/bin/bash die() { echo "$@" exit 1 } usage() { cat < $V1 expect_false $RADOS_TOOL -p $POOL setxattr $OBJ 2>/dev/null expect_false $RADOS_TOOL -p $POOL setxattr $OBJ foo fooval extraarg 2>/dev/null $RADOS_TOOL -p $POOL setxattr $OBJ foo fooval $RADOS_TOOL -p $POOL getxattr $OBJ foo > $V2 cmp $V1 $V2 cat $V1 | $RADOS_TOOL -p $POOL setxattr $OBJ bar $RADOS_TOOL -p $POOL getxattr $OBJ bar > $V2 cmp $V1 $V2 $RADOS_TOOL -p $POOL listxattr $OBJ > $V1 grep -q foo $V1 grep -q bar $V1 wc -l $V1 | grep -q "^2 " rm $V1 $V2 cleanup } test_rmobj() { p=`uuidgen` $CEPH_TOOL osd pool create $p 1 $CEPH_TOOL osd pool set-quota $p max_objects 1 V1=`mktemp fooattrXXXXXXX` rados put $OBJ $V1 -p $p while ! $CEPH_TOOL osd dump | grep 'full max_objects' do sleep 2 done rados -p $p rm $OBJ --force-full rados rmpool $p $p --yes-i-really-really-mean-it rm $V1 } test_ls() { echo "Testing rados ls command" p=`uuidgen` $CEPH_TOOL osd pool create $p 1 NS=10 OBJS=20 # Include default namespace (0) in the total TOTAL=$(expr $OBJS \* $(expr $NS + 1)) for nsnum in `seq 0 $NS` do for onum in `seq 1 $OBJS` do if [ "$nsnum" = "0" ]; then "$RADOS_TOOL" -p $p put obj${onum} /etc/fstab 2> /dev/null else "$RADOS_TOOL" -p $p -N "NS${nsnum}" put obj${onum} /etc/fstab 2> /dev/null fi done done CHECK=$("$RADOS_TOOL" -p $p ls 2> /dev/null | wc -l) if test "$OBJS" != "$CHECK"; then die "Created $OBJS objects in default namespace but saw $CHECK" fi TESTNS=NS${NS} CHECK=$("$RADOS_TOOL" -p $p -N $TESTNS ls 2> /dev/null | wc -l) if test "$OBJS" != "$CHECK"; then die "Created $OBJS objects in $TESTNS namespace but saw $CHECK" fi CHECK=$("$RADOS_TOOL" -p $p --all ls 2> /dev/null | wc -l) if test "$TOTAL" != "$CHECK"; then die "Created $TOTAL objects but saw $CHECK" fi $RADOS_TOOL rmpool $p $p --yes-i-really-really-mean-it } test_cleanup() { echo "Testing rados cleanup command" p=`uuidgen` $CEPH_TOOL osd pool create $p 1 NS=5 OBJS=4 # Include default namespace (0) in the total TOTAL=$(expr $OBJS \* $(expr $NS + 1)) for nsnum in `seq 0 $NS` do for onum in `seq 1 $OBJS` do if [ "$nsnum" = "0" ]; then "$RADOS_TOOL" -p $p put obj${onum} /etc/fstab 2> /dev/null else "$RADOS_TOOL" -p $p -N "NS${nsnum}" put obj${onum} /etc/fstab 2> /dev/null fi done done $RADOS_TOOL -p $p --all ls > $TDIR/before.ls.out 2> /dev/null $RADOS_TOOL -p $p bench 3 write --no-cleanup 2> /dev/null $RADOS_TOOL -p $p -N NS1 bench 3 write --no-cleanup 2> /dev/null $RADOS_TOOL -p $p -N NS2 bench 3 write --no-cleanup 2> /dev/null $RADOS_TOOL -p $p -N NS3 bench 3 write --no-cleanup 2> /dev/null # Leave dangling objects without a benchmark_last_metadata in NS4 expect_false timeout 3 $RADOS_TOOL -p $p -N NS4 bench 30 write --no-cleanup 2> /dev/null $RADOS_TOOL -p $p -N NS5 bench 3 write --no-cleanup 2> /dev/null $RADOS_TOOL -p $p -N NS3 cleanup 2> /dev/null #echo "Check NS3 after specific cleanup" CHECK=$($RADOS_TOOL -p $p -N NS3 ls | wc -l) if test "$OBJS" != "$CHECK"; then die "Expected $OBJS objects in NS3 but saw $CHECK" fi #echo "Try to cleanup all" $RADOS_TOOL -p $p --all cleanup #echo "Check all namespaces" $RADOS_TOOL -p $p --all ls > $TDIR/after.ls.out 2> /dev/null CHECK=$(cat $TDIR/after.ls.out | wc -l) if test "$TOTAL" != "$CHECK"; then die "Expected $TOTAL objects but saw $CHECK" fi if ! diff $TDIR/before.ls.out $TDIR/after.ls.out then die "Different objects found after cleanup" fi set +e run_expect_fail $RADOS_TOOL -p $p cleanup --prefix illegal_prefix run_expect_succ $RADOS_TOOL -p $p cleanup --prefix benchmark_data_otherhost set -e $RADOS_TOOL rmpool $p $p --yes-i-really-really-mean-it } test_xattr test_omap test_rmobj test_ls test_cleanup echo "SUCCESS!" exit 0