summaryrefslogtreecommitdiffstats
path: root/src/test/test_rados_tool.sh
diff options
context:
space:
mode:
authorDavid Zafman <dzafman@redhat.com>2015-07-15 02:47:24 +0200
committerDavid Zafman <dzafman@redhat.com>2015-07-16 21:03:10 +0200
commit9cfa88d09bed3ca5d0b4edd494d493d889df9176 (patch)
treefe7cfeca3c18be18c33007b75b462db1b6665bdc /src/test/test_rados_tool.sh
parentrados: Fix bug in export of xattr which dropped first char of key on import (diff)
downloadceph-9cfa88d09bed3ca5d0b4edd494d493d889df9176.tar.xz
ceph-9cfa88d09bed3ca5d0b4edd494d493d889df9176.zip
test: test_rados_tool.sh update due to new import/export semantics
Remove redundant check for rados binary No longer use the attr command so remove check Signed-off-by: David Zafman <dzafman@redhat.com>
Diffstat (limited to 'src/test/test_rados_tool.sh')
-rwxr-xr-xsrc/test/test_rados_tool.sh125
1 files changed, 38 insertions, 87 deletions
diff --git a/src/test/test_rados_tool.sh b/src/test/test_rados_tool.sh
index afd5f91a938..fc79dd0fe8f 100755
--- a/src/test/test_rados_tool.sh
+++ b/src/test/test_rados_tool.sh
@@ -51,10 +51,6 @@ POOL=trs_pool
POOL_CP_TARGET=trs_pool.2
[ -x "$RADOS_TOOL" ] || die "couldn't find $RADOS_TOOL binary to test"
-[ -x "$RADOS_TOOL" ] || die "couldn't find $RADOS_TOOL binary"
-which attr &>/dev/null
-[ $? -eq 0 ] || die "you must install the 'attr' tool to manipulate \
-extended attributes."
while getopts "c:hkp:" flag; do
case $flag in
@@ -69,104 +65,59 @@ done
TDIR=`mktemp -d -t test_rados_tool.XXXXXXXXXX` || die "mktemp failed"
[ $KEEP_TEMP_FILES -eq 0 ] && trap "rm -rf ${TDIR}; exit" INT TERM EXIT
-mkdir "$TDIR/dira"
-attr -q -s "rados_sync_ver" -V "1" "$TDIR/dira"
-touch "$TDIR/dira/foo"
-attr -q -s "rados_full_name" -V "foo" "$TDIR/dira/foo"
-touch "$TDIR/dira/foo2"
-attr -q -s "rados_full_name" -V "foo2" "$TDIR/dira/foo2"
-touch "$TDIR/dira/bar"
-attr -q -s "rados_full_name" -V "bar" "$TDIR/dira/bar"
-mkdir "$TDIR/dirb"
-attr -q -s "rados_sync_ver" -V "1" "$TDIR/dirb"
-mkdir "$TDIR/dirc"
-attr -q -s "rados_sync_ver" -V "1" "$TDIR/dirc"
-touch "$TDIR/dirc/foo"
-attr -q -s "rados_full_name" -V "foo" "$TDIR/dirc/foo"
-attr -q -s "rados.toothbrush" -V "toothbrush" "$TDIR/dirc/foo"
-attr -q -s "rados.toothpaste" -V "crest" "$TDIR/dirc/foo"
-attr -q -s "rados.floss" -V "myfloss" "$TDIR/dirc/foo"
-touch "$TDIR/dirc/foo2"
-attr -q -s "rados.toothbrush" -V "green" "$TDIR/dirc/foo2"
-attr -q -s "rados_full_name" -V "foo2" "$TDIR/dirc/foo2"
+run_expect_succ "$RADOS_TOOL" mkpool "$POOL"
+
+# expb happens to be the empty export for legacy reasons
+run_expect_succ "$RADOS_TOOL" -p "$POOL" export "$TDIR/expb"
+
+# expa has objects foo, foo2 and bar
+run_expect_succ "$RADOS_TOOL" -p "$POOL" put foo /etc/fstab
+run_expect_succ "$RADOS_TOOL" -p "$POOL" put foo2 /etc/fstab
+run_expect_succ "$RADOS_TOOL" -p "$POOL" put bar /etc/fstab
+run_expect_succ "$RADOS_TOOL" -p "$POOL" export "$TDIR/expa"
+
+# expc has foo and foo2 with some attributes and omaps set
+run_expect_succ "$RADOS_TOOL" -p "$POOL" rm bar
+run_expect_succ "$RADOS_TOOL" -p "$POOL" setxattr foo "rados.toothbrush" "toothbrush"
+run_expect_succ "$RADOS_TOOL" -p "$POOL" setxattr foo "rados.toothpaste" "crest"
+run_expect_succ "$RADOS_TOOL" -p "$POOL" setomapval foo "rados.floss" "myfloss"
+run_expect_succ "$RADOS_TOOL" -p "$POOL" setxattr foo2 "rados.toothbrush" "green"
+run_expect_succ "$RADOS_TOOL" -p "$POOL" setomapheader foo2 "foo2.header"
+run_expect_succ "$RADOS_TOOL" -p "$POOL" export "$TDIR/expc"
# make sure that --create works
run "$RADOS_TOOL" rmpool "$POOL" "$POOL" --yes-i-really-really-mean-it
-run_expect_succ "$RADOS_TOOL" --create import "$TDIR/dira" "$POOL"
+run_expect_succ "$RADOS_TOOL" -p "$POOL" --create import "$TDIR/expa"
# make sure that lack of --create fails
run_expect_succ "$RADOS_TOOL" rmpool "$POOL" "$POOL" --yes-i-really-really-mean-it
-run_expect_fail "$RADOS_TOOL" import "$TDIR/dira" "$POOL"
+run_expect_fail "$RADOS_TOOL" -p "$POOL" import "$TDIR/expa"
-run_expect_succ "$RADOS_TOOL" --create import "$TDIR/dira" "$POOL"
+run_expect_succ "$RADOS_TOOL" -p "$POOL" --create import "$TDIR/expa"
# inaccessible import src should fail
-run_expect_fail "$RADOS_TOOL" import "$TDIR/dir_nonexistent" "$POOL"
-
-# export some stuff
-run_expect_succ "$RADOS_TOOL" --create export "$POOL" "$TDIR/dirb"
-diff -q -r "$TDIR/dira" "$TDIR/dirb" \
- || die "failed to export the same stuff we imported!"
+run_expect_fail "$RADOS_TOOL" -p "$POOL" import "$TDIR/dir_nonexistent"
# import some stuff with extended attributes on it
-run_expect_succ "$RADOS_TOOL" import "$TDIR/dirc" "$POOL" | tee "$TDIR/out"
-run_expect_succ grep -q '\[xattr\]' $TDIR/out
+run_expect_succ "$RADOS_TOOL" -p "$POOL" import "$TDIR/expc"
+VAL=`"$RADOS_TOOL" -p "$POOL" getxattr foo "rados.toothbrush"`
+[ ${VAL} = "toothbrush" ] || die "Invalid attribute after import"
# the second time, the xattrs should match, so there should be nothing to do.
-run_expect_succ "$RADOS_TOOL" import "$TDIR/dirc" "$POOL" | tee "$TDIR/out"
-run_expect_fail grep -q '\[xattr\]' "$TDIR/out"
+run_expect_succ "$RADOS_TOOL" -p "$POOL" import "$TDIR/expc"
+VAL=`"$RADOS_TOOL" -p "$POOL" getxattr foo "rados.toothbrush"`
+[ "${VAL}" = "toothbrush" ] || die "Invalid attribute after second import"
-# now force it to copy everything
-run_expect_succ "$RADOS_TOOL" --force import "$TDIR/dirc" "$POOL" | tee "$TDIR/out2"
-run_expect_succ grep '\[force\]' "$TDIR/out2"
-
-# export some stuff with extended attributes on it
-run_expect_succ "$RADOS_TOOL" -C export "$POOL" "$TDIR/dirc_copy"
-
-# check to make sure extended attributes were preserved
-PRE_EXPORT=`attr -qg rados.toothbrush "$TDIR/dirc/foo"`
-[ $? -eq 0 ] || die "failed to get xattr"
-POST_EXPORT=`attr -qg rados.toothbrush "$TDIR/dirc_copy/foo"`
-[ $? -eq 0 ] || die "failed to get xattr"
-if [ "$PRE_EXPORT" != "$POST_EXPORT" ]; then
- die "xattr not preserved across import/export! \
-\$PRE_EXPORT = $PRE_EXPORT, \$POST_EXPORT = $POST_EXPORT"
-fi
-
-# another try with a different --worker setting
-run_expect_succ "$RADOS_TOOL" --workers 1 -C export "$POOL" "$TDIR/dirc_copy2"
-
-# another try with a different --worker setting
-run_expect_succ "$RADOS_TOOL" --workers 30 -C export "$POOL" "$TDIR/dirc_copy3"
-
-# trigger a rados delete using --delete-after
-run_expect_succ "$RADOS_TOOL" --create export "$POOL" "$TDIR/dird"
-rm -f "$TDIR/dird/foo"
-run_expect_succ "$RADOS_TOOL" --delete-after import "$TDIR/dird" "$POOL" | tee "$TDIR/out3"
-run_expect_succ grep '\[deleted\]' "$TDIR/out3"
-
-# trigger a local delete using --delete-after
-run_expect_succ "$RADOS_TOOL" --delete-after export "$POOL" "$TDIR/dirc" | tee "$TDIR/out4"
-run_expect_succ grep '\[deleted\]' "$TDIR/out4"
-[ -e "$TDIR/dird/foo" ] && die "--delete-after failed to delete a file!"
-
-# test hashed pathnames
-mkdir -p "$TDIR/dird"
-attr -q -s "rados_sync_ver" -V "1" "$TDIR/dird"
-touch "$TDIR/dird/bar@bar_00000000000055ca"
-attr -q -s "rados_full_name" -V "bar/bar" "$TDIR/dird/bar@bar_00000000000055ca"
-run_expect_succ "$RADOS_TOOL" --delete-after import "$TDIR/dird" "$POOL" | tee "$TDIR/out5"
-run_expect_succ grep '\[imported\]' "$TDIR/out5"
-run_expect_succ "$RADOS_TOOL" --delete-after --create export "$POOL" "$TDIR/dire" | tee "$TDIR/out6"
-run_expect_succ grep '\[exported\]' "$TDIR/out6"
-diff -q -r "$TDIR/dird" "$TDIR/dire" \
- || die "failed to export the same stuff we imported!"
-
-# create a temporary file and validate that export deletes it
-touch "$TDIR/dire/tmp\$tmp"
-run_expect_succ "$RADOS_TOOL" --delete-after --create export "$POOL" "$TDIR/dire" | tee "$TDIR/out7"
-run_expect_succ grep temporary "$TDIR/out7"
+# Now try with --no-overwrite option after changing an attribute
+run_expect_succ "$RADOS_TOOL" -p "$POOL" setxattr foo "rados.toothbrush" "dentist"
+run_expect_succ "$RADOS_TOOL" -p "$POOL" import --no-overwrite "$TDIR/expc"
+VAL=`"$RADOS_TOOL" -p "$POOL" getxattr foo "rados.toothbrush"`
+[ "${VAL}" = "dentist" ] || die "Invalid attribute after second import"
+# now force it to copy everything
+run_expect_succ "$RADOS_TOOL" -p "$POOL" import "$TDIR/expc"
+VAL=`"$RADOS_TOOL" -p "$POOL" getxattr foo "rados.toothbrush"`
+[ "${VAL}" = "toothbrush" ] || die "Invalid attribute after second import"
# test copy pool
run "$RADOS_TOOL" rmpool "$POOL" "$POOL" --yes-i-really-really-mean-it