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 $CEPH_ROOT/qa/standalone/ceph-helpers.sh
24 export CEPH_MON="127.0.0.1:7131" # git grep '\<7131\>' : there must be only one
26 CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
27 CEPH_ARGS+="--mon-host=$CEPH_MON "
28 CEPH_ARGS+="--crush-location=root=default,host=HOST "
29 CEPH_ARGS+="--osd-crush-initial-weight=3 "
31 # Disable device auto class feature for now.
32 # The device class is non-deterministic and will
33 # crash the crushmap comparison below.
35 CEPH_ARGS+="--osd-class-update-on-start=false "
37 local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
38 for func in $funcs ; do
39 setup $dir || return 1
40 $func $dir || return 1
41 teardown $dir || return 1
45 function TEST_choose_args_update() {
47 # adding a weighted OSD updates the weight up to the top
51 run_mon $dir a || return 1
52 run_osd $dir 0 || return 1
54 ceph osd set-require-min-compat-client luminous
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 set-require-min-compat-client luminous
110 ceph osd getcrushmap > $dir/map || return 1
111 crushtool -d $dir/map -o $dir/map.txt || return 1
112 sed -i -e '/end crush map/d' $dir/map.txt
113 cat >> $dir/map.txt <<EOF
136 crushtool -c $dir/map.txt -o $dir/map-new || return 1
137 ceph osd setcrushmap -i $dir/map-new || return 1
141 run_osd $dir 1 || return 1
143 ceph osd getcrushmap > $dir/map-one-more || return 1
144 crushtool -d $dir/map-one-more -o $dir/map-one-more.txt || return 1
145 cat $dir/map-one-more.txt
146 diff -u $dir/map-one-more.txt $CEPH_ROOT/src/test/crush/crush-choose-args-expected-one-more-0.txt || return 1
148 destroy_osd $dir 1 || return 1
150 ceph osd getcrushmap > $dir/map-one-less || return 1
151 crushtool -d $dir/map-one-less -o $dir/map-one-less.txt || return 1
152 diff -u $dir/map-one-less.txt $dir/map.txt || return 1
154 CEPH_ARGS="$ORIG_CEPH_ARGS"
157 main crush-choose-args "$@"
160 # 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"