3 # Copyright (C) 2022 Red Hat <contact@redhat.com>
5 # Author: Sridhar Seshasayee <sseshasa@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.
18 source $CEPH_ROOT/qa
/standalone
/ceph-helpers.sh
24 export CEPH_MON
="127.0.0.1:7124" # git grep '\<7124\>' : there must be only one
26 CEPH_ARGS
+="--fsid=$(uuidgen) --auth-supported=none "
27 CEPH_ARGS
+="--mon-host=$CEPH_MON "
28 CEPH_ARGS
+="--debug-bluestore 20 "
30 local funcs
=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
31 for func
in $funcs ; do
32 setup
$dir ||
return 1
33 $func $dir ||
return 1
34 teardown
$dir ||
return 1
38 function TEST_profile_builtin_to_custom
() {
42 setup
$dir ||
return 1
43 run_mon
$dir a
--osd_pool_default_size=$OSDS ||
return 1
44 run_mgr
$dir x ||
return 1
45 for osd
in $
(seq 0 $
(expr $OSDS - 1))
47 run_osd
$dir $osd --osd_op_queue=mclock_scheduler ||
return 1
50 # Verify that the default mclock profile is set on the OSDs
51 for id
in $
(seq 0 $
(expr $OSDS - 1))
53 local mclock_profile
=$
(ceph config get osd.
$id osd_mclock_profile
)
54 test "$mclock_profile" = "high_client_ops" ||
return 1
57 # Change the mclock profile to 'custom'
58 ceph config
set osd osd_mclock_profile custom ||
return 1
60 # Verify that the mclock profile is set to 'custom' on the OSDs
61 for id
in $
(seq 0 $
(expr $OSDS - 1))
63 local mclock_profile
=$
(ceph config get osd.
$id osd_mclock_profile
)
64 test "$mclock_profile" = "custom" ||
return 1
67 # Change a mclock config param and confirm the change
68 local client_res
=$
(CEPH_ARGS
='' ceph
--format=json daemon $
(get_asok_path \
69 osd.
$id) config get osd_mclock_scheduler_client_res | \
70 jq .osd_mclock_scheduler_client_res |
bc)
71 echo "client_res = $client_res"
72 local client_res_new
=$
(expr $client_res + 10)
73 echo "client_res_new = $client_res_new"
74 ceph config
set osd osd_mclock_scheduler_client_res \
75 $client_res_new ||
return 1
76 for id
in $
(seq 0 $
(expr $OSDS - 1))
78 # Check value in config monitor db
79 local res
=$
(ceph config get osd.
$id \
80 osd_mclock_scheduler_client_res
) ||
return 1
81 test $res -eq $client_res_new ||
return 1
82 # Check value in the in-memory 'values' map
83 res
=$
(CEPH_ARGS
='' ceph
--format=json daemon $
(get_asok_path \
84 osd.
$id) config get osd_mclock_scheduler_client_res | \
85 jq .osd_mclock_scheduler_client_res |
bc)
86 test $res -eq $client_res_new ||
return 1
89 teardown
$dir ||
return 1
92 function TEST_profile_custom_to_builtin
() {
96 setup
$dir ||
return 1
97 run_mon
$dir a
--osd_pool_default_size=$OSDS ||
return 1
98 run_mgr
$dir x ||
return 1
99 for osd
in $
(seq 0 $
(expr $OSDS - 1))
101 run_osd
$dir $osd --osd_op_queue=mclock_scheduler ||
return 1
104 # Verify that the default mclock profile is set on the OSDs
105 for id
in $
(seq 0 $
(expr $OSDS - 1))
107 local mclock_profile
=$
(ceph config get osd.
$id osd_mclock_profile
)
108 test "$mclock_profile" = "high_client_ops" ||
return 1
111 # Change the mclock profile to 'custom'
112 ceph config
set osd osd_mclock_profile custom ||
return 1
114 # Verify that the mclock profile is set to 'custom' on the OSDs
115 for id
in $
(seq 0 $
(expr $OSDS - 1))
117 local mclock_profile
=$
(ceph config get osd.
$id osd_mclock_profile
)
118 test "$mclock_profile" = "custom" ||
return 1
121 # Save the original client reservations allocated to the OSDs
123 for id
in $
(seq 0 $
(expr $OSDS - 1))
125 client_res
+=( $
(CEPH_ARGS
='' ceph
--format=json daemon $
(get_asok_path \
126 osd.
$id) config get osd_mclock_scheduler_client_res | \
127 jq .osd_mclock_scheduler_client_res |
bc) )
128 echo "Original client_res for osd.$id = ${client_res[$id]}"
131 # Change a mclock config param and confirm the change
132 local client_res_new
=$
(expr ${client_res[0]} + 10)
133 echo "client_res_new = $client_res_new"
134 ceph config
set osd osd_mclock_scheduler_client_res \
135 $client_res_new ||
return 1
136 for id
in $
(seq 0 $
(expr $OSDS - 1))
138 # Check value in config monitor db
139 local res
=$
(ceph config get osd.
$id \
140 osd_mclock_scheduler_client_res
) ||
return 1
141 test $res -eq $client_res_new ||
return 1
142 # Check value in the in-memory 'values' map
143 res
=$
(CEPH_ARGS
='' ceph
--format=json daemon $
(get_asok_path \
144 osd.
$id) config get osd_mclock_scheduler_client_res | \
145 jq .osd_mclock_scheduler_client_res |
bc)
146 test $res -eq $client_res_new ||
return 1
149 # Switch the mclock profile back to the original built-in profile.
150 # The config subsystem prevents the overwrite of the changed QoS config
151 # option above i.e. osd_mclock_scheduler_client_res. This fact is verified
152 # before proceeding to remove the entry from the config monitor db. After
153 # the config entry is removed, the original value for the config option is
154 # restored and is verified.
155 ceph config
set osd osd_mclock_profile high_client_ops ||
return 1
156 # Verify that the mclock profile is set to 'high_client_ops' on the OSDs
157 for id
in $
(seq 0 $
(expr $OSDS - 1))
159 local mclock_profile
=$
(ceph config get osd.
$id osd_mclock_profile
)
160 test "$mclock_profile" = "high_client_ops" ||
return 1
163 # Verify that the new value is still in effect
164 for id
in $
(seq 0 $
(expr $OSDS - 1))
166 # Check value in config monitor db
167 local res
=$
(ceph config get osd.
$id \
168 osd_mclock_scheduler_client_res
) ||
return 1
169 test $res -eq $client_res_new ||
return 1
170 # Check value in the in-memory 'values' map
171 res
=$
(CEPH_ARGS
='' ceph
--format=json daemon $
(get_asok_path \
172 osd.
$id) config get osd_mclock_scheduler_client_res | \
173 jq .osd_mclock_scheduler_client_res |
bc)
174 test $res -eq $client_res_new ||
return 1
177 # Remove the changed QoS config option from monitor db
178 ceph config
rm osd osd_mclock_scheduler_client_res ||
return 1
180 # Verify that the original values are now restored
181 for id
in $
(seq 0 $
(expr $OSDS - 1))
183 # Check value in the in-memory 'values' map
184 res
=$
(CEPH_ARGS
='' ceph
--format=json daemon $
(get_asok_path \
185 osd.
$id) config get osd_mclock_scheduler_client_res | \
186 jq .osd_mclock_scheduler_client_res |
bc)
187 test $res -eq ${client_res[$id]} ||
return 1
190 teardown
$dir ||
return 1
193 main test-mclock-profile-switch
"$@"
196 # compile-command: "cd build ; make -j4 && \
197 # ../qa/run-standalone.sh test-mclock-profile-switch.sh"