2016-01-14 13:45:38 +00:00
|
|
|
#!/bin/sh -ex
|
|
|
|
|
2016-02-01 20:48:53 +00:00
|
|
|
if ! id -u | grep -q '^0$'; then
|
2016-01-14 13:45:38 +00:00
|
|
|
echo "not root, re-running self via sudo"
|
2017-02-16 04:08:31 +00:00
|
|
|
sudo PATH=$PATH TYPE=$TYPE $0
|
2016-01-14 13:45:38 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-02-16 01:21:01 +00:00
|
|
|
expect_false()
|
2016-01-14 13:45:38 +00:00
|
|
|
{
|
|
|
|
set -x
|
|
|
|
if "$@"; then return 1; else return 0; fi
|
|
|
|
}
|
|
|
|
|
|
|
|
COT=ceph-objectstore-tool
|
|
|
|
DATA=store_test_fuse_dir
|
2016-09-13 13:40:03 +00:00
|
|
|
[ -z "$TYPE" ] && TYPE=bluestore
|
2016-01-14 13:45:38 +00:00
|
|
|
MNT=store_test_fuse_mnt
|
|
|
|
|
|
|
|
rm -rf $DATA
|
|
|
|
mkdir -p $DATA
|
|
|
|
|
2016-06-27 18:59:24 +00:00
|
|
|
test -d $MNT && fusermount -u $MNT || true
|
2016-01-14 13:45:38 +00:00
|
|
|
rmdir $MNT || true
|
|
|
|
mkdir $MNT
|
|
|
|
|
2017-02-16 09:27:16 +00:00
|
|
|
export CEPH_ARGS=--enable_experimental_unrecoverable_data_corrupting_features=bluestore
|
|
|
|
|
2018-01-31 14:35:11 +00:00
|
|
|
$COT --no-mon-config --op mkfs --data-path $DATA --type $TYPE
|
|
|
|
$COT --no-mon-config --op fuse --data-path $DATA --mountpoint $MNT &
|
2016-01-14 13:45:38 +00:00
|
|
|
|
|
|
|
while ! test -e $MNT/type ; do
|
|
|
|
echo waiting for $MNT/type to appear
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
umask 0
|
|
|
|
|
|
|
|
grep $TYPE $MNT/type
|
|
|
|
|
|
|
|
# create collection
|
|
|
|
mkdir $MNT/meta
|
|
|
|
test -e $MNT/meta/bitwise_hash_start
|
|
|
|
test -d $MNT/meta/all
|
|
|
|
test -d $MNT/meta/by_bitwise_hash
|
|
|
|
|
|
|
|
# create object
|
2016-06-27 18:59:24 +00:00
|
|
|
mkdir $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#
|
|
|
|
test -e $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/data
|
|
|
|
test -d $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/attr
|
|
|
|
test -d $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap
|
|
|
|
test -e $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/bitwise_hash
|
|
|
|
test -e $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap_header
|
2016-01-14 13:45:38 +00:00
|
|
|
|
|
|
|
# omap header
|
2016-06-27 18:59:24 +00:00
|
|
|
echo omap header > $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap_header
|
|
|
|
grep -q omap $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap_header
|
2016-01-14 13:45:38 +00:00
|
|
|
|
|
|
|
# omap
|
2016-06-27 18:59:24 +00:00
|
|
|
echo value a > $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap/keya
|
|
|
|
echo value b > $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap/keyb
|
|
|
|
ls $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap | grep -c key | grep -q 2
|
|
|
|
grep 'value a' $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap/keya
|
|
|
|
grep 'value b' $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap/keyb
|
|
|
|
rm $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap/keya
|
|
|
|
test ! -e $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap/keya
|
|
|
|
rm $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap/keyb
|
|
|
|
test ! -e $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/omap/keyb
|
2016-01-14 13:45:38 +00:00
|
|
|
|
|
|
|
# attr
|
2016-06-27 18:59:24 +00:00
|
|
|
echo value a > $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/attr/keya
|
|
|
|
echo value b > $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/attr/keyb
|
|
|
|
ls $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/attr | grep -c key | grep -q 2
|
|
|
|
grep 'value a' $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/attr/keya
|
|
|
|
grep 'value b' $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/attr/keyb
|
|
|
|
rm $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/attr/keya
|
|
|
|
test ! -e $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/attr/keya
|
|
|
|
rm $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/attr/keyb
|
|
|
|
test ! -e $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/attr/keyb
|
2016-01-14 13:45:38 +00:00
|
|
|
|
|
|
|
# data
|
2016-06-27 18:59:24 +00:00
|
|
|
test ! -s $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/data
|
|
|
|
echo asdfasdfasdf > $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/data
|
|
|
|
test -s $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/data
|
|
|
|
grep -q asdfasdfasdf $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/data
|
2016-06-27 20:09:22 +00:00
|
|
|
truncate --size 4 $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/data
|
|
|
|
stat --format=%s $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/data | grep -q ^4$
|
|
|
|
expect_false grep -q asdfasdfasdf $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/data
|
2016-06-27 18:59:24 +00:00
|
|
|
rm $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/data
|
|
|
|
test ! -s $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/data
|
2016-01-14 13:45:38 +00:00
|
|
|
|
2016-06-27 20:09:22 +00:00
|
|
|
|
2016-01-14 13:45:38 +00:00
|
|
|
# create pg collection
|
|
|
|
mkdir --mode 0003 $MNT/0.0_head
|
|
|
|
grep -q 00000000 $MNT/0.0_head/bitwise_hash_start
|
2016-09-13 13:40:03 +00:00
|
|
|
if [ "$TYPE" = "bluestore" ]; then
|
|
|
|
cat $MNT/0.0_head/bitwise_hash_bits
|
|
|
|
grep -q 3 $MNT/0.0_head/bitwise_hash_bits
|
|
|
|
grep -q 1fffffff $MNT/0.0_head/bitwise_hash_end
|
|
|
|
fi
|
2016-01-14 13:45:38 +00:00
|
|
|
test -d $MNT/0.0_head/all
|
|
|
|
|
|
|
|
mkdir --mode 0003 $MNT/0.1_head
|
|
|
|
grep -q 80000000 $MNT/0.1_head/bitwise_hash_start
|
2016-09-13 13:40:03 +00:00
|
|
|
if [ "$TYPE" = "bluestore" ]; then
|
|
|
|
grep -q 3 $MNT/0.1_head/bitwise_hash_bits
|
|
|
|
grep -q 9fffffff $MNT/0.1_head/bitwise_hash_end
|
|
|
|
fi
|
2016-01-14 13:45:38 +00:00
|
|
|
|
|
|
|
# create pg object
|
2016-06-27 18:59:24 +00:00
|
|
|
mkdir $MNT/0.0_head/all/#0:00000000::::head#/
|
|
|
|
mkdir $MNT/0.0_head/all/#0:10000000:::foo:head#/
|
2016-01-14 13:45:38 +00:00
|
|
|
|
|
|
|
# verify pg bounds check
|
2016-09-13 13:40:03 +00:00
|
|
|
if [ "$TYPE" = "bluestore" ]; then
|
|
|
|
expect_false mkdir $MNT/0.0_head/all/#0:20000000:::bar:head#/
|
|
|
|
fi
|
2016-01-14 13:45:38 +00:00
|
|
|
|
|
|
|
# remove a collection
|
|
|
|
expect_false rmdir $MNT/0.0_head
|
2016-06-27 18:59:24 +00:00
|
|
|
rmdir $MNT/0.0_head/all/#0:10000000:::foo:head#/
|
|
|
|
rmdir $MNT/0.0_head/all/#0:00000000::::head#/
|
2016-01-14 13:45:38 +00:00
|
|
|
rmdir $MNT/0.0_head
|
|
|
|
rmdir $MNT/0.1_head
|
|
|
|
|
|
|
|
fusermount -u $MNT
|
|
|
|
wait
|
|
|
|
|
|
|
|
echo OK
|