Merge "Convert spec testing to use rspec-puppet-facts"

This commit is contained in:
Zuul 2018-11-13 18:44:32 +00:00 committed by Gerrit Code Review
commit 2062ead44e
63 changed files with 2352 additions and 2194 deletions

View File

@ -1,8 +1,7 @@
require 'spec_helper'
describe 'cinder::api' do
shared_examples_for 'cinder api' do
shared_examples 'cinder api' do
let :pre_condition do
"class { '::cinder::keystone::authtoken':
password => 'foo',
@ -13,7 +12,7 @@ describe 'cinder::api' do
{}
end
describe 'with only required params' do
context 'with only required params' do
let :params do
req_params
end
@ -62,7 +61,7 @@ describe 'cinder::api' do
end
end
describe 'with deprecated parameters' do
context 'with deprecated parameters' do
let :params do
req_params.merge({
'nova_catalog_info' => 'compute:nova:publicURL',
@ -82,7 +81,7 @@ describe 'cinder::api' do
end
end
describe 'with a custom region for nova' do
context 'with a custom region for nova' do
let :params do
req_params.merge({'os_region_name' => 'MyRegion'})
end
@ -93,7 +92,7 @@ describe 'cinder::api' do
end
end
describe 'with a customized port' do
context 'with a customized port' do
let :params do
req_params.merge({'osapi_volume_listen_port' => 9999})
end
@ -104,7 +103,7 @@ describe 'cinder::api' do
end
end
describe 'with a default volume type' do
context 'with a default volume type' do
let :params do
req_params.merge({'default_volume_type' => 'foo'})
end
@ -115,7 +114,7 @@ describe 'cinder::api' do
end
end
describe 'with only required params' do
context 'with only required params' do
let :params do
req_params.merge({'bind_host' => '192.168.1.3'})
end
@ -126,7 +125,7 @@ describe 'cinder::api' do
end
end
describe 'with sync_db set to false' do
context 'with sync_db set to false' do
let :params do
{
:enabled => true,
@ -136,7 +135,7 @@ describe 'cinder::api' do
it { is_expected.not_to contain_class('cinder::db::sync') }
end
describe 'with enabled false' do
context 'with enabled false' do
let :params do
req_params.merge({'enabled' => false})
end
@ -148,7 +147,7 @@ describe 'cinder::api' do
end
end
describe 'with manage_service false' do
context 'with manage_service false' do
let :params do
req_params.merge({'manage_service' => false})
end
@ -160,7 +159,7 @@ describe 'cinder::api' do
end
end
describe 'with ratelimits' do
context 'with ratelimits' do
let :params do
req_params.merge({ :ratelimits => '(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)' })
end
@ -170,7 +169,7 @@ describe 'cinder::api' do
)}
end
describe 'with encryption_auth_url' do
context 'with encryption_auth_url' do
let :params do
req_params.merge({ :keymgr_encryption_auth_url => 'http://localhost:5000/v3' })
end
@ -180,7 +179,7 @@ describe 'cinder::api' do
)}
end
describe 'while validating the service with default command' do
context 'while validating the service with default command' do
let :params do
req_params.merge({
:validate => true,
@ -192,7 +191,7 @@ describe 'cinder::api' do
)}
end
describe 'with a custom auth_strategy' do
context 'with a custom auth_strategy' do
let :params do
req_params.merge({'auth_strategy' => 'noauth'})
end
@ -203,7 +202,7 @@ describe 'cinder::api' do
end
end
describe 'with a custom osapi_max_limit' do
context 'with a custom osapi_max_limit' do
let :params do
req_params.merge({'osapi_max_limit' => '10000'})
end
@ -213,7 +212,7 @@ describe 'cinder::api' do
)
end
end
describe 'when running cinder-api in wsgi' do
context 'when running cinder-api in wsgi' do
let :params do
req_params.merge!({ :service_name => 'httpd' })
end
@ -235,7 +234,7 @@ describe 'cinder::api' do
end
end
describe 'when service_name is not valid' do
context 'when service_name is not valid' do
let :params do
req_params.merge!({ :service_name => 'foobar' })
end
@ -251,7 +250,7 @@ describe 'cinder::api' do
it_raises 'a Puppet::Error', /Invalid service_name/
end
describe 'with SSL socket options set' do
context 'with SSL socket options set' do
let :params do
req_params.merge!({
:use_ssl => true,
@ -266,7 +265,7 @@ describe 'cinder::api' do
it { is_expected.to contain_cinder_config('ssl/key_file').with_value('/path/to/key') }
end
describe 'with SSL socket options set wrongly configured' do
context 'with SSL socket options set wrongly configured' do
let :params do
req_params.merge!({
:use_ssl => true,
@ -278,7 +277,7 @@ describe 'cinder::api' do
it_raises 'a Puppet::Error', /The cert_file parameter is required when use_ssl is set to true/
end
describe 'with barbican parameters' do
context 'with barbican parameters' do
let :params do
req_params.merge!({
:keymgr_backend => 'castellan.key_manager.barbican_key_manager.BarbicanKeyManager',
@ -293,7 +292,7 @@ describe 'cinder::api' do
end
end
describe 'with barbican deprecated parameters' do
context 'with barbican deprecated parameters' do
let :params do
req_params.merge!({
:keymgr_api_class => 'castellan.key_manager.barbican_key_manager.BarbicanKeyManager',
@ -318,7 +317,7 @@ describe 'cinder::api' do
}))
end
it_configures 'cinder api'
it_behaves_like 'cinder api'
end
end
end

View File

@ -17,11 +17,9 @@
#
# Unit tests for cinder::backends class
#
require 'spec_helper'
describe 'cinder::backends' do
let :default_params do
{}
end
@ -30,7 +28,7 @@ describe 'cinder::backends' do
{}
end
shared_examples_for 'cinder backends' do
shared_examples 'cinder backends' do
let :p do
default_params.merge(params)
@ -80,8 +78,7 @@ describe 'cinder::backends' do
facts.merge!(OSDefaults.get_facts)
end
it_configures 'cinder backends'
it_behaves_like 'cinder backends'
end
end
end

View File

@ -17,11 +17,9 @@
#
# Unit tests for cinder::ceph class
#
require 'spec_helper'
describe 'cinder::backup::ceph' do
let :default_params do
{ :backup_ceph_conf => '/etc/ceph/ceph.conf',
:backup_ceph_user => 'cinder',
@ -35,7 +33,7 @@ describe 'cinder::backup::ceph' do
{}
end
shared_examples_for 'cinder backup with ceph' do
shared_examples 'cinder backup with ceph' do
let :p do
default_params.merge(params)
end
@ -78,7 +76,7 @@ describe 'cinder::backup::ceph' do
facts.merge(OSDefaults.get_facts({}))
end
it_configures 'cinder backup with ceph'
it_behaves_like 'cinder backup with ceph'
end
end
end

View File

@ -17,21 +17,21 @@
#
# Unit tests for cinder::backup:glusterfs class
#
require 'spec_helper'
describe 'cinder::backup::glusterfs' do
let :default_params do
{ :glusterfs_backup_mount_point => '<SERVICE DEFAULT>',
:glusterfs_backup_share => '<SERVICE DEFAULT>' }
{
:glusterfs_backup_mount_point => '<SERVICE DEFAULT>',
:glusterfs_backup_share => '<SERVICE DEFAULT>'
}
end
let :params do
{}
end
shared_examples_for 'cinder backup with glusterfs' do
shared_examples 'cinder backup with glusterfs' do
let :p do
default_params.merge(params)
end
@ -62,8 +62,7 @@ describe 'cinder::backup::glusterfs' do
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
end
it_configures 'cinder backup with glusterfs'
it_behaves_like 'cinder backup with glusterfs'
end
end
end

View File

@ -17,13 +17,12 @@
#
# Unit tests for cinder::backup::google class
#
require 'spec_helper'
describe 'cinder::backup::google' do
let :default_params do
{ :backup_gcs_bucket => '<SERVICE DEFAULT>',
{
:backup_gcs_bucket => '<SERVICE DEFAULT>',
:backup_gcs_object_size => '<SERVICE DEFAULT>',
:backup_gcs_block_size => '<SERVICE DEFAULT>',
:backup_gcs_reader_chunk_size => '<SERVICE DEFAULT>',
@ -35,14 +34,15 @@ describe 'cinder::backup::google' do
:backup_gcs_credential_file => '<SERVICE DEFAULT>',
:backup_gcs_project_id => '<SERVICE DEFAULT>',
:backup_gcs_user_agent => '<SERVICE DEFAULT>',
:backup_gcs_enable_progress_timer => '<SERVICE DEFAULT>' }
:backup_gcs_enable_progress_timer => '<SERVICE DEFAULT>'
}
end
let :params do
{}
end
shared_examples_for 'cinder backup with google cloud storage' do
shared_examples 'cinder backup with google cloud storage' do
let :p do
default_params.merge(params)
end
@ -106,8 +106,7 @@ describe 'cinder::backup::google' do
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
end
it_configures 'cinder backup with google cloud storage'
it_behaves_like 'cinder backup with google cloud storage'
end
end
end

View File

@ -19,11 +19,9 @@
# under the License.
#
#
require 'spec_helper'
describe 'cinder::backup::nfs' do
let :params do
{
:backup_share => '10.0.0.1:/nfs_backup',
@ -43,7 +41,7 @@ describe 'cinder::backup::nfs' do
}
end
shared_examples_for 'cinder backup with nfs' do
shared_examples 'cinder backup with nfs' do
let :all_params do
default_params.merge(params)
end
@ -75,7 +73,7 @@ describe 'cinder::backup::nfs' do
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
end
it_configures 'cinder backup with nfs'
it_behaves_like 'cinder backup with nfs'
end
end
end

View File

@ -21,20 +21,21 @@
require 'spec_helper'
describe 'cinder::backup::posix' do
let :default_params do
{ :backup_file_size => '<SERVICE DEFAULT>',
{
:backup_file_size => '<SERVICE DEFAULT>',
:backup_sha_block_size_bytes => '<SERVICE DEFAULT>',
:backup_enable_progress_timer => '<SERVICE DEFAULT>',
:backup_posix_path => '<SERVICE DEFAULT>',
:backup_container => '<SERVICE DEFAULT>' }
:backup_container => '<SERVICE DEFAULT>'
}
end
let :params do
{}
end
shared_examples_for 'cinder backup with posix' do
shared_examples 'cinder backup with posix' do
let :p do
default_params.merge(params)
end
@ -71,7 +72,7 @@ describe 'cinder::backup::posix' do
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
end
it_configures 'cinder backup with posix'
it_behaves_like 'cinder backup with posix'
end
end

View File

@ -21,20 +21,21 @@
require 'spec_helper'
describe 'cinder::backup' do
let :default_params do
{ :enable => true,
{
:enable => true,
:manage_service => true,
:backup_manager => '<SERVICE DEFAULT>',
:backup_api_class => '<SERVICE DEFAULT>',
:backup_name_template => '<SERVICE DEFAULT>' }
:backup_name_template => '<SERVICE DEFAULT>'
}
end
let :params do
{}
end
shared_examples_for 'cinder backup' do
shared_examples 'cinder backup' do
let :p do
default_params.merge(params)
end
@ -109,7 +110,7 @@ describe 'cinder::backup' do
end
end
it_configures 'cinder backup'
it_behaves_like 'cinder backup'
end
end
end

View File

@ -21,9 +21,9 @@
require 'spec_helper'
describe 'cinder::backup::swift' do
let :default_params do
{ :backup_swift_url => '<SERVICE DEFAULT>',
{
:backup_swift_url => '<SERVICE DEFAULT>',
:backup_swift_auth_url => '<SERVICE DEFAULT>',
:backup_swift_container => 'volumebackups',
:backup_swift_object_size => '<SERVICE DEFAULT>',
@ -32,14 +32,15 @@ describe 'cinder::backup::swift' do
:backup_swift_user_domain => '<SERVICE DEFAULT>',
:backup_swift_project_domain => '<SERVICE DEFAULT>',
:backup_swift_project => '<SERVICE DEFAULT>',
:backup_compression_algorithm => '<SERVICE DEFAULT>' }
:backup_compression_algorithm => '<SERVICE DEFAULT>'
}
end
let :params do
{}
end
shared_examples_for 'cinder backup with swift' do
shared_examples 'cinder backup with swift' do
let :p do
default_params.merge(params)
end
@ -88,8 +89,7 @@ describe 'cinder::backup::swift' do
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
end
it_configures 'cinder backup with swift'
it_behaves_like 'cinder backup with swift'
end
end
end

View File

@ -17,22 +17,22 @@
#
# Unit tests for cinder::backup:tsm class
#
require 'spec_helper'
describe 'cinder::backup::tsm' do
let :default_params do
{ :backup_tsm_volume_prefix => '<SERVICE DEFAULT>',
{
:backup_tsm_volume_prefix => '<SERVICE DEFAULT>',
:backup_tsm_password => '<SERVICE DEFAULT>',
:backup_tsm_compression => '<SERVICE DEFAULT>' }
:backup_tsm_compression => '<SERVICE DEFAULT>'
}
end
let :params do
{}
end
shared_examples_for 'cinder backup with tsm' do
shared_examples 'cinder backup with tsm' do
let :p do
default_params.merge(params)
end
@ -66,8 +66,7 @@ describe 'cinder::backup::tsm' do
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
end
it_configures 'cinder backup with tsm'
it_behaves_like 'cinder backup with tsm'
end
end
end

View File

@ -1,19 +1,23 @@
require 'spec_helper'
describe 'cinder::ceilometer' do
describe 'with default parameters' do
let :facts do
OSDefaults.get_facts({})
shared_examples 'cinder::ceilometer' do
context 'with default parameters' do
it { should contain_cinder_config('oslo_messaging_notifications/transport_url').with_value('<SERVICE DEFAULT>') }
it { should contain_cinder_config('oslo_messaging_notifications/driver').with_value('messagingv2') }
it { should contain_cinder_config('oslo_messaging_notifications/topics').with_value('<SERVICE DEFAULT>') }
end
end
it 'contains default values' do
is_expected.to contain_cinder_config('oslo_messaging_notifications/transport_url').with(
:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_notifications/driver').with(
:value => 'messagingv2')
is_expected.to contain_cinder_config('oslo_messaging_notifications/topics').with(
:value => '<SERVICE DEFAULT>')
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::ceilometer'
end
end
end

View File

@ -1,16 +1,17 @@
require 'spec_helper'
describe 'cinder::client' do
let :params do
{}
end
let :default_params do
{ :package_ensure => 'present' }
{
:package_ensure => 'present'
}
end
shared_examples_for 'cinder client' do
shared_examples 'cinder client' do
let :p do
default_params.merge(params)
end
@ -55,7 +56,7 @@ describe 'cinder::client' do
end
end
it_configures 'cinder client'
it_behaves_like 'cinder client'
end
end
end

View File

@ -1,7 +1,6 @@
require 'spec_helper'
describe 'cinder::config' do
let(:config_hash) do {
'DEFAULT/foo' => { 'value' => 'fooValue' },
'DEFAULT/bar' => { 'value' => 'barValue' },
@ -9,7 +8,7 @@ describe 'cinder::config' do
}
end
shared_examples_for 'cinder_config' do
shared_examples 'cinder_config' do
let :params do
{ :cinder_config => config_hash }
end
@ -23,7 +22,7 @@ describe 'cinder::config' do
end
end
shared_examples_for 'cinder_api_paste_ini' do
shared_examples 'cinder_api_paste_ini' do
let :params do
{ :api_paste_ini_config => config_hash }
end
@ -43,8 +42,8 @@ describe 'cinder::config' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'cinder_config'
it_configures 'cinder_api_paste_ini'
it_behaves_like 'cinder_config'
it_behaves_like 'cinder_api_paste_ini'
end
end
end

View File

@ -1,33 +1,44 @@
require 'spec_helper'
describe 'cinder::cron::db_purge' do
let :facts do
{ :osfamily => 'RedHat' }
end
let :params do
{ :minute => 1,
{
:minute => 1,
:hour => 0,
:monthday => '*',
:month => '*',
:weekday => '*',
:user => 'cinder',
:age => '30',
:destination => '/var/log/cinder/cinder-rowsflush.log' }
:destination => '/var/log/cinder/cinder-rowsflush.log'
}
end
it 'configures a cron' do
is_expected.to contain_cron('cinder-manage db purge').with(
:command => "cinder-manage db purge #{params[:age]} >>#{params[:destination]} 2>&1",
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => params[:user],
:minute => params[:minute],
:hour => params[:hour],
:monthday => params[:monthday],
:month => params[:month],
:weekday => params[:weekday],
:require => 'Anchor[cinder::install::end]'
)
shared_examples 'cinder::cron::db_purge' do
context 'with required parameters' do
it { should contain_cron('cinder-manage db purge').with(
:command => "cinder-manage db purge #{params[:age]} >>#{params[:destination]} 2>&1",
:environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
:user => params[:user],
:minute => params[:minute],
:hour => params[:hour],
:monthday => params[:monthday],
:month => params[:month],
:weekday => params[:weekday],
:require => 'Anchor[cinder::install::end]'
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::cron::db_purge'
end
end
end

View File

@ -1,88 +1,95 @@
require 'spec_helper'
describe 'cinder::db::mysql' do
let :req_params do
{:password => 'pw',
}
end
let :facts do
{:osfamily => 'Debian'}
{
:password => 'pw',
}
end
let :pre_condition do
'include mysql::server'
end
describe 'with only required params' do
let :params do
req_params
end
it { is_expected.to contain_openstacklib__db__mysql('cinder').with(
:user => 'cinder',
:password_hash => '*D821809F681A40A6E379B50D0463EFAE20BDD122',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
) }
end
shared_examples 'cinder::db::mysql' do
context 'with only required params' do
let :params do
req_params
end
describe "overriding allowed_hosts param to array" do
let :params do
{
:password => 'cinderpass',
:allowed_hosts => ['127.0.0.1','%']
}
it { should contain_openstacklib__db__mysql('cinder').with(
:user => 'cinder',
:password_hash => '*D821809F681A40A6E379B50D0463EFAE20BDD122',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
end
it { is_expected.to contain_openstacklib__db__mysql('cinder').with(
:user => 'cinder',
:password_hash => '*1C8A189441ED992638DD234B6711CD5064DA8C6E',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => ['127.0.0.1', '%']
) }
context "overriding allowed_hosts param to array" do
let :params do
{
:password => 'cinderpass',
:allowed_hosts => ['127.0.0.1','%']
}
end
end
describe "overriding allowed_hosts param to string" do
let :params do
{
:password => 'cinderpass2',
:allowed_hosts => '192.168.1.1'
}
it { should contain_openstacklib__db__mysql('cinder').with(
:user => 'cinder',
:password_hash => '*1C8A189441ED992638DD234B6711CD5064DA8C6E',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => ['127.0.0.1', '%']
)}
end
it { is_expected.to contain_openstacklib__db__mysql('cinder').with(
:user => 'cinder',
:password_hash => '*0E9E710049E74D36D29D615DFC55F3FFD45413BC',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '192.168.1.1',
) }
context "overriding allowed_hosts param to string" do
let :params do
{
:password => 'cinderpass2',
:allowed_hosts => '192.168.1.1'
}
end
end
describe "overriding allowed_hosts param equals to host param " do
let :params do
{
:password => 'cinderpass2',
:allowed_hosts => '127.0.0.1'
}
it { should contain_openstacklib__db__mysql('cinder').with(
:user => 'cinder',
:password_hash => '*0E9E710049E74D36D29D615DFC55F3FFD45413BC',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '192.168.1.1',
)}
end
it { is_expected.to contain_openstacklib__db__mysql('cinder').with(
:user => 'cinder',
:password_hash => '*0E9E710049E74D36D29D615DFC55F3FFD45413BC',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '127.0.0.1',
) }
context "overriding allowed_hosts param equals to host param " do
let :params do
{
:password => 'cinderpass2',
:allowed_hosts => '127.0.0.1'
}
end
it { should contain_openstacklib__db__mysql('cinder').with(
:user => 'cinder',
:password_hash => '*0E9E710049E74D36D29D615DFC55F3FFD45413BC',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:allowed_hosts => '127.0.0.1',
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::db::mysql'
end
end
end

View File

@ -1,8 +1,7 @@
require 'spec_helper'
describe 'cinder::db::postgresql' do
shared_examples_for 'cinder::db::postgresql' do
shared_examples 'cinder::db::postgresql' do
let :req_params do
{ :password => 'pw' }
end
@ -35,7 +34,7 @@ describe 'cinder::db::postgresql' do
}))
end
it_configures 'cinder::db::postgresql'
it_behaves_like 'cinder::db::postgresql'
end
end

View File

@ -1,12 +1,9 @@
require 'spec_helper'
describe 'cinder::db' do
shared_examples 'cinder::db' do
context 'with default parameters' do
it { is_expected.to contain_oslo__db('cinder_config').with(
it { should contain_oslo__db('cinder_config').with(
:db_max_retries => '<SERVICE DEFAULT>',
:connection => 'sqlite:////var/lib/cinder/cinder.sqlite',
:idle_timeout => '<SERVICE DEFAULT>',
@ -17,12 +14,12 @@ describe 'cinder::db' do
:max_overflow => '<SERVICE DEFAULT>',
:pool_timeout => '<SERVICE DEFAULT>',
)}
end
context 'with specific parameters' do
let :params do
{ :database_db_max_retries => '-1',
{
:database_db_max_retries => '-1',
:database_connection => 'mysql+pymysql://cinder:cinder@localhost/cinder',
:database_idle_timeout => '3601',
:database_min_pool_size => '2',
@ -30,10 +27,11 @@ describe 'cinder::db' do
:database_max_retries => '11',
:database_retry_interval => '11',
:database_max_overflow => '21',
:database_pool_timeout => '21', }
:database_pool_timeout => '21',
}
end
it { is_expected.to contain_oslo__db('cinder_config').with(
it { should contain_oslo__db('cinder_config').with(
:db_max_retries => '-1',
:connection => 'mysql+pymysql://cinder:cinder@localhost/cinder',
:idle_timeout => '3601',
@ -48,83 +46,79 @@ describe 'cinder::db' do
context 'with postgresql backend' do
let :params do
{ :database_connection => 'postgresql://cinder:cinder@localhost/cinder', }
end
it 'install the proper backend package' do
is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
{
:database_connection => 'postgresql://cinder:cinder@localhost/cinder'
}
end
it { should contain_package('python-psycopg2').with(:ensure => 'present') }
end
context 'with MySQL-python library as backend package' do
let :params do
{ :database_connection => 'mysql+pymysql://cinder:cinder@localhost/cinder', }
{
:database_connection => 'mysql+pymysql://cinder:cinder@localhost/cinder'
}
end
it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
it { should contain_package('python-mysqldb').with(:ensure => 'present') }
end
context 'with incorrect database_connection string' do
let :params do
{ :database_connection => 'redis://cinder:cinder@localhost/cinder', }
{
:database_connection => 'redis://cinder:cinder@localhost/cinder'
}
end
it_raises 'a Puppet::Error', /validate_re/
it { should raise_error(Puppet::Error, /validate_re/) }
end
context 'with incorrect pymysql database_connection string' do
let :params do
{ :database_connection => 'foo+pymysql://cinder:cinder@localhost/cinder', }
{
:database_connection => 'foo+pymysql://cinder:cinder@localhost/cinder'
}
end
it_raises 'a Puppet::Error', /validate_re/
end
end
context 'on Debian platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie'
})
end
it_configures 'cinder::db'
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://cinder:cinder@localhost/cinder', }
end
it 'install the proper backend package' do
is_expected.to contain_package('python-pymysql').with(
:ensure => 'present',
:name => 'python-pymysql',
:tag => 'openstack'
)
end
it { should raise_error(Puppet::Error, /validate_re/) }
end
end
context 'on Redhat platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'RedHat',
:operatingsystemrelease => '7.1',
})
shared_examples 'cinder::db on Debian' do
let :params do
{
:database_connection => 'mysql+pymysql://cinder:cinder@localhost/cinder'
}
end
it_configures 'cinder::db'
context 'using pymysql driver' do
let :params do
{ :database_connection => 'mysql+pymysql://cinder:cinder@localhost/cinder', }
end
end
it { should contain_package('python-pymysql').with(
:ensure => 'present',
:name => 'python-pymysql',
:tag => 'openstack'
)}
end
shared_examples 'cinder::db on RedHat' do
let :params do
{
:database_connection => 'mysql+pymysql://cinder:cinder@localhost/cinder'
}
end
it { should_not contain_package('python-pymysql') }
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::db'
it_behaves_like "cinder::db on #{facts[:osfamily]}"
end
end
end

View File

@ -1,9 +1,7 @@
require 'spec_helper'
describe 'cinder::db::sync' do
shared_examples_for 'cinder-dbsync' do
shared_examples 'cinder-dbsync' do
it 'runs cinder-manage db_sync' do
is_expected.to contain_exec('cinder-manage db_sync').with(
:command => 'cinder-manage db sync',
@ -21,7 +19,7 @@ describe 'cinder::db::sync' do
)
end
describe "overriding extra_params" do
context "overriding extra_params" do
let :params do
{
:extra_params => '--config-file /etc/cinder/cinder.conf',
@ -45,11 +43,10 @@ describe 'cinder::db::sync' do
)
}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
@ -59,8 +56,7 @@ describe 'cinder::db::sync' do
}))
end
it_configures 'cinder-dbsync'
it_behaves_like 'cinder-dbsync'
end
end
end

View File

@ -17,24 +17,24 @@
#
# Unit tests for cinder::glance class
#
require 'spec_helper'
describe 'cinder::glance' do
let :default_params do
{ :glance_api_version => '2',
{
:glance_api_version => '2',
:glance_num_retries => '<SERVICE DEFAULT>',
:glance_api_insecure => '<SERVICE DEFAULT>',
:glance_api_ssl_compression => '<SERVICE DEFAULT>',
:glance_request_timeout => '<SERVICE DEFAULT>' }
:glance_request_timeout => '<SERVICE DEFAULT>'
}
end
let :params do
{}
end
shared_examples_for 'cinder with glance' do
shared_examples 'cinder with glance' do
let :p do
default_params.merge(params)
end
@ -75,8 +75,7 @@ describe 'cinder::glance' do
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
end
it_configures 'cinder with glance'
it_behaves_like 'cinder with glance'
end
end
end

View File

@ -8,258 +8,256 @@ describe 'cinder' do
}
end
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => 'jessie',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } },
})
end
shared_examples 'cinder' do
context 'with only required params' do
let :params do
req_params
end
describe 'with only required params' do
let :params do
req_params
it { should contain_class('cinder::logging') }
it { should contain_class('cinder::params') }
it { should contain_class('mysql::bindings::python') }
it { should contain_resources('cinder_config').with_purge(false) }
it {
should contain_cinder_config('DEFAULT/transport_url').with(:value => '<SERVICE DEFAULT>')
should contain_cinder_config('DEFAULT/rpc_response_timeout').with(:value => '<SERVICE DEFAULT>')
should contain_cinder_config('DEFAULT/control_exchange').with(:value => 'openstack')
should contain_cinder_config('DEFAULT/report_interval').with(:value => '<SERVICE DEFAULT>')
should contain_cinder_config('DEFAULT/service_down_time').with(:value => '<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => '<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_rabbit/heartbeat_rate').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_rabbit/kombu_reconnect_delay').with(:value => '<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_rabbit/kombu_failover_strategy').with(:value => '<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_rabbit/kombu_compression').with(:value => '<SERVICE DEFAULT>')
should contain_cinder_config('DEFAULT/storage_availability_zone').with(:value => 'nova')
should contain_cinder_config('DEFAULT/default_availability_zone').with(:value => 'nova')
should contain_cinder_config('DEFAULT/allow_availability_zone_fallback').with(:value => '<SERVICE DEFAULT>')
should contain_cinder_config('DEFAULT/api_paste_config').with(:value => '/etc/cinder/api-paste.ini')
should contain_cinder_config('DEFAULT/host').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('DEFAULT/enable_new_services').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_concurrency/lock_path').with(:value => '/var/lock/cinder')
# backend_host should not be written to DEFAULT section
should_not contain_cinder_config('DEFAULT/backend_host')
}
end
it { is_expected.to contain_class('cinder::logging') }
it { is_expected.to contain_class('cinder::params') }
it { is_expected.to contain_class('mysql::bindings::python') }
context 'with enable ha queues' do
let :params do
req_params.merge( :rabbit_ha_queues => true )
end
it 'passes purge to resource' do
is_expected.to contain_resources('cinder_config').with({
:purge => false
})
it { should contain_cinder_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(true) }
end
it 'should contain default config' do
is_expected.to contain_cinder_config('DEFAULT/transport_url').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('DEFAULT/rpc_response_timeout').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('DEFAULT/control_exchange').with(:value => 'openstack')
is_expected.to contain_cinder_config('DEFAULT/report_interval').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('DEFAULT/service_down_time').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_rabbit/heartbeat_rate').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_rabbit/kombu_reconnect_delay').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_rabbit/kombu_failover_strategy').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_rabbit/kombu_compression').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('DEFAULT/storage_availability_zone').with(:value => 'nova')
is_expected.to contain_cinder_config('DEFAULT/default_availability_zone').with(:value => 'nova')
is_expected.to contain_cinder_config('DEFAULT/allow_availability_zone_fallback').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('DEFAULT/api_paste_config').with(:value => '/etc/cinder/api-paste.ini')
is_expected.to contain_cinder_config('DEFAULT/host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('DEFAULT/enable_new_services').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_concurrency/lock_path').with(:value => '/var/lock/cinder')
context 'with rabbitmq heartbeats' do
let :params do
req_params.merge( :rabbit_heartbeat_timeout_threshold => '60',
:rabbit_heartbeat_rate => '10' )
end
# backend_host should not be written to DEFAULT section
is_expected.to_not contain_cinder_config('DEFAULT/backend_host')
it { should contain_cinder_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60') }
it { should contain_cinder_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10') }
end
end
context 'with SSL enabled with kombu' do
let :params do
req_params.merge!({
:rabbit_use_ssl => true,
:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs',
:kombu_ssl_certfile => '/path/to/ssl/cert/file',
:kombu_ssl_keyfile => '/path/to/ssl/keyfile',
:kombu_ssl_version => 'TLSv1'
})
end
describe 'with enable ha queues' do
let :params do
req_params.merge({'rabbit_ha_queues' => true})
end
it 'should contain rabbit_ha_queues' do
is_expected.to contain_cinder_config('oslo_messaging_rabbit/rabbit_ha_queues').with(:value => true)
end
end
describe 'with rabbitmq heartbeats' do
let :params do
req_params.merge({'rabbit_heartbeat_timeout_threshold' => '60', 'rabbit_heartbeat_rate' => '10'})
end
it 'should contain heartbeat config' do
is_expected.to contain_cinder_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60')
is_expected.to contain_cinder_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10')
end
end
describe 'with SSL enabled with kombu' do
let :params do
req_params.merge!({
it { should contain_oslo__messaging__rabbit('cinder_config').with(
:rabbit_use_ssl => true,
:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs',
:kombu_ssl_certfile => '/path/to/ssl/cert/file',
:kombu_ssl_keyfile => '/path/to/ssl/keyfile',
:kombu_ssl_version => 'TLSv1'
})
)}
end
it { is_expected.to contain_oslo__messaging__rabbit('cinder_config').with(
:rabbit_use_ssl => true,
:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs',
:kombu_ssl_certfile => '/path/to/ssl/cert/file',
:kombu_ssl_keyfile => '/path/to/ssl/keyfile',
:kombu_ssl_version => 'TLSv1'
)}
end
context 'with SSL enabled without kombu' do
let :params do
req_params.merge!({
:rabbit_use_ssl => true,
})
end
describe 'with SSL enabled without kombu' do
let :params do
req_params.merge!({
it { should contain_oslo__messaging__rabbit('cinder_config').with(
:rabbit_use_ssl => true,
})
)}
end
it { is_expected.to contain_oslo__messaging__rabbit('cinder_config').with(
:rabbit_use_ssl => true,
)}
end
context 'with SSL disabled' do
let :params do
req_params.merge!({
:rabbit_use_ssl => false,
:kombu_ssl_ca_certs => '<SERVICE DEFAULT>',
:kombu_ssl_certfile => '<SERVICE DEFAULT>',
:kombu_ssl_keyfile => '<SERVICE DEFAULT>',
:kombu_ssl_version => '<SERVICE DEFAULT>'
})
end
describe 'with SSL disabled' do
let :params do
req_params.merge!({
it { should contain_oslo__messaging__rabbit('cinder_config').with(
:rabbit_use_ssl => false,
:kombu_ssl_ca_certs => '<SERVICE DEFAULT>',
:kombu_ssl_certfile => '<SERVICE DEFAULT>',
:kombu_ssl_keyfile => '<SERVICE DEFAULT>',
:kombu_ssl_version => '<SERVICE DEFAULT>'
})
)}
end
it { is_expected.to contain_oslo__messaging__rabbit('cinder_config').with(
:rabbit_use_ssl => false,
:kombu_ssl_ca_certs => '<SERVICE DEFAULT>',
:kombu_ssl_certfile => '<SERVICE DEFAULT>',
:kombu_ssl_keyfile => '<SERVICE DEFAULT>',
:kombu_ssl_version => '<SERVICE DEFAULT>'
)}
end
context 'with different lock_path' do
let :params do
req_params.merge!( :lock_path => '/var/run/cinder.locks' )
end
describe 'with different lock_path' do
let(:params) { req_params.merge!({:lock_path => '/var/run/cinder.locks'}) }
it { is_expected.to contain_cinder_config('oslo_concurrency/lock_path').with_value('/var/run/cinder.locks') }
end
describe 'with amqp_durable_queues disabled' do
let :params do
req_params
it { should contain_cinder_config('oslo_concurrency/lock_path').with_value('/var/run/cinder.locks') }
end
it { is_expected.to contain_cinder_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('<SERVICE DEFAULT>') }
end
context 'with amqp_durable_queues disabled' do
let :params do
req_params
end
describe 'with amqp_durable_queues enabled' do
let :params do
req_params.merge({
:amqp_durable_queues => true,
})
it { should contain_cinder_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('<SERVICE DEFAULT>') }
end
it { is_expected.to contain_cinder_config('oslo_messaging_rabbit/amqp_durable_queues').with_value(true) }
end
context 'with amqp_durable_queues enabled' do
let :params do
req_params.merge({
:amqp_durable_queues => true,
})
end
describe 'with amqp defaults' do
it 'configures amqp' do
is_expected.to contain_cinder_config('oslo_messaging_amqp/server_request_prefix').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/broadcast_prefix').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/group_request_prefix').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/container_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/idle_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/trace').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/ssl_ca_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/ssl_cert_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/ssl_key_file').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/ssl_key_password').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/allow_insecure_clients').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/sasl_mechanisms').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/sasl_config_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/sasl_config_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/username').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/password').with_value('<SERVICE DEFAULT>')
end
end
describe 'with amqp overrides' do
let :params do
{
:amqp_idle_timeout => '60',
:amqp_trace => true,
:amqp_ssl_ca_file => '/path/to/ca.cert',
:amqp_ssl_cert_file => '/path/to/certfile',
:amqp_ssl_key_file => '/path/to/key',
:amqp_username => 'amqp_user',
:amqp_password => 'password',
}
it { should contain_cinder_config('oslo_messaging_rabbit/amqp_durable_queues').with_value(true) }
end
it do
is_expected.to contain_cinder_config('oslo_messaging_amqp/server_request_prefix').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/broadcast_prefix').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/group_request_prefix').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/container_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/idle_timeout').with_value('60')
is_expected.to contain_cinder_config('oslo_messaging_amqp/trace').with_value('true')
is_expected.to contain_cinder_config('oslo_messaging_amqp/ssl_ca_file').with_value('/path/to/ca.cert')
is_expected.to contain_cinder_config('oslo_messaging_amqp/ssl_cert_file').with_value('/path/to/certfile')
is_expected.to contain_cinder_config('oslo_messaging_amqp/ssl_key_file').with_value('/path/to/key')
is_expected.to contain_cinder_config('oslo_messaging_amqp/allow_insecure_clients').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/sasl_mechanisms').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/sasl_config_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/sasl_config_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('oslo_messaging_amqp/username').with_value('amqp_user')
is_expected.to contain_cinder_config('oslo_messaging_amqp/password').with_value('password')
end
end
describe 'with postgresql' do
let :params do
{
:database_connection => 'postgresql://user:drowssap@host/database',
context 'with amqp defaults' do
it {
should contain_cinder_config('oslo_messaging_amqp/server_request_prefix').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/broadcast_prefix').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/group_request_prefix').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/container_name').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/idle_timeout').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/trace').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/ssl_ca_file').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/ssl_cert_file').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/ssl_key_file').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/ssl_key_password').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/allow_insecure_clients').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/sasl_mechanisms').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/sasl_config_dir').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/sasl_config_name').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/username').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/password').with_value('<SERVICE DEFAULT>')
}
end
it { is_expected.to_not contain_class('mysql::python') }
it { is_expected.to_not contain_class('mysql::bindings') }
it { is_expected.to_not contain_class('mysql::bindings::python') }
end
describe 'with APIs set for Mitaka (proposed)' do
let :params do
context 'with amqp overrides' do
let :params do
{
:enable_v3_api => true,
:amqp_idle_timeout => '60',
:amqp_trace => true,
:amqp_ssl_ca_file => '/path/to/ca.cert',
:amqp_ssl_cert_file => '/path/to/certfile',
:amqp_ssl_key_file => '/path/to/key',
:amqp_username => 'amqp_user',
:amqp_password => 'password',
}
end
it {
should contain_cinder_config('oslo_messaging_amqp/server_request_prefix').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/broadcast_prefix').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/group_request_prefix').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/container_name').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/idle_timeout').with_value('60')
should contain_cinder_config('oslo_messaging_amqp/trace').with_value('true')
should contain_cinder_config('oslo_messaging_amqp/ssl_ca_file').with_value('/path/to/ca.cert')
should contain_cinder_config('oslo_messaging_amqp/ssl_cert_file').with_value('/path/to/certfile')
should contain_cinder_config('oslo_messaging_amqp/ssl_key_file').with_value('/path/to/key')
should contain_cinder_config('oslo_messaging_amqp/allow_insecure_clients').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/sasl_mechanisms').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/sasl_config_dir').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/sasl_config_name').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('oslo_messaging_amqp/username').with_value('amqp_user')
should contain_cinder_config('oslo_messaging_amqp/password').with_value('password')
}
end
it { is_expected.to contain_cinder_config('DEFAULT/enable_v3_api').with_value(true) }
context 'with postgresql' do
let :params do
{
:database_connection => 'postgresql://user:drowssap@host/database',
}
end
end
describe 'with image_conversion_dir' do
let :params do
req_params.merge({
:image_conversion_dir => '/tmp/foo',
})
it { should_not contain_class('mysql::python') }
it { should_not contain_class('mysql::bindings') }
it { should_not contain_class('mysql::bindings::python') }
end
it { is_expected.to contain_cinder_config('DEFAULT/image_conversion_dir').with_value('/tmp/foo') }
end
context 'with APIs set for Mitaka (proposed)' do
let :params do
{
:enable_v3_api => true,
}
end
describe 'with host and enable_new_services' do
let :params do
req_params.merge({
:host => 'mystring',
:enable_new_services => true,
})
it { should contain_cinder_config('DEFAULT/enable_v3_api').with_value(true) }
end
it { is_expected.to contain_cinder_config('DEFAULT/host').with_value('mystring') }
it { is_expected.to contain_cinder_config('DEFAULT/enable_new_services').with_value(true) }
end
context 'with image_conversion_dir' do
let :params do
req_params.merge({
:image_conversion_dir => '/tmp/foo',
})
end
describe 'with transport_url' do
let :params do
req_params.merge({
:default_transport_url => 'rabbit://rabbit_user:password@localhost:5673',
})
it { should contain_cinder_config('DEFAULT/image_conversion_dir').with_value('/tmp/foo') }
end
it { is_expected.to contain_cinder_config('DEFAULT/transport_url').with_value('rabbit://rabbit_user:password@localhost:5673') }
context 'with host and enable_new_services' do
let :params do
req_params.merge({
:host => 'mystring',
:enable_new_services => true,
})
end
it { should contain_cinder_config('DEFAULT/host').with_value('mystring') }
it { should contain_cinder_config('DEFAULT/enable_new_services').with_value(true) }
end
context 'with transport_url' do
let :params do
req_params.merge({
:default_transport_url => 'rabbit://rabbit_user:password@localhost:5673',
})
end
it { should contain_cinder_config('DEFAULT/transport_url').with_value('rabbit://rabbit_user:password@localhost:5673') }
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder'
end
end
end

