]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/bin/bash |
2 | ||
3 | ||
4 | #Generic create pool use crush rule test | |
5 | # | |
6 | ||
7 | # Includes | |
c07f9fc5 | 8 | source ../qa/standalone/ceph-helpers.sh |
7c673cae FG |
9 | |
10 | function run() { | |
11 | local dir=$1 | |
12 | shift | |
13 | ||
14 | export CEPH_MON="127.0.0.1:17109" # git grep '\<17109\>' : there must be only one | |
15 | export CEPH_ARGS | |
16 | CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none " | |
17 | CEPH_ARGS+="--mon-host=$CEPH_MON " | |
18 | ||
19 | local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')} | |
20 | for func in $funcs ; do | |
21 | $func $dir || return 1 | |
22 | done | |
23 | } | |
24 | ||
25 | function TEST_pool_create() { | |
26 | local dir=$1 | |
27 | setup $dir || return 1 | |
28 | run_mon $dir a || return 1 | |
29 | run_osd $dir 0 || return 1 | |
30 | run_osd $dir 1 || return 1 | |
31 | run_osd $dir 2 || return 1 | |
32 | ||
33 | local rulename=testrule | |
34 | local poolname=rulepool | |
35 | local var=`ceph osd crush rule dump|grep -w ruleset|sed -n '$p'|grep -o '[0-9]\+'` | |
36 | var=`expr $var + 1 ` | |
37 | ceph osd getcrushmap -o "$dir/map1" | |
38 | crushtool -d "$dir/map1" -o "$dir/map1.txt" | |
39 | ||
40 | local minsize=0 | |
41 | local maxsize=1 | |
42 | sed -i '/# end crush map/i\rule '$rulename' {\n ruleset \'$var'\n type replicated\n min_size \'$minsize'\n max_size \'$maxsize'\n step take default\n step choose firstn 0 type osd\n step emit\n }\n' "$dir/map1.txt" | |
43 | crushtool -c "$dir/map1.txt" -o "$dir/map1.bin" | |
44 | ceph osd setcrushmap -i "$dir/map1.bin" | |
45 | ceph osd pool create $poolname 200 $rulename 2>"$dir/rev" | |
46 | local result=$(cat "$dir/rev" | grep "Error EINVAL: pool size") | |
47 | ||
48 | if [ "$result" = "" ]; | |
49 | then | |
50 | ceph osd pool delete $poolname $poolname --yes-i-really-really-mean-it | |
51 | ceph osd crush rule rm $rulename | |
52 | return 1 | |
53 | fi | |
54 | ceph osd crush rule rm $rulename | |
55 | } | |
56 | ||
57 | main testpoolcreate | |
58 |