From 10d38bd8191fc82f4087731ea6932583dd66db8d Mon Sep 17 00:00:00 2001 From: Martin Magr Date: Wed, 20 Aug 2014 15:57:55 +0200 Subject: [PATCH] Add manage_service feature puppet-ceilometer lacks of disabling service managing. This patch adds $manage_service parameter to all relevant classes. Closes-bug: #1359823 Change-Id: Iee545b46ef5d7cf92859356ae84b8103564bf047 --- manifests/agent/central.pp | 20 +++++-- manifests/agent/compute.pp | 21 ++++--- manifests/agent/notification.pp | 20 ++++--- manifests/alarm/evaluator.pp | 36 ++++++++---- manifests/alarm/notifier.pp | 35 ++++++++---- manifests/api.pp | 57 ++++++++++++------- manifests/collector.pp | 24 +++++--- spec/classes/ceilometer_agent_central_spec.rb | 45 ++++++++++++--- spec/classes/ceilometer_agent_compute_spec.rb | 50 ++++++++++++---- .../ceilometer_agent_notification_spec.rb | 50 ++++++++++++---- .../ceilometer_alarm_evaluator_spec.rb | 56 +++++++++++++----- .../classes/ceilometer_alarm_notifier_spec.rb | 48 ++++++++++++---- spec/classes/ceilometer_api_spec.rb | 51 +++++++++++++---- spec/classes/ceilometer_collector_spec.rb | 27 +++++++++ 14 files changed, 402 insertions(+), 138 deletions(-) diff --git a/manifests/agent/central.pp b/manifests/agent/central.pp index 0a0785613..7c17d8c11 100644 --- a/manifests/agent/central.pp +++ b/manifests/agent/central.pp @@ -2,10 +2,16 @@ # # == Parameters # [*enabled*] -# Should the service be enabled. Optional. Defauls to true +# (optional) Should the service be enabled. +# Defaults to true. +# +# [*manage_service*] +# (optional) Whether the service should be managed by Puppet. +# Defaults to true. # class ceilometer::agent::central ( - $enabled = true, + $manage_service = true, + $enabled = true, ) { include ceilometer::params @@ -18,10 +24,12 @@ name => $::ceilometer::params::agent_central_package_name, } - if $enabled { - $service_ensure = 'running' - } else { - $service_ensure = 'stopped' + if $manage_service { + if $enabled { + $service_ensure = 'running' + } else { + $service_ensure = 'stopped' + } } Package['ceilometer-common'] -> Service['ceilometer-agent-central'] diff --git a/manifests/agent/compute.pp b/manifests/agent/compute.pp index fde3705d6..9a81e8c68 100644 --- a/manifests/agent/compute.pp +++ b/manifests/agent/compute.pp @@ -3,11 +3,16 @@ # # == Parameters # [*enabled*] -# should the service be started or not -# Optional. Defaults to true +# (optional) Should the service be enabled. +# Defaults to true. +# +# [*manage_service*] +# (optional) Whether the service should be managed by Puppet. +# Defaults to true. # class ceilometer::agent::compute ( - $enabled = true, + $manage_service = true, + $enabled = true, ) inherits ceilometer { include ceilometer::params @@ -30,10 +35,12 @@ } } - if $enabled { - $service_ensure = 'running' - } else { - $service_ensure = 'stopped' + if $manage_service { + if $enabled { + $service_ensure = 'running' + } else { + $service_ensure = 'stopped' + } } Package['ceilometer-common'] -> Service['ceilometer-agent-compute'] diff --git a/manifests/agent/notification.pp b/manifests/agent/notification.pp index 29993622f..f8c2631c8 100644 --- a/manifests/agent/notification.pp +++ b/manifests/agent/notification.pp @@ -23,10 +23,13 @@ # file with the OVS plugin if both are on the same machine. # # === Parameters -# # [*enabled*] -# (optional) Should the service be started or not -# Defaults to true +# (optional) Should the service be enabled. +# Defaults to true. +# +# [*manage_service*] +# (optional) Whether the service should be managed by Puppet. +# Defaults to true. # # [*ack_on_event_error*] # (optional) Acknowledge message when event persistence fails. @@ -38,6 +41,7 @@ # class ceilometer::agent::notification ( + $manage_service = true, $enabled = true, $ack_on_event_error = true, $store_events = false @@ -50,10 +54,12 @@ Package[$::ceilometer::params::agent_notification_package_name] -> Service['ceilometer-agent-notification'] ensure_packages([$::ceilometer::params::agent_notification_package_name]) - if $enabled { - $service_ensure = 'running' - } else { - $service_ensure = 'stopped' + if $manage_service { + if $enabled { + $service_ensure = 'running' + } else { + $service_ensure = 'stopped' + } } Package['ceilometer-common'] -> Service['ceilometer-agent-notification'] diff --git a/manifests/alarm/evaluator.pp b/manifests/alarm/evaluator.pp index 262153491..2b9ca643b 100644 --- a/manifests/alarm/evaluator.pp +++ b/manifests/alarm/evaluator.pp @@ -2,18 +2,32 @@ # # == Params # [*enabled*] -# should the service be enabled +# (optional) Should the service be enabled. +# Defaults to true. +# +# [*manage_service*] +# (optional) Whether the service should be managed by Puppet. +# Defaults to true. +# # [*evaluation_interval*] -# define the time interval for the alarm evaluator +# (optional) Define the time interval for the alarm evaluator +# Defaults to 60. +# # [*evaluation_service*] -# define which service use for the evaluator +# (optional) Define which service use for the evaluator +# Defaults to 'ceilometer.alarm.service.SingletonAlarmService'. +# # [*partition_rpc_topic*] -# define which topic the alarm evaluator should access +# (optional) Define which topic the alarm evaluator should access +# Defaults to 'alarm_partition_coordination'. +# # [*record_history*] -# Record alarm change events +# (optional) Record alarm change events +# Defaults to true. # class ceilometer::alarm::evaluator ( - $enabled = true, + $manage_service = true, + $enabled = true, $evaluation_interval = 60, $evaluation_service = 'ceilometer.alarm.service.SingletonAlarmService', $partition_rpc_topic = 'alarm_partition_coordination', @@ -30,10 +44,12 @@ Package[$::ceilometer::params::alarm_package_name] -> Package<| title == 'ceilometer-alarm' |> ensure_packages($::ceilometer::params::alarm_package_name) - if $enabled { - $service_ensure = 'running' - } else { - $service_ensure = 'stopped' + if $manage_service { + if $enabled { + $service_ensure = 'running' + } else { + $service_ensure = 'stopped' + } } Package['ceilometer-common'] -> Service['ceilometer-alarm-evaluator'] diff --git a/manifests/alarm/notifier.pp b/manifests/alarm/notifier.pp index 1b09baaf1..4bad22100 100644 --- a/manifests/alarm/notifier.pp +++ b/manifests/alarm/notifier.pp @@ -2,18 +2,31 @@ # # == Params # [*enabled*] -# should the service be enabled +# (optional) Should the service be enabled. +# Defaults to true. +# +# [*manage_service*] +# (optional) Whether the service should be managed by Puppet. +# Defaults to true. +# # [*notifier_rpc_topic*] -# define on which topic the notifier will have -# access +# (optional) Define on which topic the notifier will have access. +# Defaults to undef. +# # [*rest_notifier_certificate_key*] -# define the certificate key for the rest service +# (optional) Define the certificate key for the rest service. +# Defaults to undef. +# # [*rest_notifier_certificate_file*] -# define the certificate file for the rest service +# (optional) Define the certificate file for the rest service. +# Defaults to undef. +# # [*rest_notifier_ssl_verify*] -# should the ssl verify parameter be enabled +# (optional) Should the ssl verify parameter be enabled. +# Defaults to true. # class ceilometer::alarm::notifier ( + $manage_service = true, $enabled = true, $notifier_rpc_topic = undef, $rest_notifier_certificate_key = undef, @@ -31,10 +44,12 @@ Package[$::ceilometer::params::alarm_package_name] -> Package<| title == 'ceilometer-alarm' |> ensure_packages($::ceilometer::params::alarm_package_name) - if $enabled { - $service_ensure = 'running' - } else { - $service_ensure = 'stopped' + if $manage_service { + if $enabled { + $service_ensure = 'running' + } else { + $service_ensure = 'stopped' + } } Package['ceilometer-common'] -> Service['ceilometer-alarm-notifier'] diff --git a/manifests/api.pp b/manifests/api.pp index bdb0976f9..70e2bdf4a 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -2,41 +2,54 @@ # # == Parameters # [*enabled*] -# should the service be enabled. Optional. Defaults to true +# (optional) Should the service be enabled. +# Defaults to true +# +# [*manage_service*] +# (optional) Whether the service should be managed by Puppet. +# Defaults to true. # # [*keystone_host*] -# keystone's admin endpoint IP/Host. Optional. Defaults to 127.0.0.1 +# (optional) Keystone's admin endpoint IP/Host. +# Defaults to '127.0.0.1' # # [*keystone_port*] -# keystone's admin endpoint port. Optional. Defaults to 35357 +# (optional) Keystone's admin endpoint port. +# Defaults to 35357 # # [*keystone_auth_admin_prefix*] -# 'path' to the keystone admin endpoint. Optional. Defaults to false (empty) +# (optional) 'path' to the keystone admin endpoint. # Define to a path starting with a '/' and without trailing '/'. # Eg.: '/keystone/admin' to match keystone::wsgi::apache default. +# Defaults to false (empty) # -# [*keystone_protocol*] http/https -# Optional. Defaults to https +# [*keystone_protocol*] +# (optional) 'http' or 'https' +# Defaults to 'https'. # -# [*keytone_user*] user to authenticate with -# Optional. Defaults to ceilometer +# [*keytone_user*] +# (optional) User to authenticate with. +# Defaults to 'ceilometer'. # -# [*keystone_tenant*] tenant to authenticate with -# Optional. Defaults to services +# [*keystone_tenant*] +# (optional) Tenant to authenticate with. +# Defaults to 'services'. # -# [*keystone_password*] password to authenticate with +# [*keystone_password*] +# Password to authenticate with. # Mandatory. # -# [*host*] -# (optional) The ceilometer api bind address -# Defaults to 0.0.0.0 +# [*host*] +# (optional) The ceilometer api bind address. +# Defaults to 0.0.0.0 # -# [*port*] -# (optional) The ceilometer api port -# Defaults to 8777 +# [*port*] +# (optional) The ceilometer api port. +# Defaults to 8777 # class ceilometer::api ( + $manage_service = true, $enabled = true, $keystone_host = '127.0.0.1', $keystone_port = '35357', @@ -63,10 +76,12 @@ name => $::ceilometer::params::api_package_name, } - if $enabled { - $service_ensure = 'running' - } else { - $service_ensure = 'stopped' + if $manage_service { + if $enabled { + $service_ensure = 'running' + } else { + $service_ensure = 'stopped' + } } Package['ceilometer-common'] -> Service['ceilometer-api'] diff --git a/manifests/collector.pp b/manifests/collector.pp index 2506efbe7..8e1f6fcb2 100644 --- a/manifests/collector.pp +++ b/manifests/collector.pp @@ -2,10 +2,16 @@ # # == Params # [*enabled*] -# should the service be enabled +# (optional) Should the service be enabled. +# Defaults to true. +# +# [*manage_service*] +# (optional) Whether the service should be managed by Puppet. +# Defaults to true. # class ceilometer::collector ( - $enabled = true, + $manage_service = true, + $enabled = true, ) { include ceilometer::params @@ -15,12 +21,14 @@ Package[$::ceilometer::params::collector_package_name] -> Service['ceilometer-collector'] ensure_packages([$::ceilometer::params::collector_package_name]) - if $enabled { - $service_ensure = 'running' - Class['ceilometer::db'] -> Service['ceilometer-collector'] - Exec['ceilometer-dbsync'] ~> Service['ceilometer-collector'] - } else { - $service_ensure = 'stopped' + if $manage_service { + if $enabled { + $service_ensure = 'running' + Class['ceilometer::db'] -> Service['ceilometer-collector'] + Exec['ceilometer-dbsync'] ~> Service['ceilometer-collector'] + } else { + $service_ensure = 'stopped' + } } Package['ceilometer-common'] -> Service['ceilometer-collector'] diff --git a/spec/classes/ceilometer_agent_central_spec.rb b/spec/classes/ceilometer_agent_central_spec.rb index 5fab4c924..8a45c35e1 100644 --- a/spec/classes/ceilometer_agent_central_spec.rb +++ b/spec/classes/ceilometer_agent_central_spec.rb @@ -7,7 +7,8 @@ end let :params do - { :enabled => true } + { :enabled => true, + :manage_service => true } end shared_examples_for 'ceilometer-agent-central' do @@ -28,14 +29,40 @@ ) end - it 'configures ceilometer-agent-central service' do - should contain_service('ceilometer-agent-central').with( - :ensure => 'running', - :name => platform_params[:agent_service_name], - :enable => true, - :hasstatus => true, - :hasrestart => true - ) + [{:enabled => true}, {:enabled => false}].each do |param_hash| + context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do + before do + params.merge!(param_hash) + end + + it 'configures ceilometer-agent-central service' do + should contain_service('ceilometer-agent-central').with( + :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped', + :name => platform_params[:agent_service_name], + :enable => params[:enabled], + :hasstatus => true, + :hasrestart => true + ) + end + end + end + + context 'with disabled service managing' do + before do + params.merge!({ + :manage_service => false, + :enabled => false }) + end + + it 'configures ceilometer-agent-central service' do + should contain_service('ceilometer-agent-central').with( + :ensure => nil, + :name => platform_params[:agent_service_name], + :enable => false, + :hasstatus => true, + :hasrestart => true + ) + end end end diff --git a/spec/classes/ceilometer_agent_compute_spec.rb b/spec/classes/ceilometer_agent_compute_spec.rb index 16f19a048..d193bc1a7 100644 --- a/spec/classes/ceilometer_agent_compute_spec.rb +++ b/spec/classes/ceilometer_agent_compute_spec.rb @@ -9,7 +9,8 @@ end let :params do - { :enabled => true } + { :enabled => true, + :manage_service => true } end shared_examples_for 'ceilometer-agent-compute' do @@ -38,16 +39,6 @@ ) end - it 'configures ceilometer-agent-compute service' do - should contain_service('ceilometer-agent-compute').with( - :ensure => 'running', - :name => platform_params[:agent_service_name], - :enable => true, - :hasstatus => true, - :hasrestart => true - ) - end - it 'configures nova notification driver' do should contain_file_line_after('nova-notification-driver-common').with( :line => 'notification_driver=nova.openstack.common.notifier.rpc_notifier', @@ -61,6 +52,43 @@ ) end + [{:enabled => true}, {:enabled => false}].each do |param_hash| + context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do + before do + params.merge!(param_hash) + end + + it 'configures ceilometer-agent-compute service' do + + should contain_service('ceilometer-agent-compute').with( + :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped', + :name => platform_params[:agent_service_name], + :enable => params[:enabled], + :hasstatus => true, + :hasrestart => true + ) + end + end + end + + context 'with disabled service managing' do + before do + params.merge!({ + :manage_service => false, + :enabled => false }) + end + + it 'configures ceilometer-agent-compute service' do + should contain_service('ceilometer-agent-compute').with( + :ensure => nil, + :name => platform_params[:agent_service_name], + :enable => false, + :hasstatus => true, + :hasrestart => true + ) + end + end + end context 'on Debian platforms' do diff --git a/spec/classes/ceilometer_agent_notification_spec.rb b/spec/classes/ceilometer_agent_notification_spec.rb index 227b6b6bd..8646c28e3 100644 --- a/spec/classes/ceilometer_agent_notification_spec.rb +++ b/spec/classes/ceilometer_agent_notification_spec.rb @@ -27,7 +27,9 @@ end let :params do - { :ack_on_event_error => true, + { :manage_service => true, + :enabled => true, + :ack_on_event_error => true, :store_events => false } end @@ -39,21 +41,47 @@ should contain_package(platform_params[:agent_notification_package_name]) end - it 'configures ceilometer agent notification service' do - should contain_service('ceilometer-agent-notification').with( - :ensure => 'running', - :name => platform_params[:agent_notification_service_name], - :enable => true, - :hasstatus => true, - :hasrestart => true - ) - end - it 'configures notifications parameters in ceilometer.conf' do should contain_ceilometer_config('notification/ack_on_event_error').with_value( params[:ack_on_event_error] ) should contain_ceilometer_config('notification/store_events').with_value( params[:store_events] ) end + [{:enabled => true}, {:enabled => false}].each do |param_hash| + context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do + before do + params.merge!(param_hash) + end + + it 'configures ceilometer agent notification service' do + should contain_service('ceilometer-agent-notification').with( + :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped', + :name => platform_params[:agent_notification_service_name], + :enable => params[:enabled], + :hasstatus => true, + :hasrestart => true + ) + end + end + end + + context 'with disabled service managing' do + before do + params.merge!({ + :manage_service => false, + :enabled => false }) + end + + it 'configures ceilometer-agent-notification service' do + should contain_service('ceilometer-agent-notification').with( + :ensure => nil, + :name => platform_params[:agent_notification_service_name], + :enable => false, + :hasstatus => true, + :hasrestart => true + ) + end + end + end context 'on Debian platforms' do diff --git a/spec/classes/ceilometer_alarm_evaluator_spec.rb b/spec/classes/ceilometer_alarm_evaluator_spec.rb index d017695e9..b2c4c48b0 100644 --- a/spec/classes/ceilometer_alarm_evaluator_spec.rb +++ b/spec/classes/ceilometer_alarm_evaluator_spec.rb @@ -12,6 +12,7 @@ :partition_rpc_topic => 'alarm_partition_coordination', :record_history => true, :enabled => true, + :manage_service => true, } end @@ -32,17 +33,6 @@ ) end - it 'configures ceilometer-alarm-evaluator service' do - should contain_service('ceilometer-alarm-evaluator').with( - :ensure => 'running', - :name => platform_params[:alarm_evaluator_service_name], - :enable => true, - :hasstatus => true, - :hasrestart => true - ) - end - - it 'configures alarm evaluator' do should contain_ceilometer_config('alarm/evaluation_interval').with_value( params[:evaluation_interval] ) should contain_ceilometer_config('alarm/evaluation_service').with_value( params[:evaluation_service] ) @@ -63,14 +53,50 @@ it { should contain_ceilometer_config('alarm/partition_rpc_topic').with_value(params[:partition_rpc_topic]) } end - context 'when override the evaluation interval with a non numeric value' do + context 'when override the evaluation interval with a non numeric value' do + before do + params.merge!(:evaluation_interval => 'NaN') + end + + it { expect { should contain_ceilometer_config('alarm/evaluation_interval') }.to\ + raise_error(Puppet::Error, /validate_re\(\): .* does not match/) } + end + + [{:enabled => true}, {:enabled => false}].each do |param_hash| + context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do before do - params.merge!(:evaluation_interval => 'NaN') + params.merge!(param_hash) end - it { expect { should contain_ceilometer_config('alarm/evaluation_interval') }.to\ - raise_error(Puppet::Error, /validate_re\(\): .* does not match/) } + it 'configures ceilometer-alarm-evaluator service' do + should contain_service('ceilometer-alarm-evaluator').with( + :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped', + :name => platform_params[:alarm_evaluator_service_name], + :enable => params[:enabled], + :hasstatus => true, + :hasrestart => true + ) + end + end + end + + context 'with disabled service managing' do + before do + params.merge!({ + :manage_service => false, + :enabled => false }) + end + + it 'configures ceilometer-alarm-evaluator service' do + should contain_service('ceilometer-alarm-evaluator').with( + :ensure => nil, + :name => platform_params[:alarm_evaluator_service_name], + :enable => false, + :hasstatus => true, + :hasrestart => true + ) end + end end context 'on Debian platforms' do diff --git a/spec/classes/ceilometer_alarm_notifier_spec.rb b/spec/classes/ceilometer_alarm_notifier_spec.rb index 6c40d433a..d4e65a1e3 100644 --- a/spec/classes/ceilometer_alarm_notifier_spec.rb +++ b/spec/classes/ceilometer_alarm_notifier_spec.rb @@ -13,6 +13,7 @@ #:rest_notifier_certificate_file => 'UNSET', #:rest_notifier_ssl_verify => true, :enabled => true, + :manage_service => true, } end @@ -33,17 +34,6 @@ ) end - it 'configures ceilometer-alarm-notifier service' do - should contain_service('ceilometer-alarm-notifier').with( - :ensure => 'running', - :name => platform_params[:alarm_notifier_service_name], - :enable => true, - :hasstatus => true, - :hasrestart => true - ) - end - - it 'configures alarm notifier' do should_not contain_ceilometer_config('alarm/notifier_rpc_topic') should_not contain_ceilometer_config('alarm/rest_notifier_certificate_key') @@ -64,6 +54,42 @@ it { should contain_ceilometer_config('alarm/rest_notifier_ssl_verify').with_value(params[:rest_notifier_ssl_verify]) } end + [{:enabled => true}, {:enabled => false}].each do |param_hash| + context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do + before do + params.merge!(param_hash) + end + + it 'configures ceilometer-alarm-notifier service' do + should contain_service('ceilometer-alarm-notifier').with( + :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped', + :name => platform_params[:alarm_notifier_service_name], + :enable => params[:enabled], + :hasstatus => true, + :hasrestart => true + ) + end + end + end + + context 'with disabled service managing' do + before do + params.merge!({ + :manage_service => false, + :enabled => false }) + end + + it 'configures ceilometer-alarm-notifier service' do + should contain_service('ceilometer-alarm-notifier').with( + :ensure => nil, + :name => platform_params[:alarm_notifier_service_name], + :enable => false, + :hasstatus => true, + :hasrestart => true + ) + end + end + end context 'on Debian platforms' do diff --git a/spec/classes/ceilometer_api_spec.rb b/spec/classes/ceilometer_api_spec.rb index 3075d29ce..66a9c1815 100644 --- a/spec/classes/ceilometer_api_spec.rb +++ b/spec/classes/ceilometer_api_spec.rb @@ -8,6 +8,7 @@ let :params do { :enabled => true, + :manage_service => true, :keystone_host => '127.0.0.1', :keystone_port => '35357', :keystone_protocol => 'http', @@ -35,18 +36,6 @@ ) end - it 'configures ceilometer-api service' do - should contain_service('ceilometer-api').with( - :ensure => 'running', - :name => platform_params[:api_service_name], - :enable => true, - :hasstatus => true, - :hasrestart => true, - :require => 'Class[Ceilometer::Db]', - :subscribe => 'Exec[ceilometer-dbsync]' - ) - end - it 'configures keystone authentication middleware' do should contain_ceilometer_config('keystone_authtoken/auth_host').with_value( params[:keystone_host] ) should contain_ceilometer_config('keystone_authtoken/auth_port').with_value( params[:keystone_port] ) @@ -83,6 +72,44 @@ end end end + + [{:enabled => true}, {:enabled => false}].each do |param_hash| + context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do + before do + params.merge!(param_hash) + end + + it 'configures ceilometer-api service' do + should contain_service('ceilometer-api').with( + :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped', + :name => platform_params[:api_service_name], + :enable => params[:enabled], + :hasstatus => true, + :hasrestart => true, + :require => 'Class[Ceilometer::Db]', + :subscribe => 'Exec[ceilometer-dbsync]' + ) + end + end + end + + context 'with disabled service managing' do + before do + params.merge!({ + :manage_service => false, + :enabled => false }) + end + + it 'configures ceilometer-api service' do + should contain_service('ceilometer-api').with( + :ensure => nil, + :name => platform_params[:api_service_name], + :enable => false, + :hasstatus => true, + :hasrestart => true + ) + end + end end context 'on Debian platforms' do diff --git a/spec/classes/ceilometer_collector_spec.rb b/spec/classes/ceilometer_collector_spec.rb index 25e6d650b..72f2510e5 100644 --- a/spec/classes/ceilometer_collector_spec.rb +++ b/spec/classes/ceilometer_collector_spec.rb @@ -42,6 +42,33 @@ # Catalog compilation does not crash for lack of ceilometer::db it { should compile } + + it 'configures ceilometer-collector service' do + should contain_service('ceilometer-collector').with( + :ensure => 'stopped', + :name => platform_params[:collector_service_name], + :enable => false, + :hasstatus => true, + :hasrestart => true + ) + end + end + + context 'when service management is disabled' do + let :params do + { :enabled => false, + :manage_service => false } + end + + it 'configures ceilometer-collector service' do + should contain_service('ceilometer-collector').with( + :ensure => nil, + :name => platform_params[:collector_service_name], + :enable => false, + :hasstatus => true, + :hasrestart => true + ) + end end end