View File

@ -1,202 +1,208 @@
require 'spec_helper'
describe 'cinder::keystone::auth' do
let :params do
{:password => 'pw'}
{
:password => 'pw'
}
end
context 'with required parameters' do
it 'configures keystone user and service' do
is_expected.to contain_keystone_user('cinder').with(
shared_examples 'cinder::keystone::auth' do
context 'with required parameters' do
it { should contain_keystone_user('cinder').with(
:ensure => 'present',
:password => 'pw',
:email => 'cinder@localhost',
)
is_expected.to contain_keystone_user_role('cinder@services').with(
)}
it { should contain_keystone_user_role('cinder@services').with(
:ensure => 'present',
:roles => ['admin']
)
is_expected.to contain_keystone_service('cinder::volume').with(
)}
it { should contain_keystone_service('cinder::volume').with(
:ensure => 'present',
:description => 'Cinder Service'
)
is_expected.to contain_keystone_service('cinderv2::volumev2').with(
)}
it { should contain_keystone_service('cinderv2::volumev2').with(
:ensure => 'present',
:description => 'Cinder Service v2'
)
is_expected.to contain_keystone_service('cinderv3::volumev3').with(
)}
it { should contain_keystone_service('cinderv3::volumev3').with(
:ensure => 'present',
:description => 'Cinder Service v3'
)
)}
end
it 'configures keystone endpoints' do
is_expected.to contain_keystone_endpoint('RegionOne/cinder::volume').with(
it { should contain_keystone_endpoint('RegionOne/cinder::volume').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'
)
)}
is_expected.to contain_keystone_endpoint('RegionOne/cinderv2::volumev2').with(
it { should contain_keystone_endpoint('RegionOne/cinderv2::volumev2').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:8776/v2/%(tenant_id)s',
:admin_url => 'http://127.0.0.1:8776/v2/%(tenant_id)s',
:internal_url => 'http://127.0.0.1:8776/v2/%(tenant_id)s'
)
)}
is_expected.to contain_keystone_endpoint('RegionOne/cinderv3::volumev3').with(
it { should contain_keystone_endpoint('RegionOne/cinderv3::volumev3').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:8776/v3/%(tenant_id)s',
:admin_url => 'http://127.0.0.1:8776/v3/%(tenant_id)s',
:internal_url => 'http://127.0.0.1:8776/v3/%(tenant_id)s'
)
end
end
context 'when overriding parameters' do
before do
params.merge!({
:region => 'RegionThree',
:public_url => 'https://10.0.42.1:4242/v41/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v41/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v41/%(tenant_id)s',
:public_url_v2 => 'https://10.0.42.1:4242/v42/%(tenant_id)s',
:admin_url_v2 => 'https://10.0.42.2:4242/v42/%(tenant_id)s',
:internal_url_v2 => 'https://10.0.42.3:4242/v42/%(tenant_id)s',
:public_url_v3 => 'https://10.0.42.1:4242/v43/%(tenant_id)s',
:admin_url_v3 => 'https://10.0.42.2:4242/v43/%(tenant_id)s',
:internal_url_v3 => 'https://10.0.42.3:4242/v43/%(tenant_id)s'
})
end
it 'configures keystone endpoints' do
is_expected.to contain_keystone_endpoint('RegionThree/cinder::volume').with(
:ensure => 'present',
:public_url => 'https://10.0.42.1:4242/v41/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v41/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v41/%(tenant_id)s'
)
is_expected.to contain_keystone_endpoint('RegionThree/cinderv2::volumev2').with(
:ensure => 'present',
:public_url => 'https://10.0.42.1:4242/v42/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v42/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v42/%(tenant_id)s'
)
is_expected.to contain_keystone_endpoint('RegionThree/cinderv3::volumev3').with(
:ensure => 'present',
:public_url => 'https://10.0.42.1:4242/v43/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v43/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v43/%(tenant_id)s'
)
end
end
describe 'when endpoint is_expected.to not be configured' do
before do
params.merge!(
:configure_endpoint => false,
:configure_endpoint_v2 => false,
:configure_endpoint_v3 => false
)
end
it { is_expected.to_not contain_keystone_endpoint('RegionOne/cinder::volume') }
it { is_expected.to_not contain_keystone_endpoint('RegionOne/cinderv2::volumev2') }
it { is_expected.to_not contain_keystone_endpoint('RegionOne/cinderv3::volumev3') }
end
describe 'when user is_expected.to not be configured' do
before do
params.merge!(
:configure_user => false
)
)}
end
it { is_expected.to_not contain_keystone_user('cinder') }
it { is_expected.to contain_keystone_user_role('cinder@services') }
it { is_expected.to contain_keystone_service('cinder::volume').with(
context 'when overriding parameters' do
before do
params.merge!({
:region => 'RegionThree',
:public_url => 'https://10.0.42.1:4242/v41/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v41/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v41/%(tenant_id)s',
:public_url_v2 => 'https://10.0.42.1:4242/v42/%(tenant_id)s',
:admin_url_v2 => 'https://10.0.42.2:4242/v42/%(tenant_id)s',
:internal_url_v2 => 'https://10.0.42.3:4242/v42/%(tenant_id)s',
:public_url_v3 => 'https://10.0.42.1:4242/v43/%(tenant_id)s',
:admin_url_v3 => 'https://10.0.42.2:4242/v43/%(tenant_id)s',
:internal_url_v3 => 'https://10.0.42.3:4242/v43/%(tenant_id)s'
})
end
it { should contain_keystone_endpoint('RegionThree/cinder::volume').with(
:ensure => 'present',
:public_url => 'https://10.0.42.1:4242/v41/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v41/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v41/%(tenant_id)s'
)}
it { should contain_keystone_endpoint('RegionThree/cinderv2::volumev2').with(
:ensure => 'present',
:public_url => 'https://10.0.42.1:4242/v42/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v42/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v42/%(tenant_id)s'
)}
it { should contain_keystone_endpoint('RegionThree/cinderv3::volumev3').with(
:ensure => 'present',
:public_url => 'https://10.0.42.1:4242/v43/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v43/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v43/%(tenant_id)s'
)}
end
context 'when endpoint should not be configured' do
before do
params.merge!(
:configure_endpoint => false,
:configure_endpoint_v2 => false,
:configure_endpoint_v3 => false
)
end
it { should_not contain_keystone_endpoint('RegionOne/cinder::volume') }
it { should_not contain_keystone_endpoint('RegionOne/cinderv2::volumev2') }
it { should_not contain_keystone_endpoint('RegionOne/cinderv3::volumev3') }
end
context 'when user should not be configured' do
before do
params.merge!(
:configure_user => false
)
end
it { should_not contain_keystone_user('cinder') }
it { should contain_keystone_user_role('cinder@services') }
it { should contain_keystone_service('cinder::volume').with(
:ensure => 'present',
:description => 'Cinder Service'
) }
end
describe 'when user and user role is_expected.to not be configured' do
before do
params.merge!(
:configure_user => false,
:configure_user_role => false
)
)}
end
it { is_expected.to_not contain_keystone_user('cinder') }
it { is_expected.to_not contain_keystone_user_role('cinder@services') }
it { is_expected.to contain_keystone_service('cinder::volume').with(
context 'when user and user role should not be configured' do
before do
params.merge!(
:configure_user => false,
:configure_user_role => false
)
end
it { should_not contain_keystone_user('cinder') }
it { should_not contain_keystone_user_role('cinder@services') }
it { should contain_keystone_service('cinder::volume').with(
:ensure => 'present',
:description => 'Cinder Service'
) }
end
describe 'when user and user role for v2 is_expected.to be configured' do
before do
params.merge!(
:configure_user_v2 => true,
:configure_user_role_v2 => true,
)
)}
end
it { is_expected.to contain_keystone__resource__service_identity('cinderv2').with(
:configure_user => true,
:configure_user_role => true,
:email => 'cinderv2@localhost',
:tenant => 'services'
) }
context 'when user and user role for v2 should be configured' do
before do
params.merge!(
:configure_user_v2 => true,
:configure_user_role_v2 => true,
)
end
end
describe 'when user and user role for v3 is_expected.to be configured' do
before do
params.merge!(
:configure_user_v3 => true,
:configure_user_role_v3 => true,
)
it { should contain_keystone__resource__service_identity('cinderv2').with(
:configure_user => true,
:configure_user_role => true,
:email => 'cinderv2@localhost',
:tenant => 'services'
)}
end
it { is_expected.to contain_keystone__resource__service_identity('cinderv3').with(
:configure_user => true,
:configure_user_role => true,
:email => 'cinderv3@localhost',
:tenant => 'services'
) }
context 'when user and user role for v3 should be configured' do
before do
params.merge!(
:configure_user_v3 => true,
:configure_user_role_v3 => true,
)
end
end
describe 'when overriding service names' do
before do
params.merge!(
:service_name => 'cinder_service',
:service_name_v2 => 'cinder_service_v2',
:service_name_v3 => 'cinder_service_v3',
)
it { should contain_keystone__resource__service_identity('cinderv3').with(
:configure_user => true,
:configure_user_role => true,
:email => 'cinderv3@localhost',
:tenant => 'services'
)}
end
it { is_expected.to contain_keystone_user('cinder') }
it { is_expected.to contain_keystone_user_role('cinder@services') }
it { is_expected.to contain_keystone_service('cinder_service::volume') }
it { is_expected.to contain_keystone_service('cinder_service_v2::volumev2') }
it { is_expected.to contain_keystone_service('cinder_service_v3::volumev3') }
it { is_expected.to contain_keystone_endpoint('RegionOne/cinder_service::volume') }
it { is_expected.to contain_keystone_endpoint('RegionOne/cinder_service_v2::volumev2') }
it { is_expected.to contain_keystone_endpoint('RegionOne/cinder_service_v3::volumev3') }
context 'when overriding service names' do
before do
params.merge!(
:service_name => 'cinder_service',
:service_name_v2 => 'cinder_service_v2',
:service_name_v3 => 'cinder_service_v3',
)
end
it { should contain_keystone_user('cinder') }
it { should contain_keystone_user_role('cinder@services') }
it { should contain_keystone_service('cinder_service::volume') }
it { should contain_keystone_service('cinder_service_v2::volumev2') }
it { should contain_keystone_service('cinder_service_v3::volumev3') }
it { should contain_keystone_endpoint('RegionOne/cinder_service::volume') }
it { should contain_keystone_endpoint('RegionOne/cinder_service_v2::volumev2') }
it { should contain_keystone_endpoint('RegionOne/cinder_service_v3::volumev3') }
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::keystone::auth'
end
end
end

