Add basic spec tests
This commit adds basic test coverage. It is no 100% coverage, but its a great start.
This commit is contained in:
parent
d5f081ba58
commit
ec77314554
50
spec/classes/cinder_api_spec.rb
Normal file
50
spec/classes/cinder_api_spec.rb
Normal file
@ -0,0 +1,50 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'cinder::api' do
|
||||
|
||||
let :req_params do
|
||||
{:keystone_password => 'foo'}
|
||||
end
|
||||
let :facts do
|
||||
{:osfamily => 'Debian'}
|
||||
end
|
||||
|
||||
describe 'with only required params' do
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
it 'should configure cinder api correctly' do
|
||||
should contain_cinder_config('DEFAULT/auth_strategy').with(
|
||||
:value => 'keystone'
|
||||
)
|
||||
should contain_cinder_api_paste_ini('filter:authtoken/service_protocol').with(
|
||||
:value => 'http'
|
||||
)
|
||||
should contain_cinder_api_paste_ini('filter:authtoken/service_host').with(
|
||||
:value => 'localhost'
|
||||
)
|
||||
should contain_cinder_api_paste_ini('filter:authtoken/service_port').with(
|
||||
:value => '5000'
|
||||
)
|
||||
should contain_cinder_api_paste_ini('filter:authtoken/auth_protocol').with(
|
||||
:value => 'http'
|
||||
)
|
||||
should contain_cinder_api_paste_ini('filter:authtoken/auth_host').with(
|
||||
:value => 'localhost'
|
||||
)
|
||||
should contain_cinder_api_paste_ini('filter:authtoken/auth_port').with(
|
||||
:value => '35357'
|
||||
)
|
||||
should contain_cinder_api_paste_ini('filter:authtoken/admin_tenant_name').with(
|
||||
:value => 'services'
|
||||
)
|
||||
should contain_cinder_api_paste_ini('filter:authtoken/admin_user').with(
|
||||
:value => 'cinder'
|
||||
)
|
||||
should contain_cinder_api_paste_ini('filter:authtoken/admin_password').with(
|
||||
:value => 'foo'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
44
spec/classes/cinder_base_spec.rb
Normal file
44
spec/classes/cinder_base_spec.rb
Normal file
@ -0,0 +1,44 @@
|
||||
require 'spec_helper'
|
||||
describe 'cinder::base' do
|
||||
let :req_params do
|
||||
{:rabbit_password => 'rpw', :sql_connection => 'mysql://user:password@host/database'}
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{:osfamily => 'Debian'}
|
||||
end
|
||||
|
||||
describe 'with only required params' do
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
|
||||
it 'should contain default config' do
|
||||
should contain_cinder_config('DEFAULT/rabbit_password').with(
|
||||
:value => 'rpw'
|
||||
)
|
||||
should contain_cinder_config('DEFAULT/rabbit_host').with(
|
||||
:value => '127.0.0.1'
|
||||
)
|
||||
should contain_cinder_config('DEFAULT/rabbit_port').with(
|
||||
:value => '5672'
|
||||
)
|
||||
should contain_cinder_config('DEFAULT/rabbit_virtual_host').with(
|
||||
:value => '/'
|
||||
)
|
||||
should contain_cinder_config('DEFAULT/rabbit_userid').with(
|
||||
:value => 'nova'
|
||||
)
|
||||
should contain_cinder_config('DEFAULT/sql_connection').with(
|
||||
:value => 'mysql://user:password@host/database'
|
||||
)
|
||||
should contain_cinder_config('DEFAULT/verbose').with(
|
||||
:value => 'False'
|
||||
)
|
||||
should contain_cinder_config('DEFAULT/api_paste_config').with(
|
||||
:value => '/etc/cinder/api-paste.ini'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
28
spec/classes/cinder_db_mysql_spec.rb
Normal file
28
spec/classes/cinder_db_mysql_spec.rb
Normal file
@ -0,0 +1,28 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'cinder::db::mysql' do
|
||||
|
||||
let :req_params do
|
||||
{:password => 'pw'}
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{:osfamily => 'Debian'}
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
'include mysql::server'
|
||||
end
|
||||
|
||||
describe 'with only required params' do
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
it { should contain_mysql__db('cinder').with(
|
||||
:user => 'cinder',
|
||||
:password => 'pw',
|
||||
:host => '127.0.0.1',
|
||||
:charset => 'latin1'
|
||||
) }
|
||||
end
|
||||
end
|
16
spec/classes/cinder_db_sync_spec.rb
Normal file
16
spec/classes/cinder_db_sync_spec.rb
Normal file
@ -0,0 +1,16 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'cinder::db::sync' do
|
||||
|
||||
let :facts do
|
||||
{:osfamily => 'Debian'}
|
||||
end
|
||||
it { should contain_exec('cinder-manage db_sync').with(
|
||||
:command => 'cinder-manage db sync',
|
||||
:path => '/usr/bin',
|
||||
:user => 'cinder',
|
||||
:refreshonly => true,
|
||||
:logoutput => 'on_failure'
|
||||
) }
|
||||
|
||||
end
|
50
spec/classes/cinder_keystone_auth_spec.rb
Normal file
50
spec/classes/cinder_keystone_auth_spec.rb
Normal file
@ -0,0 +1,50 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'cinder::keystone::auth' do
|
||||
|
||||
let :req_params do
|
||||
{:password => 'pw'}
|
||||
end
|
||||
|
||||
describe 'with only required params' do
|
||||
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
|
||||
it 'should contain auth info' do
|
||||
|
||||
should contain_keystone_user('cinder').with(
|
||||
:ensure => 'present',
|
||||
:password => 'pw',
|
||||
:email => 'cinder@localhost',
|
||||
:tenant => 'services'
|
||||
)
|
||||
should contain_keystone_user_role('cinder@services').with(
|
||||
:ensure => 'present',
|
||||
:roles => 'admin'
|
||||
)
|
||||
should contain_keystone_service('cinder').with(
|
||||
:ensure => 'present',
|
||||
:type => 'volume',
|
||||
:description => 'Cinder Service'
|
||||
)
|
||||
|
||||
end
|
||||
it { should contain_keystone_endpoint('RegionOne/cinder').with(
|
||||
:ensure => 'present',
|
||||
:public_url => 'http://127.0.0.1:8776/v1/%(tenant_id)s',
|
||||
:admin_url => 'http://127.0.0.1:8776/v1/%(tenant_id)s',
|
||||
:internal_url => 'http://127.0.0.1:8776/v1/%(tenant_id)s'
|
||||
) }
|
||||
|
||||
end
|
||||
|
||||
describe 'when endpoint should not be configured' do
|
||||
let :params do
|
||||
req_params.merge(:configure_endpoint => false)
|
||||
end
|
||||
it { should_not contain_keystone_endpoint('RegionOne/cinder') }
|
||||
end
|
||||
|
||||
end
|
12
spec/classes/cinder_params_spec.rb
Normal file
12
spec/classes/cinder_params_spec.rb
Normal file
@ -0,0 +1,12 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'cinder::params' do
|
||||
|
||||
let :facts do
|
||||
{:osfamily => 'Debian'}
|
||||
end
|
||||
it 'should compile' do
|
||||
subject
|
||||
end
|
||||
|
||||
end
|
10
spec/classes/cinder_scheduler_spec.rb
Normal file
10
spec/classes/cinder_scheduler_spec.rb
Normal file
@ -0,0 +1,10 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'cinder::scheduler' do
|
||||
|
||||
let :facts do
|
||||
{:osfamily => 'Debian'}
|
||||
end
|
||||
it { should contain_package('cinder-scheduler') }
|
||||
it { should contain_service('cinder-scheduler') }
|
||||
end
|
11
spec/classes/cinder_setup_test_volume_spec.rb
Normal file
11
spec/classes/cinder_setup_test_volume_spec.rb
Normal file
@ -0,0 +1,11 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'cinder::setup_test_volume' do
|
||||
|
||||
it 'should contain volume creation execs' do
|
||||
should contain_exec('/bin/dd if=/dev/zero of=cinder-volumes bs=1 count=0 seek=4G')
|
||||
should contain_exec('/sbin/losetup /dev/loop2 cinder-volumes')
|
||||
should contain_exec('/sbin/pvcreate /dev/loop2')
|
||||
should contain_exec('/sbin/vgcreate cinder-volumes /dev/loop2')
|
||||
end
|
||||
end
|
31
spec/classes/cinder_volume_iscsi_spec.rb
Normal file
31
spec/classes/cinder_volume_iscsi_spec.rb
Normal file
@ -0,0 +1,31 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'cinder::volume::iscsi' do
|
||||
|
||||
let :req_params do
|
||||
{:iscsi_ip_address => '127.0.0.2'}
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{:osfamily => 'Debian'}
|
||||
end
|
||||
|
||||
describe 'with default params' do
|
||||
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
|
||||
it { should contain_cinder_config('DEFAULT/iscsi_ip_address').with(
|
||||
:value => '127.0.0.2'
|
||||
) }
|
||||
it { should contain_cinder_config('DEFAULT/iscsi_helper').with(
|
||||
:value => 'tgtadm'
|
||||
) }
|
||||
it { should contain_cinder_config('DEFAULT/volume_group').with(
|
||||
:value => 'cinder-volumes'
|
||||
) }
|
||||
|
||||
end
|
||||
|
||||
end
|
15
spec/classes/cinder_volume_spec.rb
Normal file
15
spec/classes/cinder_volume_spec.rb
Normal file
@ -0,0 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'cinder::volume' do
|
||||
|
||||
let :pre_condition do
|
||||
'class { "cinder::base": rabbit_password => "fpp", sql_connection => "mysql://a:b@c/d" }'
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{:osfamily => 'Debian'}
|
||||
end
|
||||
|
||||
it { should contain_package('cinder-volume') }
|
||||
it { should contain_service('cinder-volume') }
|
||||
end
|
1
spec/spec_helper.rb
Normal file
1
spec/spec_helper.rb
Normal file
@ -0,0 +1 @@
|
||||
require 'puppetlabs_spec_helper/module_spec_helper'
|
Loading…
x
Reference in New Issue
Block a user