summaryrefslogtreecommitdiffstats
path: root/src/test/test_split.sh
blob: d86a08af2b8ec553ff2f685d1480137a38d2c549 (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
#!/usr/bin/env bash
set -x

#
# Add some objects to the data PGs, and then test splitting those PGs
#

# Includes
source "`dirname $0`/test_common.sh"

TEST_POOL=rbd

# Constants
my_write_objects() {
        write_objects $1 $2 10 1000000 $TEST_POOL
}

setup() {
        export CEPH_NUM_OSD=$1

        # Start ceph
        ./stop.sh

        ./vstart.sh -d -n
}

get_pgp_num() {
        ./ceph -c ./ceph.conf osd pool get $TEST_POOL pgp_num > $TEMPDIR/pgp_num
        [ $? -eq 0 ] || die "failed to get pgp_num"
        PGP_NUM=`grep PGP_NUM $TEMPDIR/pgp_num | sed 's/.*PGP_NUM:\([ 0123456789]*\).*$/\1/'`
}

split1_impl() {
        # Write lots and lots of objects
        my_write_objects 1 2

        get_pgp_num
        echo "\$PGP_NUM=$PGP_NUM"

        # Double the number of PGs
        PGP_NUM=$((PGP_NUM*2))
        echo "doubling PGP_NUM to $PGP_NUM..."
        ./ceph -c ./ceph.conf osd pool set $TEST_POOL pgp_num $PGP_NUM

        sleep 30

        # success
        return 0
}

split1() {
        setup 2
        split1_impl
}

many_pools() {
        setup 3
        for i in `seq 1 3000`; do
                ./ceph -c ./ceph.conf osd pool create "pool${i}" 8 || die "pool create failed"
        done
        my_write_objects 1 10
}

run() {
        split1 || die "test failed"
}

$@