View File

@ -1,15 +1,14 @@
require 'spec_helper'
describe 'cinder::keystone::authtoken' do
let :params do
{ :password => 'cinder_password', }
{
:password => 'cinder_password',
}
end
shared_examples 'cinder authtoken' do
context 'with default parameters' do
it 'configure keystone_authtoken' do
is_expected.to contain_cinder_config('keystone_authtoken/username').with_value('cinder')
is_expected.to contain_cinder_config('keystone_authtoken/password').with_value('cinder_password')
@ -137,8 +136,7 @@ describe 'cinder::keystone::authtoken' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'cinder authtoken'
it_behaves_like 'cinder authtoken'
end
end
end

View File

@ -1,7 +1,6 @@
require 'spec_helper'
describe 'cinder::logging' do
let :params do
{
}
@ -33,7 +32,7 @@ describe 'cinder::logging' do
}
end
shared_examples_for 'cinder-logging' do
shared_examples 'cinder-logging' do
context 'with basic logging options and default settings' do
it_behaves_like 'basic default logging settings'
@ -82,7 +81,7 @@ describe 'cinder::logging' do
end
end
shared_examples_for 'logging params set' do
shared_examples 'logging params set' do
it 'enables logging params' do
is_expected.to contain_oslo__log('cinder_config').with(
:logging_context_format_string =>
@ -104,7 +103,7 @@ describe 'cinder::logging' do
end
end
shared_examples_for 'logging params unset' do
shared_examples 'logging params unset' do
[ :logging_context_format_string, :logging_default_format_string,
:logging_debug_format_suffix, :logging_exception_prefix,
:log_config_append, :publish_errors,
@ -126,5 +125,4 @@ describe 'cinder::logging' do
it_behaves_like 'cinder-logging'
end
end
end

View File

@ -65,5 +65,4 @@ describe 'cinder::nova' do
it_behaves_like 'cinder::nova'
end
end
end

View File

@ -1,12 +0,0 @@
require 'spec_helper'
describe 'cinder::params' do
let :facts do
{:osfamily => 'Debian'}
end
it 'should compile' do
subject
end
end

View File

@ -1,8 +1,7 @@
require 'spec_helper'
describe 'cinder::policy' do
shared_examples_for 'cinder policies' do
shared_examples 'cinder policies' do
let :params do
{
:policy_path => '/etc/cinder/policy.json',
@ -36,7 +35,7 @@ describe 'cinder::policy' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'cinder policies'
it_behaves_like 'cinder policies'
end
end
end

View File

@ -2,17 +2,19 @@ require 'spec_helper'
describe 'cinder::quota' do
let :default_params do
{ :quota_volumes => '<SERVICE DEFAULT>',
{
:quota_volumes => '<SERVICE DEFAULT>',
:quota_snapshots => '<SERVICE DEFAULT>',
:quota_gigabytes => '<SERVICE DEFAULT>',
:quota_driver => '<SERVICE DEFAULT>' }
:quota_driver => '<SERVICE DEFAULT>'
}
end
let :params do
{}
end
shared_examples_for 'cinder quota' do
shared_examples 'cinder quota' do
let :p do
default_params.merge(params)
@ -49,8 +51,7 @@ describe 'cinder::quota' do
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
end
it_configures 'cinder quota'
it_behaves_like 'cinder quota'
end
end
end

View File

@ -1,16 +1,17 @@
require 'spec_helper'
describe 'cinder::scheduler::filter' do
let :default_params do
{ :scheduler_default_filters => '<SERVICE DEFAULT>' }
{
:scheduler_default_filters => '<SERVICE DEFAULT>'
}
end
let :params do
{}
end
shared_examples_for 'cinder scheduler filter' do
shared_examples 'cinder scheduler filter' do
let :p do
default_params.merge(params)
@ -54,8 +55,7 @@ describe 'cinder::scheduler::filter' do
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
end
it_configures 'cinder scheduler filter'
it_behaves_like 'cinder scheduler filter'
end
end
end

View File

@ -1,87 +1,80 @@
require 'spec_helper'
describe 'cinder::scheduler' do
shared_examples 'cinder::scheduler on Debian' do
context 'with default parameters' do
it { should contain_class('cinder::params') }
it { should contain_cinder_config('DEFAULT/scheduler_driver').with_value('<SERVICE DEFAULT>') }
describe 'on debian platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } },
})
end
describe 'with default parameters' do
it { is_expected.to contain_class('cinder::params') }
it { is_expected.to contain_cinder_config('DEFAULT/scheduler_driver').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_package('cinder-scheduler').with(
it { should contain_package('cinder-scheduler').with(
:name => 'cinder-scheduler',
:ensure => 'present',
:tag => ['openstack', 'cinder-package'],
) }
)}
it { is_expected.to contain_service('cinder-scheduler').with(
it { should contain_service('cinder-scheduler').with(
:name => 'cinder-scheduler',
:enable => true,
:ensure => 'running',
:hasstatus => true,
:tag => 'cinder-service',
) }
)}
end
describe 'with parameters' do
context 'with parameters' do
let :params do
{ :scheduler_driver => 'cinder.scheduler.filter_scheduler.FilterScheduler',
{
:scheduler_driver => 'cinder.scheduler.filter_scheduler.FilterScheduler',
:package_ensure => 'present'
}
end
it { is_expected.to contain_cinder_config('DEFAULT/scheduler_driver').with_value('cinder.scheduler.filter_scheduler.FilterScheduler') }
it { is_expected.to contain_package('cinder-scheduler').with_ensure('present') }
it { should contain_cinder_config('DEFAULT/scheduler_driver').with_value('cinder.scheduler.filter_scheduler.FilterScheduler') }
it { should contain_package('cinder-scheduler').with_ensure('present') }
end
describe 'with manage_service false' do
context 'with manage_service false' do
let :params do
{ 'manage_service' => false
{
:manage_service => false
}
end
it 'should not change the state of the service' do
is_expected.to contain_service('cinder-scheduler').without_ensure
end
it { should contain_service('cinder-scheduler').without_ensure }
end
end
shared_examples 'cinder::scheduler on RedHat' do
context 'with default parameters' do
it { should contain_class('cinder::params') }
describe 'on rhel platforms' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'RedHat',
:os => { :name => 'CentOS', :family => 'RedHat', :release => { :major => '7', :minor => '0' } },
})
it { should contain_service('cinder-scheduler').with(
:name => 'openstack-cinder-scheduler',
:enable => true,
:ensure => 'running',
)}
end
describe 'with default parameters' do
it { is_expected.to contain_class('cinder::params') }
it { is_expected.to contain_service('cinder-scheduler').with(
:name => 'openstack-cinder-scheduler',
:enable => true,
:ensure => 'running',
) }
end
describe 'with parameters' do
context 'with parameters' do
let :params do
{ :scheduler_driver => 'cinder.scheduler.filter_scheduler.FilterScheduler' }
{
:scheduler_driver => 'cinder.scheduler.filter_scheduler.FilterScheduler'
}
end
it { is_expected.to contain_cinder_config('DEFAULT/scheduler_driver').with_value('cinder.scheduler.filter_scheduler.FilterScheduler') }
it { should contain_cinder_config('DEFAULT/scheduler_driver').with_value('cinder.scheduler.filter_scheduler.FilterScheduler') }
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like "cinder::scheduler on #{facts[:osfamily]}"
end
end
end

View File

@ -1,23 +1,31 @@
require 'spec_helper'
describe 'cinder::setup_test_volume' do
shared_examples 'cinder::setup_test_volume' do
it { should contain_package('lvm2').with_ensure('present') }
it { is_expected.to contain_package('lvm2').with(
:ensure => 'present',
) }
it { should contain_exec('create_/var/lib/cinder/cinder-volumes').with(
:command => 'dd if=/dev/zero of="/var/lib/cinder/cinder-volumes" bs=1 count=0 seek=4G'
)}
it 'should contain volume creation execs' do
is_expected.to contain_exec('create_/var/lib/cinder/cinder-volumes').with(
:command => 'dd if=/dev/zero of="/var/lib/cinder/cinder-volumes" bs=1 count=0 seek=4G'
)
is_expected.to contain_exec('losetup /dev/loop2 /var/lib/cinder/cinder-volumes')
is_expected.to contain_exec('pvcreate /dev/loop2')
is_expected.to contain_exec('vgcreate cinder-volumes /dev/loop2')
it {
should contain_exec('losetup /dev/loop2 /var/lib/cinder/cinder-volumes')
should contain_exec('pvcreate /dev/loop2')
should contain_exec('vgcreate cinder-volumes /dev/loop2')
}
it { should contain_file('/var/lib/cinder/cinder-volumes').with_mode('0640') }
end
it 'should set 0640 permissions for cinder-volumes' do
is_expected.to contain_file('/var/lib/cinder/cinder-volumes').with(
:mode => '0640'
)
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::setup_test_volume'
end
end
end

View File

@ -1,28 +1,44 @@
require 'spec_helper'
describe 'cinder::vmware' do
shared_examples 'cinder::vmware' do
context 'with defaults' do
it { should contain_cinder_type('vmware-thin').with(
:ensure => :present,
:properties => ['vmware:vmdk_type=thin']
)}
describe 'with defaults' do
it 'should create vmware special types' do
is_expected.to contain_cinder_type('vmware-thin').with(
:ensure => :present,
:properties => ['vmware:vmdk_type=thin'])
it { should contain_cinder_type('vmware-thick').with(
:ensure => :present,
:properties => ['vmware:vmdk_type=thick']
)}
is_expected.to contain_cinder_type('vmware-thick').with(
:ensure => :present,
:properties => ['vmware:vmdk_type=thick'])
it { should contain_cinder_type('vmware-eagerZeroedThick').with(
:ensure => :present,
:properties => ['vmware:vmdk_type=eagerZeroedThick']
)}
is_expected.to contain_cinder_type('vmware-eagerZeroedThick').with(
:ensure => :present,
:properties => ['vmware:vmdk_type=eagerZeroedThick'])
it { should contain_cinder_type('vmware-full').with(
:ensure => :present,
:properties => ['vmware:clone_type=full']
)}
is_expected.to contain_cinder_type('vmware-full').with(
:ensure => :present,
:properties => ['vmware:clone_type=full'])
it { should contain_cinder_type('vmware-linked').with(
:ensure => :present,
:properties => ['vmware:clone_type=linked']
)}
end
end
is_expected.to contain_cinder_type('vmware-linked').with(
:ensure => :present,
:properties => ['vmware:clone_type=linked'])
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::vmware'
end
end
end

View File

@ -1,48 +1,66 @@
require 'spec_helper'
describe 'cinder::volume' do
let :pre_condition do
'class { "cinder": database_connection => "mysql://a:b@c/d" }'
"class { 'cinder':
database_connection => 'mysql://a:b@c/d'
}"
end
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } },
})
end
shared_examples 'cinder::volume' do
it { should contain_service('cinder-volume').with(
:hasstatus => true,
:tag => 'cinder-service',
)}
it { is_expected.to contain_package('cinder-volume').with_ensure('present') }
it { is_expected.to contain_service('cinder-volume').with(
'hasstatus' => true,
'tag' => 'cinder-service',
)}
it { is_expected.to contain_cinder_config('DEFAULT/volume_clear').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_cinder_config('DEFAULT/volume_clear_size').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_cinder_config('DEFAULT/volume_clear_ionice').with_value('<SERVICE DEFAULT>') }
it { should contain_cinder_config('DEFAULT/volume_clear').with_value('<SERVICE DEFAULT>') }
it { should contain_cinder_config('DEFAULT/volume_clear_size').with_value('<SERVICE DEFAULT>') }
it { should contain_cinder_config('DEFAULT/volume_clear_ionice').with_value('<SERVICE DEFAULT>') }
describe 'with manage_service false' do
let :params do
{ 'manage_service' => false }
context 'with manage_service false' do
let :params do
{
:manage_service => false
}
end
it { should contain_service('cinder-volume').without_ensure }
end
it 'should not change the state of the service' do
is_expected.to contain_service('cinder-volume').without_ensure
end
end
describe 'with volume_clear parameters' do
let :params do
{
'volume_clear' => 'none',
'volume_clear_size' => '10',
'volume_clear_ionice' => '-c3',
context 'with volume_clear parameters' do
let :params do
{
:volume_clear => 'none',
:volume_clear_size => '10',
:volume_clear_ionice => '-c3',
}
end
it {
should contain_cinder_config('DEFAULT/volume_clear').with_value('none')
should contain_cinder_config('DEFAULT/volume_clear_size').with_value('10')
should contain_cinder_config('DEFAULT/volume_clear_ionice').with_value('-c3')
}
end
it 'should set volume_clear parameters' do
is_expected.to contain_cinder_config('DEFAULT/volume_clear').with_value('none')
is_expected.to contain_cinder_config('DEFAULT/volume_clear_size').with_value('10')
is_expected.to contain_cinder_config('DEFAULT/volume_clear_ionice').with_value('-c3')
end
shared_examples 'cinder::volume on Debian' do
it { should contain_package('cinder-volume').with_ensure('present') }
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::volume'
if facts[:osfamily] == 'Debian'
it_behaves_like 'cinder::volume on Debian'
end
end
end
end

View File

@ -1,8 +1,7 @@
require 'spec_helper'
describe 'cinder::wsgi::apache' do
shared_examples_for 'apache serving cinder with mod_wsgi' do
shared_examples 'apache serving cinder with mod_wsgi' do
context 'with default parameters' do
it { is_expected.to contain_class('cinder::params') }
it { is_expected.to contain_class('apache') }

View File

@ -1,18 +1,18 @@
require 'spec_helper'
describe 'cinder::backend::bdd' do
let(:title) { 'hippo' }
let :params do {
:target_ip_address => '127.0.0.2',
:available_devices => '/dev/sda',
}
let :params do
{
:target_ip_address => '127.0.0.2',
:available_devices => '/dev/sda',
}
end
shared_examples_for 'cinder block device' do
shared_examples 'cinder block device' do
context 'with default parameters' do
it 'should configure bdd driver in cinder.conf with defaults' do
it {
should contain_cinder_config('hippo/volume_backend_name').with_value('hippo')
should contain_cinder_config('hippo/volume_driver').with_value('cinder.volume.drivers.block_device.BlockDeviceDriver')
should contain_cinder_config('hippo/available_devices').with_value('/dev/sda')
@ -23,7 +23,7 @@ describe 'cinder::backend::bdd' do
should contain_cinder_config('hippo/target_protocol').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('hippo/volume_clear').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('hippo/backend_availability_zone').with_value('<SERVICE DEFAULT>')
end
}
end
context 'with optional parameters' do
@ -40,7 +40,7 @@ describe 'cinder::backend::bdd' do
})
end
it 'should configure bdd driver in cinder.conf' do
it {
should contain_cinder_config('hippo/available_devices').with_value('/dev/sdb,/dev/sdc')
should contain_cinder_config('hippo/volumes_dir').with_value('/var/lib/cinder/bdd-volumes')
should contain_cinder_config('hippo/target_ip_address').with_value('10.20.0.2')
@ -48,22 +48,20 @@ describe 'cinder::backend::bdd' do
should contain_cinder_config('hippo/volume_group').with_value('cinder')
should contain_cinder_config('hippo/volume_clear').with_value('zero')
should contain_cinder_config('hippo/backend_availability_zone').with_value('my_zone')
end
it 'should create type with properties' do
should contain_cinder_type('hippo').with(:ensure => :present, :properties => ['volume_backend_name=hippo'])
end
}
it { should contain_cinder_type('hippo').with(
:ensure => 'present',
:properties => ['volume_backend_name=hippo']
)}
end
context 'block device backend with additional configuration' do
before do
params.merge!({:extra_options => {'hippo/param1' => { 'value' => 'value1' }}})
params.merge!( :extra_options => {'hippo/param1' => { 'value' => 'value1' }} )
end
it 'configure vmdk backend with additional configuration' do
is_expected.to contain_cinder_config('hippo/param1').with({
:value => 'value1'
})
end
it { should contain_cinder_config('hippo/param1').with_value('value1') }
end
context 'with deprecated iscsi_ip_address' do
@ -73,46 +71,44 @@ describe 'cinder::backend::bdd' do
:iscsi_ip_address => '127.0.0.42',
})
end
it 'should configure bdd driver using that address' do
should contain_cinder_config('hippo/target_ip_address').with_value('127.0.0.42')
end
it { should contain_cinder_config('hippo/target_ip_address').with_value('127.0.0.42') }
end
context 'with no target_ip_address or iscsi_ip_address' do
before do
params.delete(:target_ip_address)
end
it 'is expected to raise error' do
is_expected.to raise_error(Puppet::Error, /A target_ip_address or iscsi_ip_address must be specified./)
end
it { should raise_error(Puppet::Error, /A target_ip_address or iscsi_ip_address must be specified./) }
end
end
shared_examples_for 'check needed daemons' do
shared_examples 'check needed daemons' do
context 'tgtadm helper' do
it 'is expected to have tgtd daemon' do
is_expected.to contain_package('tgt').with(:ensure => :present)
is_expected.to contain_service('tgtd').with(:ensure => :running)
end
it {
should contain_package('tgt').with_ensure('present')
should contain_service('tgtd').with_ensure('running')
}
end
context 'lioadm helper' do
before do
params.merge!({:target_helper => 'lioadm'})
end
it 'is expected to have target daemon' do
is_expected.to contain_package('targetcli').with(:ensure => :present)
is_expected.to contain_service('target').with(:ensure => :running)
params.merge!( :target_helper => 'lioadm' )
end
it {
should contain_package('targetcli').with_ensure('present')
should contain_service('target').with_ensure('running')
}
end
context 'wrong helper' do
before do
params.merge!({:target_helper => 'fake'})
end
it 'is expected to raise error' do
is_expected.to raise_error(Puppet::Error, /Unsupported target helper: fake/)
params.merge!( :target_helper => 'fake' )
end
it { should raise_error(Puppet::Error, /Unsupported target helper: fake/) }
end
end
@ -124,8 +120,8 @@ describe 'cinder::backend::bdd' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'cinder block device'
it_configures 'check needed daemons'
it_behaves_like 'cinder block device'
it_behaves_like 'check needed daemons'
end
end
end

