Merge "Add support for [collector] options"
This commit is contained in:
31
manifests/collector.pp
Normal file
31
manifests/collector.pp
Normal file
@@ -0,0 +1,31 @@
|
||||
# == Class: watcher::collector
|
||||
#
|
||||
# Configure the collector options
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*collector_plugins*]
|
||||
# (Optional) The cluster data model plugin names
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*api_query_retries*]
|
||||
# (Optional) Number of retries before giving up on external service queries.
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
# [*api_query_interval*]
|
||||
# (Optional) How many seconds Watcher should wait to do query again.
|
||||
# Defaults to $facts['os_service_default']
|
||||
#
|
||||
class watcher::collector (
|
||||
$collector_plugins = $facts['os_service_default'],
|
||||
$api_query_retries = $facts['os_service_default'],
|
||||
$api_query_interval = $facts['os_service_default'],
|
||||
) {
|
||||
include watcher::deps
|
||||
|
||||
watcher_config {
|
||||
'collector/collector_plugins': value => join(any2array($collector_plugins), ',');
|
||||
'collector/api_query_retries': value => $api_query_retries;
|
||||
'collector/api_query_interval': value => $api_query_interval;
|
||||
}
|
||||
}
|
4
releasenotes/notes/collector-8c7882fca3595152.yaml
Normal file
4
releasenotes/notes/collector-8c7882fca3595152.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new ``watcher::collector`` class has been added.
|
46
spec/classes/watcher_collector_spec.rb
Normal file
46
spec/classes/watcher_collector_spec.rb
Normal file
@@ -0,0 +1,46 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'watcher::collector' do
|
||||
|
||||
shared_examples 'watcher::collector' do
|
||||
context 'with defaults' do
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
it 'should set the defaults' do
|
||||
should contain_watcher_config('collector/collector_plugins').with_value('<SERVICE DEFAULT>')
|
||||
should contain_watcher_config('collector/api_query_retries').with_value('<SERVICE DEFAULT>')
|
||||
should contain_watcher_config('collector/api_query_interval').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with parameters overridden' do
|
||||
let :params do
|
||||
{
|
||||
:collector_plugins => ['compute', 'storage'],
|
||||
:api_query_retries => 10,
|
||||
:api_query_interval => 1,
|
||||
}
|
||||
end
|
||||
|
||||
it 'should set the overridden values' do
|
||||
should contain_watcher_config('collector/collector_plugins').with_value('compute,storage')
|
||||
should contain_watcher_config('collector/api_query_retries').with_value(10)
|
||||
should contain_watcher_config('collector/api_query_interval').with_value(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
it_behaves_like 'watcher::collector'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user