Add ability to disable ceilometer-collector without db

You are no longer required to include ceilometer::db when
disabling ceilometer-collector using the enabled parameter.

The relationships with any database resources are now only enforced
when the service is enabled.

Closes-bug: #1352958
Change-Id: I00a5e651184788acdd30de1908e2bf38566f78e1
This commit is contained in:
Mathieu Gagné 2014-08-05 11:58:27 -04:00
parent e3ffea2b03
commit 8c9f4fcd53
2 changed files with 34 additions and 16 deletions

View File

@ -17,6 +17,8 @@ class ceilometer::collector (
if $enabled {
$service_ensure = 'running'
Class['ceilometer::db'] -> Service['ceilometer-collector']
Exec['ceilometer-dbsync'] ~> Service['ceilometer-collector']
} else {
$service_ensure = 'stopped'
}
@ -27,8 +29,6 @@ class ceilometer::collector (
name => $::ceilometer::params::collector_service_name,
enable => $enabled,
hasstatus => true,
hasrestart => true,
require => Class['ceilometer::db'],
subscribe => Exec['ceilometer-dbsync']
hasrestart => true
}
}

View File

@ -8,22 +8,40 @@ describe 'ceilometer::collector' do
shared_examples_for 'ceilometer-collector' do
it { should contain_class('ceilometer::params') }
context 'when enabled' do
before do
pre_condition << "class { 'ceilometer::db': }"
end
it 'installs ceilometer-collector package' do
should contain_package(platform_params[:collector_package_name])
it { should contain_class('ceilometer::params') }
it 'installs ceilometer-collector package' do
should contain_package(platform_params[:collector_package_name])
end
it 'configures ceilometer-collector service' do
should contain_service('ceilometer-collector').with(
:ensure => 'running',
:name => platform_params[:collector_service_name],
:enable => true,
:hasstatus => true,
:hasrestart => true
)
end
it 'configures relationships on database' do
should contain_class('ceilometer::db').with_before('Service[ceilometer-collector]')
should contain_exec('ceilometer-dbsync').with_notify('Service[ceilometer-collector]')
end
end
it 'configures ceilometer-collector service' do
should contain_service('ceilometer-collector').with(
:ensure => 'running',
:name => platform_params[:collector_service_name],
:enable => true,
:hasstatus => true,
:hasrestart => true,
:require => 'Class[Ceilometer::Db]',
:subscribe => 'Exec[ceilometer-dbsync]'
)
context 'when disabled' do
let :params do
{ :enabled => false }
end
# Catalog compilation does not crash for lack of ceilometer::db
it { should compile }
end
end