View File

@ -1,17 +1,16 @@
require 'spec_helper'
describe 'cinder::backend::dellemc_unity' do
let (:config_group_name) { 'dellemc_unity' }
let (:title) { config_group_name }
let :params do
{
:san_ip => '172.23.8.101',
:san_login => 'Admin',
:san_password => '12345',
:storage_protocol => 'iSCSI',
:san_ip => '172.23.8.101',
:san_login => 'Admin',
:san_password => '12345',
:storage_protocol => 'iSCSI',
}
end
@ -31,55 +30,65 @@ describe 'cinder::backend::dellemc_unity' do
}
end
let :facts do
OSDefaults.get_facts({})
end
shared_examples_for 'dellemc_unity volume driver' do
shared_examples 'dellemc_unity volume driver' do
let :params_hash do
default_params.merge(params)
end
it 'configures cinder volume driver' do
is_expected.to contain_cinder__backend__dellemc_unity(config_group_name)
is_expected.to contain_cinder_config("#{title}/volume_driver").with_value(
'cinder.volume.drivers.dell_emc.unity.Driver')
it { should contain_cinder__backend__dellemc_unity(config_group_name) }
it { should contain_cinder_config("#{title}/volume_driver").with(
:value => 'cinder.volume.drivers.dell_emc.unity.Driver'
)}
it {
params_hash.each_pair do |config,value|
is_expected.to contain_cinder_config("#{config_group_name}/#{config}").with_value( value )
should contain_cinder_config("#{config_group_name}/#{config}").with_value(value)
end
}
end
shared_examples 'cinder::backend::dellemc_unity' do
context 'with default parameters' do
it_behaves_like 'dellemc_unity volume driver'
end
context 'with custom parameters' do
before do
params.merge(custom_params)
end
it_behaves_like 'dellemc_unity volume driver'
end
context 'dellemc_unity backend with additional configuration' do
before do
params.merge!( :extra_options => {'dellemc_unity/param1' => { 'value' => 'value1' }} )
end
it { should contain_cinder_config('dellemc_unity/param1').with_value('value1') }
end
context 'dellemc_unity backend with cinder type' do
before do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('dellemc_unity').with(
:ensure => 'present',
:properties => ['volume_backend_name=dellemc_unity']
)}
end
end
context 'with default parameters' do
it_configures 'dellemc_unity volume driver'
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
context 'with custom parameters' do
before do
params.merge(custom_params)
end
it_configures 'dellemc_unity volume driver'
end
context 'dellemc_unity backend with additional configuration' do
before do
params.merge!({:extra_options => {'dellemc_unity/param1' => { 'value' => 'value1' }}})
end
it 'configure dellemc_unity backend with additional configuration' do
is_expected.to contain_cinder_config('dellemc_unity/param1').with({
:value => 'value1'
})
it_behaves_like 'cinder::backend::dellemc_unity'
end
end
context 'dellemc_unity backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('dellemc_unity').with(:ensure => :present, :properties => ['volume_backend_name=dellemc_unity'])
end
end
end

View File

@ -14,42 +14,52 @@ describe 'cinder::backend::dellemc_vmax_iscsi' do
req_params
end
describe 'dell emc vmax iscsi volume driver' do
it 'configure dell emc vmax iscsi volume driver' do
is_expected.to contain_package('pywbem').with(:ensure => :present)
is_expected.to contain_cinder_config('dellemc_vmax_iscsi/volume_driver').with_value('cinder.volume.drivers.dell_emc.vmax.iscsi.VMAXISCSIDriver')
is_expected.to contain_cinder_config('dellemc_vmax_iscsi/cinder_emc_config_file').with_value('/etc/cinder/cinder_emc_config_CONF_GROUP_ISCSI.xml')
shared_examples 'cinder::backend::dellemc_vmax_iscsi' do
context 'dell emc vmax iscsi volume driver' do
it {
should contain_package('pywbem').with(:ensure => :present)
should contain_cinder_config('dellemc_vmax_iscsi/volume_driver').with_value('cinder.volume.drivers.dell_emc.vmax.iscsi.VMAXISCSIDriver')
should contain_cinder_config('dellemc_vmax_iscsi/cinder_emc_config_file').with_value('/etc/cinder/cinder_emc_config_CONF_GROUP_ISCSI.xml')
}
end
context 'dell emc vmax iscsi backend overriding some parameters' do
before :each do
params.merge!({
:backend_availability_zone => 'my_zone',
:manage_volume_type => true,
})
end
it {
should contain_cinder_config('dellemc_vmax_iscsi/cinder_emc_config_file').with_value('/etc/cinder/cinder_emc_config_CONF_GROUP_ISCSI.xml')
should contain_cinder_config('dellemc_vmax_iscsi/backend_availability_zone').with_value('my_zone')
}
it { should contain_cinder_type('dellemc_vmax_iscsi').with(
:ensure => 'present',
:properties => ['volume_backend_name=dellemc_vmax_iscsi']
)}
end
context 'dell emc vmax iscsi backend with additional configuration' do
before :each do
params.merge!( :extra_options => {'dellemc_vmax_iscsi/param1' => {'value' => 'value1'}} )
end
it { should contain_cinder_config('dellemc_vmax_iscsi/param1').with_value('value1') }
end
end
describe 'dell emc vmax iscsi backend overriding some parameters' do
before :each do
params.merge!({
:backend_availability_zone => 'my_zone',
:manage_volume_type => true,
})
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it 'configure dell emc vmax iscsi volume driver' do
is_expected.to contain_cinder_config('dellemc_vmax_iscsi/cinder_emc_config_file').with_value('/etc/cinder/cinder_emc_config_CONF_GROUP_ISCSI.xml')
is_expected.to contain_cinder_config('dellemc_vmax_iscsi/backend_availability_zone').with_value('my_zone')
end
it 'should create type with properties' do
should contain_cinder_type('dellemc_vmax_iscsi').with(:ensure => :present, :properties => ['volume_backend_name=dellemc_vmax_iscsi'])
it_behaves_like 'cinder::backend::dellemc_vmax_iscsi'
end
end
describe 'dell emc vmax iscsi backend with additional configuration' do
before :each do
params.merge!({:extra_options => {'dellemc_vmax_iscsi/param1' => {'value' => 'value1'}}})
end
it 'configure dell emc vmax iscsi backend with additional configuration' do
is_expected.to contain_cinder_config('dellemc_vmax_iscsi/param1').with({
:value => 'value1',
})
end
end
end

View File

@ -1,7 +1,6 @@
require 'spec_helper'
describe 'cinder::backend::dellemc_xtremio_iscsi' do
let (:config_group_name) { 'dellemc_xtremio_iscsi' }
let (:title) { config_group_name }
@ -25,7 +24,7 @@ describe 'cinder::backend::dellemc_xtremio_iscsi' do
end
let :custom_params do
{
{
:backend_availability_zone => 'my_zone',
:xtremio_array_busy_retry_count => 15,
:xtremio_array_busy_retry_interval => 25,
@ -33,56 +32,65 @@ describe 'cinder::backend::dellemc_xtremio_iscsi' do
}
end
let :facts do
OSDefaults.get_facts({})
end
shared_examples_for 'dellemc_xtremio_iscsi volume driver' do
shared_examples 'dellemc_xtremio_iscsi volume driver' do
let :params_hash do
default_params.merge(params)
end
it 'configures cinder volume driver' do
is_expected.to contain_cinder__backend__dellemc_xtremio_iscsi(config_group_name)
is_expected.to contain_cinder_config("#{title}/volume_driver").with_value(
'cinder.volume.drivers.dell_emc.xtremio.XtremIOISCSIDriver')
it {
should contain_cinder__backend__dellemc_xtremio_iscsi(config_group_name)
should contain_cinder_config("#{title}/volume_driver").with_value('cinder.volume.drivers.dell_emc.xtremio.XtremIOISCSIDriver')
}
it {
params_hash.each_pair do |config,value|
is_expected.to contain_cinder_config("#{config_group_name}/#{config}").with_value( value )
should contain_cinder_config("#{config_group_name}/#{config}").with_value( value )
end
}
end
shared_examples 'cinder::backend::dellemc_xtremio_iscsi' do
context 'with default parameters' do
it_behaves_like 'dellemc_xtremio_iscsi volume driver'
end
context 'with custom parameters' do
before do
params.merge(custom_params)
end
it_behaves_like 'dellemc_xtremio_iscsi volume driver'
end
context 'dellemc_xtremio_iscsi backend with additional configuration' do
before do
params.merge!( :extra_options => {'dellemc_xtremio_iscsi/param1' => { 'value' => 'value1' }} )
end
it { should contain_cinder_config('dellemc_xtremio_iscsi/param1').with_value('value1') }
end
context 'dellemc_xtremio_iscsi backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it { should contain_cinder_type('dellemc_xtremio_iscsi').with(
:ensure => 'present',
:properties => ['volume_backend_name=dellemc_xtremio_iscsi']
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
context 'with default parameters' do
it_configures 'dellemc_xtremio_iscsi volume driver'
end
context 'with custom parameters' do
before do
params.merge(custom_params)
end
it_configures 'dellemc_xtremio_iscsi volume driver'
end
context 'dellemc_xtremio_iscsi backend with additional configuration' do
before do
params.merge!({:extra_options => {'dellemc_xtremio_iscsi/param1' => { 'value' => 'value1' }}})
end
it 'configure dellemc_xtremio_iscsi backend with additional configuration' do
is_expected.to contain_cinder_config('dellemc_xtremio_iscsi/param1').with({
:value => 'value1'
})
it_behaves_like 'cinder::backend::dellemc_xtremio_iscsi'
end
end
context 'dellemc_xtremio_iscsi backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('dellemc_xtremio_iscsi').with(:ensure => :present, :properties => ['volume_backend_name=dellemc_xtremio_iscsi'])
end
end
end

View File

@ -1,7 +1,6 @@
require 'spec_helper'
describe 'cinder::backend::dellsc_iscsi' do
let (:config_group_name) { 'dellsc_iscsi' }
let (:title) { config_group_name }
@ -49,78 +48,83 @@ describe 'cinder::backend::dellsc_iscsi' do
}
end
let :facts do
OSDefaults.get_facts({})
end
shared_examples_for 'dellsc_iscsi volume driver' do
shared_examples 'dellsc_iscsi volume driver' do
let :params_hash do
default_params.merge(params)
end
it 'configures cinder volume driver' do
is_expected.to contain_cinder__backend__dellsc_iscsi(config_group_name)
it { should contain_cinder__backend__dellsc_iscsi(config_group_name) }
it {
params_hash.each_pair do |config,value|
is_expected.to contain_cinder_config("#{config_group_name}/#{config}").with_value( value )
should contain_cinder_config("#{config_group_name}/#{config}").with_value( value )
end
is_expected.to contain_cinder_config("#{config_group_name}/volume_driver").with_value(
'cinder.volume.drivers.dell_emc.sc.storagecenter_iscsi.SCISCSIDriver')
is_expected.to contain_cinder_config("#{config_group_name}/use_multipath_for_image_xfer").with_value('true')
}
it {
should contain_cinder_config("#{config_group_name}/volume_driver").with_value('cinder.volume.drivers.dell_emc.sc.storagecenter_iscsi.SCISCSIDriver')
should contain_cinder_config("#{config_group_name}/use_multipath_for_image_xfer").with_value('true')
}
end
shared_examples 'cinder::backend::dellsc_iscsi' do
context 'with default parameters' do
it_behaves_like 'dellsc_iscsi volume driver'
end
context 'with custom parameters' do
before do
params.merge(custom_params)
end
it_behaves_like 'dellsc_iscsi volume driver'
end
context 'dellsc_iscsi backend with additional configuration' do
before do
params.merge!({:extra_options => {'dellsc_iscsi/param1' => { 'value' => 'value1' }}})
end
it { should contain_cinder_config('dellsc_iscsi/param1').with_value('value1') }
end
context 'dellsc_iscsi backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it { should contain_cinder_type('dellsc_iscsi').with(:ensure => :present, :properties => ['volume_backend_name=dellsc_iscsi']) }
end
context 'with deprecated iscsi_ip_address' do
before do
params.merge!({
:target_ip_address => :undef,
:iscsi_ip_address => '127.0.0.42',
})
end
it { should contain_cinder_config('dellsc_iscsi/target_ip_address').with_value('127.0.0.42') }
end
context 'with no target_ip_address or iscsi_ip_address' do
before do
params.delete(:target_ip_address)
end
it { should raise_error(Puppet::Error, /A target_ip_address or iscsi_ip_address must be specified./) }
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
context 'with default parameters' do
it_configures 'dellsc_iscsi volume driver'
end
context 'with custom parameters' do
before do
params.merge(custom_params)
end
it_configures 'dellsc_iscsi volume driver'
end
context 'dellsc_iscsi backend with additional configuration' do
before do
params.merge!({:extra_options => {'dellsc_iscsi/param1' => { 'value' => 'value1' }}})
end
it 'configure dellsc_iscsi backend with additional configuration' do
is_expected.to contain_cinder_config('dellsc_iscsi/param1').with({
:value => 'value1'
})
it_behaves_like 'cinder::backend::dellsc_iscsi'
end
end
context 'dellsc_iscsi backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('dellsc_iscsi').with(:ensure => :present, :properties => ['volume_backend_name=dellsc_iscsi'])
end
end
context 'with deprecated iscsi_ip_address' do
before do
params.merge!({
:target_ip_address => :undef,
:iscsi_ip_address => '127.0.0.42',
})
end
it 'should configure dellsc_iscsi backend using that address' do
should contain_cinder_config('dellsc_iscsi/target_ip_address').with_value('127.0.0.42')
end
end
context 'with no target_ip_address or iscsi_ip_address' do
before do
params.delete(:target_ip_address)
end
it 'is expected to raise error' do
is_expected.to raise_error(Puppet::Error, /A target_ip_address or iscsi_ip_address must be specified./)
end
end
end

View File

@ -12,70 +12,73 @@ describe 'cinder::backend::emc_vnx' do
}
end
let :facts do
OSDefaults.get_facts({
:osfamily => 'Redhat',
:os => { :name => 'CentOS', :family => 'RedHat', :release => { :major => '7', :minor => '0' } },
})
end
let :params do
req_params
end
describe 'emc vnx volume driver' do
it 'configure emc vnx volume driver' do
is_expected.to contain_cinder_config('emc/volume_driver').with_value('cinder.volume.drivers.dell_emc.vnx.driver.VNXDriver')
is_expected.to contain_cinder_config('emc/storage_protocol').with_value('iscsi')
is_expected.to contain_cinder_config('emc/san_ip').with_value('127.0.0.2')
is_expected.to contain_cinder_config('emc/san_login').with_value('emc')
is_expected.to contain_cinder_config('emc/san_password').with_value('password').with_secret(true)
is_expected.to contain_cinder_config('emc/storage_vnx_pool_names').with_value('emc-storage-pool')
is_expected.to contain_cinder_config('emc/initiator_auto_registration').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('emc/storage_vnx_authentication_type').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('emc/storage_vnx_security_file_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('emc/naviseccli_path').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('emc/backend_availability_zone').with_value('<SERVICE DEFAULT>')
shared_examples 'cinder::backend::emc_vnx' do
context 'emc vnx volume driver' do
it {
should contain_cinder_config('emc/volume_driver').with_value('cinder.volume.drivers.dell_emc.vnx.driver.VNXDriver')
should contain_cinder_config('emc/storage_protocol').with_value('iscsi')
should contain_cinder_config('emc/san_ip').with_value('127.0.0.2')
should contain_cinder_config('emc/san_login').with_value('emc')
should contain_cinder_config('emc/san_password').with_value('password').with_secret(true)
should contain_cinder_config('emc/storage_vnx_pool_names').with_value('emc-storage-pool')
should contain_cinder_config('emc/initiator_auto_registration').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('emc/storage_vnx_authentication_type').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('emc/storage_vnx_security_file_dir').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('emc/naviseccli_path').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('emc/backend_availability_zone').with_value('<SERVICE DEFAULT>')
}
end
context 'emc vnx backend overriding some parameters' do
before :each do
params.merge!({
:initiator_auto_registration => true,
:storage_vnx_auth_type => 'global',
:storage_vnx_security_file_dir => '/etc/secfile/array1',
:naviseccli_path => '/opt/Navisphere/bin/naviseccli',
:manage_volume_type => true,
:storage_protocol => 'fc',
:backend_availability_zone => 'my_zone',
})
end
it {
should contain_cinder_config('emc/initiator_auto_registration').with_value(params[:initiator_auto_registration])
should contain_cinder_config('emc/storage_vnx_authentication_type').with_value(params[:storage_vnx_auth_type])
should contain_cinder_config('emc/storage_vnx_security_file_dir').with_value(params[:storage_vnx_security_file_dir])
should contain_cinder_config('emc/naviseccli_path').with_value(params[:naviseccli_path])
should contain_cinder_config('emc/storage_protocol').with_value(params[:storage_protocol])
should contain_cinder_config('emc/backend_availability_zone').with_value(params[:backend_availability_zone])
}
it { should contain_cinder_type('emc').with(
:ensure => 'present',
:properties => ['volume_backend_name=emc']
)}
end
context 'emc vnx backend with additional configuration' do
before :each do
params.merge!( :extra_options => {'emc/param1' => {'value' => 'value1'}} )
end
it { should contain_cinder_config('emc/param1').with_value('value1') }
end
end
describe 'emc vnx backend overriding some parameters' do
before :each do
params.merge!({
:initiator_auto_registration => true,
:storage_vnx_auth_type => 'global',
:storage_vnx_security_file_dir => '/etc/secfile/array1',
:naviseccli_path => '/opt/Navisphere/bin/naviseccli',
:manage_volume_type => true,
:storage_protocol => 'fc',
:backend_availability_zone => 'my_zone',
})
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it 'configure emc vnx volume driver' do
is_expected.to contain_cinder_config('emc/initiator_auto_registration').with_value(params[:initiator_auto_registration])
is_expected.to contain_cinder_config('emc/storage_vnx_authentication_type').with_value(params[:storage_vnx_auth_type])
is_expected.to contain_cinder_config('emc/storage_vnx_security_file_dir').with_value(params[:storage_vnx_security_file_dir])
is_expected.to contain_cinder_config('emc/naviseccli_path').with_value(params[:naviseccli_path])
is_expected.to contain_cinder_config('emc/storage_protocol').with_value(params[:storage_protocol])
is_expected.to contain_cinder_config('emc/backend_availability_zone').with_value(params[:backend_availability_zone])
end
it 'should create type with properties' do
should contain_cinder_type('emc').with(:ensure => :present, :properties => ['volume_backend_name=emc'])
it_behaves_like 'cinder::backend::emc_vnx'
end
end
describe 'emc vnx backend with additional configuration' do
before :each do
params.merge!({:extra_options => {'emc/param1' => {'value' => 'value1'}}})
end
it 'configure emc vnx backend with additional configuration' do
is_expected.to contain_cinder_config('emc/param1').with({
:value => 'value1',
})
end
end
end

View File

@ -24,60 +24,80 @@ describe 'cinder::backend::eqlx' do
}
end
shared_examples_for 'eqlx volume driver' do
it 'configure eqlx volume driver' do
is_expected.to contain_cinder__backend__eqlx(config_group_name)
is_expected.to contain_cinder_config(
"#{config_group_name}/volume_driver").with_value(
'cinder.volume.drivers.dell_emc.ps.PSSeriesISCSIDriver')
shared_examples 'eqlx volume driver' do
it { should contain_cinder__backend__eqlx(config_group_name) }
it { should contain_cinder_config("#{config_group_name}/volume_driver").with(
:value => 'cinder.volume.drivers.dell_emc.ps.PSSeriesISCSIDriver'
)}
it {
params.each_pair do |config,value|
is_expected.to contain_cinder_config(
"#{config_group_name}/#{config}").with_value(value)
should contain_cinder_config("#{config_group_name}/#{config}").with_value(value)
end
}
end
shared_examples 'cinder::backend::eqlx' do
context 'eqlx backend with additional configuration' do
before :each do
params.merge!( :extra_options => {'eqlx-1/param1' => {'value' => 'value1'}} )
end
it { should contain_cinder_config('eqlx-1/param1').with_value('value1') }
end
context 'eqlx backend with cinder type' do
before :each do
params.merge!({:manage_volume_type => true})
end
it { should contain_cinder_type('eqlx-1').with(
:ensure => 'present',
:properties => ['volume_backend_name=eqlx-1']
)}
end
context 'eqlx backend with chap' do
before :each do
params.merge!({
:use_chap_auth => true,
:chap_username => 'myuser',
:chap_password => 'mypass'
})
end
it_behaves_like 'eqlx volume driver'
end
context 'eqlx with invalid values' do
context 'with invalid chap_username' do
before do
params.merge!( :chap_username => '<SERVICE DEFAULT>' )
end
it { should raise_error(Puppet::Error, /chap_username need to be set./) }
end
context 'with invalid chap_password' do
before do
params.merge!( :chap_password => '<SERVICE DEFAULT>' )
end
it { should raise_error(Puppet::Error, /chap_password need to be set./) }
end
end
end
describe 'eqlx backend with additional configuration' do
before :each do
params.merge!({:extra_options => {'eqlx-1/param1' => {'value' => 'value1'}}})
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it 'configure eqlx backend with additional configuration' do
is_expected.to contain_cinder_config('eqlx-1/param1').with({
:value => 'value1',
})
it_behaves_like 'cinder::backend::eqlx'
end
end
describe 'eqlx backend with cinder type' do
before :each do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('eqlx-1').with(:ensure => :present, :properties => ['volume_backend_name=eqlx-1'])
end
end
context 'eqlx backend with chap' do
before :each do
params.merge!({
:use_chap_auth => true,
:chap_username => 'myuser',
:chap_password => 'mypass'
})
end
it_configures 'eqlx volume driver'
end
describe 'eqlx with invalid values' do
it 'should fail with chap_username with default value' do
params[:chap_username] = '<SERVICE DEFAULT>'
is_expected.to raise_error(Puppet::Error, /chap_username need to be set./)
end
it 'should fail with chap_password with default value' do
params[:chap_password] = '<SERVICE DEFAULT>'
is_expected.to raise_error(Puppet::Error, /chap_password need to be set./)
end
end
end

