Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / standalone / mon / test_pool_quota.sh
1 #!/bin/bash
2
3 #
4 # Generic pool quota test
5 #
6
7 # Includes
8
9
10 source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
11
12 function run() {
13     local dir=$1
14     shift
15
16     export CEPH_MON="127.0.0.1:17108" # git grep '\<17108\>' : there must be only one
17     export CEPH_ARGS
18     CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
19     CEPH_ARGS+="--mon-host=$CEPH_MON "
20
21     local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
22     for func in $funcs ; do
23         $func $dir || return 1
24     done
25 }
26
27 function TEST_pool_quota() {
28     local dir=$1
29     setup $dir || return 1
30
31     run_mon $dir a || return 1
32     run_osd $dir 0 || return 1
33     run_osd $dir 1 || return 1
34     run_osd $dir 2 || return 1
35
36     local poolname=testquota
37     create_pool $poolname 20
38     local objects=`ceph df detail | grep -w $poolname|awk '{print $3}'`
39     local bytes=`ceph df detail | grep -w $poolname|awk '{print $4}'`
40
41     echo $objects
42     echo $bytes
43     if [ $objects != 'N/A' ] || [ $bytes != 'N/A' ] ;
44       then
45       return 1
46     fi
47
48     ceph osd pool set-quota  $poolname   max_objects 1000
49     ceph osd pool set-quota  $poolname  max_bytes 1024
50
51     objects=`ceph df detail | grep -w $poolname|awk '{print $3}'`
52     bytes=`ceph df detail | grep -w $poolname|awk '{print $4}'`
53
54      if [ $objects != '1000' ] || [ $bytes != '1024' ] ;
55        then
56        return 1
57      fi
58
59      ceph osd pool delete  $poolname $poolname  --yes-i-really-really-mean-it
60      teardown $dir || return 1
61 }
62
63 main testpoolquota