X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fcinder%2Fspec%2Fdefines%2Fcinder_backend_netapp_spec.rb;fp=3rdparty%2Fmodules%2Fcinder%2Fspec%2Fdefines%2Fcinder_backend_netapp_spec.rb;h=3f2ece54cf8536cf6766d1fc4daea65a91d85bf9;hb=4631045ebb77ee8622f6fa09277a50c372bcc02e;hp=0000000000000000000000000000000000000000;hpb=3d4dc4fd9e59bd0e07646c99f6b356c7d9d859aa;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/cinder/spec/defines/cinder_backend_netapp_spec.rb b/3rdparty/modules/cinder/spec/defines/cinder_backend_netapp_spec.rb new file mode 100644 index 000000000..3f2ece54c --- /dev/null +++ b/3rdparty/modules/cinder/spec/defines/cinder_backend_netapp_spec.rb @@ -0,0 +1,115 @@ +require 'spec_helper' + +describe 'cinder::backend::netapp' do + + let(:title) {'hippo'} + + let :params do + { + :volume_backend_name => 'netapp-cdot-nfs', + :netapp_login => 'netapp', + :netapp_password => 'password', + :netapp_server_hostname => '127.0.0.2', + } + end + + let :default_params do + { + :netapp_server_port => '80', + :netapp_size_multiplier => '1.2', + :netapp_storage_family => 'ontap_cluster', + :netapp_storage_protocol => 'nfs', + :netapp_transport_type => 'http', + :netapp_vfiler => '', + :netapp_volume_list => '', + :netapp_vserver => '', + :expiry_thres_minutes => '720', + :thres_avl_size_perc_start => '20', + :thres_avl_size_perc_stop => '60', + :nfs_shares_config => '/etc/cinder/shares.conf', + :netapp_copyoffload_tool_path => '', + :netapp_controller_ips => '', + :netapp_sa_password => '', + :netapp_storage_pools => '', + :nfs_mount_options => nil, + :netapp_webservice_path => '/devmgr/v2', + } + end + + shared_examples_for 'netapp volume driver' do + let :params_hash do + default_params.merge(params) + end + + it 'configures netapp volume driver' do + should contain_cinder_config("#{params_hash[:volume_backend_name]}/volume_driver").with_value( + 'cinder.volume.drivers.netapp.common.NetAppDriver') + params_hash.each_pair do |config,value| + should contain_cinder_config("#{params_hash[:volume_backend_name]}/#{config}").with_value( value ) + end + end + + it 'marks netapp_password as secret' do + should contain_cinder_config("#{params_hash[:volume_backend_name]}/netapp_password").with_secret( true ) + end + + it 'marks netapp_sa_password as secret' do + should contain_cinder_config("#{params_hash[:volume_backend_name]}/netapp_sa_password").with_secret( true ) + end + end + + + context 'with default parameters' do + before do + params = {} + 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 + let (:req_params) { params.merge!({ + :netapp_storage_family => 'eseries', + }) } + + it { should contain_cinder_config("#{req_params[:volume_backend_name]}/use_multipath_for_image_xfer").with_value('true') } + end + + context 'with NFS mount options' do + let (:req_params) { params.merge!({ + :nfs_mount_options => 'rw,proto=tcp,sec=sys', + }) } + + it { should contain_cinder_config("#{req_params[:volume_backend_name]}/nfs_mount_options").with_value('rw,proto=tcp,sec=sys') } + 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 + should 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 'throw error' do + expect {subject}.to raise_error(Puppet::Error, /"not an array" is not an Array. It looks to be a String/) + end + end + +end