3 # Copyright (C) 2019 Red Hat <contact@redhat.com>
5 # Author: David Zafman <dzafman@redhat.com>
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.
17 source $CEPH_ROOT/qa
/standalone
/ceph-helpers.sh
23 export CEPH_MON
="127.0.0.1:7102" # git grep '\<7102\>' : there must be only one
25 CEPH_ARGS
+="--fsid=$(uuidgen) --auth-supported=none "
26 CEPH_ARGS
+="--mon-host=$CEPH_MON "
28 local funcs
=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
29 for func
in $funcs ; do
30 $func $dir ||
return 1
37 function TEST_balancer
() {
40 setup
$dir ||
return 1
41 run_mon
$dir a ||
return 1
42 run_mgr
$dir x ||
return 1
43 run_osd
$dir 0 ||
return 1
44 run_osd
$dir 1 ||
return 1
45 run_osd
$dir 2 ||
return 1
46 create_pool
$TEST_POOL1 8
47 create_pool
$TEST_POOL2 8
49 wait_for_clean ||
return 1
52 ceph osd set-require-min-compat-client luminous
53 ceph balancer status ||
return 1
54 eval MODE
=$
(ceph balancer status | jq
'.mode')
55 test $MODE = "none" ||
return 1
56 ACTIVE
=$
(ceph balancer status | jq
'.active')
57 test $ACTIVE = "false" ||
return 1
59 ceph balancer
ls ||
return 1
60 PLANS
=$
(ceph balancer
ls)
61 test "$PLANS" = "[]" ||
return 1
62 ceph balancer
eval ||
return 1
63 EVAL
="$(ceph balancer eval)"
64 test "$EVAL" = "current cluster score 0.000000 (lower is better)"
65 ceph balancer eval-verbose ||
return 1
67 ceph balancer pool add
$TEST_POOL1 ||
return 1
68 ceph balancer pool add
$TEST_POOL2 ||
return 1
69 ceph balancer pool
ls ||
return 1
70 eval POOL
=$
(ceph balancer pool
ls | jq
'.[0]')
71 test "$POOL" = "$TEST_POOL1" ||
return 1
72 eval POOL
=$
(ceph balancer pool
ls | jq
'.[1]')
73 test "$POOL" = "$TEST_POOL2" ||
return 1
74 ceph balancer pool
rm $TEST_POOL1 ||
return 1
75 ceph balancer pool
rm $TEST_POOL2 ||
return 1
76 ceph balancer pool
ls ||
return 1
77 ceph balancer pool add
$TEST_POOL1 ||
return 1
79 ceph balancer mode crush-compat ||
return 1
80 ceph balancer status ||
return 1
81 eval MODE
=$
(ceph balancer status | jq
'.mode')
82 test $MODE = "crush-compat" ||
return 1
83 ! ceph balancer optimize plan_crush
$TEST_POOL1 ||
return 1
84 ceph balancer status ||
return 1
85 eval RESULT
=$
(ceph balancer status | jq
'.optimize_result')
86 test "$RESULT" = "Distribution is already perfect" ||
return 1
88 ceph balancer on ||
return 1
89 ACTIVE
=$
(ceph balancer status | jq
'.active')
90 test $ACTIVE = "true" ||
return 1
92 ceph balancer status ||
return 1
93 ceph balancer off ||
return 1
94 ACTIVE
=$
(ceph balancer status | jq
'.active')
95 test $ACTIVE = "false" ||
return 1
98 ceph balancer
reset ||
return 1
100 ceph balancer mode upmap ||
return 1
101 ceph balancer status ||
return 1
102 eval MODE
=$
(ceph balancer status | jq
'.mode')
103 test $MODE = "upmap" ||
return 1
104 ! ceph balancer optimize plan_upmap
$TEST_POOL ||
return 1
105 ceph balancer status ||
return 1
106 eval RESULT
=$
(ceph balancer status | jq
'.optimize_result')
107 test "$RESULT" = "Unable to find further optimization, or pool(s)' pg_num is decreasing, or distribution is already perfect" ||
return 1
109 ceph balancer on ||
return 1
110 ACTIVE
=$
(ceph balancer status | jq
'.active')
111 test $ACTIVE = "true" ||
return 1
113 ceph balancer status ||
return 1
114 ceph balancer off ||
return 1
115 ACTIVE
=$
(ceph balancer status | jq
'.active')
116 test $ACTIVE = "false" ||
return 1
118 teardown
$dir ||
return 1
124 # compile-command: "make -j4 && ../qa/run-standalone.sh balancer.sh"