]> git.proxmox.com Git - ceph.git/blame - ceph/qa/standalone/misc/test-mclock-profile-switch.sh
bump version to 17.2.5-pve1
[ceph.git] / ceph / qa / standalone / misc / test-mclock-profile-switch.sh
CommitLineData
2a845540
TL
1#!/usr/bin/env bash
2#
3# Copyright (C) 2022 Red Hat <contact@redhat.com>
4#
5# Author: Sridhar Seshasayee <sseshasa@redhat.com>
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 $CEPH_ROOT/qa/standalone/ceph-helpers.sh
19
20function run() {
21 local dir=$1
22 shift
23
24 export CEPH_MON="127.0.0.1:7124" # git grep '\<7124\>' : there must be only one
25 export CEPH_ARGS
26 CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
27 CEPH_ARGS+="--mon-host=$CEPH_MON "
28 CEPH_ARGS+="--debug-bluestore 20 "
29
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
35 done
36}
37
38function TEST_profile_builtin_to_custom() {
39 local dir=$1
40 local OSDS=3
41
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))
46 do
47 run_osd $dir $osd --osd_op_queue=mclock_scheduler || return 1
48 done
49
50 # Verify that the default mclock profile is set on the OSDs
51 for id in $(seq 0 $(expr $OSDS - 1))
52 do
53 local mclock_profile=$(ceph config get osd.$id osd_mclock_profile)
54 test "$mclock_profile" = "high_client_ops" || return 1
55 done
56
57 # Change the mclock profile to 'custom'
58 ceph config set osd osd_mclock_profile custom || return 1
59
60 # Verify that the mclock profile is set to 'custom' on the OSDs
61 for id in $(seq 0 $(expr $OSDS - 1))
62 do
63 local mclock_profile=$(ceph config get osd.$id osd_mclock_profile)
64 test "$mclock_profile" = "custom" || return 1
65 done
66
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))
77 do
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
87 done
88
89 teardown $dir || return 1
90}
91
92function TEST_profile_custom_to_builtin() {
93 local dir=$1
94 local OSDS=3
95
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))
100 do
101 run_osd $dir $osd --osd_op_queue=mclock_scheduler || return 1
102 done
103
104 # Verify that the default mclock profile is set on the OSDs
105 for id in $(seq 0 $(expr $OSDS - 1))
106 do
107 local mclock_profile=$(ceph config get osd.$id osd_mclock_profile)
108 test "$mclock_profile" = "high_client_ops" || return 1
109 done
110
111 # Change the mclock profile to 'custom'
112 ceph config set osd osd_mclock_profile custom || return 1
113
114 # Verify that the mclock profile is set to 'custom' on the OSDs
115 for id in $(seq 0 $(expr $OSDS - 1))
116 do
117 local mclock_profile=$(ceph config get osd.$id osd_mclock_profile)
118 test "$mclock_profile" = "custom" || return 1
119 done
120
121 # Save the original client reservations allocated to the OSDs
122 local client_res=()
123 for id in $(seq 0 $(expr $OSDS - 1))
124 do
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]}"
129 done
130
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))
137 do
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
147 done
148
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))
158 do
159 local mclock_profile=$(ceph config get osd.$id osd_mclock_profile)
160 test "$mclock_profile" = "high_client_ops" || return 1
161 done
162
163 # Verify that the new value is still in effect
164 for id in $(seq 0 $(expr $OSDS - 1))
165 do
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
175 done
176
177 # Remove the changed QoS config option from monitor db
178 ceph config rm osd osd_mclock_scheduler_client_res || return 1
179
180 # Verify that the original values are now restored
181 for id in $(seq 0 $(expr $OSDS - 1))
182 do
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
188 done
189
190 teardown $dir || return 1
191}
192
193main test-mclock-profile-switch "$@"
194
195# Local Variables:
196# compile-command: "cd build ; make -j4 && \
197# ../qa/run-standalone.sh test-mclock-profile-switch.sh"
198# End: