From eb3e229484d2c1a6818142cbd7edcf71302bb949 Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Wed, 7 Nov 2012 00:13:38 -0800 Subject: [PATCH] add spec tests - for making horizon optional - for adding rabbit_virtual_host --- spec/classes/openstack_all_spec.rb | 55 +++++++++++++++++++++++ spec/classes/openstack_compute_spec.rb | 31 +++++++------ spec/classes/openstack_controller_spec.rb | 29 +++++++----- 3 files changed, 91 insertions(+), 24 deletions(-) diff --git a/spec/classes/openstack_all_spec.rb b/spec/classes/openstack_all_spec.rb index b90e1d2..0eade20 100644 --- a/spec/classes/openstack_all_spec.rb +++ b/spec/classes/openstack_all_spec.rb @@ -2,4 +2,59 @@ require 'spec_helper' describe 'openstack::all' do + # minimum set of default parameters + let :default_params do + { + :public_address => '10.0.0.1', + :public_interface => 'eth1', + :private_interface => 'eth0', + :admin_email => 'some_user@some_fake_email_address.foo', + :mysql_root_password => 'foo', + :admin_password => 'ChangeMe', + :rabbit_password => 'rabbit_pw', + :keystone_db_password => 'keystone_pass', + :keystone_admin_token => 'keystone_admin_token', + :glance_db_password => 'glance_pass', + :glance_user_password => 'glance_pass', + :nova_db_password => 'nova_pass', + :nova_user_password => 'nova_pass', + :secret_key => 'secret_key', + :quantum => false, + } + end + + let :facts do + { + :operatingsystem => 'Ubuntu', + :osfamily => 'Debian', + :puppetversion => '2.7.x', + :memorysize => '2GB', + :processorcount => '2' + } + end + + let :params do + default_params + end + + context 'config for horizon' do + + it 'should contain enabled horizon' do + should contain_class('horizon').with( + :secret_key => 'secret_key', + :cache_server_ip => '127.0.0.1', + :cache_server_port => '11211', + :swift => false, + :quantum => false, + :horizon_app_links => false + ) + end + + describe 'when horizon is disabled' do + let :params do + default_params.merge(:horizon => false) + end + it { should_not contain_class('horizon') } + end + end end diff --git a/spec/classes/openstack_compute_spec.rb b/spec/classes/openstack_compute_spec.rb index 250720d..2a9de1e 100644 --- a/spec/classes/openstack_compute_spec.rb +++ b/spec/classes/openstack_compute_spec.rb @@ -28,13 +28,14 @@ describe 'openstack::compute' do end it { should contain_class('nova').with( - :sql_connection => 'mysql://user:pass@host/dbname/', - :rabbit_host => '127.0.0.1', - :rabbit_userid => 'nova', - :rabbit_password => 'rabbit_pw', - :image_service => 'nova.image.glance.GlanceImageService', - :glance_api_servers => false, - :verbose => 'False' + :sql_connection => 'mysql://user:pass@host/dbname/', + :rabbit_host => '127.0.0.1', + :rabbit_userid => 'nova', + :rabbit_password => 'rabbit_pw', + :rabbit_virtual_host => '/', + :image_service => 'nova.image.glance.GlanceImageService', + :glance_api_servers => false, + :verbose => 'False' ) should contain_class('nova::compute').with( :enabled => true, @@ -76,6 +77,7 @@ describe 'openstack::compute' do :rabbit_host => 'my_host', :rabbit_password => 'my_rabbit_pw', :rabbit_user => 'my_rabbit_user', + :rabbit_virtual_host => '/foo', :glance_api_servers => ['controller:9292'], :libvirt_type => 'qemu', :vncproxy_host => '127.0.0.2', @@ -88,13 +90,14 @@ describe 'openstack::compute' do end it do 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 + :sql_connection => 'mysql://user:passwd@host/name', + :rabbit_host => 'my_host', + :rabbit_userid => 'my_rabbit_user', + :rabbit_password => 'my_rabbit_pw', + :rabbit_virtual_host => '/foo', + :image_service => 'nova.image.glance.GlanceImageService', + :glance_api_servers => ['controller:9292'], + :verbose => true ) should contain_class('nova::compute').with( :enabled => true, diff --git a/spec/classes/openstack_controller_spec.rb b/spec/classes/openstack_controller_spec.rb index 47ed501..e0fae91 100644 --- a/spec/classes/openstack_controller_spec.rb +++ b/spec/classes/openstack_controller_spec.rb @@ -330,18 +330,20 @@ describe 'openstack::controller' do it 'should contain enabled nova services' do should contain_class('nova::rabbitmq').with( - :userid => 'nova', - :password => 'rabbit_pw', - :enabled => true + :userid => 'nova', + :password => 'rabbit_pw', + :virtual_host => '/', + :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' + :sql_connection => 'mysql://nova:nova_pass@127.0.0.1/nova', + :rabbit_host => '127.0.0.1', + :rabbit_userid => 'nova', + :rabbit_password => 'rabbit_pw', + :rabbit_virtual_host => '/', + :image_service => 'nova.image.glance.GlanceImageService', + :glance_api_servers => '10.0.0.1:9292', + :verbose => 'False' ) should contain_class('nova::api').with( :enabled => true, @@ -392,6 +394,13 @@ describe 'openstack::controller' do :horizon_app_links => false ) end + + describe 'when horizon is disabled' do + let :params do + default_params.merge(:horizon => false) + end + it { should_not contain_class('horizon') } + end end context 'cinder' do