Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / test_split.sh
1 #!/bin/bash -x
2
3 #
4 # Add some objects to the data PGs, and then test splitting those PGs
5 #
6
7 # Includes
8 source "`dirname $0`/test_common.sh"
9
10 TEST_POOL=rbd
11
12 # Constants
13 my_write_objects() {
14         write_objects $1 $2 10 1000000 $TEST_POOL
15 }
16
17 setup() {
18         export CEPH_NUM_OSD=$1
19
20         # Start ceph
21         ./stop.sh
22
23         ./vstart.sh -d -n
24 }
25
26 get_pgp_num() {
27         ./ceph -c ./ceph.conf osd pool get $TEST_POOL pgp_num > $TEMPDIR/pgp_num
28         [ $? -eq 0 ] || die "failed to get pgp_num"
29         PGP_NUM=`grep PGP_NUM $TEMPDIR/pgp_num | sed 's/.*PGP_NUM:\([ 0123456789]*\).*$/\1/'`
30 }
31
32 split1_impl() {
33         # Write lots and lots of objects
34         my_write_objects 1 2
35
36         get_pgp_num
37         echo "\$PGP_NUM=$PGP_NUM"
38
39         # Double the number of PGs
40         PGP_NUM=$((PGP_NUM*2))
41         echo "doubling PGP_NUM to $PGP_NUM..."
42         ./ceph -c ./ceph.conf osd pool set $TEST_POOL pgp_num $PGP_NUM
43
44         sleep 30
45
46         # success
47         return 0
48 }
49
50 split1() {
51         setup 2
52         split1_impl
53 }
54
55 many_pools() {
56         setup 3
57         for i in `seq 1 3000`; do
58                 ./rados -c ./ceph.conf mkpool "pool${i}" || die "mkpool failed"
59         done
60         my_write_objects 1 10
61 }
62
63 run() {
64         split1 || die "test failed"
65 }
66
67 $@