3 # Copyright (C) 2017 Red Hat <contact@redhat.com>
5 # Author: Loic Dachary <loic@dachary.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Library Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Library Public License for more details.
18 source $
(dirname $0)/..
/detect-build-env-vars.sh
19 source $CEPH_ROOT/qa
/workunits
/ceph-helpers.sh
25 export CEPH_MON
="127.0.0.1:7131" # git grep '\<7131\>' : there must be only one
27 CEPH_ARGS
+="--fsid=$(uuidgen) --auth-supported=none "
28 CEPH_ARGS
+="--mon-host=$CEPH_MON "
29 CEPH_ARGS
+="--crush-location=root=default,host=HOST "
30 CEPH_ARGS
+="--osd-crush-initial-weight=3 "
32 # Disable device auto class feature for now.
33 # The device class is non-deterministic and will
34 # crash the crushmap comparison below.
36 CEPH_ARGS
+="--osd-class-update-on-start=false "
38 local funcs
=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
39 for func
in $funcs ; do
40 setup
$dir ||
return 1
41 $func $dir ||
return 1
42 teardown
$dir ||
return 1
46 function TEST_choose_args_update
() {
48 # adding a weighted OSD updates the weight up to the top
52 run_mon
$dir a ||
return 1
53 run_osd
$dir 0 ||
return 1
55 ceph osd getcrushmap
> $dir/map ||
return 1
56 crushtool
-d $dir/map
-o $dir/map.txt ||
return 1
57 sed -i -e '/end crush map/d' $dir/map.txt
58 cat >> $dir/map.txt
<<EOF
81 crushtool
-c $dir/map.txt
-o $dir/map-new ||
return 1
82 ceph osd setcrushmap
-i $dir/map-new ||
return 1
84 run_osd
$dir 1 ||
return 1
85 ceph osd getcrushmap
> $dir/map-one-more ||
return 1
86 crushtool
-d $dir/map-one-more
-o $dir/map-one-more.txt ||
return 1
87 cat $dir/map-one-more.txt
88 diff -u $dir/map-one-more.txt
$CEPH_ROOT/src
/test
/crush
/crush-choose-args-expected-one-more-3.txt ||
return 1
90 destroy_osd
$dir 1 ||
return 1
91 ceph osd getcrushmap
> $dir/map-one-less ||
return 1
92 crushtool
-d $dir/map-one-less
-o $dir/map-one-less.txt ||
return 1
93 diff -u $dir/map-one-less.txt
$dir/map.txt ||
return 1
96 function TEST_no_update_weight_set
() {
98 # adding a zero weight OSD does not update the weight set at all
102 ORIG_CEPH_ARGS
="$CEPH_ARGS"
103 CEPH_ARGS
+="--osd-crush-update-weight-set=false "
105 run_mon
$dir a ||
return 1
106 run_osd
$dir 0 ||
return 1
108 ceph osd getcrushmap
> $dir/map ||
return 1
109 crushtool
-d $dir/map
-o $dir/map.txt ||
return 1
110 sed -i -e '/end crush map/d' $dir/map.txt
111 cat >> $dir/map.txt
<<EOF
134 crushtool
-c $dir/map.txt
-o $dir/map-new ||
return 1
135 ceph osd setcrushmap
-i $dir/map-new ||
return 1
138 run_osd
$dir 1 ||
return 1
139 ceph osd getcrushmap
> $dir/map-one-more ||
return 1
140 crushtool
-d $dir/map-one-more
-o $dir/map-one-more.txt ||
return 1
141 cat $dir/map-one-more.txt
142 diff -u $dir/map-one-more.txt
$CEPH_ROOT/src
/test
/crush
/crush-choose-args-expected-one-more-0.txt ||
return 1
144 destroy_osd
$dir 1 ||
return 1
145 ceph osd getcrushmap
> $dir/map-one-less ||
return 1
146 crushtool
-d $dir/map-one-less
-o $dir/map-one-less.txt ||
return 1
147 diff -u $dir/map-one-less.txt
$dir/map.txt ||
return 1
149 CEPH_ARGS
="$ORIG_CEPH_ARGS"
152 main crush-choose-args
"$@"
155 # compile-command: "cd ../../../build ; ln -sf ../src/ceph-disk/ceph_disk/main.py bin/ceph-disk && make -j4 && ../src/test/crush/crush-choose-args.sh"