memcached (openstack) is no longer in use
[mirror/dsa-puppet.git] / 3rdparty / modules / cinder / spec / defines / cinder_backend_netapp_spec.rb
1 require 'spec_helper'
2
3 describe 'cinder::backend::netapp' do
4
5   let(:title) {'hippo'}
6
7   let :params do
8     {
9       :volume_backend_name    => 'netapp-cdot-nfs',
10       :netapp_login           => 'netapp',
11       :netapp_password        => 'password',
12       :netapp_server_hostname => '127.0.0.2',
13     }
14   end
15
16   let :default_params do
17     {
18       :netapp_server_port           => '80',
19       :netapp_size_multiplier       => '1.2',
20       :netapp_storage_family        => 'ontap_cluster',
21       :netapp_storage_protocol      => 'nfs',
22       :netapp_transport_type        => 'http',
23       :netapp_vfiler                => '',
24       :netapp_volume_list           => '',
25       :netapp_vserver               => '',
26       :expiry_thres_minutes         => '720',
27       :thres_avl_size_perc_start    => '20',
28       :thres_avl_size_perc_stop     => '60',
29       :nfs_shares_config            => '/etc/cinder/shares.conf',
30       :netapp_copyoffload_tool_path => '',
31       :netapp_controller_ips        => '',
32       :netapp_sa_password           => '',
33       :netapp_storage_pools         => '',
34       :nfs_mount_options            => nil,
35       :netapp_webservice_path       => '/devmgr/v2',
36     }
37   end
38
39   shared_examples_for 'netapp volume driver' do
40     let :params_hash do
41       default_params.merge(params)
42     end
43
44     it 'configures netapp volume driver' do
45       should contain_cinder_config("#{params_hash[:volume_backend_name]}/volume_driver").with_value(
46         'cinder.volume.drivers.netapp.common.NetAppDriver')
47       params_hash.each_pair do |config,value|
48         should contain_cinder_config("#{params_hash[:volume_backend_name]}/#{config}").with_value( value )
49       end
50     end
51
52     it 'marks netapp_password as secret' do
53       should contain_cinder_config("#{params_hash[:volume_backend_name]}/netapp_password").with_secret( true )
54     end
55
56     it 'marks netapp_sa_password as secret' do
57       should contain_cinder_config("#{params_hash[:volume_backend_name]}/netapp_sa_password").with_secret( true )
58     end
59   end
60
61
62   context 'with default parameters' do
63     before do
64       params = {}
65     end
66
67     it_configures 'netapp volume driver'
68   end
69
70   context 'with provided parameters' do
71     it_configures 'netapp volume driver'
72   end
73
74   context 'with netapp_storage_family eseries' do
75     let (:req_params) { params.merge!({
76         :netapp_storage_family   => 'eseries',
77     }) }
78
79     it { should contain_cinder_config("#{req_params[:volume_backend_name]}/use_multipath_for_image_xfer").with_value('true') }
80   end
81
82   context 'with NFS mount options' do
83     let (:req_params) { params.merge!({
84         :nfs_mount_options => 'rw,proto=tcp,sec=sys',
85     }) }
86
87     it { should contain_cinder_config("#{req_params[:volume_backend_name]}/nfs_mount_options").with_value('rw,proto=tcp,sec=sys') }
88   end
89
90   context 'with NFS shares provided' do
91     let (:req_params) { params.merge!({
92         :nfs_shares => ['10.0.0.1:/test1', '10.0.0.2:/test2'],
93         :nfs_shares_config => '/etc/cinder/shares.conf',
94     }) }
95
96     it 'writes NFS shares to file' do
97       should contain_file("#{req_params[:nfs_shares_config]}") \
98         .with_content("10.0.0.1:/test1\n10.0.0.2:/test2")
99     end
100   end
101
102   context 'with invalid NFS shares provided' do
103     before do
104       params.merge!({
105         :nfs_shares => "not an array",
106         :nfs_shares_config => '/etc/cinder/shares.conf',
107       })
108     end
109
110     it 'throw error' do
111         expect {subject}.to raise_error(Puppet::Error, /"not an array" is not an Array.  It looks to be a String/)
112     end
113   end
114
115 end