Expand tests for compute and controller

This commit contains tests that were added to
capture the complete functionality of the current
compute and controller classes.

These tests were created in order to help accepting
this commit series and its significant refactor by
capturing the current working state of the previous code.

After these tests were created against the former
version, they were applied against this commit
series to verify that this patch worked
exactly the same as the previous code.
This commit is contained in:
Dan Bode
2012-08-19 00:28:11 -07:00
parent 0f7f03284c
commit 9644278f54
2 changed files with 543 additions and 9 deletions

View File

@@ -15,18 +15,106 @@ describe 'openstack::compute' do
:osfamily => 'Debian', :osfamily => 'Debian',
} }
end end
describe "when using default class paramaters" do
describe "when using default class parameters" do
let :params do let :params do
default_params default_params
end end
it { it {
should contain_nova_config('multi_host').with({ 'value' => 'False' }) should contain_class('nova').with(
:sql_connection => false,
:rabbit_host => false,
:rabbit_userid => 'nova',
:rabbit_password => 'rabbit_pw',
:image_service => 'nova.image.glance.GlanceImageService',
:glance_api_servers => false,
:verbose => false
)
should contain_class('nova::compute').with(
:enabled => true,
:vnc_enabled => true,
:vncserver_proxyclient_address => '0.0.0.0',
:vncproxy_host => false
)
should contain_class('nova::compute::libvirt').with(
:libvirt_type => 'kvm',
:vncserver_listen => '0.0.0.0'
)
should contain_nova_config('multi_host').with( :value => 'False' )
should contain_nova_config('send_arp_for_ha').with( :value => 'False' )
should_not contain_class('nova::api') should_not contain_class('nova::api')
should_not contain_class('nova::volume') should_not contain_class('nova::volume')
should_not contain_class('nova::volume::iscsi') should_not contain_class('nova::volume::iscsi')
should contain_class('nova::network').with({ should contain_class('nova::network').with({
'enabled' => false, :enabled => false,
'install_service' => false :install_service => false,
:private_interface => 'eth0',
:public_interface => nil,
:fixed_range => '10.0.0.0/16',
:floating_range => false,
:network_manager => 'nova.network.manager.FlatDHCPManager',
:config_overrides => {},
:create_networks => false,
:enabled => false,
:install_service => false
})
}
end
describe "when overriding parameters, but not enabling multi-host or volume management" do
let :override_params do
{
:private_interface => 'eth1',
:internal_address => '127.0.0.1',
:public_interface => 'eth2',
:sql_connection => 'mysql://user:passwd@host/name',
:nova_user_password => 'nova_pass',
:rabbit_host => 'my_host',
:rabbit_password => 'my_rabbit_pw',
:rabbit_user => 'my_rabbit_user',
:glance_api_servers => ['controller:9292'],
:libvirt_type => 'qemu',
:vncproxy_host => '127.0.0.2',
:vnc_enabled => false,
:verbose => true,
}
end
let :params do
default_params.merge(override_params)
end
it {
should contain_class('nova').with(
:sql_connection => 'mysql://user:passwd@host/name',
:rabbit_host => 'my_host',
:rabbit_userid => 'my_rabbit_user',
:rabbit_password => 'my_rabbit_pw',
:image_service => 'nova.image.glance.GlanceImageService',
:glance_api_servers => ['controller:9292'],
:verbose => true
)
should contain_class('nova::compute').with(
:enabled => true,
:vnc_enabled => false,
:vncserver_proxyclient_address => '127.0.0.1',
:vncproxy_host => '127.0.0.2'
)
should contain_class('nova::compute::libvirt').with(
:libvirt_type => 'qemu',
:vncserver_listen => '127.0.0.1'
)
should contain_nova_config('multi_host').with( :value => 'False' )
should contain_nova_config('send_arp_for_ha').with( :value => 'False' )
should_not contain_class('nova::api')
should_not contain_class('nova::volume')
should_not contain_class('nova::volume::iscsi')
should contain_class('nova::network').with({
:enabled => false,
:install_service => false,
:private_interface => 'eth1',
:public_interface => 'eth2',
:create_networks => false,
:enabled => false,
:install_service => false
}) })
} }
end end
@@ -38,16 +126,34 @@ describe 'openstack::compute' do
}) })
end end
it { it do
should contain_nova_config('multi_host').with({ 'value' => 'False'}) should contain_nova_config('multi_host').with({ 'value' => 'False'})
should_not contain_class('nova::api') should_not contain_class('nova::api')
should contain_class('nova::volume') should contain_class('nova::volume').with(:enabled => true)
should contain_class('nova::volume::iscsi')
should contain_class('nova::network').with({ should contain_class('nova::network').with({
'enabled' => false, 'enabled' => false,
'install_service' => false 'install_service' => false
}) })
} end
describe 'with default volume settings' do
it { should contain_class('nova::volume::iscsi').with(
:volume_group => 'nova-volumes',
:iscsi_ip_address => '0.0.0.0'
)}
end
describe 'when overriding volume parameters' do
let :params do
default_params.merge({
:manage_volumes => true,
:nova_volume => 'nova-volumes2',
:internal_address => '127.0.0.1'
})
end
it { should contain_class('nova::volume::iscsi').with(
:volume_group => 'nova-volumes2',
:iscsi_ip_address => '127.0.0.1'
) }
end
end end
describe "when configuring for multi host" do describe "when configuring for multi host" do
@@ -59,8 +165,9 @@ describe 'openstack::compute' do
end end
it { it {
should contain_class('keystone::python')
should contain_nova_config('multi_host').with({ 'value' => 'True'}) should contain_nova_config('multi_host').with({ 'value' => 'True'})
should contain_class('nova::api') should contain_nova_config('send_arp_for_ha').with(:value => 'True')
should_not contain_class('nova::volume') should_not contain_class('nova::volume')
should_not contain_class('nova::volume::iscsi') should_not contain_class('nova::volume::iscsi')
should contain_class('nova::network').with({ should contain_class('nova::network').with({
@@ -68,6 +175,26 @@ describe 'openstack::compute' do
'install_service' => true 'install_service' => true
}) })
} }
describe 'with defaults' do
it { should contain_class('nova::api').with(
:enabled => true,
:admin_tenant_name => 'services',
:admin_user => 'nova',
:admin_password => 'nova_pass'
)}
end
describe 'when overrding nova volumes' do
let :params do
default_params.merge({
:multi_host => true,
:public_interface => 'eth0',
:nova_user_password => 'foo'
})
end
it { should contain_class('nova::api').with(
:admin_password => 'foo'
)}
end
end end
describe "when configuring for multi host without a public interface" do describe "when configuring for multi host without a public interface" do
@@ -102,4 +229,31 @@ describe 'openstack::compute' do
}) })
} }
end end
describe 'when overriding network params' do
let :params do
default_params.merge({
:multi_host => true,
:public_interface => 'eth0',
:manage_volumes => true,
:private_interface => 'eth1',
:public_interface => 'eth2',
:fixed_range => '12.0.0.0/24',
:network_manager => 'nova.network.manager.VlanManager',
:network_config => {'vlan_interface' => 'eth0'}
})
end
it { should contain_class('nova::network').with({
:private_interface => 'eth1',
:public_interface => 'eth2',
:fixed_range => '12.0.0.0/24',
:floating_range => false,
:network_manager => 'nova.network.manager.VlanManager',
:config_overrides => {'vlan_interface' => 'eth0'},
:create_networks => false,
'enabled' => true,
'install_service' => true
})}
end
end end

