]> git.proxmox.com Git - ceph.git/blame - ceph/src/test/crush/crush-choose-args.sh
update sources to v12.1.1
[ceph.git] / ceph / src / test / crush / crush-choose-args.sh
CommitLineData
31f18b77
FG
1#!/bin/bash
2#
3# Copyright (C) 2017 Red Hat <contact@redhat.com>
4#
5# Author: Loic Dachary <loic@dachary.org>
6#
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)
10# any later version.
11#
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.
16#
17
18source $(dirname $0)/../detect-build-env-vars.sh
19source $CEPH_ROOT/qa/workunits/ceph-helpers.sh
20
21function run() {
22 local dir=$1
23 shift
24
25 export CEPH_MON="127.0.0.1:7131" # git grep '\<7131\>' : there must be only one
26 export CEPH_ARGS
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 "
224ce89b
WB
31 #
32 # Disable device auto class feature for now.
33 # The device class is non-deterministic and will
34 # crash the crushmap comparison below.
35 #
36 CEPH_ARGS+="--osd-class-update-on-start=false "
31f18b77
FG
37
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
43 done
44}
45
46function TEST_choose_args_update() {
47 #
48 # adding a weighted OSD updates the weight up to the top
49 #
50 local dir=$1
51
52 run_mon $dir a || return 1
53 run_osd $dir 0 || return 1
54
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
59# choose_args
60choose_args 0 {
61 {
62 bucket_id -1
63 weight_set [
64 [ 3.000 ]
65 [ 3.000 ]
66 ]
67 ids [ -10 ]
68 }
69 {
70 bucket_id -2
71 weight_set [
72 [ 2.000 ]
73 [ 2.000 ]
74 ]
75 ids [ -20 ]
76 }
77}
78
79# end crush map
80EOF
81 crushtool -c $dir/map.txt -o $dir/map-new || return 1
82 ceph osd setcrushmap -i $dir/map-new || return 1
83
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
89
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
94}
95
96function TEST_no_update_weight_set() {
97 #
98 # adding a zero weight OSD does not update the weight set at all
99 #
100 local dir=$1
101
102 ORIG_CEPH_ARGS="$CEPH_ARGS"
103 CEPH_ARGS+="--osd-crush-update-weight-set=false "
104
105 run_mon $dir a || return 1
106 run_osd $dir 0 || return 1
107
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
112# choose_args
113choose_args 0 {
114 {
115 bucket_id -1
116 weight_set [
117 [ 6.000 ]
118 [ 7.000 ]
119 ]
120 ids [ -10 ]
121 }
122 {
123 bucket_id -2
124 weight_set [
125 [ 2.000 ]
126 [ 2.000 ]
127 ]
128 ids [ -20 ]
129 }
130}
131
132# end crush map
133EOF
134 crushtool -c $dir/map.txt -o $dir/map-new || return 1
135 ceph osd setcrushmap -i $dir/map-new || return 1
136
137
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
143
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
148
149 CEPH_ARGS="$ORIG_CEPH_ARGS"
150}
151
152main crush-choose-args "$@"
153
154# Local Variables:
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"
156# End: