Cleanup rspec tests of nova::api

Change-Id: I0b93f4e22671ca71408e0a1aa2b7d959bb57437d
This commit is contained in:
Mathieu Gagné
2014-01-30 16:30:43 -05:00
parent f93e33c0ea
commit f61a058c5e

View File

@@ -10,42 +10,29 @@ describe 'nova::api' do
{ :admin_password => 'passw0rd' }
end
describe 'on debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
{ :processorcount => 5 }
end
it { should contain_service('nova-api').with(
'name' => 'nova-api',
'ensure' => 'stopped',
'hasstatus' => true,
'enable' => false
)}
it { should contain_package('nova-api').with(
'name' => 'nova-api',
'ensure' => 'present',
'notify' => 'Service[nova-api]'
) }
describe 'with enabled as true' do
let :params do
{:admin_password => 'passw0rd', :enabled => true}
shared_examples 'nova-api' do
context 'with default parameters' do
it 'installs nova-api package and service' do
should contain_service('nova-api').with(
:name => platform_params[:nova_api_service],
:ensure => 'stopped',
:hasstatus => true,
:enable => false
)
should contain_package('nova-api').with(
:name => platform_params[:nova_api_package],
:ensure => 'present',
:notify => 'Service[nova-api]'
)
end
it { should contain_service('nova-api').with(
'name' => 'nova-api',
'ensure' => 'running',
'hasstatus' => true,
'enable' => true
)}
end
describe 'with package version' do
let :params do
{:admin_password => 'passw0rd', :ensure_package => '2012.1-2'}
end
it { should contain_package('nova-api').with(
'ensure' => '2012.1-2'
)}
end
describe 'with defaults' do
it 'should use default params for nova.conf' do
it 'configures keystone_authtoken middleware' do
should contain_nova_config(
'keystone_authtoken/auth_host').with_value('127.0.0.1')
should contain_nova_config(
@@ -63,24 +50,25 @@ describe 'nova::api' do
should contain_nova_config(
'keystone_authtoken/admin_password').with_value('passw0rd').with_secret(true)
end
it { should contain_nova_config('DEFAULT/ec2_listen').with('value' => '0.0.0.0') }
it { should contain_nova_config('DEFAULT/osapi_compute_listen').with('value' => '0.0.0.0') }
it { should contain_nova_config('DEFAULT/metadata_listen').with('value' => '0.0.0.0') }
it { should contain_nova_config('DEFAULT/osapi_volume_listen').with('value' => '0.0.0.0') }
it 'should unconfigure neutron_metadata proxy' do
should contain_nova_config('DEFAULT/service_neutron_metadata_proxy').with('value' => false)
should contain_nova_config('DEFAULT/neutron_metadata_proxy_shared_secret').with('ensure' => 'absent')
it 'configures various stuff' do
should contain_nova_config('DEFAULT/ec2_listen').with('value' => '0.0.0.0')
should contain_nova_config('DEFAULT/osapi_compute_listen').with('value' => '0.0.0.0')
should contain_nova_config('DEFAULT/metadata_listen').with('value' => '0.0.0.0')
should contain_nova_config('DEFAULT/osapi_volume_listen').with('value' => '0.0.0.0')
end
it 'unconfigures neutron_metadata proxy' do
should contain_nova_config('DEFAULT/service_neutron_metadata_proxy').with(:value => false)
should contain_nova_config('DEFAULT/neutron_metadata_proxy_shared_secret').with(:ensure => 'absent')
end
end
describe 'with params' do
let :facts do
{
:osfamily => 'RedHat',
:processorcount => 5
}
end
let :params do
{
context 'with overridden parameters' do
before do
params.merge!({
:enabled => true,
:ensure_package => '2012.1-2',
:auth_host => '10.0.0.1',
:auth_port => 1234,
:auth_protocol => 'https',
@@ -93,11 +81,25 @@ describe 'nova::api' do
:metadata_listen => '127.0.0.1',
:volume_api_class => 'nova.volume.cinder.API',
:use_forwarded_for => false,
:ratelimits => '(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)',
:neutron_metadata_proxy_shared_secret => 'secrete',
:ratelimits => '(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)'
}
})
end
it 'should use defined params for nova.conf and api-paste.ini' do
it 'installs nova-api package and service' do
should contain_package('nova-api').with(
:name => platform_params[:nova_api_package],
:ensure => '2012.1-2'
)
should contain_service('nova-api').with(
:name => platform_params[:nova_api_service],
:ensure => 'running',
:hasstatus => true,
:enable => true
)
end
it 'configures keystone_authtoken middleware' do
should contain_nova_config(
'keystone_authtoken/auth_host').with_value('10.0.0.1')
should contain_nova_config(
@@ -117,14 +119,17 @@ describe 'nova::api' do
should contain_nova_paste_api_ini(
'filter:ratelimit/limits').with_value('(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)')
end
it { should contain_nova_config('DEFAULT/ec2_listen').with('value' => '192.168.56.210') }
it { should contain_nova_config('DEFAULT/osapi_compute_listen').with('value' => '192.168.56.210') }
it { should contain_nova_config('DEFAULT/metadata_listen').with('value' => '127.0.0.1') }
it { should contain_nova_config('DEFAULT/osapi_volume_listen').with('value' => '192.168.56.210') }
it { should contain_nova_config('DEFAULT/use_forwarded_for').with('value' => false) }
it { should contain_nova_config('DEFAULT/osapi_compute_workers').with('value' => '5') }
it { should contain_nova_config('DEFAULT/service_neutron_metadata_proxy').with('value' => true) }
it { should contain_nova_config('DEFAULT/neutron_metadata_proxy_shared_secret').with('value' => 'secrete') }
it 'configures various stuff' do
should contain_nova_config('DEFAULT/ec2_listen').with('value' => '192.168.56.210')
should contain_nova_config('DEFAULT/osapi_compute_listen').with('value' => '192.168.56.210')
should contain_nova_config('DEFAULT/metadata_listen').with('value' => '127.0.0.1')
should contain_nova_config('DEFAULT/osapi_volume_listen').with('value' => '192.168.56.210')
should contain_nova_config('DEFAULT/use_forwarded_for').with('value' => false)
should contain_nova_config('DEFAULT/osapi_compute_workers').with('value' => '5')
should contain_nova_config('DEFAULT/service_neutron_metadata_proxy').with('value' => true)
should contain_nova_config('DEFAULT/neutron_metadata_proxy_shared_secret').with('value' => 'secrete')
end
end
[
@@ -135,28 +140,40 @@ describe 'nova::api' do
'keystone/admin/',
'keystone/admin'
].each do |auth_admin_prefix|
describe "with auth_admin_prefix_containing incorrect value #{auth_admin_prefix}" do
let :params do
{
:auth_admin_prefix => auth_admin_prefix,
:admin_password => 'dummy'
}
context "with auth_admin_prefix_containing incorrect value #{auth_admin_prefix}" do
before do
params.merge!({ :auth_admin_prefix => auth_admin_prefix })
end
it { expect { should contain_nova_config('keystone_authtoken/auth_admin_prefix') }.to \
raise_error(Puppet::Error, /validate_re\(\): "#{auth_admin_prefix}" does not match/) }
end
end
end
describe 'on rhel' do
let :facts do
{ :osfamily => 'RedHat' }
context 'on Debian platforms' do
before do
facts.merge!( :osfamily => 'Debian' )
end
it { should contain_service('nova-api').with(
'name' => 'openstack-nova-api',
'ensure' => 'stopped',
'enable' => false
)}
it { should contain_package('nova-api').with_name('openstack-nova-api') }
let :platform_params do
{ :nova_api_package => 'nova-api',
:nova_api_service => 'nova-api' }
end
it_behaves_like 'nova-api'
end
context 'on RedHat platforms' do
before do
facts.merge!( :osfamily => 'RedHat' )
end
let :platform_params do
{ :nova_api_package => 'openstack-nova-api',
:nova_api_service => 'openstack-nova-api' }
end
it_behaves_like 'nova-api'
end
end