Convert define spec testing to rspec-puppet-facts

Change-Id: Icf7228fa1cd3d466c32650c0f607acb86fb122de
This commit is contained in:
Tobias Urdin 2018-11-07 16:45:52 +01:00
parent 0e5843dc89
commit 4a96a902cc
15 changed files with 318 additions and 214 deletions

View File

@ -40,27 +40,39 @@ describe 'manila::backend::dellemc_isilon' do
end
end
shared_examples 'manila::backend::dellemc_isilon' do
context 'with default parameters' do
before do
params = {}
end
context 'with default parameters' do
before do
params = {}
it_configures 'dell emc isilon share driver'
end
it_configures 'dell emc isilon share driver'
end
context 'with provided parameters' do
it_configures 'dell emc isilon share driver'
end
context 'with share server config' do
before do
params.merge!({
:emc_nas_password => true,
})
context 'with provided parameters' do
it_configures 'dell emc isilon share driver'
end
it { is_expected.to raise_error(Puppet::Error, /true is not a string. It looks to be a TrueClass/) }
context 'with share server config' do
before do
params.merge!({
:emc_nas_password => true,
})
end
it { is_expected.to raise_error(Puppet::Error, /true is not a string. It looks to be a TrueClass/) }
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 'manila::backend::dellemc_isilon'
end
end
end

View File

@ -49,27 +49,39 @@ describe 'manila::backend::dellemc_unity' do
end
end
shared_examples 'manila::backend::dellemc_unity' do
context 'with default parameters' do
before do
params = {}
end
context 'with default parameters' do
before do
params = {}
it_configures 'dell emc unity share driver'
end
it_configures 'dell emc unity share driver'
end
context 'with provided parameters' do
it_configures 'dell emc unity share driver'
end
context 'with share server config' do
before do
params.merge!({
:emc_nas_password => true,
})
context 'with provided parameters' do
it_configures 'dell emc unity share driver'
end
it { is_expected.to raise_error(Puppet::Error, /true is not a string. It looks to be a TrueClass/) }
context 'with share server config' do
before do
params.merge!({
:emc_nas_password => true,
})
end
it { is_expected.to raise_error(Puppet::Error, /true is not a string. It looks to be a TrueClass/) }
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 'manila::backend::dellemc_unity'
end
end
end

View File

@ -43,27 +43,39 @@ describe 'manila::backend::dellemc_vmax' do
end
end
shared_examples 'manila::backend::dellemc_vmax' do
context 'with default parameters' do
before do
params = {}
end
context 'with default parameters' do
before do
params = {}
it_configures 'dell emc vmax share driver'
end
it_configures 'dell emc vmax share driver'
end
context 'with provided parameters' do
it_configures 'dell emc vmax share driver'
end
context 'with share server config' do
before do
params.merge!({
:emc_nas_password => true,
})
context 'with provided parameters' do
it_configures 'dell emc vmax share driver'
end
it { is_expected.to raise_error(Puppet::Error, /true is not a string. It looks to be a TrueClass/) }
context 'with share server config' do
before do
params.merge!({
:emc_nas_password => true,
})
end
it { is_expected.to raise_error(Puppet::Error, /true is not a string. It looks to be a TrueClass/) }
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 'manila::backend::dellemc_vmax'
end
end
end

View File

@ -49,27 +49,39 @@ describe 'manila::backend::dellemc_vnx' do
end
end
shared_examples 'manila::backend::dellemc_vnx' do
context 'with default parameters' do
before do
params = {}
end
context 'with default parameters' do
before do
params = {}
it_configures 'dell emc vnx share driver'
end
it_configures 'dell emc vnx share driver'
end
context 'with provided parameters' do
it_configures 'dell emc vnx share driver'
end
context 'with share server config' do
before do
params.merge!({
:emc_nas_password => true,
})
context 'with provided parameters' do
it_configures 'dell emc vnx share driver'
end
it { is_expected.to raise_error(Puppet::Error, /true is not a string. It looks to be a TrueClass/) }
context 'with share server config' do
before do
params.merge!({
:emc_nas_password => true,
})
end
it { is_expected.to raise_error(Puppet::Error, /true is not a string. It looks to be a TrueClass/) }
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 'manila::backend::dellemc_vnx'
end
end
end

