Skip to content

Commit

Permalink
Add ability to disable ceilometer-collector without db
Browse files Browse the repository at this point in the history
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
(cherry picked from commit 8c9f4fc)
  • Loading branch information
mgagne committed Aug 6, 2014
1 parent 474c9b9 commit 43ad685
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
6 changes: 3 additions & 3 deletions manifests/collector.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

if $enabled {
$service_ensure = 'running'
Class['ceilometer::db'] -> Service['ceilometer-collector']
Exec['ceilometer-dbsync'] ~> Service['ceilometer-collector']
} else {
$service_ensure = 'stopped'
}
Expand All @@ -27,8 +29,6 @@
name => $::ceilometer::params::collector_service_name,
enable => $enabled,
hasstatus => true,
hasrestart => true,
require => Class['ceilometer::db'],
subscribe => Exec['ceilometer-dbsync']
hasrestart => true
}
}
44 changes: 31 additions & 13 deletions spec/classes/ceilometer_collector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,40 @@

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

Expand Down

0 comments on commit 43ad685

Please sign in to comment.