decision_engine: Accept string/array values for weights

Change-Id: I14c325d116a7a062fe049064946ce61f16b703b4
This commit is contained in:
Takashi Kajinami 2023-07-13 21:59:21 +09:00
parent 6c560ed913
commit 0a9e188d30
2 changed files with 7 additions and 6 deletions

View File

@ -67,11 +67,10 @@ class watcher::decision_engine (
include watcher::params
include watcher::deps
if !is_service_default($weights) {
validate_legacy(Hash, 'validate_hash', $weights)
if $weights =~ Hash {
$weights_real = join(sort(join_keys_to_values($weights, ':')), ',')
} else {
$weights_real = $weights
$weights_real = join(any2array($weights), ',')
}
if !is_service_default($decision_engine_notification_topics) or

View File

@ -69,8 +69,10 @@ describe 'watcher::decision_engine' do
:decision_engine_publisher_id => '123456',
:decision_engine_workers => '10',
:planner => 'NoPlanner',
:weights => {'foo' => 'fooValue',
'foo2' => 'fooValue2'},
:weights => {
'foo1' => 'fooValue1',
'foo2' => 'fooValue2'
},
}
end
it 'configures watcher decision engine' do
@ -80,7 +82,7 @@ describe 'watcher::decision_engine' do
is_expected.to contain_watcher_config('watcher_decision_engine/publisher_id').with_value('123456')
is_expected.to contain_watcher_config('watcher_decision_engine/max_workers').with_value('10')
is_expected.to contain_watcher_config('watcher_planner/planner').with_value('NoPlanner')
is_expected.to contain_watcher_config('watcher_planners.default/weights').with_value('foo2:fooValue2,foo:fooValue')
is_expected.to contain_watcher_config('watcher_planners.default/weights').with_value('foo1:fooValue1,foo2:fooValue2')
end
end
end