spec: updates for rspec-puppet 2.x and rspec 3.x

This patch aim to update our specs test in order to work with the new
rspec-puppet release 2.0.0, in the mean time, we update rspec syntax
in order to be prepared for rspec 3.x move.

In details:

  * Use shared_examples "a Puppet::Error" for puppet::error tests
  * Convert 'should' keyword to 'is_expected.to' (prepare rspec 3.x)
  * Fix spec tests for rspec-puppet 2.0.0
  * Upgrade and pin rspec-puppet from 1.0.1 to 2.0.0
  * Clean Gemfile (remove over-specificication of runtime deps of puppetlabs_spec_helper)

Change-Id: Ieaff6bc8bdd8548648ff5e76b212d4df382fa8a3
Card: https://trello.com/c/eHXc1Ryd/4-investigate-the-necessary-change-to-be-rspec-puppet-2-0-0-compliant
This commit is contained in:
Sebastien Badia 2015-02-22 22:02:45 +01:00 committed by Gael Chamoulaud
parent 85c742cd83
commit 55b7aad8cf
21 changed files with 245 additions and 248 deletions

View File

@ -2,12 +2,9 @@ source 'https://rubygems.org'
group :development, :test do
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-puppet', '~> 1.0.1'
gem 'rspec-puppet', '~> 2.0.0'
gem 'puppet-lint-param-docs'
gem 'metadata-json-lint'
gem 'puppet-syntax'
gem 'rake', '10.1.1'
gem 'rspec', '< 2.99'
gem 'json'
gem 'webmock'
end

View File

@ -19,20 +19,20 @@ describe 'ceilometer::agent::auth' do
shared_examples_for 'ceilometer-agent-auth' do
it 'configures authentication' do
should contain_ceilometer_config('service_credentials/os_auth_url').with_value('http://localhost:5000/v2.0')
should contain_ceilometer_config('service_credentials/os_region_name').with_value('RegionOne')
should contain_ceilometer_config('service_credentials/os_username').with_value('ceilometer')
should contain_ceilometer_config('service_credentials/os_password').with_value('password')
should contain_ceilometer_config('service_credentials/os_password').with_value(params[:auth_password]).with_secret(true)
should contain_ceilometer_config('service_credentials/os_tenant_name').with_value('services')
should contain_ceilometer_config('service_credentials/os_cacert').with(:ensure => 'absent')
is_expected.to contain_ceilometer_config('service_credentials/os_auth_url').with_value('http://localhost:5000/v2.0')
is_expected.to contain_ceilometer_config('service_credentials/os_region_name').with_value('RegionOne')
is_expected.to contain_ceilometer_config('service_credentials/os_username').with_value('ceilometer')
is_expected.to contain_ceilometer_config('service_credentials/os_password').with_value('password')
is_expected.to contain_ceilometer_config('service_credentials/os_password').with_value(params[:auth_password]).with_secret(true)
is_expected.to contain_ceilometer_config('service_credentials/os_tenant_name').with_value('services')
is_expected.to contain_ceilometer_config('service_credentials/os_cacert').with(:ensure => 'absent')
end
context 'when overriding parameters' do
before do
params.merge!(:auth_cacert => '/tmp/dummy.pem')
end
it { should contain_ceilometer_config('service_credentials/os_cacert').with_value(params[:auth_cacert]) }
it { is_expected.to contain_ceilometer_config('service_credentials/os_cacert').with_value(params[:auth_cacert]) }
end
end

View File