View File

@ -1,78 +1,67 @@
require 'spec_helper'
describe 'cinder::backend::glusterfs' do
let(:title) {'mygluster'}
shared_examples_for 'glusterfs volume driver' do
let(:title) {'mygluster'}
let :params do
{
:backend_availability_zone => 'my_zone',
:glusterfs_shares => ['10.10.10.10:/volumes', '10.10.10.11:/volumes'],
:glusterfs_shares_config => '/etc/cinder/other_shares.conf',
:glusterfs_sparsed_volumes => true,
:glusterfs_mount_point_base => '/cinder_mount_point',
}
end
let :facts do
OSDefaults.get_facts({})
end
shared_examples 'glusterfs volume driver' do
it { should contain_cinder_config('mygluster/volume_driver').with(
:value => 'cinder.volume.drivers.glusterfs.GlusterfsDriver'
)}
let :params do
{
:backend_availability_zone => 'my_zone',
:glusterfs_shares => ['10.10.10.10:/volumes', '10.10.10.11:/volumes'],
:glusterfs_shares_config => '/etc/cinder/other_shares.conf',
:glusterfs_sparsed_volumes => true,
:glusterfs_mount_point_base => '/cinder_mount_point',
}
end
it {
should contain_cinder_config('mygluster/backend_availability_zone').with_value('my_zone')
should contain_cinder_config('mygluster/glusterfs_backup_mount_point').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('mygluster/glusterfs_backup_share').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('mygluster/glusterfs_shares_config').with_value('/etc/cinder/other_shares.conf')
should contain_cinder_config('mygluster/glusterfs_sparsed_volumes').with_value(true)
should contain_cinder_config('mygluster/glusterfs_mount_point_base').with_value('/cinder_mount_point')
}
it 'configures glusterfs volume driver' do
is_expected.to contain_cinder_config('mygluster/volume_driver').with_value(
'cinder.volume.drivers.glusterfs.GlusterfsDriver')
is_expected.to contain_cinder_config('mygluster/backend_availability_zone').with_value(
'my_zone')
is_expected.to contain_cinder_config('mygluster/glusterfs_backup_mount_point').with_value(
'<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('mygluster/glusterfs_backup_share').with_value(
'<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('mygluster/glusterfs_shares_config').with_value(
'/etc/cinder/other_shares.conf')
is_expected.to contain_cinder_config('mygluster/glusterfs_sparsed_volumes').with_value(
true)
is_expected.to contain_cinder_config('mygluster/glusterfs_mount_point_base').with_value(
'/cinder_mount_point')
is_expected.to contain_file('/etc/cinder/other_shares.conf').with(
:content => "10.10.10.10:/volumes\n10.10.10.11:/volumes\n",
:require => 'Anchor[cinder::install::end]',
:notify => 'Anchor[cinder::service::begin]'
)
end
it { should contain_file('/etc/cinder/other_shares.conf').with(
:content => "10.10.10.10:/volumes\n10.10.10.11:/volumes\n",
:require => 'Anchor[cinder::install::end]',
:notify => 'Anchor[cinder::service::begin]'
)}
context 'glusterfs backend with additional configuration' do
before do
params.merge!({:extra_options => {'mygluster/param1' => { 'value' => 'value1' }}})
end
it 'configure glusterfs backend with additional configuration' do
is_expected.to contain_cinder_config('mygluster/param1').with({
:value => 'value1'
})
params.merge!( :extra_options => {'mygluster/param1' => { 'value' => 'value1' }} )
end
it { should contain_cinder_config('mygluster/param1').with_value('value1') }
end
context 'glusterfs backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('mygluster').with(:ensure => :present, :properties => ['volume_backend_name=mygluster'])
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('mygluster').with(
:ensure => 'present',
:properties => ['volume_backend_name=mygluster']
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
facts.merge(OSDefaults.get_facts( :os_workers => 8 ))
end
it_configures 'glusterfs volume driver'
it_behaves_like 'glusterfs volume driver'
end
end
end

View File

@ -1,17 +1,16 @@
require 'spec_helper'
describe 'cinder::backend::gpfs' do
let (:title) { 'gpfs' }
let :params do
{
{
:gpfs_mount_point_base => '/opt/gpfs/cinder/volumes',
}
}
end
let :default_params do
{
{
:backend_availability_zone => '<SERVICE DEFAULT>',
:gpfs_max_clone_depth => '<SERVICE DEFAULT>',
:gpfs_sparse_volumes => '<SERVICE DEFAULT>',
@ -23,11 +22,11 @@ describe 'cinder::backend::gpfs' do
:nas_password => '<SERVICE DEFAULT>',
:nas_private_key => '<SERVICE DEFAULT>',
:nas_ssh_port => '<SERVICE DEFAULT>',
}
}
end
let :custom_params do
{
{
:backend_availability_zone => 'my_zone',
:gpfs_max_clone_depth => 1,
:gpfs_sparse_volumes => false,
@ -40,81 +39,95 @@ describe 'cinder::backend::gpfs' do
}
end
let :facts do
OSDefaults.get_facts({})
end
shared_examples_for 'gpfs volume driver' do
shared_examples 'gpfs volume driver' do
let :params_hash do
default_params.merge(params)
end
it 'configures gpfs volume driver' do
is_expected.to contain_cinder_config('gpfs/volume_driver').with_value(
'cinder.volume.drivers.ibm.gpfs.GPFSDriver')
it { should contain_cinder_config('gpfs/volume_driver').with(
:value => 'cinder.volume.drivers.ibm.gpfs.GPFSDriver'
)}
it {
params_hash.each_pair do |config,value|
is_expected.to contain_cinder_config("gpfs/#{config}").with_value( value )
should contain_cinder_config("gpfs/#{config}").with_value( value )
end
}
end
shared_examples 'cinder::backend::gpfs' do
context 'with default parameters' do
it_behaves_like 'gpfs volume driver'
end
context 'with additional image parameters' do
before do
params.merge!({
:gpfs_images_dir => '/gpfs/glance/images',
:gpfs_images_share_mode => 'copy_on_write',
})
end
it_behaves_like 'gpfs volume driver'
end
context 'with custom parameters' do
before do
params.merge(custom_params)
end
it_behaves_like 'gpfs volume driver'
end
context 'with image share mode but without image path' do
before do
params.merge!({
:gpfs_images_share_mode => 'copy_on_write',
})
end
it { should raise_error(Puppet::Error, /gpfs_images_share_mode only in conjunction with gpfs_images_dir/) }
end
context 'with wrong gpfs_images_share_mode' do
before do
params.merge!({
:gpfs_images_share_mode => 'foo',
})
end
it { should raise_error(Puppet::Error, /gpfs_images_share_mode only support `copy` or `copy_on_write`/) }
end
context 'gpfs backend with cinder type' do
before do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('gpfs').with(
:ensure => 'present',
:properties => ['volume_backend_name=gpfs']
)}
end
context 'gpfs backend with additional configuration' do
before do
params.merge!( :extra_options => {'gpfs/param1' => { 'value' => 'value1' }} )
end
it { should contain_cinder_config('gpfs/param1').with_value('value1') }
end
end
context 'with default parameters' do
it_configures 'gpfs volume driver'
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
context 'with additional image parameters' do
before do
params.merge!({
:gpfs_images_dir => '/gpfs/glance/images',
:gpfs_images_share_mode => 'copy_on_write',
})
end
it_configures 'gpfs volume driver'
end
context 'with custom parameters' do
before do
params.merge(custom_params)
end
it_configures 'gpfs volume driver'
end
context 'with image share mode but without image path' do
before do
params.merge!({
:gpfs_images_share_mode => 'copy_on_write',
})
end
it_raises 'a Puppet::Error', /gpfs_images_share_mode only in conjunction with gpfs_images_dir/
end
context 'with wrong gpfs_images_share_mode' do
before do
params.merge!({
:gpfs_images_share_mode => 'foo',
})
end
it_raises 'a Puppet::Error', /gpfs_images_share_mode only support `copy` or `copy_on_write`/
end
context 'gpfs backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('gpfs').with(:ensure => :present, :properties => ['volume_backend_name=gpfs'])
end
end
context 'gpfs backend with additional configuration' do
before do
params.merge!({:extra_options => {'gpfs/param1' => { 'value' => 'value1' }}})
end
it 'configure gpfs backend with additional configuration' do
is_expected.to contain_cinder_config('gpfs/param1').with({
:value => 'value1'
})
it_behaves_like 'cinder::backend::gpfs'
end
end
end

View File

@ -20,39 +20,50 @@ describe 'cinder::backend::hpe3par_iscsi' do
req_params
end
describe 'hpe3par_iscsi volume driver' do
it 'configure hpe3par_iscsi volume driver' do
is_expected.to contain_cinder_config('hpe3par_iscsi/volume_driver').with_value('cinder.volume.drivers.hpe.hpe_3par_iscsi.HPE3PARISCSIDriver')
is_expected.to contain_cinder_config('hpe3par_iscsi/backend_availability_zone').with_value('my_zone')
is_expected.to contain_cinder_config('hpe3par_iscsi/hpe3par_api_url').with_value('https://172.0.0.2:8080/api/v1')
is_expected.to contain_cinder_config('hpe3par_iscsi/hpe3par_username').with_value('3paradm')
is_expected.to contain_cinder_config('hpe3par_iscsi/hpe3par_password').with_value('password')
is_expected.to contain_cinder_config('hpe3par_iscsi/hpe3par_iscsi_ips').with_value('172.0.0.3')
is_expected.to contain_cinder_config('hpe3par_iscsi/san_ip').with_value('172.0.0.2')
is_expected.to contain_cinder_config('hpe3par_iscsi/san_login').with_value('3paradm')
is_expected.to contain_cinder_config('hpe3par_iscsi/san_password').with_value('password')
shared_examples 'cinder::backend::hpe3par_iscsi' do
context 'hpe3par_iscsi volume driver' do
it {
should contain_cinder_config('hpe3par_iscsi/volume_driver').with_value('cinder.volume.drivers.hpe.hpe_3par_iscsi.HPE3PARISCSIDriver')
should contain_cinder_config('hpe3par_iscsi/backend_availability_zone').with_value('my_zone')
should contain_cinder_config('hpe3par_iscsi/hpe3par_api_url').with_value('https://172.0.0.2:8080/api/v1')
should contain_cinder_config('hpe3par_iscsi/hpe3par_username').with_value('3paradm')
should contain_cinder_config('hpe3par_iscsi/hpe3par_password').with_value('password')
should contain_cinder_config('hpe3par_iscsi/hpe3par_iscsi_ips').with_value('172.0.0.3')
should contain_cinder_config('hpe3par_iscsi/san_ip').with_value('172.0.0.2')
should contain_cinder_config('hpe3par_iscsi/san_login').with_value('3paradm')
should contain_cinder_config('hpe3par_iscsi/san_password').with_value('password')
}
end
context 'hpe3par_iscsi backend with additional configuration' do
before :each do
params.merge!( :extra_options => {'hpe3par_iscsi/param1' => {'value' => 'value1'}} )
end
it { should contain_cinder_config('hpe3par_iscsi/param1').with_value('value1') }
end
context 'hpe3par_iscsi backend with cinder type' do
before :each do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('hpe3par_iscsi').with(
:ensure => 'present',
:properties => ['volume_backend_name=hpe3par_iscsi']
)}
end
end
describe 'hpe3par_iscsi backend with additional configuration' do
before :each do
params.merge!({:extra_options => {'hpe3par_iscsi/param1' => {'value' => 'value1'}}})
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it 'configure hpe3par_iscsi backend with additional configuration' do
is_expected.to contain_cinder_config('hpe3par_iscsi/param1').with({
:value => 'value1',
})
it_behaves_like 'cinder::backend::hpe3par_iscsi'
end
end
describe 'hpe3par_iscsi backend with cinder type' do
before :each do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('hpe3par_iscsi').with(:ensure => :present, :properties => ['volume_backend_name=hpe3par_iscsi'])
end
end
end

View File

@ -17,36 +17,44 @@ describe 'cinder::backend::hpelefthand_iscsi' do
req_params
end
describe 'hpelefthand_iscsi volume driver' do
it 'configure hpelefthand_iscsi volume driver' do
is_expected.to contain_cinder_config('hpelefthand_iscsi/volume_driver').with_value('cinder.volume.drivers.hpe.hpe_lefthand_iscsi.HPELeftHandISCSIDriver')
is_expected.to contain_cinder_config('hpelefthand_iscsi/backend_availability_zone').with_value('my_zone')
is_expected.to contain_cinder_config('hpelefthand_iscsi/hpelefthand_api_url').with_value('https://10.206.219.18:8081/lhos')
is_expected.to contain_cinder_config('hpelefthand_iscsi/hpelefthand_username').with_value('admin')
is_expected.to contain_cinder_config('hpelefthand_iscsi/hpelefthand_password').with_value('password')
is_expected.to contain_cinder_config('hpelefthand_iscsi/hpelefthand_clustername').with_value('nfvsys_clust_001')
shared_examples 'cinder::backend::hpelefthand_iscsi' do
context 'hpelefthand_iscsi volume driver' do
it {
should contain_cinder_config('hpelefthand_iscsi/volume_driver').with_value('cinder.volume.drivers.hpe.hpe_lefthand_iscsi.HPELeftHandISCSIDriver')
should contain_cinder_config('hpelefthand_iscsi/backend_availability_zone').with_value('my_zone')
should contain_cinder_config('hpelefthand_iscsi/hpelefthand_api_url').with_value('https://10.206.219.18:8081/lhos')
should contain_cinder_config('hpelefthand_iscsi/hpelefthand_username').with_value('admin')
should contain_cinder_config('hpelefthand_iscsi/hpelefthand_password').with_value('password')
should contain_cinder_config('hpelefthand_iscsi/hpelefthand_clustername').with_value('nfvsys_clust_001')
}
end
context 'hpelefthand_iscsi backend with additional configuration' do
before :each do
params.merge!({:extra_options => {'hpelefthand_iscsi/param1' => {'value' => 'value1'}}})
end
it { should contain_cinder_config('hpelefthand_iscsi/param1').with_value('value1') }
end
context 'hpelefthand_iscsi backend with cinder type' do
before :each do
params.merge!({:manage_volume_type => true})
end
it { should contain_cinder_type('hpelefthand_iscsi').with(:ensure => :present, :properties => ['volume_backend_name=hpelefthand_iscsi']) }
end
end
describe 'hpelefthand_iscsi backend with additional configuration' do
before :each do
params.merge!({:extra_options => {'hpelefthand_iscsi/param1' => {'value' => 'value1'}}})
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it 'configure hpelefthand_iscsi backend with additional configuration' do
is_expected.to contain_cinder_config('hpelefthand_iscsi/param1').with({
:value => 'value1',
})
it_behaves_like 'cinder::backend::hpelefthand_iscsi'
end
end
describe 'hpelefthand_iscsi backend with cinder type' do
before :each do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('hpelefthand_iscsi').with(:ensure => :present, :properties => ['volume_backend_name=hpelefthand_iscsi'])
end
end
end

View File

