]> git.proxmox.com Git - ceph.git/blame - ceph/src/test/test_crush_bucket.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / test / test_crush_bucket.sh
CommitLineData
11fdf7f2 1#!/usr/bin/env bash
7c673cae
FG
2
3
4#Generic test_crush_bucket test
5#
6
7# Includes
8source $(dirname $0)/detect-build-env-vars.sh
c07f9fc5 9source ../qa/standalone/ceph-helpers.sh
7c673cae
FG
10function run() {
11 local dir=$1
12 shift
13
14 export CEPH_MON="127.0.0.1:17119" # git grep '\<17119\>' : 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
25function TEST_crush_bucket() {
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
34 ceph osd getcrushmap -o "$dir/map1" || return 1
35 crushtool -d "$dir/map1" -o "$dir/map1.txt"|| return 1
36 local var=`ceph osd crush dump|grep -w id|grep '-'|grep -Eo '[0-9]+'|sort|uniq|${SED} -n '$p'`
37 local id=`expr $var + 1`
38 local item=`${SED} -n '/^root/,/}/p' $dir/map1.txt|grep 'item'|head -1`
39 local weight=`${SED} -n '/^root/,/}/p' $dir/map1.txt|grep 'item'|head -1|awk '{print $4}'`
40 local bucket="host test {\n id -$id\n # weight $weight\n alg straw \n hash 0 # rjenkins1 \n $item\n}\n"
41 ${SED} -i "/# buckets/a\ $bucket" "$dir/map1.txt"
42 crushtool -c "$dir/map1.txt" -o "$dir/map1.bin" 2>"$dir/rev"
43 local result=$(cat "$dir/rev")
44 if [ "$result" != "" ];
45 then
46 return 1
47 fi
48
49}
50
51main testcrushbucket
52