summaryrefslogtreecommitdiffstats
path: root/qa/workunits/objectstore/test_fuse.sh
blob: f1dcbd04fd790007ad191c4a765efec1862c9549 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/sh -ex

if ! id -u | grep -q '^0$'; then
    echo "not root, re-running self via sudo"
    sudo PATH=$PATH TYPE=$TYPE $0
    exit 0
fi

expect_false()
{
        set -x
        if "$@"; then return 1; else return 0; fi
}

COT=ceph-objectstore-tool
DATA=store_test_fuse_dir
[ -z "$TYPE" ] && TYPE=bluestore
MNT=store_test_fuse_mnt

rm -rf $DATA
mkdir -p $DATA

test -d $MNT && fusermount -u $MNT || true
rmdir $MNT || true
mkdir $MNT

export CEPH_ARGS=--enable_experimental_unrecoverable_data_corrupting_features=bluestore

$COT --no-mon-config --op mkfs --data-path $DATA --type $TYPE
$COT --no-mon-config --op fuse --data-path $DATA --mountpoint $MNT &

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
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

# omap header
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

# omap
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

# attr
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

# data
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
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
rm $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/data
test ! -s $MNT/meta/all/#-1:7b3f43c4:::osd_superblock:0#/data


# create pg collection
mkdir --mode 0003 $MNT/0.0_head
grep -q 00000000 $MNT/0.0_head/bitwise_hash_start
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
test -d $MNT/0.0_head/all

mkdir --mode 0003 $MNT/0.1_head
grep -q 80000000 $MNT/0.1_head/bitwise_hash_start
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

# create pg object
mkdir $MNT/0.0_head/all/#0:00000000::::head#/
mkdir $MNT/0.0_head/all/#0:10000000:::foo:head#/

# verify pg bounds check
if [ "$TYPE" = "bluestore" ]; then
    expect_false mkdir $MNT/0.0_head/all/#0:20000000:::bar:head#/
fi

# remove a collection
expect_false rmdir $MNT/0.0_head
rmdir $MNT/0.0_head/all/#0:10000000:::foo:head#/
rmdir $MNT/0.0_head/all/#0:00000000::::head#/
rmdir $MNT/0.0_head
rmdir $MNT/0.1_head

fusermount -u $MNT
wait

echo OK