@ -1,20 +1,13 @@
require 'spec_helper'
describe 'cinder::backend::iscsi' do
let(:title) {'hippo'}
let :req_params do {
:target_ip_address => '127.0.0.2',
:target_helper => 'tgtadm',
}
end
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } },
})
let :req_params do
{
:target_ip_address => '127.0.0.2',
:target_helper => 'tgtadm',
}
end
let :params do
@ -22,113 +15,108 @@ describe 'cinder::backend::iscsi' do
end
let :iser_params do
{:target_protocol => 'iser'}
{
:target_protocol => 'iser'
}
end
let :volumes_dir_params do
{:volumes_dir => '/etc/cinder/volumes'}
{
:volumes_dir => '/etc/cinder/volumes'
}
end
describe 'with default params' do
it 'should configure iscsi driver' do
is_expected.to contain_cinder_config('hippo/volume_backend_name').with(
:value => 'hippo')
is_expected.to contain_cinder_config('hippo/backend_availability_zone').with(
:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('hippo/volume_driver').with(
:value => 'cinder.volume.drivers.lvm.LVMVolumeDriver')
is_expected.to contain_cinder_config('hippo/target_ip_address').with(
:value => '127.0.0.2')
is_expected.to contain_cinder_config('hippo/target_helper').with(
:value => 'tgtadm')
is_expected.to contain_cinder_config('hippo/volume_group').with(
:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('hippo/volumes_dir').with(
:value => '/var/lib/cinder/volumes')
is_expected.to contain_cinder_config('hippo/target_protocol').with(
:value => '<SERVICE DEFAULT>')
end
end
describe 'with iser protocol' do
before :each do
params.merge!(iser_params)
shared_examples 'cinder::backend::iscsi' do
context 'with default params' do
it {
should contain_cinder_config('hippo/volume_backend_name').with_value('hippo')
should contain_cinder_config('hippo/backend_availability_zone').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('hippo/volume_driver').with_value('cinder.volume.drivers.lvm.LVMVolumeDriver')
should contain_cinder_config('hippo/target_ip_address').with_value('127.0.0.2')
should contain_cinder_config('hippo/target_helper').with_value('tgtadm')
should contain_cinder_config('hippo/volume_group').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('hippo/volumes_dir').with_value('/var/lib/cinder/volumes')
should contain_cinder_config('hippo/target_protocol').with_value('<SERVICE DEFAULT>')
}
end
it 'should configure iscsi driver with iser protocol' do
is_expected.to contain_cinder_config('hippo/target_protocol').with(
:value => 'iser')
end
end
context 'with iser protocol' do
before :each do
params.merge!(iser_params)
end
describe 'with non-default $volumes_dir' do
before :each do
params.merge!(volumes_dir_params)
it { should contain_cinder_config('hippo/target_protocol').with_value('iser') }
end
it 'should configure iscsi driver with /etc/cinder/volumes as volumes_dir' do
is_expected.to contain_cinder_config('hippo/volumes_dir').with(
:value => '/etc/cinder/volumes'
)
end
end
context 'with non-default volumes_dir' do
before :each do
params.merge!(volumes_dir_params)
end
describe 'iscsi backend with cinder type' do
before :each do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('hippo').with(:ensure => :present, :properties => ['volume_backend_name=hippo'])
end
end
describe 'iscsi backend with additional configuration' do
before :each do
params.merge!({:extra_options => {'hippo/param1' => {'value' => 'value1'}}})
it { should contain_cinder_config('hippo/volumes_dir').with_value('/etc/cinder/volumes') }
end
it 'configure iscsi backend with additional configuration' do
is_expected.to contain_cinder_config('hippo/param1').with({
context 'iscsi backend with cinder type' do
before :each do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('hippo').with(
:ensure => 'present',
:properties => ['volume_backend_name=hippo']
)}
end
context 'iscsi backend with additional configuration' do
before :each do
params.merge!( :extra_options => {'hippo/param1' => {'value' => 'value1'}} )
end
it { should contain_cinder_config('hippo/param1').with(
:value => 'value1',
})
)}
end
context 'with deprecated iscsi_ip_address' do
before :each do
params.merge!({
:target_ip_address => :undef,
:iscsi_ip_address => '127.0.0.42',
})
end
it { should contain_cinder_config('hippo/target_ip_address').with_value('127.0.0.42') }
end
context 'with no target_ip_address or iscsi_ip_address' do
before :each do
params.delete(:target_ip_address)
end
it { should raise_error(Puppet::Error, /A target_ip_address or iscsi_ip_address must be specified./) }
end
end
describe 'with deprecated iscsi_ip_address' do
before :each do
params.merge!({
:target_ip_address => :undef,
:iscsi_ip_address => '127.0.0.42',
})
end
it 'should configure iscsi backend using that address' do
should contain_cinder_config('hippo/target_ip_address').with_value('127.0.0.42')
end
end
describe 'with no target_ip_address or iscsi_ip_address' do
before :each do
params.delete(:target_ip_address)
end
it 'is expected to raise error' do
is_expected.to raise_error(Puppet::Error, /A target_ip_address or iscsi_ip_address must be specified./)
end
end
describe 'with RedHat' do
let :facts do
OSDefaults.get_facts({
:osfamily => 'RedHat',
:os => { :name => 'CentOS', :family => 'RedHat', :release => { :major => '7', :minor => '0' } },
})
end
it { is_expected.to contain_file_line('cinder include').with(
shared_examples 'cinder::backend::iscsi on RedHat' do
it { should contain_file_line('cinder include').with(
:line => 'include /var/lib/cinder/volumes/*',
:path => '/etc/tgt/targets.conf'
) }
)}
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::backend::iscsi'
if facts[:osfamily] == 'RedHat'
it_behaves_like 'cinder::backend::iscsi on RedHat'
end
end
end
end

View File

@ -1,13 +1,8 @@
require 'spec_helper'
describe 'cinder::backend::netapp' do
let(:title) {'netapp'}
let :facts do
OSDefaults.get_facts({})
end
let :params do
{
:volume_backend_name => 'netapp-cdot-nfs',
@ -26,132 +21,130 @@ describe 'cinder::backend::netapp' do
let :default_params do
{
:backend_availability_zone => '<SERVICE DEFAULT>',
:netapp_server_port => '80',
:netapp_size_multiplier => '1.2',
:netapp_storage_family => 'ontap_cluster',
:netapp_storage_protocol => 'nfs',
:netapp_transport_type => 'http',
:expiry_thres_minutes => '720',
:thres_avl_size_perc_start => '20',
:thres_avl_size_perc_stop => '60',
:nfs_shares_config => '/etc/cinder/shares.conf',
:nfs_mount_options => '<SERVICE DEFAULT>',
:netapp_webservice_path => '/devmgr/v2',
:nas_secure_file_operations => '<SERVICE DEFAULT>',
:nas_secure_file_permissions => '<SERVICE DEFAULT>',
:backend_availability_zone => '<SERVICE DEFAULT>',
:netapp_server_port => '80',
:netapp_size_multiplier => '1.2',
:netapp_storage_family => 'ontap_cluster',
:netapp_storage_protocol => 'nfs',
:netapp_transport_type => 'http',
:expiry_thres_minutes => '720',
:thres_avl_size_perc_start => '20',
:thres_avl_size_perc_stop => '60',
:nfs_shares_config => '/etc/cinder/shares.conf',
:nfs_mount_options => '<SERVICE DEFAULT>',
:netapp_webservice_path => '/devmgr/v2',
:nas_secure_file_operations => '<SERVICE DEFAULT>',
:nas_secure_file_permissions => '<SERVICE DEFAULT>',
}
end
shared_examples_for 'netapp volume driver' do
shared_examples 'netapp volume driver' do
let :params_hash do
default_params.merge(params)
end
it 'configures netapp volume driver' do
is_expected.to contain_cinder_config('netapp/volume_driver').with_value(
'cinder.volume.drivers.netapp.common.NetAppDriver')
it { should contain_cinder_config('netapp/volume_driver').with_value('cinder.volume.drivers.netapp.common.NetAppDriver') }
it {
params_hash.each_pair do |config,value|
is_expected.to contain_cinder_config("netapp/#{config}").with_value( value )
should contain_cinder_config("netapp/#{config}").with_value( value )
end
}
it {
should contain_cinder_config('netapp/netapp_password').with_secret( true )
should contain_cinder_config('netapp/netapp_sa_password').with_secret( true )
}
end
shared_examples 'cinder::backend::netapp' do
context 'with default parameters' do
before do
params = {}
end
it_behaves_like 'netapp volume driver'
end
it 'marks netapp_password as secret' do
is_expected.to contain_cinder_config('netapp/netapp_password').with_secret( true )
context 'with provided parameters' do
it_behaves_like 'netapp volume driver'
end
it 'marks netapp_sa_password as secret' do
is_expected.to contain_cinder_config('netapp/netapp_sa_password').with_secret( true )
context 'with netapp_storage_family eseries' do
before do
params.merge!( :netapp_storage_family => 'eseries' )
end
it { should contain_cinder_config('netapp/use_multipath_for_image_xfer').with_value('true') }
end
context 'with nfs_mount_options' do
before do
params.merge!( :nfs_mount_options => 'rw,proto=tcp,sec=sys' )
end
it { should contain_cinder_config('netapp/nfs_mount_options').with_value('rw,proto=tcp,sec=sys') }
end
context 'netapp backend with cinder type' do
before do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('netapp').with(
:ensure => 'present',
:properties => ['volume_backend_name=netapp']
)}
end
context 'netapp backend with additional configuration' do
before do
params.merge!( :extra_options => {'netapp/param1' => { 'value' => 'value1' }} )
end
it { should contain_cinder_config('netapp/param1').with_value('value1') }
end
context 'with NFS shares provided' do
before do
params.merge!( :nfs_shares => ['10.0.0.1:/test1', '10.0.0.2:/test2'],
:nfs_shares_config => '/etc/cinder/shares.conf' )
end
it { should contain_file('/etc/cinder/shares.conf').with(
:content => "10.0.0.1:/test1\n10.0.0.2:/test2",
)}
end
context 'with invalid NFS shares provided' do
before do
params.merge!({
:nfs_shares => "not an array",
:nfs_shares_config => '/etc/cinder/shares.conf',
})
end
it { should raise_error(Puppet::Error, /"not an array" is not an Array. It looks to be a String/) }
end
context 'with name search pattern' do
before do
params.merge!( :netapp_pool_name_search_pattern => '(something)' )
end
it { should contain_cinder_config('netapp/netapp_pool_name_search_pattern').with_value('(something)') }
end
end
context 'with default parameters' do
before do
params = {}
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'netapp volume driver'
end
context 'with provided parameters' do
it_configures 'netapp volume driver'
end
context 'with netapp_storage_family eseries' do
before do
params.merge!(:netapp_storage_family => 'eseries')
end
it 'sets use_multipath_for_image_xfer to true' do
is_expected.to contain_cinder_config('netapp/use_multipath_for_image_xfer').with({
:value => 'true'
})
end
end
context 'with nfs_mount_options' do
before do
params.merge!(:nfs_mount_options => 'rw,proto=tcp,sec=sys')
end
it 'sets the nfs mount options' do
is_expected.to contain_cinder_config('netapp/nfs_mount_options').with({
:value => 'rw,proto=tcp,sec=sys'
})
end
end
context 'netapp backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('netapp').with(:ensure => :present, :properties => ['volume_backend_name=netapp'])
end
end
context 'netapp backend with additional configuration' do
before do
params.merge!({:extra_options => {'netapp/param1' => { 'value' => 'value1' }}})
end
it 'configure netapp backend with additional configuration' do
is_expected.to contain_cinder_config('netapp/param1').with({
:value => 'value1'
})
end
end
context 'with NFS shares provided' do
let (:req_params) { params.merge!({
:nfs_shares => ['10.0.0.1:/test1', '10.0.0.2:/test2'],
:nfs_shares_config => '/etc/cinder/shares.conf',
}) }
it 'writes NFS shares to file' do
is_expected.to contain_file("#{req_params[:nfs_shares_config]}") \
.with_content("10.0.0.1:/test1\n10.0.0.2:/test2")
end
end
context 'with invalid NFS shares provided' do
before do
params.merge!({
:nfs_shares => "not an array",
:nfs_shares_config => '/etc/cinder/shares.conf',
})
end
it_raises 'a Puppet::Error', /"not an array" is not an Array. It looks to be a String/
end
context 'with name search pattern' do
before do
params.merge!({ :netapp_pool_name_search_pattern => '(something)' })
end
it 'configures name seach pattern' do
is_expected.to contain_cinder_config('netapp/netapp_pool_name_search_pattern').with_value('(something)')
it_behaves_like 'cinder::backend::netapp'
end
end
end

View File

@ -4,58 +4,67 @@ describe 'cinder::backend::nexenta_edge' do
let (:title) { 'nexenta_edge' }
let :params do
{ :nexenta_rest_user => 'nexenta',
{
:nexenta_rest_user => 'nexenta',
:nexenta_rest_password => 'password',
:nexenta_rest_address => '127.0.0.2',
:nexenta_client_address => '127.0.0.3' }
:nexenta_client_address => '127.0.0.3'
}
end
let :default_params do
{ :nexenta_rest_port => '8080',
{
:nexenta_rest_port => '8080',
:nexenta_lun_container => 'cinder',
:nexenta_iscsi_service => 'cinder',
:nexenta_chunksize => '32768',
:volume_driver => 'cinder.volume.drivers.nexenta.nexentaedge.iscsi.NexentaEdgeISCSIDriver',
:backend_availability_zone => '<SERVICE DEFAULT>',
:backend_availability_zone => '<SERVICE DEFAULT>'
}
end
let :facts do
OSDefaults.get_facts({})
end
context 'with required params' do
let :params_hash do
default_params.merge(params)
end
it 'configures nexenta edge volue driver' do
params_hash.each_pair do |config, value|
is_expected.to contain_cinder_config("nexenta_edge/#{config}").with_value(value)
shared_examples 'cinder::backend::nexenta_edge' do
context 'with required params' do
let :params_hash do
default_params.merge(params)
end
it {
params_hash.each_pair do |config, value|
should contain_cinder_config("nexenta_edge/#{config}").with_value(value)
end
}
end
context 'nexenta edge backend with additional configuration' do
before do
params.merge!( :extra_options => {'nexenta_edge/param1' => { 'value' => 'value1' }} )
end
it { should contain_cinder_config('nexenta_edge/param1').with_value('value1') }
end
context 'nexenta edge backend with cinder type' do
before do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('nexenta_edge').with(
:ensure => 'present',
:properties => ['volume_backend_name=nexenta_edge']
)}
end
end
context 'nexenta edge backend with additional configuration' do
before do
params.merge!({:extra_options => {'nexenta_edge/param1' => { 'value' => 'value1' }}})
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it 'configure nexenta edge backend with additional configuration' do
is_expected.to contain_cinder_config('nexenta_edge/param1').with({
:value => 'value1'
})
it_behaves_like 'cinder::backend::nexenta_edge'
end
end
context 'nexenta edge backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('nexenta_edge').with(:ensure => :present, :properties => ['volume_backend_name=nexenta_edge'])
end
end
end

View File

@ -7,13 +7,16 @@ describe 'cinder::backend::nexenta' do
let (:title) { 'nexenta' }
let :params do
{ :nexenta_user => 'nexenta',
{
:nexenta_user => 'nexenta',
:nexenta_password => 'password',
:nexenta_host => '127.0.0.2' }
:nexenta_host => '127.0.0.2'
}
end
let :default_params do
{ :nexenta_volume => 'cinder',
{
:nexenta_volume => 'cinder',
:nexenta_target_prefix => 'iqn:',
:nexenta_target_group_prefix => 'cinder/',
:nexenta_blocksize => '8192',
@ -24,42 +27,48 @@ describe 'cinder::backend::nexenta' do
}
end
let :facts do
OSDefaults.get_facts({})
end
context 'with required params' do
let :params_hash do
default_params.merge(params)
end
it 'configures nexenta volume driver' do
params_hash.each_pair do |config, value|
is_expected.to contain_cinder_config("nexenta/#{config}").with_value(value)
shared_examples 'cinder::backend::nexenta' do
context 'with required params' do
let :params_hash do
default_params.merge(params)
end
it {
params_hash.each_pair do |config, value|
should contain_cinder_config("nexenta/#{config}").with_value(value)
end
}
end
context 'nexenta backend with additional configuration' do
before do
params.merge!( :extra_options => {'nexenta/param1' => { 'value' => 'value1' }} )
end
it { should contain_cinder_config('nexenta/param1').with_value('value1') }
end
context 'nexenta backend with cinder type' do
before do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('nexenta').with(
:ensure => 'present',
:properties => ['volume_backend_name=nexenta']
)}
end
end
context 'nexenta backend with additional configuration' do
before do
params.merge!({:extra_options => {'nexenta/param1' => { 'value' => 'value1' }}})
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it 'configure nexenta backend with additional configuration' do
is_expected.to contain_cinder_config('nexenta/param1').with({
:value => 'value1'
})
it_behaves_like 'cinder::backend::nexenta'
end
end
context 'nexenta backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('nexenta').with(:ensure => :present, :properties => ['volume_backend_name=nexenta'])
end
end
end

View File

@ -1,7 +1,6 @@
require 'spec_helper'
describe 'cinder::backend::nfs' do
let(:title) {'hippo'}
let :params do
@ -23,66 +22,62 @@ describe 'cinder::backend::nfs' do
}
end
describe 'nfs volume driver' do
shared_examples 'cinder::backend::nfs' do
context 'nfs volume driver' do
it {
should contain_cinder_config('hippo/volume_backend_name').with_value('hippo')
should contain_cinder_config('hippo/backend_availability_zone').with_value('my_zone')
should contain_cinder_config('hippo/volume_driver').with_value('cinder.volume.drivers.nfs.NfsDriver')
should contain_cinder_config('hippo/nfs_shares_config').with_value('/etc/cinder/other_shares.conf')
should contain_cinder_config('hippo/nfs_mount_attempts').with_value('4')
should contain_cinder_config('hippo/nfs_mount_options').with_value('vers=3')
should contain_cinder_config('hippo/nfs_sparsed_volumes').with_value(true)
should contain_cinder_config('hippo/nfs_mount_point_base').with_value('/cinder_mount_point')
should contain_cinder_config('hippo/nfs_disk_util').with_value('du')
should contain_cinder_config('hippo/nfs_used_ratio').with_value('0.7')
should contain_cinder_config('hippo/nfs_oversub_ratio').with_value('0.9')
should contain_cinder_config('hippo/nas_secure_file_operations').with_value('auto')
should contain_cinder_config('hippo/nas_secure_file_permissions').with_value('false')
should contain_cinder_config('hippo/nfs_snapshot_support').with_value('true')
should contain_cinder_config('hippo/nfs_qcow2_volumes').with_value('true')
}
it 'configures nfs volume driver' do
is_expected.to contain_cinder_config('hippo/volume_backend_name').with(
:value => 'hippo')
is_expected.to contain_cinder_config('hippo/backend_availability_zone').with_value(
'my_zone')
is_expected.to contain_cinder_config('hippo/volume_driver').with_value(
'cinder.volume.drivers.nfs.NfsDriver')
is_expected.to contain_cinder_config('hippo/nfs_shares_config').with_value(
'/etc/cinder/other_shares.conf')
is_expected.to contain_cinder_config('hippo/nfs_mount_attempts').with_value(
'4')
is_expected.to contain_cinder_config('hippo/nfs_mount_options').with_value(
'vers=3')
is_expected.to contain_cinder_config('hippo/nfs_sparsed_volumes').with_value(
true)
is_expected.to contain_cinder_config('hippo/nfs_mount_point_base').with_value(
'/cinder_mount_point')
is_expected.to contain_cinder_config('hippo/nfs_disk_util').with_value(
'du')
is_expected.to contain_cinder_config('hippo/nfs_used_ratio').with_value(
'0.7')
is_expected.to contain_cinder_config('hippo/nfs_oversub_ratio').with_value(
'0.9')
is_expected.to contain_cinder_config('hippo/nas_secure_file_operations').with_value(
'auto')
is_expected.to contain_cinder_config('hippo/nas_secure_file_permissions').with_value(
'false')
is_expected.to contain_cinder_config('hippo/nfs_snapshot_support').with_value(
'true')
is_expected.to contain_cinder_config('hippo/nfs_qcow2_volumes').with_value(
'true')
is_expected.to contain_file('/etc/cinder/other_shares.conf').with(
it { should contain_file('/etc/cinder/other_shares.conf').with(
:content => "10.10.10.10:/shares\n10.10.10.10:/shares2",
:require => 'Anchor[cinder::install::end]',
:notify => 'Anchor[cinder::service::begin]'
)
)}
end
context 'nfs backend with additional configuration' do
before :each do
params.merge!( :extra_options => {'hippo/param1' => {'value' => 'value1'}} )
end
it { should contain_cinder_config('hippo/param1').with_value('value1') }
end
context 'nfs backend with cinder type' do
before :each do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('hippo').with(
:ensure => 'present',
:properties => ['volume_backend_name=hippo']
)}
end
end
describe 'nfs backend with additional configuration' do
before :each do
params.merge!({:extra_options => {'hippo/param1' => {'value' => 'value1'}}})
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it 'configure nfs backend with additional configuration' do
is_expected.to contain_cinder_config('hippo/param1').with({
:value => 'value1',
})
it_behaves_like 'cinder::backend::nfs'
end
end
describe 'nfs backend with cinder type' do
before :each do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('hippo').with(:ensure => :present, :properties => ['volume_backend_name=hippo'])
end
end
end

View File

@ -1,63 +1,58 @@
require 'spec_helper'
describe 'cinder::backend::nvmeof' do
let(:title) {'nvme-backend'}
let :req_params do {
:target_ip_address => '127.0.0.2',
:target_port => '4420',
:target_helper => 'nvmet',
:target_protocol => 'nvmet_rdma',
}
end
let :facts do
OSDefaults.get_facts({
:osfamily => 'Debian',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } },
})
let :req_params do
{
:target_ip_address => '127.0.0.2',
:target_port => '4420',
:target_helper => 'nvmet',
:target_protocol => 'nvmet_rdma',
}
end
let :params do
req_params
end
describe 'with default params' do
shared_examples 'cinder::backend::nvmeof' do
context 'with default params' do
it {
should contain_cinder_config('nvme-backend/target_ip_address').with_value('127.0.0.2')
should contain_cinder_config('nvme-backend/target_port').with_value('4420')
should contain_cinder_config('nvme-backend/target_helper').with_value('nvmet')
should contain_cinder_config('nvme-backend/target_protocol').with_value('nvmet_rdma')
should contain_cinder_config('nvme-backend/nvmet_port_id').with_value('1')
should contain_cinder_config('nvme-backend/nvmet_ns_id').with_value('10')
should contain_cinder_config('nvme-backend/volume_backend_name').with_value('nvme-backend')
should contain_cinder_config('nvme-backend/backend_availability_zone').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('nvme-backend/volume_driver').with_value('cinder.volume.drivers.lvm.LVMVolumeDriver')
}
it 'should configure nvmet target' do
is_expected.to contain_cinder_config('nvme-backend/target_ip_address').with(
:value => '127.0.0.2')
is_expected.to contain_cinder_config('nvme-backend/target_port').with(
:value => '4420')
is_expected.to contain_cinder_config('nvme-backend/target_helper').with(
:value => 'nvmet')
is_expected.to contain_cinder_config('nvme-backend/target_protocol').with(
:value => 'nvmet_rdma')
is_expected.to contain_cinder_config('nvme-backend/nvmet_port_id').with(
:value => '1')
is_expected.to contain_cinder_config('nvme-backend/nvmet_ns_id').with(
:value => '10')
is_expected.to contain_cinder_config('nvme-backend/volume_backend_name').with(
:value => 'nvme-backend')
is_expected.to contain_cinder_config('nvme-backend/backend_availability_zone').with(
:value => '<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('nvme-backend/volume_driver').with(
:value => 'cinder.volume.drivers.lvm.LVMVolumeDriver')
it { should contain_package('nvmetcli').with(
:name => 'nvmetcli',
:ensure => 'present',
:tag => 'cinder-support-package',
)}
it { should contain_package('nvme-cli').with(
:name => 'nvme-cli',
:ensure => 'present',
:tag => 'cinder-support-package',
)}
end
it { is_expected.to contain_package('nvmetcli').with(
:name => 'nvmetcli',
:ensure => 'present',
:tag => 'cinder-support-package',
) }
it { is_expected.to contain_package('nvme-cli').with(
:name => 'nvme-cli',
:ensure => 'present',
:tag => 'cinder-support-package',
) }
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::backend::nvmeof'
end
end
end

View File

