puppet-nova/spec/shared_examples.rb
Clayton O'Neill cb77bc295f Add hooks for external install & svc management
This adds defined anchor points for external modules to hook into the
software install, config and service dependency chain.  This allows
external modules to manage software installation (virtualenv,
containers, etc) and service management (pacemaker) without needing rely
on resources that may change or be renamed.

Change-Id: I0b524e354b095f2642fd38a2f88536d15bcdf855
2015-12-08 10:14:11 -05:00

67 lines
2.4 KiB
Ruby

shared_examples_for "a Puppet::Error" do |description|
it "with message matching #{description.inspect}" do
expect { is_expected.to have_class_count(1) }.to raise_error(Puppet::Error, description)
end
end
shared_examples 'generic nova service' do |service|
context 'with default parameters' do
it 'installs package and service' do
is_expected.to contain_package(service[:name]).with({
:name => service[:package_name],
:ensure => 'present',
:tag => ['openstack', 'nova-package'],
})
is_expected.to contain_package(service[:name]).that_requires('Anchor[nova::install::begin]')
is_expected.to contain_package(service[:name]).that_notifies('Anchor[nova::install::end]')
is_expected.to contain_service(service[:name]).with({
:name => service[:service_name],
:ensure => 'running',
:hasstatus => true,
:enable => true,
:tag => 'nova-service',
})
is_expected.to contain_service(service[:name]).that_subscribes_to('Anchor[nova::service::begin]')
is_expected.to contain_service(service[:name]).that_notifies('Anchor[nova::service::end]')
end
end
context 'with overridden parameters' do
let :params do
{ :enabled => false,
:ensure_package => '2012.1-2' }
end
it 'installs package and service' do
is_expected.to contain_package(service[:name]).with({
:name => service[:package_name],
:ensure => '2012.1-2',
:tag => ['openstack', 'nova-package'],
})
is_expected.to contain_package(service[:name]).that_requires('Anchor[nova::install::begin]')
is_expected.to contain_package(service[:name]).that_notifies('Anchor[nova::install::end]')
is_expected.to contain_service(service[:name]).with({
:name => service[:service_name],
:ensure => 'stopped',
:hasstatus => true,
:enable => false,
:tag => 'nova-service',
})
is_expected.to contain_service(service[:name]).that_subscribes_to('Anchor[nova::service::begin]')
is_expected.to contain_service(service[:name]).that_notifies('Anchor[nova::service::end]')
end
end
context 'while not managing service state' do
let :params do
{ :enabled => false,
:manage_service => false }
end
it 'does not control service state' do
is_expected.to contain_service(service[:name]).without_ensure
end
end
end