Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / workunits / fs / misc / layout_vxattrs.sh
1 #!/bin/bash -x
2
3 set -e
4 set -x
5
6 # detect data pool
7 datapool=
8 dir=.
9 while true ; do
10     echo $dir
11     datapool=$(getfattr -n ceph.dir.layout.pool $dir --only-values) && break
12     dir=$dir/..
13 done
14
15 # file
16 rm -f file file2
17 touch file file2
18
19 getfattr -n ceph.file.layout file
20 getfattr -n ceph.file.layout file | grep -q object_size=
21 getfattr -n ceph.file.layout file | grep -q stripe_count=
22 getfattr -n ceph.file.layout file | grep -q stripe_unit=
23 getfattr -n ceph.file.layout file | grep -q pool=
24 getfattr -n ceph.file.layout.pool file
25 getfattr -n ceph.file.layout.pool_namespace file
26 getfattr -n ceph.file.layout.stripe_unit file
27 getfattr -n ceph.file.layout.stripe_count file
28 getfattr -n ceph.file.layout.object_size file
29
30 getfattr -n ceph.file.layout.bogus file   2>&1 | grep -q 'No such attribute'
31 getfattr -n ceph.dir.layout file    2>&1 | grep -q 'No such attribute'
32
33 setfattr -n ceph.file.layout.stripe_unit -v 1048576 file2
34 setfattr -n ceph.file.layout.stripe_count -v 8 file2
35 setfattr -n ceph.file.layout.object_size -v 10485760 file2
36
37 setfattr -n ceph.file.layout.pool -v $datapool file2
38 getfattr -n ceph.file.layout.pool file2 | grep -q $datapool
39 setfattr -n ceph.file.layout.pool_namespace -v foons file2
40 getfattr -n ceph.file.layout.pool_namespace file2 | grep -q foons
41 setfattr -x ceph.file.layout.pool_namespace file2
42 getfattr -n ceph.file.layout.pool_namespace file2 | grep -q -v foons
43
44 getfattr -n ceph.file.layout.stripe_unit file2 | grep -q 1048576
45 getfattr -n ceph.file.layout.stripe_count file2 | grep -q 8
46 getfattr -n ceph.file.layout.object_size file2 | grep -q 10485760
47
48 setfattr -n ceph.file.layout -v "stripe_unit=4194304 stripe_count=16 object_size=41943040 pool=$datapool pool_namespace=foons" file2
49 getfattr -n ceph.file.layout.stripe_unit file2 | grep -q 4194304
50 getfattr -n ceph.file.layout.stripe_count file2 | grep -q 16
51 getfattr -n ceph.file.layout.object_size file2 | grep -q 41943040
52 getfattr -n ceph.file.layout.pool file2 | grep -q $datapool
53 getfattr -n ceph.file.layout.pool_namespace file2 | grep -q foons
54
55 setfattr -n ceph.file.layout -v "stripe_unit=1048576" file2
56 getfattr -n ceph.file.layout.stripe_unit file2 | grep -q 1048576
57 getfattr -n ceph.file.layout.stripe_count file2 | grep -q 16
58 getfattr -n ceph.file.layout.object_size file2 | grep -q 41943040
59 getfattr -n ceph.file.layout.pool file2 | grep -q $datapool
60 getfattr -n ceph.file.layout.pool_namespace file2 | grep -q foons
61
62 setfattr -n ceph.file.layout -v "stripe_unit=2097152 stripe_count=4 object_size=2097152 pool=$datapool pool_namespace=barns" file2
63 getfattr -n ceph.file.layout.stripe_unit file2 | grep -q 2097152
64 getfattr -n ceph.file.layout.stripe_count file2 | grep -q 4
65 getfattr -n ceph.file.layout.object_size file2 | grep -q 2097152
66 getfattr -n ceph.file.layout.pool file2 | grep -q $datapool
67 getfattr -n ceph.file.layout.pool_namespace file2 | grep -q barns
68
69 # dir
70 rm -f dir/file || true
71 rmdir dir || true
72 mkdir -p dir
73
74 getfattr -d -m - dir | grep -q ceph.dir.layout       && exit 1 || true
75 getfattr -d -m - dir | grep -q ceph.file.layout      && exit 1 || true
76 getfattr -n ceph.dir.layout dir                      && exit 1 || true
77
78 setfattr -n ceph.dir.layout.stripe_unit -v 1048576 dir
79 setfattr -n ceph.dir.layout.stripe_count -v 8 dir
80 setfattr -n ceph.dir.layout.object_size -v 10485760 dir
81 setfattr -n ceph.dir.layout.pool -v $datapool dir
82 setfattr -n ceph.dir.layout.pool_namespace -v dirns dir
83
84 getfattr -n ceph.dir.layout dir
85 getfattr -n ceph.dir.layout dir | grep -q object_size=10485760
86 getfattr -n ceph.dir.layout dir | grep -q stripe_count=8
87 getfattr -n ceph.dir.layout dir | grep -q stripe_unit=1048576
88 getfattr -n ceph.dir.layout dir | grep -q pool=$datapool
89 getfattr -n ceph.dir.layout dir | grep -q pool_namespace=dirns
90 getfattr -n ceph.dir.layout.pool dir | grep -q $datapool
91 getfattr -n ceph.dir.layout.stripe_unit dir | grep -q 1048576
92 getfattr -n ceph.dir.layout.stripe_count dir | grep -q 8
93 getfattr -n ceph.dir.layout.object_size dir | grep -q 10485760
94 getfattr -n ceph.dir.layout.pool_namespace dir | grep -q dirns
95
96
97 setfattr -n ceph.file.layout -v "stripe_count=16" file2
98 getfattr -n ceph.file.layout.stripe_count file2 | grep -q 16
99 setfattr -n ceph.file.layout -v "object_size=10485760 stripe_count=8 stripe_unit=1048576 pool=$datapool pool_namespace=dirns" file2
100 getfattr -n ceph.file.layout.stripe_count file2 | grep -q 8
101
102 touch dir/file
103 getfattr -n ceph.file.layout.pool dir/file | grep -q $datapool
104 getfattr -n ceph.file.layout.stripe_unit dir/file | grep -q 1048576
105 getfattr -n ceph.file.layout.stripe_count dir/file | grep -q 8
106 getfattr -n ceph.file.layout.object_size dir/file | grep -q 10485760
107 getfattr -n ceph.file.layout.pool_namespace dir/file | grep -q dirns
108
109 setfattr -x ceph.dir.layout.pool_namespace dir
110 getfattr -n ceph.dir.layout dir | grep -q -v pool_namespace=dirns
111
112 setfattr -x ceph.dir.layout dir
113 getfattr -n ceph.dir.layout dir     2>&1 | grep -q 'No such attribute'
114
115 echo OK
116