@ -10,72 +10,85 @@ describe 'cinder::backend::pure' do
}
end
describe 'pure volume driver defaults' do
let :params do
req_params
shared_examples 'cinder::backend::pure' do
context 'pure volume driver defaults' do
let :params do
req_params
end
it {
should contain_cinder_config('pure/volume_driver').with_value('cinder.volume.drivers.pure.PureISCSIDriver')
should contain_cinder_config('pure/san_ip').with_value('127.0.0.2')
should contain_cinder_config('pure/pure_api_token').with_value('abc123def456ghi789')
should contain_cinder_config('pure/use_multipath_for_image_xfer').with_value('true')
should contain_cinder_config('pure/use_chap_auth').with_value('false')
}
end
it 'configure pure volume driver' do
is_expected.to contain_cinder_config('pure/volume_driver').with_value('cinder.volume.drivers.pure.PureISCSIDriver')
is_expected.to contain_cinder_config('pure/san_ip').with_value('127.0.0.2')
is_expected.to contain_cinder_config('pure/pure_api_token').with_value('abc123def456ghi789')
is_expected.to contain_cinder_config('pure/use_multipath_for_image_xfer').with_value('true')
is_expected.to contain_cinder_config('pure/use_chap_auth').with_value('false')
end
end
context 'pure iscsi volume driver' do
let :params do
req_params.merge({
:backend_availability_zone => 'my_zone',
:pure_storage_protocol => 'iSCSI',
:use_chap_auth => 'true',
})
end
describe 'pure iscsi volume driver' do
let :params do
req_params.merge({
'backend_availability_zone' => 'my_zone',
'pure_storage_protocol' => 'iSCSI',
'use_chap_auth' => 'true',
})
it {
should contain_cinder_config('pure/volume_driver').with_value('cinder.volume.drivers.pure.PureISCSIDriver')
should contain_cinder_config('pure/backend_availability_zone').with_value('my_zone')
should contain_cinder_config('pure/san_ip').with_value('127.0.0.2')
should contain_cinder_config('pure/pure_api_token').with_value('abc123def456ghi789')
should contain_cinder_config('pure/use_multipath_for_image_xfer').with_value('true')
should contain_cinder_config('pure/use_chap_auth').with_value('true')
}
end
it 'configure pure volume driver' do
is_expected.to contain_cinder_config('pure/volume_driver').with_value('cinder.volume.drivers.pure.PureISCSIDriver')
is_expected.to contain_cinder_config('pure/backend_availability_zone').with_value('my_zone')
is_expected.to contain_cinder_config('pure/san_ip').with_value('127.0.0.2')
is_expected.to contain_cinder_config('pure/pure_api_token').with_value('abc123def456ghi789')
is_expected.to contain_cinder_config('pure/use_multipath_for_image_xfer').with_value('true')
is_expected.to contain_cinder_config('pure/use_chap_auth').with_value('true')
end
end
context 'pure fc volume driver' do
let :params do
req_params.merge({'pure_storage_protocol' => 'FC'})
end
describe 'pure fc volume driver' do
let :params do
req_params.merge({'pure_storage_protocol' => 'FC'})
it {
should contain_cinder_config('pure/volume_driver').with_value('cinder.volume.drivers.pure.PureFCDriver')
should contain_cinder_config('pure/san_ip').with_value('127.0.0.2')
should contain_cinder_config('pure/pure_api_token').with_value('abc123def456ghi789')
should contain_cinder_config('pure/use_multipath_for_image_xfer').with_value('true')
should contain_cinder_config('pure/use_chap_auth').with_value('false')
}
end
it 'configure pure volume driver' do
is_expected.to contain_cinder_config('pure/volume_driver').with_value('cinder.volume.drivers.pure.PureFCDriver')
is_expected.to contain_cinder_config('pure/san_ip').with_value('127.0.0.2')
is_expected.to contain_cinder_config('pure/pure_api_token').with_value('abc123def456ghi789')
is_expected.to contain_cinder_config('pure/use_multipath_for_image_xfer').with_value('true')
is_expected.to contain_cinder_config('pure/use_chap_auth').with_value('false')
end
end
context 'pure volume driver with additional configuration' do
let :params do
req_params.merge({:extra_options => {'pure_backend/param1' => {'value' => 'value1'}}})
end
describe 'pure volume driver with additional configuration' do
let :params do
req_params.merge({:extra_options => {'pure_backend/param1' => {'value' => 'value1'}}})
end
it 'configure pure volume with additional configuration' do
is_expected.to contain_cinder__backend__pure('pure').with({
it { should contain_cinder__backend__pure('pure').with(
:extra_options => {'pure_backend/param1' => {'value' => 'value1'}}
})
)}
end
context 'pure backend with cinder type' do
let :params do
req_params.merge!({:manage_volume_type => true})
end
it { should contain_cinder_type('pure').with(
:ensure => 'present',
:properties => ['volume_backend_name=pure']
)}
end
end
describe 'pure backend with cinder type' do
let :params do
req_params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('pure').with(:ensure => :present, :properties => ['volume_backend_name=pure'])
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::backend::pure'
end
end
end

View File