View File

@ -19,19 +19,32 @@ describe 'manila::backend::generic' do
}
end
describe 'generic share driver' do
it 'configures generic share driver' do
is_expected.to contain_manila_config('hippo/share_backend_name').with(
:value => 'hippo')
is_expected.to contain_manila_config('hippo/share_driver').with_value(
'manila.share.drivers.generic.GenericShareDriver')
is_expected.to contain_manila_config('hippo/share_helpers').with_value(
'CIFS=manila.share.drivers.helpers.CIFSHelperIPAccess,'\
'NFS=manila.share.drivers.helpers.NFSHelper')
params.each_pair do |config,value|
is_expected.to contain_manila_config("hippo/#{config}").with_value( value )
shared_examples 'manila::backend::generic' do
context 'generic share driver' do
it 'configures generic share driver' do
is_expected.to contain_manila_config('hippo/share_backend_name').with(
:value => 'hippo')
is_expected.to contain_manila_config('hippo/share_driver').with_value(
'manila.share.drivers.generic.GenericShareDriver')
is_expected.to contain_manila_config('hippo/share_helpers').with_value(
'CIFS=manila.share.drivers.helpers.CIFSHelperIPAccess,'\
'NFS=manila.share.drivers.helpers.NFSHelper')
params.each_pair do |config,value|
is_expected.to contain_manila_config("hippo/#{config}").with_value( value )
end
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 'manila::backend::generic'
end
end
end

View File

@ -24,20 +24,15 @@ describe 'manila::backend::glusterfs' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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 'glusterfs share driver'
end
it_configures 'glusterfs share driver'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'glusterfs share driver'
end
end

View File

@ -26,20 +26,15 @@ describe 'manila::backend::glusternative' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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 'glusternative volume driver'
end
it_configures 'glusternative volume driver'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'glusternative volume driver'
end
end

View File

@ -28,20 +28,15 @@ describe 'manila::backend::glusternfs' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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 'glusternfs volume driver'
end
it_configures 'glusternfs volume driver'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'glusternfs volume driver'
end
end

View File

@ -30,18 +30,31 @@ describe 'manila::backend::hitachi_hnas' do
end
end
context 'with provided parameters' do
it_configures 'hitachi hnas share driver'
end
context 'with share server config' do
before do
params.merge!({
:hitachi_hnas_password => true,
})
shared_examples 'manila::backend::hitachi_hnas' do
context 'with provided parameters' do
it_configures 'hitachi hnas share driver'
end
it { is_expected.to raise_error(Puppet::Error, /true is not a string. It looks to be a TrueClass/) }
context 'with share server config' do
before do
params.merge!({
:hitachi_hnas_password => true,
})
end
it { is_expected.to raise_error(Puppet::Error, /true is not a string. It looks to be a TrueClass/) }
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 'manila::backend::hitachi_hnas'
end
end
end

View File

@ -48,27 +48,39 @@ describe 'manila::backend::netapp' do
end
end
shared_examples 'manila::backend::netapp' do
context 'with default parameters' do
before do
params = {}
end
context 'with default parameters' do
before do
params = {}
it_configures 'netapp share driver'
end
it_configures 'netapp share driver'
end
context 'with provided parameters' do
it_configures 'netapp share driver'
end
context 'with share server config' do
before do
params.merge!({
:netapp_password => true,
})
context 'with provided parameters' do
it_configures 'netapp share driver'
end
it { is_expected.to raise_error(Puppet::Error, /true is not a string. It looks to be a TrueClass/) }
context 'with share server config' do
before do
params.merge!({
:netapp_password => true,
})
end
it { is_expected.to raise_error(Puppet::Error, /true is not a string. It looks to be a TrueClass/) }
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 'manila::backend::netapp'
end
end
end

View File

