]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/libradosstriper/rados-striper.sh
bump version to 12.1.1-pve1 while rebasing patches
[ceph.git] / ceph / src / test / libradosstriper / rados-striper.sh
1 #!/bin/bash
2 #
3 # Copyright (C) 2014 Red Hat <contact@redhat.com>
4 #
5 # Author: Sebastien Ponce <sebastien.ponce@cern.ch>
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Library Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Library Public License for more details.
16 #
17 source $(dirname $0)/../detect-build-env-vars.sh
18 source $CEPH_ROOT/qa/workunits/ceph-helpers.sh
19
20 function run() {
21 local dir=$1
22 shift
23
24 export CEPH_MON="127.0.0.1:7116" # git grep '\<7116\>' : there must be only one
25 export CEPH_ARGS
26 CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
27 CEPH_ARGS+="--mon-host=$CEPH_MON "
28
29 # setup
30 setup $dir || return 1
31
32 # create a cluster with one monitor and three osds
33 run_mon $dir a || return 1
34 run_osd $dir 0 || return 1
35 run_osd $dir 1 || return 1
36 run_osd $dir 2 || return 1
37
38 # create toyfile
39 dd if=/dev/urandom of=$dir/toyfile bs=1234 count=1
40
41 # put a striped object
42 rados --pool rbd --striper put toyfile $dir/toyfile || return 1
43
44 # stat it, with and without striping
45 rados --pool rbd --striper stat toyfile | cut -d ',' -f 2 > $dir/stripedStat || return 1
46 rados --pool rbd stat toyfile.0000000000000000 | cut -d ',' -f 2 > $dir/stat || return 1
47 echo ' size 1234' > $dir/refstat
48 diff -w $dir/stripedStat $dir/refstat || return 1
49 diff -w $dir/stat $dir/refstat || return 1
50 rados --pool rbd stat toyfile >& $dir/staterror
51 grep -q 'No such file or directory' $dir/staterror || return 1
52
53 # get the file back with and without striping
54 rados --pool rbd --striper get toyfile $dir/stripedGroup || return 1
55 diff -w $dir/toyfile $dir/stripedGroup || return 1
56 rados --pool rbd get toyfile.0000000000000000 $dir/nonSTripedGroup || return 1
57 diff -w $dir/toyfile $dir/nonSTripedGroup || return 1
58
59 # test truncate
60 rados --pool rbd --striper truncate toyfile 12
61 rados --pool rbd --striper stat toyfile | cut -d ',' -f 2 > $dir/stripedStat || return 1
62 rados --pool rbd stat toyfile.0000000000000000 | cut -d ',' -f 2 > $dir/stat || return 1
63 echo ' size 12' > $dir/reftrunc
64 diff -w $dir/stripedStat $dir/reftrunc || return 1
65 diff -w $dir/stat $dir/reftrunc || return 1
66
67 # test xattrs
68
69 rados --pool rbd --striper setxattr toyfile somexattr somevalue || return 1
70 rados --pool rbd --striper getxattr toyfile somexattr > $dir/xattrvalue || return 1
71 rados --pool rbd getxattr toyfile.0000000000000000 somexattr > $dir/xattrvalue2 || return 1
72 echo 'somevalue' > $dir/refvalue
73 diff -w $dir/xattrvalue $dir/refvalue || return 1
74 diff -w $dir/xattrvalue2 $dir/refvalue || return 1
75 rados --pool rbd --striper listxattr toyfile > $dir/xattrlist || return 1
76 echo 'somexattr' > $dir/reflist
77 diff -w $dir/xattrlist $dir/reflist || return 1
78 rados --pool rbd listxattr toyfile.0000000000000000 | grep -v striper > $dir/xattrlist2 || return 1
79 diff -w $dir/xattrlist2 $dir/reflist || return 1
80 rados --pool rbd --striper rmxattr toyfile somexattr || return 1
81
82 local attr_not_found_str="No data available"
83 [ `uname` = FreeBSD ] && \
84 attr_not_found_str="Attribute not found"
85 expect_failure $dir "$attr_not_found_str" \
86 rados --pool rbd --striper getxattr toyfile somexattr || return 1
87 expect_failure $dir "$attr_not_found_str" \
88 rados --pool rbd getxattr toyfile.0000000000000000 somexattr || return 1
89
90 # test rm
91 rados --pool rbd --striper rm toyfile || return 1
92 expect_failure $dir 'No such file or directory' \
93 rados --pool rbd --striper stat toyfile || return 1
94 expect_failure $dir 'No such file or directory' \
95 rados --pool rbd stat toyfile.0000000000000000 || return 1
96
97 # cleanup
98 teardown $dir || return 1
99 }
100
101 main rados-striper "$@"