@ -1,8 +1,7 @@
require 'spec_helper'
describe 'cinder::backend::quobyte' do
shared_examples_for 'quobyte volume driver' do
shared_examples 'cinder::backend::quobyte' do
let(:title) {'myquobyte'}
let :params do
@ -14,39 +13,41 @@ describe 'cinder::backend::quobyte' do
}
end
it 'configures quobyte volume driver' do
is_expected.to contain_cinder_config('myquobyte/volume_driver').with_value(
'cinder.volume.drivers.quobyte.QuobyteDriver')
is_expected.to contain_cinder_config('myquobyte/quobyte_volume_url').with_value(
'quobyte://quobyte.cluster.example.com/volume-name')
is_expected.to contain_cinder_config('myquobyte/quobyte_qcow2_volumes').with_value(
false)
is_expected.to contain_cinder_config('myquobyte/quobyte_sparsed_volumes').with_value(
true)
is_expected.to contain_cinder_config('myquobyte/backend_availability_zone').with_value(
'my_zone')
end
it { should contain_cinder_config('myquobyte/volume_driver').with(
:value => 'cinder.volume.drivers.quobyte.QuobyteDriver'
)}
it { should contain_cinder_config('myquobyte/quobyte_volume_url').with(
:value => 'quobyte://quobyte.cluster.example.com/volume-name'
)}
it {
should contain_cinder_config('myquobyte/quobyte_qcow2_volumes').with_value(false)
should contain_cinder_config('myquobyte/quobyte_sparsed_volumes').with_value(true)
should contain_cinder_config('myquobyte/backend_availability_zone').with_value('my_zone')
}
context 'quobyte backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('myquobyte').with(:ensure => :present, :properties => ['volume_backend_name=myquobyte'])
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('myquobyte').with(
:ensure => 'present',
:properties => ['volume_backend_name=myquobyte']
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
facts.merge(OSDefaults.get_facts( :os_workers => 8 ))
end
it_configures 'quobyte volume driver'
it_behaves_like 'cinder::backend::quobyte'
end
end
end

View File

@ -1,13 +1,8 @@
require 'spec_helper'
describe 'cinder::backend::rbd' do
let(:title) {'rbd-ssd'}
let :facts do
OSDefaults.get_facts({})
end
let :req_params do
{
:volume_backend_name => 'rbd-ssd',
@ -24,125 +19,116 @@ describe 'cinder::backend::rbd' do
}
end
it { is_expected.to contain_class('cinder::params') }
let :params do
req_params
end
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
:os => { :name => 'Debian', :family => 'Debian', :release => { :major => '8', :minor => '0' } },
})
end
shared_examples 'cinder::backend::rbd' do
it { should contain_class('cinder::params') }
describe 'rbd backend volume driver' do
it 'configure rbd volume driver' do
is_expected.to contain_package('ceph-common').with(:ensure => :present)
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/volume_backend_name").with_value(req_params[:volume_backend_name])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/volume_driver").with_value('cinder.volume.drivers.rbd.RBDDriver')
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_ceph_conf").with_value(req_params[:rbd_ceph_conf])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_flatten_volume_from_snapshot").with_value(req_params[:rbd_flatten_volume_from_snapshot])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_max_clone_depth").with_value(req_params[:rbd_max_clone_depth])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_pool").with_value(req_params[:rbd_pool])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_user").with_value(req_params[:rbd_user])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_secret_uuid").with_value(req_params[:rbd_secret_uuid])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/backend_host").with_value('rbd:'"#{req_params[:rbd_pool]}")
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rados_connect_timeout").with_value(req_params[:rados_connect_timeout])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rados_connection_interval").with_value(req_params[:rados_connection_interval])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rados_connection_retries").with_value(req_params[:rados_connection_retries])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_store_chunk_size").with_value(req_params[:rbd_store_chunk_size])
is_expected.to contain_file('/etc/init/cinder-volume.override').with(:ensure => 'present')
is_expected.to contain_file_line('set initscript env rbd-ssd').with(
:line => /env CEPH_ARGS=\"--id test\"/,
:path => '/etc/init/cinder-volume.override',
:notify => 'Anchor[cinder::service::begin]')
end
context 'rbd backend volume driver' do
it {
should contain_package('ceph-common').with_ensure('present')
should contain_cinder_config("#{req_params[:volume_backend_name]}/volume_backend_name").with_value(req_params[:volume_backend_name])
should contain_cinder_config("#{req_params[:volume_backend_name]}/volume_driver").with_value('cinder.volume.drivers.rbd.RBDDriver')
should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_ceph_conf").with_value(req_params[:rbd_ceph_conf])
should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_flatten_volume_from_snapshot").with_value(req_params[:rbd_flatten_volume_from_snapshot])
should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_max_clone_depth").with_value(req_params[:rbd_max_clone_depth])
should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_pool").with_value(req_params[:rbd_pool])
should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_user").with_value(req_params[:rbd_user])
should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_secret_uuid").with_value(req_params[:rbd_secret_uuid])
should contain_cinder_config("#{req_params[:volume_backend_name]}/backend_host").with_value('rbd:'"#{req_params[:rbd_pool]}")
should contain_cinder_config("#{req_params[:volume_backend_name]}/rados_connect_timeout").with_value(req_params[:rados_connect_timeout])
should contain_cinder_config("#{req_params[:volume_backend_name]}/rados_connection_interval").with_value(req_params[:rados_connection_interval])
should contain_cinder_config("#{req_params[:volume_backend_name]}/rados_connection_retries").with_value(req_params[:rados_connection_retries])
should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_store_chunk_size").with_value(req_params[:rbd_store_chunk_size])
}
context 'with another RBD backend' do
let :pre_condition do
"cinder::backend::rbd { 'ceph2':
rbd_ceph_conf => '/foo/boo/zoo/ceph2.conf',
rbd_pool => 'volumes2',
rbd_user => 'test2'
}"
end
it { is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/volume_driver").with_value('cinder.volume.drivers.rbd.RBDDriver') }
it { is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_pool").with_value(req_params[:rbd_pool]) }
it { is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_user").with_value(req_params[:rbd_user]) }
it { is_expected.to contain_cinder_config("ceph2/volume_driver").with_value('cinder.volume.drivers.rbd.RBDDriver') }
it { is_expected.to contain_cinder_config("ceph2/rbd_cluster_name").with_value('ceph2') }
it { is_expected.to contain_cinder_config("ceph2/rbd_pool").with_value('volumes2') }
it { is_expected.to contain_cinder_config("ceph2/rbd_user").with_value('test2') }
end
context 'with another RBD backend' do
let :pre_condition do
"cinder::backend::rbd { 'ceph2':
rbd_ceph_conf => '/foo/boo/zoo/ceph2.conf',
rbd_pool => 'volumes2',
rbd_user => 'test2'
}"
end
context 'rbd backend with additional configuration' do
before do
params.merge!({:extra_options => {'rbd-ssd/param1' => { 'value' => 'value1' }}})
it { should contain_cinder_config("#{req_params[:volume_backend_name]}/volume_driver").with_value('cinder.volume.drivers.rbd.RBDDriver') }
it { should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_pool").with_value(req_params[:rbd_pool]) }
it { should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_user").with_value(req_params[:rbd_user]) }
it { should contain_cinder_config("ceph2/volume_driver").with_value('cinder.volume.drivers.rbd.RBDDriver') }
it { should contain_cinder_config("ceph2/rbd_cluster_name").with_value('ceph2') }
it { should contain_cinder_config("ceph2/rbd_pool").with_value('volumes2') }
it { should contain_cinder_config("ceph2/rbd_user").with_value('test2') }
end
it 'configure rbd backend with additional configuration' do
is_expected.to contain_cinder_config('rbd-ssd/param1').with({
:value => 'value1'
})
end
end
context 'rbd backend with additional configuration' do
before do
params.merge!( :extra_options => {'rbd-ssd/param1' => { 'value' => 'value1' }} )
end
context 'override backend_host and backend_availability_zone parameters' do
before do
params.merge!(
{
it { should contain_cinder_config('rbd-ssd/param1').with_value('value1') }
end
context 'override backend_host and backend_availability_zone parameters' do
before do
params.merge!({
:backend_host => 'test_host.fqdn.com',
:backend_availability_zone => 'my_zone',
})
end
it { should contain_cinder_config('rbd-ssd/backend_host').with_value('test_host.fqdn.com') }
it { should contain_cinder_config('rbd-ssd/backend_availability_zone').with_value('my_zone') }
end
it 'configure rbd backend with specific hostname and availability zone' do
is_expected.to contain_cinder_config('rbd-ssd/backend_host').with({
:value => 'test_host.fqdn.com',
})
is_expected.to contain_cinder_config('rbd-ssd/backend_availability_zone').with({
:value => 'my_zone',
})
context 'rbd backend with cinder type' do
before do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('rbd-ssd').with(
:ensure => 'present',
:properties => ['volume_backend_name=rbd-ssd']
)}
end
end
context 'rbd backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('rbd-ssd').with(:ensure => :present, :properties => ['volume_backend_name=rbd-ssd'])
end
end
end
describe 'with RedHat' do
let :facts do
@default_facts.merge({
:osfamily => 'RedHat',
:os => { :name => 'CentOS', :family => 'RedHat', :release => { :major => '7', :minor => '0' } },
})
end
let :params do
req_params
end
it 'should ensure that the cinder-volume sysconfig file is present' do
is_expected.to contain_file('/etc/sysconfig/openstack-cinder-volume').with(
:ensure => 'present'
)
end
it 'should configure RedHat init override' do
is_expected.to contain_file_line('set initscript env rbd-ssd').with(
:line => /export CEPH_ARGS=\"--id test\"/,
:path => '/etc/sysconfig/openstack-cinder-volume',
:notify => 'Anchor[cinder::service::begin]')
end
end
shared_examples 'cinder::backend::rbd on Debian' do
it { should contain_file('/etc/init/cinder-volume.override').with(
:ensure => 'present'
)}
it { should contain_file_line('set initscript env rbd-ssd').with(
:line => /env CEPH_ARGS=\"--id test\"/,
:path => '/etc/init/cinder-volume.override',
:notify => 'Anchor[cinder::service::begin]'
)}
end
shared_examples 'cinder::backend::rbd on RedHat' do
it { should contain_file('/etc/sysconfig/openstack-cinder-volume').with(
:ensure => 'present'
)}
it { should contain_file_line('set initscript env rbd-ssd').with(
:line => /export CEPH_ARGS=\"--id test\"/,
:path => '/etc/sysconfig/openstack-cinder-volume',
:notify => 'Anchor[cinder::service::begin]'
)}
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::backend::rbd'
it_behaves_like "cinder::backend::rbd on #{facts[:osfamily]}"
end
end
end

View File

@ -15,51 +15,63 @@ describe 'cinder::backend::san' do
end
let :default_params do
{ :san_thin_provision => true,
{
:san_thin_provision => true,
:san_login => 'admin',
:san_ssh_port => 22,
:san_is_local => false,
:ssh_conn_timeout => 30,
:ssh_min_pool_conn => 1,
:ssh_max_pool_conn => 5 }
:ssh_max_pool_conn => 5
}
end
shared_examples_for 'a san volume driver' do
shared_examples 'a san volume driver' do
let :params_hash do
default_params.merge(params)
end
it 'configures cinder volume driver' do
it {
params_hash.each_pair do |config,value|
is_expected.to contain_cinder_config("mysan/#{config}").with_value( value )
should contain_cinder_config("mysan/#{config}").with_value(value)
end
}
end
shared_examples 'cinder::backend::san' do
context 'with parameters' do
it_behaves_like 'a san volume driver'
end
context 'san backend with additional configuration' do
before do
params.merge!( :extra_options => {'mysan/param1' => { 'value' => 'value1' }} )
end
it { should contain_cinder_config('mysan/param1').with_value('value1') }
end
context 'san backend with cinder type' do
before do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('mysan').with(
:ensure => 'present',
:properties => ['volume_backend_name=mysan']
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
context 'with parameters' do
it_configures 'a san volume driver'
end
context 'san backend with additional configuration' do
before do
params.merge!({:extra_options => {'mysan/param1' => { 'value' => 'value1' }}})
end
it 'configure san backend with additional configuration' do
is_expected.to contain_cinder_config('mysan/param1').with({
:value => 'value1'
})
it_behaves_like 'cinder::backend::san'
end
end
context 'san backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('mysan').with(:ensure => :present, :properties => ['volume_backend_name=mysan'])
end
end
end

View File

@ -5,12 +5,12 @@ describe 'cinder::backend::scaleio' do
let :params1 do
{
:sio_login => 'admin',
:sio_password => 'password',
:sio_server_hostname => 'scaleio.example.com',
:sio_server_port => '443',
:manage_volume_type => true,
:sio_thin_provision => false,
:sio_login => 'admin',
:sio_password => 'password',
:sio_server_hostname => 'scaleio.example.com',
:sio_server_port => '443',
:manage_volume_type => true,
:sio_thin_provision => false,
}
end
@ -34,45 +34,57 @@ describe 'cinder::backend::scaleio' do
params1.merge(params2)
end
describe 'scaleio volume driver' do
it 'configures scaleio volume driver' do
is_expected.to contain_cinder_config("#{title}/volume_driver").with_value(
'cinder.volume.drivers.dell_emc.scaleio.driver.ScaleIODriver')
is_expected.to contain_cinder_config("#{title}/san_login").with_value('admin')
is_expected.to contain_cinder_config("#{title}/san_ip").with_value('scaleio.example.com')
is_expected.to contain_cinder_config("#{title}/san_thin_provision").with_value('false')
is_expected.to contain_cinder_config("#{title}/sio_rest_server_port").with_value('443')
params2.each_pair do |config,value|
is_expected.to contain_cinder_config("#{title}/#{config}").with_value(value)
shared_examples 'cinder::backend::scaleio' do
context 'scaleio volume driver' do
it { should contain_cinder_config("#{title}/volume_driver").with(
:value => 'cinder.volume.drivers.dell_emc.scaleio.driver.ScaleIODriver'
)}
it {
should contain_cinder_config("#{title}/san_login").with_value('admin')
should contain_cinder_config("#{title}/san_ip").with_value('scaleio.example.com')
should contain_cinder_config("#{title}/san_thin_provision").with_value('false')
should contain_cinder_config("#{title}/sio_rest_server_port").with_value('443')
}
it {
params2.each_pair do |config,value|
should contain_cinder_config("#{title}/#{config}").with_value(value)
end
}
it { should contain_cinder_config("#{title}/san_password").with_secret(true) }
end
context 'scaleio backend with additional configuration' do
before :each do
params.merge!( :extra_options => {"#{title}/param1" => {'value' => 'value1'}} )
end
it { should contain_cinder_config("#{title}/param1").with_value('value1') }
end
it 'marks sio_password as secret' do
is_expected.to contain_cinder_config("#{title}/san_password").with_secret( true )
context 'scaleio backend with cinder type' do
before :each do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type("#{title}").with(
:ensure => 'present',
:properties => ["volume_backend_name=#{title}"]
)}
end
end
describe 'scaleio backend with additional configuration' do
before :each do
params.merge!({:extra_options => {"#{title}/param1" => {'value' => 'value1'}}})
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it 'configure scaleio backend with additional configuration' do
is_expected.to contain_cinder_config("#{title}/param1").with({
:value => 'value1',
})
it_behaves_like 'cinder::backend::scaleio'
end
end
describe 'scaleio backend with cinder type' do
before :each do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type("#{title}").with(
:ensure => :present, :properties => ["volume_backend_name=#{title}"])
end
end
end

View File

@ -15,104 +15,98 @@ describe 'cinder::backend::solidfire' do
let :other_params do
{
:backend_availability_zone => '<SERVICE DEFAULT>',
:sf_emulate_512 => '<SERVICE DEFAULT>',
:sf_allow_tenant_qos => '<SERVICE DEFAULT>',
:sf_account_prefix => '<SERVICE DEFAULT>',
:sf_template_account_name => '<SERVICE DEFAULT>',
:sf_allow_template_caching => '<SERVICE DEFAULT>',
:sf_api_port => '<SERVICE DEFAULT>',
:sf_volume_prefix => '<SERVICE DEFAULT>',
:sf_svip => '<SERVICE DEFAULT>',
:sf_enable_volume_mapping => '<SERVICE DEFAULT>',
:sf_enable_vag => '<SERVICE DEFAULT>',
:backend_availability_zone => '<SERVICE DEFAULT>',
:sf_emulate_512 => '<SERVICE DEFAULT>',
:sf_allow_tenant_qos => '<SERVICE DEFAULT>',
:sf_account_prefix => '<SERVICE DEFAULT>',
:sf_template_account_name => '<SERVICE DEFAULT>',
:sf_allow_template_caching => '<SERVICE DEFAULT>',
:sf_api_port => '<SERVICE DEFAULT>',
:sf_volume_prefix => '<SERVICE DEFAULT>',
:sf_svip => '<SERVICE DEFAULT>',
:sf_enable_volume_mapping => '<SERVICE DEFAULT>',
:sf_enable_vag => '<SERVICE DEFAULT>',
}
end
let :facts do
OSDefaults.get_facts({})
end
context 'SolidFire backend driver with minimal params' do
let :params do
req_params
end
it 'configure solidfire volume driver' do
is_expected.to contain_cinder__backend__solidfire(config_group_name)
is_expected.to contain_cinder_config(
"#{config_group_name}/volume_driver").with_value(
'cinder.volume.drivers.solidfire.SolidFireDriver')
params.each_pair do |config,value|
is_expected.to contain_cinder_config(
"#{config_group_name}/#{config}").with_value(value)
shared_examples 'cinder::backend::solidfire' do
context 'SolidFire backend driver with minimal params' do
let :params do
req_params
end
it { should contain_cinder__backend__solidfire(config_group_name) }
it { should contain_cinder_config("#{config_group_name}/volume_driver").with(
:value => 'cinder.volume.drivers.solidfire.SolidFireDriver'
)}
it {
params.each_pair do |config,value|
should contain_cinder_config(
"#{config_group_name}/#{config}").with_value(value)
end
}
it { should contain_cinder_config('solidfire/san_password').with_secret(true) }
end
it 'marks san_password as secret' do
is_expected.to contain_cinder_config('solidfire/san_password'
).with_secret( true )
end
end
context 'SolidFire backend driver with all params' do
let :params do
req_params.merge(other_params)
end
it 'configure solidfire volume driver' do
is_expected.to contain_cinder__backend__solidfire(config_group_name)
is_expected.to contain_cinder_config(
"#{config_group_name}/volume_driver").with_value(
'cinder.volume.drivers.solidfire.SolidFireDriver')
params.each_pair do |config,value|
is_expected.to contain_cinder_config(
"#{config_group_name}/#{config}").with_value(value)
context 'SolidFire backend driver with all params' do
let :params do
req_params.merge(other_params)
end
it { should contain_cinder__backend__solidfire(config_group_name) }
it { should contain_cinder_config("#{config_group_name}/volume_driver").with(
:value => 'cinder.volume.drivers.solidfire.SolidFireDriver'
)}
it {
params.each_pair do |config,value|
should contain_cinder_config(
"#{config_group_name}/#{config}").with_value(value)
end
}
it { should contain_cinder_config('solidfire/san_password').with_secret(true) }
end
it 'marks san_password as secret' do
is_expected.to contain_cinder_config('solidfire/san_password'
).with_secret( true )
context 'solidfire backend with additional configuration' do
let :params do
req_params
end
before :each do
params.merge!( :extra_options => {'solidfire/param1' => {'value' => 'value1'}} )
end
it { should contain_cinder_config('solidfire/param1').with_value('value1') }
end
end
context 'solidfire backend with cinder type' do
let :params do
req_params
end
context 'solidfire backend with additional configuration' do
let :params do
req_params
end
before :each do
params.merge!({:extra_options =>
{'solidfire/param1' => {'value' => 'value1'}}})
end
before :each do
params.merge!( :manage_volume_type => true )
end
it 'configure solidfire backend with additional configuration' do
is_expected.to contain_cinder_config('solidfire/param1').with({
:value => 'value1',
})
it { should contain_cinder_type('solidfire').with(
:ensure => 'present',
:properties => ['volume_backend_name=solidfire']
)}
end
end
context 'solidfire backend with cinder type' do
let :params do
req_params
end
before :each do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('solidfire').with(:ensure => :present, :properties => ['volume_backend_name=solidfire'])
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::backend::solidfire'
end
end
context 'without required parameters' do
before do
params = {}
end
it { expect { is_expected.to raise_error(Puppet::PreformattedError) } }
end
end

View File

@ -1,47 +1,43 @@
require 'spec_helper'
describe 'cinder::backend::veritas_hyperscale' do
let (:title) { 'Veritas_HyperScale' }
let :params do {
let :params do
{
:backend_availability_zone => 'my_zone',
:manage_volume_type => true,
}
end
shared_examples_for 'veritas_hyperscale volume driver' do
it 'configures veritas_hyperscale volume driver' do
should contain_cinder_config("#{title}/volume_driver").with_value(
'cinder.volume.drivers.veritas.vrtshyperscale.HyperScaleDriver')
should contain_cinder_config("#{title}/volume_backend_name").with_value(
"#{title}")
should contain_cinder_config("#{title}/backend_availability_zone").with_value(
'my_zone')
should contain_cinder_config("#{title}/image_volume_cache_enabled").with_value(
true)
end
shared_examples 'cinder::backend::veritas_hyperscale' do
it { should contain_cinder_config("#{title}/volume_driver").with(
:value => 'cinder.volume.drivers.veritas.vrtshyperscale.HyperScaleDriver'
)}
describe 'veritas_hyperscale backend with additional configuration' do
it {
should contain_cinder_config("#{title}/volume_backend_name").with_value(title)
should contain_cinder_config("#{title}/backend_availability_zone").with_value('my_zone')
should contain_cinder_config("#{title}/image_volume_cache_enabled").with_value(true)
}
context 'veritas_hyperscale backend with additional configuration' do
before do
params.merge!({:extra_options => {"#{title}/param1" => {'value' => 'value1'}}})
params.merge!( :extra_options => {"#{title}/param1" => {'value' => 'value1'}} )
end
it 'configure veritas_hyperscale backend with additional configuration' do
is_expected.to contain_cinder_config("#{title}/param1").with({
:value => 'value1',
})
end
it { should contain_cinder_config("#{title}/param1").with_value('value1') }
end
end
describe 'veritas_hyperScale backend with cinder type' do
before :each do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type("#{title}").with(
:ensure => :present, :properties => ["volume_backend_name=#{title}"])
context 'veritas_hyperScale backend with cinder type' do
before :each do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type(title).with(
:ensure => 'present',
:properties => ["volume_backend_name=#{title}"]
)}
end
end
@ -53,8 +49,7 @@ describe 'cinder::backend::veritas_hyperscale' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'veritas_hyperscale volume driver'
it_behaves_like 'cinder::backend::veritas_hyperscale'
end
end
end

View File

@ -1,93 +1,96 @@
require 'spec_helper'
describe 'cinder::backend::vmdk' do
let(:title) { 'hippo' }
let :facts do
OSDefaults.get_facts({})
end
let :params do
{
:host_ip => '172.16.16.16',
:host_password => 'asdf',
:host_username => 'user',
:api_retry_count => '<SERVICE DEFAULT>',
:max_object_retrieval => '<SERVICE DEFAULT>',
:image_transfer_timeout_secs => '<SERVICE DEFAULT>'
:host_ip => '172.16.16.16',
:host_password => 'asdf',
:host_username => 'user',
:api_retry_count => '<SERVICE DEFAULT>',
:max_object_retrieval => '<SERVICE DEFAULT>',
:image_transfer_timeout_secs => '<SERVICE DEFAULT>'
}
end
let :optional_params do
{
:volume_folder => 'cinder-volume-folder',
:api_retry_count => 5,
:max_object_retrieval => 200,
:task_poll_interval => 10,
:image_transfer_timeout_secs => 3600,
:backend_availability_zone => 'my_zone',
:wsdl_location => 'http://127.0.0.1:8080/vmware/SDK/wsdl/vim25/vimService.wsdl'
:volume_folder => 'cinder-volume-folder',
:api_retry_count => 5,
:max_object_retrieval => 200,
:task_poll_interval => 10,
:image_transfer_timeout_secs => 3600,
:backend_availability_zone => 'my_zone',
:wsdl_location => 'http://127.0.0.1:8080/vmware/SDK/wsdl/vim25/vimService.wsdl'
}
end
it 'should configure vmdk driver in cinder.conf' do
is_expected.to contain_cinder_config('hippo/volume_backend_name').with_value('hippo')
is_expected.to contain_cinder_config('hippo/volume_driver').with_value('cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver')
is_expected.to contain_cinder_config('hippo/vmware_host_ip').with_value(params[:host_ip])
is_expected.to contain_cinder_config('hippo/vmware_host_username').with_value(params[:host_username])
is_expected.to contain_cinder_config('hippo/vmware_host_password').with_value(params[:host_password]).with_secret(true)
is_expected.to contain_cinder_config('hippo/vmware_volume_folder').with_value('cinder-volumes')
is_expected.to contain_cinder_config('hippo/vmware_api_retry_count').with_value(params[:api_retry_count])
is_expected.to contain_cinder_config('hippo/vmware_max_object_retrieval').with_value(params[:max_object_retrieval])
is_expected.to contain_cinder_config('hippo/vmware_task_poll_interval').with_value(5)
is_expected.to contain_cinder_config('hippo/vmware_image_transfer_timeout_secs').with_value(params[:image_transfer_timeout_secs])
is_expected.to contain_cinder_config('hippo/vmware_wsdl_location').with_value('<SERVICE DEFAULT>')
is_expected.to contain_cinder_config('hippo/backend_availability_zone').with_value('<SERVICE DEFAULT>')
end
shared_examples 'cinder::backend::vmdk' do
it {
should contain_cinder_config('hippo/volume_backend_name').with_value('hippo')
should contain_cinder_config('hippo/volume_driver').with_value('cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver')
should contain_cinder_config('hippo/vmware_host_ip').with_value(params[:host_ip])
should contain_cinder_config('hippo/vmware_host_username').with_value(params[:host_username])
should contain_cinder_config('hippo/vmware_host_password').with_value(params[:host_password]).with_secret(true)
should contain_cinder_config('hippo/vmware_volume_folder').with_value('cinder-volumes')
should contain_cinder_config('hippo/vmware_api_retry_count').with_value(params[:api_retry_count])
should contain_cinder_config('hippo/vmware_max_object_retrieval').with_value(params[:max_object_retrieval])
should contain_cinder_config('hippo/vmware_task_poll_interval').with_value(5)
should contain_cinder_config('hippo/vmware_image_transfer_timeout_secs').with_value(params[:image_transfer_timeout_secs])
should contain_cinder_config('hippo/vmware_wsdl_location').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('hippo/backend_availability_zone').with_value('<SERVICE DEFAULT>')
}
it 'installs suds python package' do
is_expected.to contain_package('python-suds').with(
:ensure => 'present')
end
it { should contain_package('python-suds').with_ensure('present') }
context 'with optional parameters' do
before :each do
params.merge!(optional_params)
context 'with optional parameters' do
before :each do
params.merge!(optional_params)
end
it {
should contain_cinder_config('hippo/backend_availability_zone').with_value(params[:backend_availability_zone])
should contain_cinder_config('hippo/vmware_volume_folder').with_value(params[:volume_folder])
should contain_cinder_config('hippo/vmware_api_retry_count').with_value(params[:api_retry_count])
should contain_cinder_config('hippo/vmware_max_object_retrieval').with_value(params[:max_object_retrieval])
should contain_cinder_config('hippo/vmware_task_poll_interval').with_value(params[:task_poll_interval])
should contain_cinder_config('hippo/vmware_image_transfer_timeout_secs').with_value(params[:image_transfer_timeout_secs])
should contain_cinder_config('hippo/vmware_wsdl_location').with_value(params[:wsdl_location])
should contain_cinder_config('hippo/backend_availability_zone').with_value(params[:backend_availability_zone])
should contain_cinder_config('hippo/host').with_value("vmdk:#{params[:host_ip]}-#{params[:volume_folder]}")
}
end
it 'should configure vmdk driver in cinder.conf' do
is_expected.to contain_cinder_config('hippo/backend_availability_zone').with_value(params[:backend_availability_zone])
is_expected.to contain_cinder_config('hippo/vmware_volume_folder').with_value(params[:volume_folder])
is_expected.to contain_cinder_config('hippo/vmware_api_retry_count').with_value(params[:api_retry_count])
is_expected.to contain_cinder_config('hippo/vmware_max_object_retrieval').with_value(params[:max_object_retrieval])
is_expected.to contain_cinder_config('hippo/vmware_task_poll_interval').with_value(params[:task_poll_interval])
is_expected.to contain_cinder_config('hippo/vmware_image_transfer_timeout_secs').with_value(params[:image_transfer_timeout_secs])
is_expected.to contain_cinder_config('hippo/vmware_wsdl_location').with_value(params[:wsdl_location])
is_expected.to contain_cinder_config('hippo/backend_availability_zone').with_value(params[:backend_availability_zone])
is_expected.to contain_cinder_config('hippo/host').with_value("vmdk:#{params[:host_ip]}-#{params[:volume_folder]}")
context 'vmdk backend with additional configuration' do
before do
params.merge!( :extra_options => {'hippo/param1' => { 'value' => 'value1' }} )
end
it { should contain_cinder_config('hippo/param1').with_value('value1') }
end
context 'vmdk backend with cinder type' do
before do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('hippo').with(
:ensure => 'present',
:properties => ['volume_backend_name=hippo']
)}
end
end
context 'vmdk backend with additional configuration' do
before do
params.merge!({:extra_options => {'hippo/param1' => { 'value' => 'value1' }}})
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it 'configure vmdk backend with additional configuration' do
is_expected.to contain_cinder_config('hippo/param1').with({
:value => 'value1'
})
it_behaves_like 'cinder::backend::vmdk'
end
end
context 'vmdk backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create type with properties' do
should contain_cinder_type('hippo').with(:ensure => :present, :properties => ['volume_backend_name=hippo'])
end
end
end

View File

@ -1,7 +1,6 @@
require 'spec_helper'
describe 'cinder::backend::vstorage' do
let(:title) {'vstorage'}
let :params do
@ -21,48 +20,56 @@ describe 'cinder::backend::vstorage' do
}
end
it 'configures vstorage volume driver' do
is_expected.to contain_cinder_config('vstorage/volume_backend_name').with(
:value => 'vstorage')
is_expected.to contain_cinder_config('vstorage/backend_availability_zone').with_value(
'my_zone')
is_expected.to contain_cinder_config('vstorage/volume_driver').with_value(
'cinder.volume.drivers.vzstorage.VZStorageDriver')
is_expected.to contain_cinder_config('vstorage/vzstorage_shares_config').with_value(
'/etc/cinder/vstorage_shares.conf')
is_expected.to contain_cinder_config('vstorage/vzstorage_sparsed_volumes').with_value(
true)
is_expected.to contain_cinder_config('vstorage/vzstorage_used_ratio').with_value(
'0.9')
is_expected.to contain_cinder_config('vstorage/vzstorage_mount_point_base').with_value(
'/vstorage')
is_expected.to contain_cinder_config('vstorage/vzstorage_default_volume_format').with_value(
'ploop')
end
shared_examples 'cinder::backend::vstorage' do
it {
should contain_cinder_config('vstorage/volume_backend_name').with_value('vstorage')
should contain_cinder_config('vstorage/backend_availability_zone').with_value('my_zone')
should contain_cinder_config('vstorage/vzstorage_sparsed_volumes').with_value(true)
should contain_cinder_config('vstorage/vzstorage_used_ratio').with_value('0.9')
should contain_cinder_config('vstorage/vzstorage_mount_point_base').with_value('/vstorage')
should contain_cinder_config('vstorage/vzstorage_default_volume_format').with_value('ploop')
}
it 'installs vstorage-client package' do
is_expected.to contain_package('vstorage-client').with(
:ensure => 'present')
end
it { should contain_cinder_config('vstorage/vzstorage_shares_config').with(
:value => '/etc/cinder/vstorage_shares.conf'
)}
it 'creates shares config file' do
is_expected.to contain_file('/etc/cinder/vstorage_shares.conf').with_content(
"stor1:passw0rd [\"-u\", \"cinder\", \"-g\", \"root\", \"-m\", \"0770\"]"
)
end
it { should contain_cinder_config('vstorage/volume_driver').with(
:value => 'cinder.volume.drivers.vzstorage.VZStorageDriver'
)}
context 'vstorage backend with cinder type' do
before do
params.merge!({:manage_volume_type => true})
end
it 'should create volume types' do
should contain_cinder_type('vstorage').with(
:ensure => :present,
:properties => ['vz:volume_format=qcow2'])
should contain_cinder_type('vstorage-ploop').with(
:ensure => :present,
:properties => ['vz:volume_format=ploop'])
it { should contain_package('vstorage-client').with_ensure('present') }
it { should contain_file('/etc/cinder/vstorage_shares.conf').with(
:content => "stor1:passw0rd [\"-u\", \"cinder\", \"-g\", \"root\", \"-m\", \"0770\"]"
)}
context 'vstorage backend with cinder type' do
before do
params.merge!( :manage_volume_type => true )
end
it { should contain_cinder_type('vstorage').with(
:ensure => 'present',
:properties => ['vz:volume_format=qcow2']
)}
it { should contain_cinder_type('vstorage-ploop').with(
:ensure => 'present',
:properties => ['vz:volume_format=ploop']
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::backend::vstorage'
end
end
end

View File

@ -2,24 +2,40 @@
require 'spec_helper'
describe 'cinder::qos' do
let(:title) {'tomato'}
context 'default creation' do
it 'should create basic qos' do
should contain_cinder_qos('tomato').with(:ensure => :present)
shared_examples 'cinder::qos' do
context 'with default parameters' do
it { should contain_cinder_qos('tomato').with_ensure('present') }
end
context 'with specified parameters' do
let :params do
{
:properties => ['var1=value1', 'var2=value2'],
:associations => ['vol_type1', 'vol_type2'],
:consumer => 'front-end',
}
end
it { should contain_cinder_qos('tomato').with(
:ensure => 'present',
:properties => ['var1=value1', 'var2=value2'],
:associations => ['vol_type1', 'vol_type2'],
:consumer => 'front-end'
)}
end
end
context 'creation with properties' do
let :params do {
:properties => ['var1=value1','var2=value2'],
:associations => ['vol_type1','vol_type2'],
:consumer => 'front-end',
}
end
it 'should create qos with properties' do
should contain_cinder_qos('tomato').with(:ensure => :present, :properties => ['var1=value1','var2=value2'], :associations => ['vol_type1','vol_type2'], :consumer => 'front-end')
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::qos'
end
end
end

View File

@ -3,62 +3,65 @@
require 'spec_helper'
describe 'cinder::quota_set' do
let(:title) {'hippo'}
let :params do {
:os_password => 'asdf',
:os_tenant_name => 'admin',
:os_username => 'admin',
:os_auth_url => 'http://127.127.127.1:5000/v2.0/',
:quota_volumes => '10',
:quota_snapshots => '10',
:quota_gigabytes => '1000',
:class_name => 'default',
}
let :params do
{
:os_password => 'asdf',
:os_tenant_name => 'admin',
:os_username => 'admin',
:os_auth_url => 'http://127.127.127.1:5000/v2.0/',
:quota_volumes => '10',
:quota_snapshots => '10',
:quota_gigabytes => '1000',
:class_name => 'default',
}
end
shared_examples_for 'cinder_quota_set' do
[{},
{ :os_region_name => 'test' }
].each do |param_set|
describe "when #{param_set == {} ? 'using default' : 'specifying'} class parameters" do
before do
params.merge!(param_set)
end
it do
is_expected.to contain_exec('openstack quota set --class default').with(
:command => "openstack quota set --class default --volumes 10 --snapshots 10 --gigabytes 1000 --volume-type 'hippo'",
:environment => (param_set == {}) ?
['OS_TENANT_NAME=admin',
'OS_USERNAME=admin',
'OS_PASSWORD=asdf',
'OS_AUTH_URL=http://127.127.127.1:5000/v2.0/'] :
['OS_TENANT_NAME=admin',
'OS_USERNAME=admin',
'OS_PASSWORD=asdf',
'OS_AUTH_URL=http://127.127.127.1:5000/v2.0/',
'OS_REGION_NAME=test'],
:onlyif => 'openstack quota show --class default | grep -qP -- -1',
:require => 'Anchor[cinder::install::end]')
end
shared_examples 'cinder::quota_set' do
context 'with specified parameters' do
it { should contain_exec('openstack quota set --class default').with(
:command => "openstack quota set --class default --volumes 10 --snapshots 10 --gigabytes 1000 --volume-type 'hippo'",
:environment => [
'OS_TENANT_NAME=admin',
'OS_USERNAME=admin',
'OS_PASSWORD=asdf',
'OS_AUTH_URL=http://127.127.127.1:5000/v2.0/',
],
:onlyif => 'openstack quota show --class default | grep -qP -- -1',
:require => 'Anchor[cinder::install::end]',
)}
end
context 'with region name set' do
before do
params.merge!( :os_region_name => 'test' )
end
it { should contain_exec('openstack quota set --class default').with(
:command => "openstack quota set --class default --volumes 10 --snapshots 10 --gigabytes 1000 --volume-type 'hippo'",
:environment => [
'OS_TENANT_NAME=admin',
'OS_USERNAME=admin',
'OS_PASSWORD=asdf',
'OS_AUTH_URL=http://127.127.127.1:5000/v2.0/',
'OS_REGION_NAME=test',
],
:onlyif => 'openstack quota show --class default | grep -qP -- -1',
:require => 'Anchor[cinder::install::end]',
)}
end
end
context 'on Debian platforms' do
let :facts do
{ :operatingsystem => 'Ubuntu',
:osfamily => 'Debian' }
end
it_configures 'cinder_quota_set'
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
context 'on Redhat platforms' do
let :facts do
{ :operatingsystem => 'Redhat',
:osfamily => 'Redhat' }
it_behaves_like 'cinder::quota_set'
end
it_configures 'cinder_quota_set'
end
end

View File

@ -3,28 +3,48 @@
require 'spec_helper'
describe 'cinder::type_set' do
let(:title) {'hippo'}
let :default_params do {
:type => 'sith',
:key => 'monchichi',
}
let :default_params do
{
:type => 'sith',
:key => 'monchichi',
}
end
describe 'by default' do
let(:params){ default_params }
it 'should create type with properties' do
should contain_cinder_type('sith').with(:ensure => :present, :properties => ['monchichi=hippo'])
let :params do
default_params
end
shared_examples 'cinder::type_set' do
context 'by default' do
it { should contain_cinder_type('sith').with(
:ensure => 'present',
:properties => ['monchichi=hippo']
)}
end
context 'with a different value' do
before do
params.merge!( :value => 'hippi' )
end
it { should contain_cinder_type('sith').with(
:ensure => 'present',
:properties => ['monchichi=hippi']
)}
end
end
describe 'with a different value' do
let(:params){
default_params.merge({:value => 'hippi'})
}
it 'should create type with properties' do
should contain_cinder_type('sith').with(:ensure => :present, :properties => ['monchichi=hippi'])
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::type_set'
end
end
end

View File

@ -3,23 +3,37 @@
require 'spec_helper'
describe 'cinder::type' do
let(:title) {'hippo'}
context 'default creation' do
it 'should create type basic' do
should contain_cinder_type('hippo').with(:ensure => :present)
shared_examples 'cinder::type' do
context 'default creation' do
it { should contain_cinder_type('hippo').with_ensure('present') }
end
context 'creation with properties' do
let :params do
{
:set_value => ['name1', 'name2'],
:set_key => 'volume_backend_name',
}
end
it { should contain_cinder_type('hippo').with(
:ensure => 'present',
:properties => ['volume_backend_name=name1,name2']
)}
end
end
context 'creation with properties' do
let :params do {
:set_value => ['name1','name2'],
:set_key => 'volume_backend_name',
}
end
it 'should create type with properties' do
should contain_cinder_type('hippo').with(:ensure => :present, :properties => ['volume_backend_name=name1,name2'])
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'cinder::type'
end
end
end