Implement rspec tests

This commit implements rspec coversage for nova.
This commit is contained in:
Dan Bode 2012-05-09 16:54:09 -07:00
parent 0ce30bf79e
commit 65c481de17
7 changed files with 329 additions and 48 deletions

View File

@ -35,6 +35,11 @@ describe 'nova::compute' do
'ensure' => 'present',
'notify' => 'Service[nova-compute]'
) }
it { should contain_package('bridge-utils').with(
:ensure => 'present',
:before => 'Nova::Generic_service[compute]'
) }
describe 'with enabled as true' do
let :params do
{

View File

@ -16,6 +16,10 @@ describe 'nova' do
'ensure' => 'present',
'require' => 'Package[python-greenlet]'
)}
it { should contain_package('nova-common').with(
'name' => 'nova-common',
'ensure' => 'present'
)}
it { should contain_group('nova').with(
'ensure' => 'present',
@ -57,27 +61,27 @@ describe 'nova' do
it { should_not contain_nova_config('sql_connection') }
it { should contain_nova_config('verbose').with_value(false) }
it { should contain_nova_config('nodaemon').with_value('false') }
it { should contain_nova_config('logdir').with_value('/var/log/nova') }
it { should contain_nova_config('image_service').with_value('nova.image.local.LocalImageService') }
it { should contain_nova_config('allow_admin_api').with_value('false') }
it { should contain_nova_config('image_service').with_value('nova.image.glance.GlanceImageService') }
it { should contain_nova_config('glance_api_servers').with_value('localhost:9292') }
it { should contain_nova_config('auth_strategy').with_value('keystone') }
it { should contain_nova_config('use_deprecated_auth').with_value('false') }
it { should contain_nova_config('rabbit_host').with_value('localhost') }
it { should contain_nova_config('rabbit_password').with_value('guest') }
it { should contain_nova_config('rabbit_port').with_value('5672') }
it { should contain_nova_config('rabbit_userid').with_value('guest') }
it { should contain_nova_config('rabbit_virtual_host').with_value('/') }
it { should contain_nova_config('verbose').with_value(false) }
it { should contain_nova_config('logdir').with_value('/var/log/nova') }
it { should contain_nova_config('state_path').with_value('/var/lib/nova') }
it { should contain_nova_config('lock_path').with_value('/var/lock/nova') }
it { should contain_nova_config('service_down_time').with_value('60') }
it { should contain_nova_config('root_helper').with_value('sudo nova-rootwrap') }
it { should contain_nova_config('network_manager').with_value('nova.network.manager.FlatManager') }
it { should_not contain_nova_config('dhcpbridge').with_value('/usr/bin/nova-dhcpbridge') }
it { should_not contain_nova_config('dhcpbridge_flagfile').with_value('/etc/nova/nova.conf') }
it { should contain_nova_config('flat_network_bridge').with_value('br100') }
it { should contain_nova_config('root_helper').with_value('sudo nova-rootwrap') }
it { should contain_nova_config('use_deprecated_auth').with_value('false') }
describe 'with parameters supplied' do
@ -85,45 +89,39 @@ describe 'nova' do
{
'sql_connection' => 'mysql://user:pass@db/db',
'verbose' => true,
'nodaemon' => true,
'logdir' => '/var/log/nova2',
'image_service' => 'nova.image.glance.GlanceImageService',
'allow_admin_api' => true,
'image_service' => 'nova.image.local.LocalImageService',
'rabbit_host' => 'rabbit',
'rabbit_userid' => 'rabbit_user',
'rabbit_port' => '5672',
'rabbit_userid' => 'rabbit_user',
'rabbit_port' => '5673',
'rabbit_password' => 'password',
'lock_path' => '/var/locky/path',
'state_path' => '/var/lib/nova2',
'service_down_time' => '120',
'network_manager' => 'nova.network.manager.FlatDHCPManager',
'auth_strategy' => 'foo'
}
end
it { should contain_nova_config('use_deprecated_auth').with_value('true') }
it { should contain_nova_config('sql_connection').with_value('mysql://user:pass@db/db') }
it { should contain_nova_config('verbose').with_value(true) }
it { should contain_nova_config('nodaemon').with_value(true) }
it { should contain_nova_config('logdir').with_value('/var/log/nova2') }
# glance config
it { should contain_nova_config('image_service').with_value('nova.image.glance.GlanceImageService') }
it { should contain_nova_config('glance_api_servers').with_value('localhost:9292') }
it { should contain_nova_config('allow_admin_api').with_value(true) }
it { should contain_nova_config('image_service').with_value('nova.image.local.LocalImageService') }
it { should_not contain_nova_config('glance_api_servers') }
it { should contain_nova_config('auth_strategy').with_value('foo') }
it { should contain_nova_config('use_deprecated_auth').with_value(true) }
it { should contain_nova_config('rabbit_host').with_value('rabbit') }
it { should contain_nova_config('rabbit_password').with_value('password') }
it { should contain_nova_config('rabbit_port').with_value('5672') }
it { should contain_nova_config('rabbit_port').with_value('5673') }
it { should contain_nova_config('rabbit_userid').with_value('rabbit_user') }
it { should contain_nova_config('rabbit_virtual_host').with_value('/') }
it { should contain_nova_config('verbose').with_value(true) }
it { should contain_nova_config('logdir').with_value('/var/log/nova2') }
it { should contain_nova_config('state_path').with_value('/var/lib/nova2') }
it { should contain_nova_config('lock_path').with_value('/var/locky/path') }
it { should contain_nova_config('service_down_time').with_value('120') }
it { should contain_nova_config('network_manager').with_value('nova.network.manager.FlatDHCPManager') }
it { should contain_nova_config('dhcpbridge').with_value('/usr/bin/nova-dhcpbridge') }
it { should contain_nova_config('dhcpbridge_flagfile').with_value('/etc/nova/nova.conf') }
end
describe "When platform is RedHat" do
@ -134,6 +132,7 @@ describe 'nova' do
'name' => 'openstack-nova',
'ensure' => 'present'
)}
it { should contain_nova_config('root_helper').with_value('sudo nova-rootwrap') }
end
end
end