@ -12,15 +12,28 @@ describe 'manila::network::neutron_single_network' do
}
end
context 'with provided parameters' do
it 'configures neutron single network plugin' do
shared_examples 'manila::network::neutron_single_network' do
context 'with provided parameters' do
it 'configures neutron single network plugin' do
is_expected.to contain_manila_config("neutronsingle/network_api_class").with_value(
'manila.network.neutron.neutron_network_plugin.NeutronSingleNetworkPlugin')
is_expected.to contain_manila_config("neutronsingle/network_api_class").with_value(
'manila.network.neutron.neutron_network_plugin.NeutronSingleNetworkPlugin')
params.each_pair do |config,value|
is_expected.to contain_manila_config("neutronsingle/#{config}").with_value( value )
params.each_pair do |config,value|
is_expected.to contain_manila_config("neutronsingle/#{config}").with_value( value )
end
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 'manila::network::neutron_single_network'
end
end
end

View File

@ -26,15 +26,29 @@ describe 'manila::network::standalone' do
end
end
context 'with default parameters' do
before do
params = {}
shared_examples 'manila::network::standalone' do
context 'with default parameters' do
before do
params = {}
end
it_configures 'standalone network plugin'
end
it_configures 'standalone network plugin'
context 'with provided parameters' do
it_configures 'standalone network plugin'
end
end
context 'with provided parameters' do
it_configures 'standalone network plugin'
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 'manila::network::standalone'
end
end
end

View File

@ -24,41 +24,55 @@ describe 'manila::service_instance' do
}
end
context 'with default parameters' do
it 'configures service instance' do
expect {
params.each_pair do |config,value|
is_expected.to contain_manila_config("DEFAULT/#{config}").with_value( value )
end
}.to raise_error(Puppet::Error, /Missing required parameter service_image_location/)
shared_examples 'manila::service_instance' do
context 'with default parameters' do
it 'configures service instance' do
expect {
params.each_pair do |config,value|
is_expected.to contain_manila_config("DEFAULT/#{config}").with_value( value )
end
}.to raise_error(Puppet::Error, /Missing required parameter service_image_location/)
end
end
context 'with service image provided' do
let (:req_params) { params.merge!({
:service_image_name => 'manila-service-image',
:service_image_location => 'http://example.com/manila_service_image.iso',
}) }
it 'creates Glance image' do
is_expected.to contain_glance_image(req_params[:service_image_name]).with(
:ensure => 'present',
:is_public => 'yes',
:container_format => 'bare',
:disk_format => 'qcow2',
:source => req_params[:service_image_location]
)
end
end
context 'with create_service_image false' do
let (:req_params) { params.merge!({
:create_service_image => false,
:service_image_name => 'manila-service-image',
}) }
it 'does not create Glance image' do
is_expected.to_not contain_glance_image(req_params[:service_image_name])
end
end
end
context 'with service image provided' do
let (:req_params) { params.merge!({
:service_image_name => 'manila-service-image',
:service_image_location => 'http://example.com/manila_service_image.iso',
}) }
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 'creates Glance image' do
is_expected.to contain_glance_image(req_params[:service_image_name]).with(
:ensure => 'present',
:is_public => 'yes',
:container_format => 'bare',
:disk_format => 'qcow2',
:source => req_params[:service_image_location]
)
end
end
context 'with create_service_image false' do
let (:req_params) { params.merge!({
:create_service_image => false,
:service_image_name => 'manila-service-image',
}) }
it 'does not create Glance image' do
is_expected.to_not contain_glance_image(req_params[:service_image_name])
it_behaves_like 'manila::service_instance'
end
end
end

View File

@ -31,19 +31,15 @@ describe 'manila::type_set' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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 'manila types'
end
it_configures 'manila types'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'manila types'
end
end

View File

@ -35,19 +35,15 @@ describe 'manila::type' do
end
end
context 'on Debian platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'Debian' })
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 'manila types'
end
it_configures 'manila types'
end
context 'on RedHat platforms' do
let :facts do
@default_facts.merge({ :osfamily => 'RedHat' })
end
it_configures 'manila types'
end
end