View File

@@ -1,5 +1,385 @@
require 'spec_helper' require 'spec_helper'
describe 'openstack::controller' do describe 'openstack::controller' do
let :default_params do
{
:private_interface => 'eth0',
:public_interface => 'eth1',
:internal_address => '127.0.0.1',
:public_address => '10.0.0.1',
:export_resources => false,
}
end
let :facts do
{
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:concat_basedir => '/tmp/',
:puppetversion => '2.7.x',
:memorysize => '2GB',
:processorcount => '2'
}
end
let :params do
default_params
end
it { should_not contain_nova_config('auto_assign_floating_ip') }
describe 'when auto assign floating ip is assigned' do
let :params do
default_params.merge(:auto_assign_floating_ip => 'true')
end
it { should contain_nova_config('auto_assign_floating_ip').with(:value => 'True')}
end
it do
should contain_class('mysql::server').with(
:config_hash => {'bind_address' => '0.0.0.0', 'root_password' => 'sql_pass' }
)
should contain_class('memcached').with(
:listen_ip => '127.0.0.1'
)
end
describe 'when enabled' do
it 'should contain enabled database configs' do
should contain_class('mysql::server').with(
:enabled => true
)
should contain_class('keystone::db::mysql').with(
:password => 'keystone_pass'
)
should contain_class('glance::db::mysql').with(
:host => '127.0.0.1',
:password => 'glance_pass',
:before => ["Class[Glance::Registry]", "Exec[glance-manage db_sync]"]
)
should contain_class('nova::db::mysql').with(
:password => 'nova_pass',
:host => '127.0.0.1',
:allowed_hosts => '%'
)
end
it 'should contain enabled keystone configs with defaults' do
should contain_class('keystone').with(
:admin_token => 'keystone_admin_token',
:bind_host => '0.0.0.0',
:log_verbose => false,
:log_debug => false,
:catalog_type => 'sql',
:enabled => true
)
should contain_class('keystone::config::mysql').with(
:password => 'keystone_pass'
)
should contain_class('keystone::roles::admin').with(
:email => 'some_user@some_fake_email_address.foo',
:password => 'ChangeMe'
)
should contain_class('keystone::endpoint').with(
:public_address => '10.0.0.1',
:internal_address => '127.0.0.1',
:admin_address => '127.0.0.1'
)
should contain_class('glance::keystone::auth').with(
:password => 'glance_pass',
:public_address => '10.0.0.1',
:internal_address => '127.0.0.1',
:admin_address => '127.0.0.1'
#:before => ['Class[glance::api]', 'Class[glance::registry]']
)
should contain_class('nova::keystone::auth').with(
:password => 'nova_pass',
:public_address => '10.0.0.1',
:internal_address => '127.0.0.1',
:admin_address => '127.0.0.1'
#:before => 'Class[nova::api]'
)
should contain_class('glance::api').with(
:log_verbose => false,
:log_debug => false,
:auth_type => 'keystone',
:auth_host => '127.0.0.1',
:auth_port => '35357',
:keystone_tenant => 'services',
:keystone_user => 'glance',
:keystone_password => 'glance_pass',
:enabled => true
)
should contain_class('glance::backend::file')
should contain_class('glance::registry').with(
:log_verbose => false,
:log_debug => false,
:auth_type => 'keystone',
:auth_host => '127.0.0.1',
:auth_port => '35357',
:keystone_tenant => 'services',
:keystone_user => 'glance',
:keystone_password => 'glance_pass',
:sql_connection => "mysql://glance:glance_pass@127.0.0.1/glance",
:enabled => true
)
should contain_class('nova::rabbitmq').with(
:userid => 'nova',
:password => 'rabbit_pw',
:enabled => true
)
should contain_class('nova').with(
:sql_connection => 'mysql://nova:nova_pass@127.0.0.1/nova',
:rabbit_host => '127.0.0.1',
:rabbit_userid => 'nova',
:rabbit_password => 'rabbit_pw',
:image_service => 'nova.image.glance.GlanceImageService',
:glance_api_servers => '10.0.0.1:9292',
:verbose => false
)
should contain_class('nova::api').with(
:enabled => true,
:admin_tenant_name => 'services',
:admin_user => 'nova',
:admin_password => 'nova_pass'
)
should contain_class('nova::cert').with(:enabled => true)
should contain_class('nova::consoleauth').with(:enabled => true)
should contain_class('nova::scheduler').with(:enabled => true)
should contain_class('nova::objectstore').with(:enabled => true)
should contain_class('nova::vncproxy').with(:enabled => true)
should contain_class('horizon').with(
:secret_key => 'dummy_secret_key',
:cache_server_ip => '127.0.0.1',
:cache_server_port => '11211',
:swift => false,
:quantum => false,
:horizon_app_links => false
)
end
describe 'when overriding params' do
let :params do
default_params.merge(
:keystone_db_password => 'pass',
:glance_db_password => 'pass2',
:nova_db_password => 'pass3',
:verbose => true,
:keystone_admin_token => 'foo',
:nova_user_password => 'pass5',
:glance_user_password => 'pass6',
:admin_email => 'dan@puppetlabs.com',
:admin_address => '127.0.0.2',
:admin_password => 'pass7',
:rabbit_user => 'rabby',
:rabbit_password => 'rabby_pw',
:fixed_range => '10.0.0.0/24',
:floating_range => '11.0.0.0/24',
:network_manager => 'nova.network.manager.VlanManager',
:network_config => {'vlan_interface' => 'eth4'},
:num_networks => 2,
:secret_key => 'real_secret_key',
:cache_server_ip => '127.0.0.2',
:cache_server_port => '11212',
:swift => true,
:quantum => true,
:horizon_app_links => true,
:glance_api_servers => '127.0.0.1:9292'
)
end
it 'should override db config' do
should contain_class('keystone::db::mysql').with(
:password => 'pass'
)
should contain_class('glance::db::mysql').with(
:password => 'pass2'
)
should contain_class('nova::db::mysql').with(
:password => 'pass3'
)
end
it 'should override keystone config' do
should contain_class('keystone').with(
:log_verbose => true,
:log_debug => true,
:admin_token => 'foo'
)
should contain_class('keystone::config::mysql').with(
:password => 'pass'
)
should contain_class('keystone::endpoint').with(
:admin_address => '127.0.0.2'
)
should contain_class('keystone::roles::admin').with(
:email => 'dan@puppetlabs.com',
:password => 'pass7'
)
should contain_class('glance::keystone::auth').with(
:password => 'pass6',
:admin_address => '127.0.0.2'
)
should contain_class('nova::keystone::auth').with(
:password => 'pass5',
:admin_address => '127.0.0.2'
)
end
it 'should override glance config' do
should contain_class('glance::api').with(
:log_verbose => true,
:log_debug => true,
:keystone_password => 'pass6',
:enabled => true
)
should contain_class('glance::registry').with(
:log_verbose => true,
:log_debug => true,
:keystone_password => 'pass6',
:sql_connection => "mysql://glance:pass2@127.0.0.1/glance",
:enabled => true
)
end
it 'should override nova config' do
should contain_class('nova::rabbitmq').with(
:userid => 'rabby',
:password => 'rabby_pw',
:enabled => true
)
should contain_class('nova').with(
:sql_connection => 'mysql://nova:pass3@127.0.0.1/nova',
:rabbit_host => '127.0.0.1',
:rabbit_userid => 'rabby',
:rabbit_password => 'rabby_pw',
:image_service => 'nova.image.glance.GlanceImageService',
:glance_api_servers => '127.0.0.1:9292',
:verbose => true
)
should contain_class('nova::api').with(
:enabled => true,
:admin_tenant_name => 'services',
:admin_user => 'nova',
:admin_password => 'pass5'
)
should contain_class('nova::network').with(
:fixed_range => '10.0.0.0/24',
:floating_range => '11.0.0.0/24',
:network_manager => 'nova.network.manager.VlanManager',
:config_overrides => {'vlan_interface' => 'eth4'},
:num_networks => 2
)
end
describe 'it should override horizon params' do
it { should contain_class('horizon').with(
:secret_key => 'real_secret_key',
:cache_server_ip => '127.0.0.2',
:cache_server_port => '11212',
:swift => true,
:quantum => true,
:horizon_app_links => true
)}
end
end
end
describe 'when not enabled' do
let :params do
default_params.merge(:enabled => false)
end
it do
should contain_class('mysql::server').with(
:enabled => false
)
should_not contain_class('keystone::db::mysql')
should_not contain_class('glance::db::mysql')
should_not contain_class('nova::db::mysql')
should contain_class('keystone::config::mysql')
should contain_class('keystone').with(:enabled => false)
should_not contain_class('keystone::roles::admin')
should_not contain_class('keystone::endpoint')
should_not contain_class('glance::keystone::auth')
should_not contain_class('nova::keystone::auth')
should contain_class('glance::api').with(:enabled => false)
should contain_class('glance::backend::file')
should contain_class('glance::registry').with(:enabled => false)
should contain_class('nova::rabbitmq').with(:enabled => false)
should contain_class('nova::api').with(:enabled => false)
should contain_class('nova::cert').with(:enabled => false)
should contain_class('nova::consoleauth').with(:enabled => false)
should contain_class('nova::scheduler').with(:enabled => false)
should contain_class('nova::objectstore').with(:enabled => false)
should contain_class('nova::vncproxy').with(:enabled => false)
end
end
describe 'nova network config' do
describe 'when enabled' do
describe 'when multihost is not set' do
it {should contain_class('nova::network').with(
:private_interface => 'eth0',
:public_interface => 'eth1',
:fixed_range => '10.0.0.0/24',
:floating_range => false,
:network_manager => 'nova.network.manager.FlatDHCPManager',
:config_overrides => {},
:create_networks => true,
:num_networks => 1,
:enabled => true,
:install_service => true
)}
end
describe 'when multihost is set' do
let :params do
default_params.merge(:multi_host => true)
end
it { should contain_nova_config('multi_host').with(:value => 'True')}
it {should contain_class('nova::network').with(
:create_networks => true,
:enabled => false,
:install_service => false
)}
end
end
describe 'when not enabled' do
describe 'when multihost is set' do
let :params do
default_params.merge(
:multi_host => true,
:enabled => false
)
end
it {should contain_class('nova::network').with(
:create_networks => false,
:enabled => false,
:install_service => false
)}
end
describe 'when multihost is not set' do
let :params do
default_params.merge(
:multi_host => false,
:enabled => false
)
end
it {should contain_class('nova::network').with(
:create_networks => false,
:enabled => false,
:install_service => false
)}
end
end
end
end end