View File

@ -0,0 +1,38 @@
require 'spec_helper'
describe 'nova::network::flat' do
describe 'with only required parameters' do
let :params do
{
:flat_interface => 'eth1',
:fixed_range => '10.0.0.0/32'
}
end
it { should contain_nova_config('network_manager').with_value('nova.network.manager.FlatManager') }
it { should_not contain_nova_config('public_interface') }
it { should contain_nova_config('fixed_range').with_value('10.0.0.0/32') }
it { should contain_nova_config('flat_network_bridge').with_value('br100') }
it { should contain_nova_config('flat_interface').with_value('eth1') }
end
describe 'when overriding class parameters' do
let :params do
{
:flat_interface => 'eth1',
:fixed_range => '10.0.0.0/32',
:public_interface => 'eth0',
:flat_network_bridge => 'br1001',
}
end
it { should contain_nova_config('public_interface').with_value('eth0') }
it { should contain_nova_config('flat_network_bridge').with_value('br1001') }
it { should contain_nova_config('fixed_range').with_value('10.0.0.0/32') }
it { should contain_nova_config('flat_interface').with_value('eth1') }
end
end

View File

@ -0,0 +1,49 @@
require 'spec_helper'
describe 'nova::network::flatdhcp' do
describe 'with only required parameters' do
let :params do
{
:flat_interface => 'eth1',
:fixed_range => '10.0.0.0/32'
}
end
it { should contain_nova_config('network_manager').with_value('nova.network.manager.FlatDHCPManager') }
it { should_not contain_nova_config('public_interface') }
it { should contain_nova_config('fixed_range').with_value('10.0.0.0/32') }
it { should contain_nova_config('flat_interface').with_value('eth1') }
it { should contain_nova_config('flat_interface').with_value('eth1') }
it { should contain_nova_config('flat_network_bridge').with_value('br100') }
it { should contain_nova_config('force_dhcp_release').with_value('true') }
it { should contain_nova_config('flat_injected').with_value('false') }
it { should contain_nova_config('dhcpbridge').with_value('/usr/bin/nova-dhcpbridge') }
it { should contain_nova_config('dhcpbridge_flagfile').with_value('/etc/nova/nova.conf') }
end
describe 'when overriding class parameters' do
let :params do
{
:flat_interface => 'eth1',
:fixed_range => '10.0.0.0/32',
:public_interface => 'eth0',
:flat_network_bridge => 'br1001',
:force_dhcp_release => false,
:flat_injected => true,
:dhcpbridge => '/usr/bin/dhcpbridge',
:dhcpbridge_flagfile => '/etc/nova/nova-dhcp.conf'
}
end
it { should contain_nova_config('public_interface').with_value('eth0') }
it { should contain_nova_config('flat_network_bridge').with_value('br1001') }
it { should contain_nova_config('force_dhcp_release').with_value('false') }
it { should contain_nova_config('flat_injected').with_value('true') }
it { should contain_nova_config('dhcpbridge').with_value('/usr/bin/dhcpbridge') }
it { should contain_nova_config('dhcpbridge_flagfile').with_value('/etc/nova/nova-dhcp.conf') }
end
end