@ -16,10 +16,10 @@ describe 'ceilometer::agent::central' do
shared_examples_for 'ceilometer-agent-central' do
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer-agent-central package' do
should contain_package('ceilometer-agent-central').with(
is_expected.to contain_package('ceilometer-agent-central').with(
:ensure => 'latest',
:name => platform_params[:agent_package_name],
:before => 'Service[ceilometer-agent-central]'
@ -27,7 +27,7 @@ describe 'ceilometer::agent::central' do
end
it 'ensures ceilometer-common is installed before the service' do
should contain_package('ceilometer-common').with(
is_expected.to contain_package('ceilometer-common').with(
:before => /Service\[ceilometer-agent-central\]/
)
end
@ -39,7 +39,7 @@ describe 'ceilometer::agent::central' do
end
it 'configures ceilometer-agent-central service' do
should contain_service('ceilometer-agent-central').with(
is_expected.to contain_service('ceilometer-agent-central').with(
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
:name => platform_params[:agent_service_name],
:enable => params[:enabled],
@ -51,7 +51,7 @@ describe 'ceilometer::agent::central' do
end
it 'configures central agent' do
should contain_ceilometer_config('coordination/backend_url').with_value( params[:coordination_url] )
is_expected.to contain_ceilometer_config('coordination/backend_url').with_value( params[:coordination_url] )
end
context 'with disabled service managing' do
@ -62,7 +62,7 @@ describe 'ceilometer::agent::central' do
end
it 'configures ceilometer-agent-central service' do
should contain_service('ceilometer-agent-central').with(
is_expected.to contain_service('ceilometer-agent-central').with(
:ensure => nil,
:name => platform_params[:agent_service_name],
:enable => false,

View File

@ -16,10 +16,10 @@ describe 'ceilometer::agent::compute' do
shared_examples_for 'ceilometer-agent-compute' do
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer-agent-compute package' do
should contain_package('ceilometer-agent-compute').with(
is_expected.to contain_package('ceilometer-agent-compute').with(
:ensure => 'installed',
:name => platform_params[:agent_package_name],
:before => 'Service[ceilometer-agent-compute]'
@ -28,31 +28,31 @@ describe 'ceilometer::agent::compute' do
it 'adds ceilometer user to nova group and, if required, to libvirt group' do
if platform_params[:libvirt_group]
should contain_user('ceilometer').with_groups(['nova', "#{platform_params[:libvirt_group]}"])
is_expected.to contain_user('ceilometer').with_groups(['nova', "#{platform_params[:libvirt_group]}"])
else
should contain_user('ceilometer').with_groups('nova')
is_expected.to contain_user('ceilometer').with_groups('nova')
end
end
it 'ensures ceilometer-common is installed before the service' do
should contain_package('ceilometer-common').with(
is_expected.to contain_package('ceilometer-common').with(
:before => /Service\[ceilometer-agent-compute\]/
)
end
it 'ensures nova-common is installed before the package ceilometer-common' do
should contain_package('nova-common').with(
is_expected.to contain_package('nova-common').with(
:before => /Package\[ceilometer-common\]/
)
end
it 'configures nova notification driver' do
should contain_file_line_after('nova-notification-driver-common').with(
is_expected.to contain_file_line_after('nova-notification-driver-common').with(
:line => 'notification_driver=nova.openstack.common.notifier.rpc_notifier',
:path => '/etc/nova/nova.conf',
:notify => 'Service[nova-compute]'
)
should contain_file_line_after('nova-notification-driver-ceilometer').with(
is_expected.to contain_file_line_after('nova-notification-driver-ceilometer').with(
:line => 'notification_driver=ceilometer.compute.nova_notifier',
:path => '/etc/nova/nova.conf',
:notify => 'Service[nova-compute]'
@ -67,7 +67,7 @@ describe 'ceilometer::agent::compute' do
it 'configures ceilometer-agent-compute service' do
should contain_service('ceilometer-agent-compute').with(
is_expected.to contain_service('ceilometer-agent-compute').with(
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
:name => platform_params[:agent_service_name],
:enable => params[:enabled],
@ -86,7 +86,7 @@ describe 'ceilometer::agent::compute' do
end
it 'configures ceilometer-agent-compute service' do
should contain_service('ceilometer-agent-compute').with(
is_expected.to contain_service('ceilometer-agent-compute').with(
:ensure => nil,
:name => platform_params[:agent_service_name],
:enable => false,

View File

@ -35,17 +35,17 @@ describe 'ceilometer::agent::notification' do
shared_examples_for 'ceilometer-agent-notification' do
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer agent notification package' do
should contain_package(platform_params[:agent_notification_package_name]).with(
is_expected.to contain_package(platform_params[:agent_notification_package_name]).with(
:ensure => 'present'
)
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] )
is_expected.to contain_ceilometer_config('notification/ack_on_event_error').with_value( params[:ack_on_event_error] )
is_expected.to contain_ceilometer_config('notification/store_events').with_value( params[:store_events] )
end
[{:enabled => true}, {:enabled => false}].each do |param_hash|
@ -55,7 +55,7 @@ describe 'ceilometer::agent::notification' do
end
it 'configures ceilometer agent notification service' do
should contain_service('ceilometer-agent-notification').with(
is_expected.to contain_service('ceilometer-agent-notification').with(
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
:name => platform_params[:agent_notification_service_name],
:enable => params[:enabled],
@ -74,7 +74,7 @@ describe 'ceilometer::agent::notification' do
end
it 'configures ceilometer-agent-notification service' do
should contain_service('ceilometer-agent-notification').with(
is_expected.to contain_service('ceilometer-agent-notification').with(
:ensure => nil,
:name => platform_params[:agent_notification_service_name],
:enable => false,

View File

@ -17,28 +17,28 @@ describe 'ceilometer::alarm::evaluator' do
end
shared_examples_for 'ceilometer-alarm-evaluator' do
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer-alarm package' do
should contain_package(platform_params[:alarm_evaluator_package_name]).with_before('Service[ceilometer-alarm-evaluator]')
should contain_package(platform_params[:alarm_evaluator_package_name]).with(
is_expected.to contain_package(platform_params[:alarm_evaluator_package_name]).with_before('Service[ceilometer-alarm-evaluator]')
is_expected.to contain_package(platform_params[:alarm_evaluator_package_name]).with(
:ensure => 'present',
:name => platform_params[:alarm_evaluator_package_name]
)
end
it 'ensures ceilometer-common is installed before the service' do
should contain_package('ceilometer-common').with(
is_expected.to contain_package('ceilometer-common').with(
:before => /Service\[ceilometer-alarm-evaluator\]/
)
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] )
should contain_ceilometer_config('alarm/partition_rpc_topic').with_value( params[:partition_rpc_topic] )
should contain_ceilometer_config('alarm/record_history').with_value( params[:record_history] )
should_not contain_ceilometer_config('coordination/backend_url')
is_expected.to contain_ceilometer_config('alarm/evaluation_interval').with_value( params[:evaluation_interval] )
is_expected.to contain_ceilometer_config('alarm/evaluation_service').with_value( params[:evaluation_service] )
is_expected.to contain_ceilometer_config('alarm/partition_rpc_topic').with_value( params[:partition_rpc_topic] )
is_expected.to contain_ceilometer_config('alarm/record_history').with_value( params[:record_history] )
is_expected.to_not contain_ceilometer_config('coordination/backend_url')
end
context 'when overriding parameters' do
@ -49,11 +49,11 @@ describe 'ceilometer::alarm::evaluator' do
:evaluation_service => 'ceilometer.alarm.service.SingletonTestAlarmService',
:coordination_url => 'redis://localhost:6379')
end
it { should contain_ceilometer_config('alarm/evaluation_interval').with_value(params[:evaluation_interval]) }
it { should contain_ceilometer_config('alarm/evaluation_service').with_value(params[:evaluation_service]) }
it { should contain_ceilometer_config('alarm/record_history').with_value(params[:record_history]) }
it { should contain_ceilometer_config('alarm/partition_rpc_topic').with_value(params[:partition_rpc_topic]) }
it { should contain_ceilometer_config('coordination/backend_url').with_value( params[:coordination_url]) }
it { is_expected.to contain_ceilometer_config('alarm/evaluation_interval').with_value(params[:evaluation_interval]) }
it { is_expected.to contain_ceilometer_config('alarm/evaluation_service').with_value(params[:evaluation_service]) }
it { is_expected.to contain_ceilometer_config('alarm/record_history').with_value(params[:record_history]) }
it { is_expected.to contain_ceilometer_config('alarm/partition_rpc_topic').with_value(params[:partition_rpc_topic]) }
it { is_expected.to contain_ceilometer_config('coordination/backend_url').with_value( params[:coordination_url]) }
end
context 'when override the evaluation interval with a non numeric value' do
@ -61,7 +61,7 @@ describe 'ceilometer::alarm::evaluator' do
params.merge!(:evaluation_interval => 'NaN')
end
it { expect { should contain_ceilometer_config('alarm/evaluation_interval') }.to\
it { expect { is_expected.to contain_ceilometer_config('alarm/evaluation_interval') }.to\
raise_error(Puppet::Error, /validate_re\(\): .* does not match/) }
end
@ -72,7 +72,7 @@ describe 'ceilometer::alarm::evaluator' do
end
it 'configures ceilometer-alarm-evaluator service' do
should contain_service('ceilometer-alarm-evaluator').with(
is_expected.to contain_service('ceilometer-alarm-evaluator').with(
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
:name => platform_params[:alarm_evaluator_service_name],
:enable => params[:enabled],
@ -91,7 +91,7 @@ describe 'ceilometer::alarm::evaluator' do
end
it 'configures ceilometer-alarm-evaluator service' do
should contain_service('ceilometer-alarm-evaluator').with(
is_expected.to contain_service('ceilometer-alarm-evaluator').with(
:ensure => nil,
:name => platform_params[:alarm_evaluator_service_name],
:enable => false,

View File

@ -18,27 +18,27 @@ describe 'ceilometer::alarm::notifier' do
end
shared_examples_for 'ceilometer-alarm-notifier' do
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer-alarm package' do
should contain_package(platform_params[:alarm_notifier_package_name]).with_before('Service[ceilometer-alarm-notifier]')
should contain_package(platform_params[:alarm_notifier_package_name]).with(
is_expected.to contain_package(platform_params[:alarm_notifier_package_name]).with_before('Service[ceilometer-alarm-notifier]')
is_expected.to contain_package(platform_params[:alarm_notifier_package_name]).with(
:ensure => 'present',
:name => platform_params[:alarm_notifier_package_name]
)
end
it 'ensures ceilometer-common is installed before the service' do
should contain_package('ceilometer-common').with(
is_expected.to contain_package('ceilometer-common').with(
:before => /Service\[ceilometer-alarm-notifier\]/
)
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')
should_not contain_ceilometer_config('alarm/rest_notifier_certificate_file')
should_not contain_ceilometer_config('alarm/rest_notifier_ssl_verify')
is_expected.to_not contain_ceilometer_config('alarm/notifier_rpc_topic')
is_expected.to_not contain_ceilometer_config('alarm/rest_notifier_certificate_key')
is_expected.to_not contain_ceilometer_config('alarm/rest_notifier_certificate_file')
is_expected.to_not contain_ceilometer_config('alarm/rest_notifier_ssl_verify')
end
context 'when overriding parameters' do
@ -48,10 +48,10 @@ describe 'ceilometer::alarm::notifier' do
:rest_notifier_certificate_file => '/var/file',
:rest_notifier_ssl_verify => true)
end
it { should contain_ceilometer_config('alarm/notifier_rpc_topic').with_value(params[:notifier_rpc_topic]) }
it { should contain_ceilometer_config('alarm/rest_notifier_certificate_key').with_value(params[:rest_notifier_certificate_key]) }
it { should contain_ceilometer_config('alarm/rest_notifier_certificate_file').with_value(params[:rest_notifier_certificate_file]) }
it { should contain_ceilometer_config('alarm/rest_notifier_ssl_verify').with_value(params[:rest_notifier_ssl_verify]) }
it { is_expected.to contain_ceilometer_config('alarm/notifier_rpc_topic').with_value(params[:notifier_rpc_topic]) }
it { is_expected.to contain_ceilometer_config('alarm/rest_notifier_certificate_key').with_value(params[:rest_notifier_certificate_key]) }
it { is_expected.to contain_ceilometer_config('alarm/rest_notifier_certificate_file').with_value(params[:rest_notifier_certificate_file]) }
it { is_expected.to contain_ceilometer_config('alarm/rest_notifier_ssl_verify').with_value(params[:rest_notifier_ssl_verify]) }
end
[{:enabled => true}, {:enabled => false}].each do |param_hash|
@ -61,7 +61,7 @@ describe 'ceilometer::alarm::notifier' do
end
it 'configures ceilometer-alarm-notifier service' do
should contain_service('ceilometer-alarm-notifier').with(
is_expected.to contain_service('ceilometer-alarm-notifier').with(
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
:name => platform_params[:alarm_notifier_service_name],
:enable => params[:enabled],
@ -80,7 +80,7 @@ describe 'ceilometer::alarm::notifier' do
end
it 'configures ceilometer-alarm-notifier service' do
should contain_service('ceilometer-alarm-notifier').with(
is_expected.to contain_service('ceilometer-alarm-notifier').with(
:ensure => nil,
:name => platform_params[:alarm_notifier_service_name],
:enable => false,

View File

@ -25,37 +25,37 @@ describe 'ceilometer::api' do
context 'without required parameter keystone_password' do
before { params.delete(:keystone_password) }
it { expect { should raise_error(Puppet::Error) } }
it { expect { is_expected.to raise_error(Puppet::Error) } }
end
it { should contain_class('ceilometer::params') }
it { should contain_class('ceilometer::policy') }
it { is_expected.to contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::policy') }
it 'installs ceilometer-api package' do
should contain_package('ceilometer-api').with(
is_expected.to contain_package('ceilometer-api').with(
:ensure => 'latest',
:name => platform_params[:api_package_name]
)
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] )
should contain_ceilometer_config('keystone_authtoken/auth_protocol').with_value( params[:keystone_protocol] )
should contain_ceilometer_config('keystone_authtoken/admin_tenant_name').with_value( params[:keystone_tenant] )
should contain_ceilometer_config('keystone_authtoken/admin_user').with_value( params[:keystone_user] )
should contain_ceilometer_config('keystone_authtoken/admin_password').with_value( params[:keystone_password] )
should contain_ceilometer_config('keystone_authtoken/admin_password').with_value( params[:keystone_password] ).with_secret(true)
should contain_ceilometer_config('keystone_authtoken/auth_admin_prefix').with_ensure('absent')
should contain_ceilometer_config('keystone_authtoken/auth_uri').with_value( params[:keystone_protocol] + "://" + params[:keystone_host] + ":5000/" )
should contain_ceilometer_config('api/host').with_value( params[:host] )
should contain_ceilometer_config('api/port').with_value( params[:port] )
is_expected.to contain_ceilometer_config('keystone_authtoken/auth_host').with_value( params[:keystone_host] )
is_expected.to contain_ceilometer_config('keystone_authtoken/auth_port').with_value( params[:keystone_port] )
is_expected.to contain_ceilometer_config('keystone_authtoken/auth_protocol').with_value( params[:keystone_protocol] )
is_expected.to contain_ceilometer_config('keystone_authtoken/admin_tenant_name').with_value( params[:keystone_tenant] )
is_expected.to contain_ceilometer_config('keystone_authtoken/admin_user').with_value( params[:keystone_user] )
is_expected.to contain_ceilometer_config('keystone_authtoken/admin_password').with_value( params[:keystone_password] )
is_expected.to contain_ceilometer_config('keystone_authtoken/admin_password').with_value( params[:keystone_password] ).with_secret(true)
is_expected.to contain_ceilometer_config('keystone_authtoken/auth_admin_prefix').with_ensure('absent')
is_expected.to contain_ceilometer_config('keystone_authtoken/auth_uri').with_value( params[:keystone_protocol] + "://" + params[:keystone_host] + ":5000/" )
is_expected.to contain_ceilometer_config('api/host').with_value( params[:host] )
is_expected.to contain_ceilometer_config('api/port').with_value( params[:port] )
end
context 'when specifying keystone_auth_admin_prefix' do
describe 'with a correct value' do
before { params['keystone_auth_admin_prefix'] = '/keystone/admin' }
it { should contain_ceilometer_config('keystone_authtoken/auth_admin_prefix').with_value('/keystone/admin') }
it { is_expected.to contain_ceilometer_config('keystone_authtoken/auth_admin_prefix').with_value('/keystone/admin') }
end
[
@ -69,7 +69,7 @@ describe 'ceilometer::api' do
describe "with an incorrect value #{auth_admin_prefix}" do
before { params['keystone_auth_admin_prefix'] = auth_admin_prefix }
it { expect { should contain_ceilomete_config('keystone_authtoken/auth_admin_prefix') }.to \
it { expect { is_expected.to contain_ceilomete_config('keystone_authtoken/auth_admin_prefix') }.to \
raise_error(Puppet::Error, /validate_re\(\): "#{auth_admin_prefix}" does not match/) }
end
end
@ -82,7 +82,7 @@ describe 'ceilometer::api' do
end
it 'configures ceilometer-api service' do
should contain_service('ceilometer-api').with(
is_expected.to contain_service('ceilometer-api').with(
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
:name => platform_params[:api_service_name],
:enable => params[:enabled],
@ -103,7 +103,7 @@ describe 'ceilometer::api' do
end
it 'configures ceilometer-api service' do
should contain_service('ceilometer-api').with(
is_expected.to contain_service('ceilometer-api').with(
:ensure => nil,
:name => platform_params[:api_service_name],
:enable => false,
@ -150,7 +150,7 @@ describe 'ceilometer::api' do
})
end
it 'should configure custom auth_uri correctly' do
should contain_ceilometer_config('keystone_authtoken/auth_uri').with_value( 'https://foo.bar:1234/' )
is_expected.to contain_ceilometer_config('keystone_authtoken/auth_uri').with_value( 'https://foo.bar:1234/' )
end
end

View File

@ -4,10 +4,10 @@ describe 'ceilometer::client' do
shared_examples_for 'ceilometer client' do
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer client package' do
should contain_package('python-ceilometerclient').with(
is_expected.to contain_package('python-ceilometerclient').with(
:ensure => 'present',
:name => platform_params[:client_package_name]
)

View File

@ -13,16 +13,16 @@ describe 'ceilometer::collector' do
pre_condition << "class { 'ceilometer::db': }"
end
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer-collector package' do
should contain_package(platform_params[:collector_package_name]).with(
is_expected.to contain_package(platform_params[:collector_package_name]).with(
:ensure => 'present'
)
end
it 'configures ceilometer-collector service' do
should contain_service('ceilometer-collector').with(
is_expected.to contain_service('ceilometer-collector').with(
:ensure => 'running',
:name => platform_params[:collector_service_name],
:enable => true,
@ -32,8 +32,8 @@ describe 'ceilometer::collector' do
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]')
is_expected.to contain_class('ceilometer::db').with_before('Service[ceilometer-collector]')
is_expected.to contain_exec('ceilometer-dbsync').with_notify('Service[ceilometer-collector]')
end
end
@ -43,10 +43,10 @@ describe 'ceilometer::collector' do
end
# Catalog compilation does not crash for lack of ceilometer::db
it { should compile }
it { is_expected.to compile }
it 'configures ceilometer-collector service' do
should contain_service('ceilometer-collector').with(
is_expected.to contain_service('ceilometer-collector').with(
:ensure => 'stopped',
:name => platform_params[:collector_service_name],
:enable => false,
@ -63,7 +63,7 @@ describe 'ceilometer::collector' do
end
it 'configures ceilometer-collector service' do
should contain_service('ceilometer-collector').with(
is_expected.to contain_service('ceilometer-collector').with(
:ensure => nil,
:name => platform_params[:collector_service_name],
:enable => false,

View File

@ -11,8 +11,8 @@ describe 'ceilometer::config' do
end
it 'with [api] options ceilometer_config ' do
should contain_ceilometer_config('api/host').with_value('0.0.0.0')
should contain_ceilometer_config('api/port').with_value('8777')
is_expected.to contain_ceilometer_config('api/host').with_value('0.0.0.0')
is_expected.to contain_ceilometer_config('api/port').with_value('8777')
end
describe 'with [rpc_notifier2] options ceilometer_config' do
@ -22,7 +22,7 @@ describe 'ceilometer::config' do
})
end
it 'should configure rpc_notifier2 topics correctly' do
should contain_ceilometer_config('rpc_notifier2/topics').with_value('notifications')
is_expected.to contain_ceilometer_config('rpc_notifier2/topics').with_value('notifications')
end
end

View File

@ -20,11 +20,11 @@ describe 'ceilometer::db::mysql' do
context 'when omiting the required parameter password' do
before { params.delete(:password) }
it { expect { should raise_error(Puppet::Error) } }
it { expect { is_expected.to raise_error(Puppet::Error) } }
end
it 'creates a mysql database' do
should contain_openstacklib__db__mysql( params[:dbname] ).with(
is_expected.to contain_openstacklib__db__mysql( params[:dbname] ).with(
:user => params[:user],
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',
:host => params[:host],

View File

@ -24,7 +24,7 @@ describe 'ceilometer::db::postgresql' do
req_params
end
it { should contain_postgresql__server__db('ceilometer').with(
it { is_expected.to contain_postgresql__server__db('ceilometer').with(
:user => 'ceilometer',
:password => 'md52899c518e96bce6633ab342b0ca38292'
)}
@ -47,7 +47,7 @@ describe 'ceilometer::db::postgresql' do
req_params
end
it { should contain_postgresql__server__db('ceilometer').with(
it { is_expected.to contain_postgresql__server__db('ceilometer').with(
:user => 'ceilometer',
:password => 'md52899c518e96bce6633ab342b0ca38292'
)}

View File

@ -13,18 +13,18 @@ describe 'ceilometer::db' do
:sync_db => true }
end
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs python-mongodb package' do
should contain_package('ceilometer-backend-package').with(
is_expected.to contain_package('ceilometer-backend-package').with(
:ensure => 'present',
:name => 'python-pymongo')
should contain_ceilometer_config('database/connection').with_value('mongodb://localhost:1234/ceilometer')
should contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
is_expected.to contain_ceilometer_config('database/connection').with_value('mongodb://localhost:1234/ceilometer')
is_expected.to contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
end
it 'runs ceilometer-dbsync' do
should contain_exec('ceilometer-dbsync').with(
is_expected.to contain_exec('ceilometer-dbsync').with(
:command => 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf',
:path => '/usr/bin',
:refreshonly => 'true',
@ -47,18 +47,18 @@ describe 'ceilometer::db' do
:sync_db => false }
end
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs pymongo package' do
should contain_package('ceilometer-backend-package').with(
is_expected.to contain_package('ceilometer-backend-package').with(
:ensure => 'present',
:name => 'python-pymongo')
should contain_ceilometer_config('database/connection').with_value('mongodb://localhost:1234/ceilometer')
should contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
is_expected.to contain_ceilometer_config('database/connection').with_value('mongodb://localhost:1234/ceilometer')
is_expected.to contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
end
it 'runs ceilometer-dbsync' do
should contain_exec('ceilometer-dbsync').with(
is_expected.to contain_exec('ceilometer-dbsync').with(
:command => '/bin/true',
:path => '/usr/bin',
:refreshonly => 'true',
@ -82,16 +82,16 @@ describe 'ceilometer::db' do
:sync_db => true }
end
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs pymongo package' do
should contain_package('ceilometer-backend-package').with(
is_expected.to contain_package('ceilometer-backend-package').with(
:ensure => 'present',
:name => 'python-pymongo')
end
it 'runs ceilometer-dbsync' do
should contain_exec('ceilometer-dbsync').with(
is_expected.to contain_exec('ceilometer-dbsync').with(
:command => 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf',
:path => '/usr/bin',
:refreshonly => 'true',
@ -115,15 +115,15 @@ describe 'ceilometer::db' do
:sync_db => false }
end
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs pymongo package' do
should contain_ceilometer_config('database/connection').with_value('sqlite:///var/lib/ceilometer.db')
should contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
is_expected.to contain_ceilometer_config('database/connection').with_value('sqlite:///var/lib/ceilometer.db')
is_expected.to contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
end
it 'runs ceilometer-dbsync' do
should contain_exec('ceilometer-dbsync').with(
is_expected.to contain_exec('ceilometer-dbsync').with(
:command => '/bin/true',
:path => '/usr/bin',
:refreshonly => 'true',
@ -144,16 +144,16 @@ describe 'ceilometer::db' do
:sync_db => true }
end
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs python-mongodb package' do
should contain_package('ceilometer-backend-package').with(
is_expected.to contain_package('ceilometer-backend-package').with(
:ensure => 'present',
:name => 'python-pysqlite2')
end
it 'runs ceilometer-dbsync' do
should contain_exec('ceilometer-dbsync').with(
is_expected.to contain_exec('ceilometer-dbsync').with(
:command => 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf',
:path => '/usr/bin',
:refreshonly => 'true',

View File

@ -32,17 +32,17 @@ describe 'ceilometer::expirer' do
shared_examples_for 'ceilometer-expirer' do
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer common package' do
should contain_package('ceilometer-common').with(
is_expected.to contain_package('ceilometer-common').with(
:ensure => 'present',
:name => platform_params[:common_package_name]
)
end
it 'configures a cron' do
should contain_cron('ceilometer-expirer').with(
is_expected.to contain_cron('ceilometer-expirer').with(
:command => 'ceilometer-expirer',
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => 'ceilometer',
@ -55,7 +55,7 @@ describe 'ceilometer::expirer' do
end
it 'configures database section in ceilometer.conf' do
should contain_ceilometer_config('database/time_to_live').with_value( params[:time_to_live] )
is_expected.to contain_ceilometer_config('database/time_to_live').with_value( params[:time_to_live] )
end
end

View File

@ -67,17 +67,17 @@ describe 'ceilometer' do
shared_examples_for 'a ceilometer base installation' do
it { should contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::params') }
it 'configures ceilometer group' do
should contain_group('ceilometer').with(
is_expected.to contain_group('ceilometer').with(
:name => 'ceilometer',
:require => 'Package[ceilometer-common]'
)
end
it 'configures ceilometer user' do
should contain_user('ceilometer').with(
is_expected.to contain_user('ceilometer').with(
:name => 'ceilometer',
:gid => 'ceilometer',
:system => true,
@ -86,7 +86,7 @@ describe 'ceilometer' do
end
it 'configures ceilometer configuration folder' do
should contain_file('/etc/ceilometer/').with(
is_expected.to contain_file('/etc/ceilometer/').with(
:ensure => 'directory',
:owner => 'ceilometer',
:group => 'ceilometer',
@ -96,7 +96,7 @@ describe 'ceilometer' do
end
it 'configures ceilometer configuration file' do
should contain_file('/etc/ceilometer/ceilometer.conf').with(
is_expected.to contain_file('/etc/ceilometer/ceilometer.conf').with(
:owner => 'ceilometer',
:group => 'ceilometer',
:mode => '0640',
@ -105,50 +105,50 @@ describe 'ceilometer' do
end
it 'installs ceilometer common package' do
should contain_package('ceilometer-common').with(
is_expected.to contain_package('ceilometer-common').with(
:ensure => 'present',
:name => platform_params[:common_package_name]
)
end
it 'configures required metering_secret' do
should contain_ceilometer_config('publisher/metering_secret').with_value('metering-s3cr3t')
should contain_ceilometer_config('publisher/metering_secret').with_value( params[:metering_secret] ).with_secret(true)
is_expected.to contain_ceilometer_config('publisher/metering_secret').with_value('metering-s3cr3t')
is_expected.to contain_ceilometer_config('publisher/metering_secret').with_value( params[:metering_secret] ).with_secret(true)
end
context 'without the required metering_secret' do
before { params.delete(:metering_secret) }
it { expect { should raise_error(Puppet::Error) } }
it { expect { is_expected.to raise_error(Puppet::Error) } }
end
it 'configures debug and verbosity' do
should contain_ceilometer_config('DEFAULT/debug').with_value( params[:debug] )
should contain_ceilometer_config('DEFAULT/verbose').with_value( params[:verbose] )
is_expected.to contain_ceilometer_config('DEFAULT/debug').with_value( params[:debug] )
is_expected.to contain_ceilometer_config('DEFAULT/verbose').with_value( params[:verbose] )
end
it 'configures logging directory by default' do
should contain_ceilometer_config('DEFAULT/log_dir').with_value( params[:log_dir] )
is_expected.to contain_ceilometer_config('DEFAULT/log_dir').with_value( params[:log_dir] )
end
context 'with logging directory disabled' do
before { params.merge!( :log_dir => false) }
it { should contain_ceilometer_config('DEFAULT/log_dir').with_ensure('absent') }
it { is_expected.to contain_ceilometer_config('DEFAULT/log_dir').with_ensure('absent') }
end
it 'configures notification_topics' do
should contain_ceilometer_config('DEFAULT/notification_topics').with_value('notifications')
is_expected.to contain_ceilometer_config('DEFAULT/notification_topics').with_value('notifications')
end
it 'configures syslog to be disabled by default' do
should contain_ceilometer_config('DEFAULT/use_syslog').with_value('false')
is_expected.to contain_ceilometer_config('DEFAULT/use_syslog').with_value('false')
end
context 'with syslog enabled' do
before { params.merge!( :use_syslog => 'true' ) }
it { should contain_ceilometer_config('DEFAULT/use_syslog').with_value('true') }
it { should contain_ceilometer_config('DEFAULT/syslog_log_facility').with_value('LOG_USER') }
it { is_expected.to contain_ceilometer_config('DEFAULT/use_syslog').with_value('true') }
it { is_expected.to contain_ceilometer_config('DEFAULT/syslog_log_facility').with_value('LOG_USER') }
end
context 'with syslog enabled and custom settings' do
@ -157,15 +157,15 @@ describe 'ceilometer' do
:log_facility => 'LOG_LOCAL0'
) }
it { should contain_ceilometer_config('DEFAULT/use_syslog').with_value('true') }
it { should contain_ceilometer_config('DEFAULT/syslog_log_facility').with_value('LOG_LOCAL0') }
it { is_expected.to contain_ceilometer_config('DEFAULT/use_syslog').with_value('true') }
it { is_expected.to contain_ceilometer_config('DEFAULT/syslog_log_facility').with_value('LOG_LOCAL0') }
end
context 'with overriden notification_topics parameter' do
before { params.merge!( :notification_topics => ['notifications', 'custom']) }
it 'configures notification_topics' do
should contain_ceilometer_config('DEFAULT/notification_topics').with_value('notifications,custom')
is_expected.to contain_ceilometer_config('DEFAULT/notification_topics').with_value('notifications,custom')
end
end
end
@ -173,58 +173,58 @@ describe 'ceilometer' do
shared_examples_for 'rabbit without HA support (with backward compatibility)' do
it 'configures rabbit' do
should contain_ceilometer_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
should contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
should contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] ).with_secret(true)
should contain_ceilometer_config('DEFAULT/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] )
is_expected.to contain_ceilometer_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
is_expected.to contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
is_expected.to contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] ).with_secret(true)
is_expected.to contain_ceilometer_config('DEFAULT/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] )
end
it { should contain_ceilometer_config('DEFAULT/rabbit_host').with_value( params[:rabbit_host] ) }
it { should contain_ceilometer_config('DEFAULT/rabbit_port').with_value( params[:rabbit_port] ) }
it { should contain_ceilometer_config('DEFAULT/rabbit_hosts').with_value( "#{params[:rabbit_host]}:#{params[:rabbit_port]}" ) }
it { should contain_ceilometer_config('DEFAULT/rabbit_ha_queues').with_value('false') }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_host').with_value( params[:rabbit_host] ) }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_port').with_value( params[:rabbit_port] ) }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_hosts').with_value( "#{params[:rabbit_host]}:#{params[:rabbit_port]}" ) }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_ha_queues').with_value('false') }
end
shared_examples_for 'rabbit without HA support (without backward compatibility)' do
it 'configures rabbit' do
should contain_ceilometer_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
should contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
should contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] ).with_secret(true)
should contain_ceilometer_config('DEFAULT/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] )
is_expected.to contain_ceilometer_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
is_expected.to contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
is_expected.to contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] ).with_secret(true)
is_expected.to contain_ceilometer_config('DEFAULT/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] )
end
it { should contain_ceilometer_config('DEFAULT/rabbit_host').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/rabbit_port').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) }
it { should contain_ceilometer_config('DEFAULT/rabbit_ha_queues').with_value('false') }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_host').with_ensure('absent') }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_port').with_ensure('absent') }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_ha_queues').with_value('false') }
end
shared_examples_for 'rabbit with HA support' do
it 'configures rabbit' do
should contain_ceilometer_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
should contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
should contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] ).with_secret(true)
should contain_ceilometer_config('DEFAULT/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] )
is_expected.to contain_ceilometer_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
is_expected.to contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
is_expected.to contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] ).with_secret(true)
is_expected.to contain_ceilometer_config('DEFAULT/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] )
end
it { should contain_ceilometer_config('DEFAULT/rabbit_host').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/rabbit_port').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) }
it { should contain_ceilometer_config('DEFAULT/rabbit_ha_queues').with_value('true') }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_host').with_ensure('absent') }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_port').with_ensure('absent') }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_ha_queues').with_value('true') }
end
shared_examples_for 'rabbit with SSL support' do
context "with default parameters" do
it { should contain_ceilometer_config('DEFAULT/rabbit_use_ssl').with_value('false') }
it { should contain_ceilometer_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/kombu_ssl_version').with_ensure('absent') }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_use_ssl').with_value('false') }
it { is_expected.to contain_ceilometer_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') }
it { is_expected.to contain_ceilometer_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') }
it { is_expected.to contain_ceilometer_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') }
it { is_expected.to contain_ceilometer_config('DEFAULT/kombu_ssl_version').with_ensure('absent') }
end
context "with SSL enabled with kombu" do
@ -236,11 +236,11 @@ describe 'ceilometer' do
:kombu_ssl_version => 'TLSv1'
) }
it { should contain_ceilometer_config('DEFAULT/rabbit_use_ssl').with_value('true') }
it { should contain_ceilometer_config('DEFAULT/kombu_ssl_ca_certs').with_value('/path/to/ca.crt') }
it { should contain_ceilometer_config('DEFAULT/kombu_ssl_certfile').with_value('/path/to/cert.crt') }
it { should contain_ceilometer_config('DEFAULT/kombu_ssl_keyfile').with_value('/path/to/cert.key') }
it { should contain_ceilometer_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_use_ssl').with_value('true') }
it { is_expected.to contain_ceilometer_config('DEFAULT/kombu_ssl_ca_certs').with_value('/path/to/ca.crt') }
it { is_expected.to contain_ceilometer_config('DEFAULT/kombu_ssl_certfile').with_value('/path/to/cert.crt') }
it { is_expected.to contain_ceilometer_config('DEFAULT/kombu_ssl_keyfile').with_value('/path/to/cert.key') }
it { is_expected.to contain_ceilometer_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') }
end
context "with SSL enabled without kombu" do
@ -248,11 +248,11 @@ describe 'ceilometer' do
:rabbit_use_ssl => 'true'
) }
it { should contain_ceilometer_config('DEFAULT/rabbit_use_ssl').with_value('true') }
it { should contain_ceilometer_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') }
it { should contain_ceilometer_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') }
it { is_expected.to contain_ceilometer_config('DEFAULT/rabbit_use_ssl').with_value('true') }
it { is_expected.to contain_ceilometer_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') }
it { is_expected.to contain_ceilometer_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') }
it { is_expected.to contain_ceilometer_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') }
it { is_expected.to contain_ceilometer_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') }
end
context "with SSL wrongly configured" do
@ -275,29 +275,29 @@ describe 'ceilometer' do
shared_examples_for 'qpid support' do
context("with default parameters") do
it { should contain_ceilometer_config('DEFAULT/qpid_reconnect').with_value(true) }
it { should contain_ceilometer_config('DEFAULT/qpid_reconnect_timeout').with_value('0') }
it { should contain_ceilometer_config('DEFAULT/qpid_reconnect_limit').with_value('0') }
it { should contain_ceilometer_config('DEFAULT/qpid_reconnect_interval_min').with_value('0') }
it { should contain_ceilometer_config('DEFAULT/qpid_reconnect_interval_max').with_value('0') }
it { should contain_ceilometer_config('DEFAULT/qpid_reconnect_interval').with_value('0') }
it { should contain_ceilometer_config('DEFAULT/qpid_heartbeat').with_value('60') }
it { should contain_ceilometer_config('DEFAULT/qpid_protocol').with_value('tcp') }
it { should contain_ceilometer_config('DEFAULT/qpid_tcp_nodelay').with_value(true) }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_reconnect').with_value(true) }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_reconnect_timeout').with_value('0') }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_reconnect_limit').with_value('0') }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_reconnect_interval_min').with_value('0') }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_reconnect_interval_max').with_value('0') }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_reconnect_interval').with_value('0') }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_heartbeat').with_value('60') }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_protocol').with_value('tcp') }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_tcp_nodelay').with_value(true) }
end
context("with mandatory parameters set") do
it { should contain_ceilometer_config('DEFAULT/rpc_backend').with_value('ceilometer.openstack.common.rpc.impl_qpid') }
it { should contain_ceilometer_config('DEFAULT/qpid_hostname').with_value( params[:qpid_hostname] ) }
it { should contain_ceilometer_config('DEFAULT/qpid_port').with_value( params[:qpid_port] ) }
it { should contain_ceilometer_config('DEFAULT/qpid_username').with_value( params[:qpid_username]) }
it { should contain_ceilometer_config('DEFAULT/qpid_password').with_value(params[:qpid_password]) }
it { should contain_ceilometer_config('DEFAULT/qpid_password').with_value( params[:qpid_password] ).with_secret(true) }
it { is_expected.to contain_ceilometer_config('DEFAULT/rpc_backend').with_value('ceilometer.openstack.common.rpc.impl_qpid') }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_hostname').with_value( params[:qpid_hostname] ) }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_port').with_value( params[:qpid_port] ) }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_username').with_value( params[:qpid_username]) }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_password').with_value(params[:qpid_password]) }
it { is_expected.to contain_ceilometer_config('DEFAULT/qpid_password').with_value( params[:qpid_password] ).with_secret(true) }
end
context("failing if the rpc_backend is not present") do
before { params.delete( :rpc_backend) }
it { expect { should raise_error(Puppet::Error) } }
it { expect { is_expected.to raise_error(Puppet::Error) } }
end
end

View File

@ -23,7 +23,7 @@ describe 'ceilometer::keystone::auth' do
shared_examples_for 'ceilometer keystone auth' do
context 'without the required password parameter' do
it { expect { should raise_error(Puppet::Error) } }
it { expect { is_expected.to raise_error(Puppet::Error) } }
end
let :params do
@ -32,7 +32,7 @@ describe 'ceilometer::keystone::auth' do
context 'with the required parameters' do
it 'configures ceilometer user' do
should contain_keystone_user( default_params[:auth_name] ).with(
is_expected.to contain_keystone_user( default_params[:auth_name] ).with(
:ensure => 'present',
:password => params[:password],
:email => default_params[:email],
@ -41,14 +41,14 @@ describe 'ceilometer::keystone::auth' do
end
it 'configures ceilometer user roles' do
should contain_keystone_user_role("#{default_params[:auth_name]}@#{default_params[:tenant]}").with(
is_expected.to contain_keystone_user_role("#{default_params[:auth_name]}@#{default_params[:tenant]}").with(
:ensure => 'present',
:roles => ['admin','ResellerAdmin']
)
end
it 'configures ceilometer service' do
should contain_keystone_service( default_params[:auth_name] ).with(
is_expected.to contain_keystone_service( default_params[:auth_name] ).with(
:ensure => 'present',
:type => default_params[:service_type],
:description => 'Openstack Metering Service'
@ -56,7 +56,7 @@ describe 'ceilometer::keystone::auth' do
end
it 'configure ceilometer endpoints' do
should contain_keystone_endpoint("#{default_params[:region]}/#{default_params[:auth_name]}").with(
is_expected.to contain_keystone_endpoint("#{default_params[:region]}/#{default_params[:auth_name]}").with(
:ensure => 'present',
:public_url => "#{default_params[:public_protocol]}://#{default_params[:public_address]}:#{default_params[:port]}",
:admin_url => "#{default_params[:admin_protocol]}://#{default_params[:admin_address]}:#{default_params[:port]}",
@ -84,7 +84,7 @@ describe 'ceilometer::keystone::auth' do
end
it 'configures ceilometer user' do
should contain_keystone_user( params[:auth_name] ).with(
is_expected.to contain_keystone_user( params[:auth_name] ).with(
:ensure => 'present',
:password => params[:password],
:email => params[:email],
@ -93,14 +93,14 @@ describe 'ceilometer::keystone::auth' do
end
it 'configures ceilometer user roles' do
should contain_keystone_user_role("#{params[:auth_name]}@#{params[:tenant]}").with(
is_expected.to contain_keystone_user_role("#{params[:auth_name]}@#{params[:tenant]}").with(
:ensure => 'present',
:roles => ['admin','ResellerAdmin']
)
end
it 'configures ceilometer service' do
should contain_keystone_service( params[:auth_name] ).with(
is_expected.to contain_keystone_service( params[:auth_name] ).with(
:ensure => 'present',
:type => params[:service_type],
:description => 'Openstack Metering Service'
@ -108,7 +108,7 @@ describe 'ceilometer::keystone::auth' do
end
it 'configure ceilometer endpoints' do
should contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}").with(
is_expected.to contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}").with(
:ensure => 'present',
:public_url => "#{params[:public_protocol]}://#{params[:public_address]}:#{params[:port]}",
:admin_url => "#{params[:admin_protocol]}://#{params[:admin_address]}:#{params[:port]}",
@ -125,7 +125,7 @@ describe 'ceilometer::keystone::auth' do
})
end
it 'configure ceilometer endpoints' do
should contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}").with(
is_expected.to contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}").with(
:ensure => 'present',
:public_url => params[:public_url],
:admin_url => params[:admin_url],
@ -138,7 +138,7 @@ describe 'ceilometer::keystone::auth' do
before do
params.delete!(:configure_endpoint)
it 'does not configure ceilometer endpoints' do
should_not contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}")
is_expected.to_not contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}")
end
end
end
@ -151,16 +151,16 @@ describe 'ceilometer::keystone::auth' do
})
end
it 'configures correct user name' do
should contain_keystone_user('ceilometer')
is_expected.to contain_keystone_user('ceilometer')
end
it 'configures correct user role' do
should contain_keystone_user_role('ceilometer@services')
is_expected.to contain_keystone_user_role('ceilometer@services')
end
it 'configures correct service name' do
should contain_keystone_service('ceilometer_service')
is_expected.to contain_keystone_service('ceilometer_service')
end
it 'configures correct endpoint name' do
should contain_keystone_endpoint('RegionOne/ceilometer_service')
is_expected.to contain_keystone_endpoint('RegionOne/ceilometer_service')
end
end
@ -169,10 +169,10 @@ describe 'ceilometer::keystone::auth' do
params.merge!( :configure_user => false )
end
it { should_not contain_keystone_user('ceilometer') }
it { should contain_keystone_user_role('ceilometer@services') }
it { is_expected.to_not contain_keystone_user('ceilometer') }
it { is_expected.to contain_keystone_user_role('ceilometer@services') }
it { should contain_keystone_service('ceilometer').with(
it { is_expected.to contain_keystone_service('ceilometer').with(
:ensure => 'present',
:type => 'metering',
:description => 'Openstack Metering Service'
@ -187,10 +187,10 @@ describe 'ceilometer::keystone::auth' do
)
end
it { should_not contain_keystone_user('ceilometer') }
it { should_not contain_keystone_user_role('ceilometer@services') }
it { is_expected.to_not contain_keystone_user('ceilometer') }
it { is_expected.to_not contain_keystone_user_role('ceilometer@services') }
it { should contain_keystone_service('ceilometer').with(
it { is_expected.to contain_keystone_service('ceilometer').with(
:ensure => 'present',
:type => 'metering',
:description => 'Openstack Metering Service'

View File

@ -42,36 +42,36 @@ describe 'ceilometer::logging' do
shared_examples_for 'logging params set' do
it 'enables logging params' do
should contain_ceilometer_config('DEFAULT/logging_context_format_string').with_value(
is_expected.to contain_ceilometer_config('DEFAULT/logging_context_format_string').with_value(
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s')
should contain_ceilometer_config('DEFAULT/logging_default_format_string').with_value(
is_expected.to contain_ceilometer_config('DEFAULT/logging_default_format_string').with_value(
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s')