View File

@ -6,29 +6,181 @@ describe 'nova::network' do
'include nova'
end
let :default_params do
{
:private_interface => 'eth1',
:fixed_range => '10.0.0.0/32',
}
end
let :params do
default_params
end
describe 'on debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it { should contain_service('nova-network').with(
'name' => 'nova-network',
'ensure' => 'stopped',
'enable' => false
)}
it { should contain_package('nova-network').with(
'name' => 'nova-network',
'ensure' => 'present',
'notify' => 'Service[nova-network]'
) }
describe 'with enabled as true' do
let :params do
{:enabled => true}
it { should contain_sysctl__value('net.ipv4.ip_forward').with_value('1') }
describe 'when installing service' do
it { should contain_package('nova-network').with(
'name' => 'nova-network',
'ensure' => 'present',
'notify' => 'Service[nova-network]'
) }
describe 'with enabled as true' do
let :params do
default_params.merge(:enabled => true)
end
it { should contain_service('nova-network').with(
'name' => 'nova-network',
'ensure' => 'running',
'enable' => true
)}
end
describe 'when enabled is set to false' do
it { should contain_service('nova-network').with(
'name' => 'nova-network',
'ensure' => 'stopped',
'enable' => false
)}
end
end
describe 'when not installing service' do
let :params do
default_params.merge(:install_service => false)
end
it { should_not contain_package('nova-network') }
it { should_not contain_service('nova-network') }
end
describe 'when not creating networks' do
let :params do
default_params.merge(:create_networks => false)
end
it { should_not contain_nova__manage__network('nova-vm-net') }
it { should_not contain_nova__manage__floating('nova-vm-floating') }
end
describe 'when creating networks' do
it { should contain_nova__manage__network('nova-vm-net').with(
:network => '10.0.0.0/32',
:num_networks => '1'
) }
it { should_not contain__nova__manage__floating('nova-vm-floating') }
describe 'when number of networks is set' do
let :params do
default_params.merge(:num_networks => '2')
end
it { should contain_nova__manage__network('nova-vm-net').with(
:num_networks => '2'
) }
end
describe 'when floating range is set' do
let :params do
default_params.merge(:floating_range => '10.0.0.0/30')
end
it { should contain_nova_config('floating_range').with_value('10.0.0.0/30') }
it { should contain_nova__manage__floating('nova-vm-floating').with_network('10.0.0.0/30') }
end
end
describe 'when configuring networks' do
describe 'when configuring flatdhcpmanager' do
let :params do
default_params.merge(:network_manager => 'nova.network.manager.FlatDHCPManager')
end
it { should contain_class('nova::network::flatdhcp').with(
:fixed_range => '10.0.0.0/32',
:public_interface => nil,
:flat_interface => 'eth1',
:flat_network_bridge => 'br100',
:force_dhcp_release => true,
:flat_injected => false,
:dhcpbridge => '/usr/bin/nova-dhcpbridge',
:dhcpbridge_flagfile => '/etc/nova/nova.conf'
) }
describe 'when overriding parameters' do
let :params do
default_params.merge(
{
:network_manager => 'nova.network.manager.FlatDHCPManager',
:public_interface => 'eth0',
:config_overrides =>
{
'flat_network_bridge' => 'br400',
'force_dhcp_release' => false,
'flat_injected' => true,
'dhcpbridge' => '/tmp/bridge',
'dhcpbridge_flagfile' => '/tmp/file',
}
}
)
end
it { should contain_class('nova::network::flatdhcp').with(
:fixed_range => '10.0.0.0/32',
:public_interface => 'eth0',
:flat_interface => 'eth1',
:flat_network_bridge => 'br400',
#:force_dhcp_release => false,
:flat_injected => true,
:dhcpbridge => '/tmp/bridge',
:dhcpbridge_flagfile => '/tmp/file'
) }
end
end
describe 'when configuring flatmanager' do
let :params do
default_params.merge(:network_manager => 'nova.network.manager.FlatManager')
end
it { should contain_class('nova::network::flat').with(
:fixed_range => '10.0.0.0/32',
:public_interface => nil,
:flat_interface => 'eth1',
:flat_network_bridge => 'br100'
) }
describe 'when overriding flat network params' do
let :params do
default_params.merge(
{
:network_manager => 'nova.network.manager.FlatManager',
:public_interface => 'eth0',
:config_overrides => {'flat_network_bridge' => 'br400' }
}
)
end
it { should contain_class('nova::network::flat').with(
:public_interface => 'eth0',
:flat_network_bridge => 'br400'
) }
end
end
describe 'when configuring vlan' do
let :params do
default_params.merge(:network_manager => 'nova.network.manager.VlanManager')
end
it { should contain_class('nova::network::vlan').with(
:fixed_range => '10.0.0.0/32',
:public_interface => nil,
:vlan_interface => 'eth1'
) }
describe 'when overriding parameters' do
let :params do
default_params.merge(
{
}
)
end
end
end
it { should contain_service('nova-network').with(
'name' => 'nova-network',
'ensure' => 'running',
'enable' => true
)}
end
end
describe 'on rhel' do

View File

@ -0,0 +1,38 @@
require 'spec_helper'
describe 'nova::network::vlan' do
describe 'with only required parameters' do
let :params do
{
:vlan_interface => 'eth1',
:fixed_range => '10.0.0.0/32'
}
end
it { should contain_nova_config('network_manager').with_value('nova.network.manager.VlanManager') }
it { should_not contain_nova_config('public_interface') }
it { should contain_nova_config('fixed_range').with_value('10.0.0.0/32') }
it { should contain_nova_config('vlan_start').with_value('300') }
it { should contain_nova_config('vlan_interface').with_value('eth1') }
end
describe 'with parameters overridden' do
let :params do
{
:vlan_interface => 'eth1',
:fixed_range => '10.0.0.0/32',
:public_interface => 'eth0',
:vlan_start => '100'
}
end
it { should contain_nova_config('network_manager').with_value('nova.network.manager.VlanManager') }
it { should contain_nova_config('public_interface').with_value('eth0') }
it { should contain_nova_config('fixed_range').with_value('10.0.0.0/32') }
it { should contain_nova_config('vlan_start').with_value('100') }
it { should contain_nova_config('vlan_interface').with_value('eth1') }
end
end

View File

@ -1 +1 @@
../../../
../../../../nova