summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorChristoph Albers <c.albers@x-ion.de>2015-12-03 17:07:34 +0100
committerChristoph Albers <c.albers@x-ion.de>2016-02-08 14:39:27 +0100
commit4a7dc692b997a0ad3dcf8e012f6a25f8e042f4a3 (patch)
treed1a4d2ff6ac067bc73283a07350d6cd11e008779 /spec
parent8a2f26d6fef1819b5bb09f67c21fac7db123dcb3 (diff)
refactoring final step
* added endpoint attributes (moved from common) * removed qpid as a messaging option (can be incuded in a wrapper) * deleted default attributes from nova.conf.rb originated in openstack-common * adapted optimized endpoint logic * removed rubocop exceptions in recipes and regenerated the .rubocop_todo.yaml containing all remaining exceptions * added versionbumb for refactored os-identity and common * moved version up to 13.0.0 for mitaka release * removed fedora, suse as supported platform * adapted the specs (unit tests) to work again * added new logic into templates/default/cinder.conf.erb * refactored attributes throughout all recipes that were connected to the attributes used for the cinder.conf.erb template to adapt the new template attribute syntax * moved all attributes from attributes/default.rb that were used in cinder_conf.erb to attributes/cinder_conf.rb * refactored attributes to fit upcomming template logic * refactored recipes to fit upcomming template logic * removed all attributes from default.rb and cinder.conf.erb which are set as default in attributes, openstack doc and used to render the template Depends-On: Ifa5a7f4e1df47a3961976e64f654224864c3dcb4 Depends-On: I3262b2e6f792f37c32a446e6567790b82bdd4613 Depends-On: I0547182085eed91d05384fdd7734408a839a9a2c Implements: blueprint cookbook-refactoring Change-Id: Idadc97bd7380d6c4f9f6f33d9c6b1215a5f24772
Notes
Notes (review): Code-Review+2: Mark Vanderwiel <vanderwl@us.ibm.com> Workflow+1: Samuel Cassiba <sam@cassiba.com> Workflow+1: Jan Klare <j.klare@cloudbau.de> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 11 Feb 2016 08:45:59 +0000 Reviewed-on: https://review.openstack.org/253039 Project: openstack/cookbook-openstack-block-storage Branch: refs/heads/master
Diffstat (limited to 'spec')
-rw-r--r--spec/api-opensuse_spec.rb37
-rw-r--r--spec/api_spec.rb4
-rw-r--r--spec/backup-suse_spec.rb43
-rw-r--r--spec/backup_spec.rb35
-rw-r--r--spec/cinder_common-suse_spec.rb19
-rw-r--r--spec/cinder_common_spec.rb900
-rw-r--r--spec/client_spec.rb4
-rw-r--r--spec/identity_registration_spec.rb108
-rw-r--r--spec/scheduler-suse_spec.rb42
-rw-r--r--spec/scheduler_spec.rb41
-rw-r--r--spec/spec_helper.rb7
-rw-r--r--spec/volume-redhat_spec.rb154
-rw-r--r--spec/volume-suse_spec.rb79
-rw-r--r--spec/volume_spec.rb282
14 files changed, 82 insertions, 1673 deletions
diff --git a/spec/api-opensuse_spec.rb b/spec/api-opensuse_spec.rb
deleted file mode 100644
index 22b3443..0000000
--- a/spec/api-opensuse_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
1# encoding: UTF-8
2#
3# Cookbook Name:: openstack-block-storage
4
5require_relative 'spec_helper'
6
7describe 'openstack-block-storage::api' do
8 describe 'suse' do
9 let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
10 let(:node) { runner.node }
11 let(:chef_run) { runner.converge(described_recipe) }
12
13 include_context 'block-storage-stubs'
14
15 it 'upgrades cinder api package' do
16 expect(chef_run).to upgrade_package 'openstack-cinder-api'
17 end
18
19 it 'upgrades mysql python package' do
20 expect(chef_run).to upgrade_package 'python-mysql'
21 end
22
23 it 'upgrades postgresql python packages if explicitly told' do
24 node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
25
26 expect(chef_run).to upgrade_package 'python-psycopg2'
27 expect(chef_run).not_to upgrade_package 'python-mysql'
28 end
29
30 it 'starts cinder api on boot' do
31 expect(chef_run).to enable_service 'openstack-cinder-api'
32 end
33
34 expect_creates_cinder_conf(
35 'service[cinder-api]', 'openstack-cinder', 'openstack-cinder')
36 end
37end
diff --git a/spec/api_spec.rb b/spec/api_spec.rb
index 5df877c..d04f2d0 100644
--- a/spec/api_spec.rb
+++ b/spec/api_spec.rb
@@ -35,8 +35,8 @@ describe 'openstack-block-storage::api' do
35 expect(chef_run).not_to upgrade_package('python-mysqldb') 35 expect(chef_run).not_to upgrade_package('python-mysqldb')
36 end 36 end
37 37
38 describe '/var/cache/cinder' do 38 describe '/var/cache/cinder/api' do
39 let(:dir) { chef_run.directory('/var/cache/cinder') } 39 let(:dir) { chef_run.directory('/var/cache/cinder/api') }
40 40
41 it 'should create the directory' do 41 it 'should create the directory' do
42 expect(chef_run).to create_directory(dir.name).with( 42 expect(chef_run).to create_directory(dir.name).with(
diff --git a/spec/backup-suse_spec.rb b/spec/backup-suse_spec.rb
deleted file mode 100644
index 8ee21c4..0000000
--- a/spec/backup-suse_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
1# encoding: UTF-8
2#
3# Cookbook Name:: openstack-block-storage
4
5require_relative 'spec_helper'
6
7describe 'openstack-block-storage::backup' do
8 describe 'suse' do
9 let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
10 let(:node) { runner.node }
11 let(:chef_run) { runner.converge(described_recipe) }
12
13 include_context 'block-storage-stubs'
14
15 describe 'enable cinder backup service' do
16 before do
17 node.set['openstack']['block-storage']['backup']['enabled'] = true
18 end
19 it 'upgrades cinder backup package' do
20 expect(chef_run).to upgrade_package 'openstack-cinder-backup'
21 end
22
23 it 'starts cinder backup' do
24 expect(chef_run).to start_service 'openstack-cinder-backup'
25 end
26
27 it 'starts cinder backup on boot' do
28 expect(chef_run).to enable_service 'openstack-cinder-backup'
29 end
30
31 it 'upgrades mysql python package' do
32 expect(chef_run).to upgrade_package 'python-mysql'
33 end
34
35 it 'upgrades postgresql python packages if explicitly told' do
36 node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
37
38 expect(chef_run).to upgrade_package 'python-psycopg2'
39 expect(chef_run).not_to upgrade_package 'python-mysql'
40 end
41 end
42 end
43end
diff --git a/spec/backup_spec.rb b/spec/backup_spec.rb
index 06705a3..d8ff358 100644
--- a/spec/backup_spec.rb
+++ b/spec/backup_spec.rb
@@ -13,9 +13,6 @@ describe 'openstack-block-storage::backup' do
13 include_context 'block-storage-stubs' 13 include_context 'block-storage-stubs'
14 14
15 describe 'enable cinder backup service' do 15 describe 'enable cinder backup service' do
16 before do
17 node.set['openstack']['block-storage']['backup']['enabled'] = true
18 end
19 it 'upgrades cinder backup package' do 16 it 'upgrades cinder backup package' do
20 expect(chef_run).to upgrade_package 'cinder-backup' 17 expect(chef_run).to upgrade_package 'cinder-backup'
21 end 18 end
@@ -43,37 +40,5 @@ describe 'openstack-block-storage::backup' do
43 expect(chef_run).not_to upgrade_package 'python-mysqldb' 40 expect(chef_run).not_to upgrade_package 'python-mysqldb'
44 end 41 end
45 end 42 end
46
47 describe 'disable cinder backup service' do
48 before do
49 node.set['openstack']['block-storage']['backup']['enabled'] = false
50 end
51 it 'not to upgrades cinder backup package' do
52 expect(chef_run).not_to upgrade_package 'cinder-backup'
53 end
54
55 it 'not to starts cinder backup' do
56 expect(chef_run).not_to start_service 'cinder-backup'
57 end
58
59 it 'not to starts cinder backup on boot' do
60 expect(chef_run).not_to enable_service 'cinder-backup'
61 end
62
63 it 'not to subscribes to the template change' do
64 expect(chef_run.service('cinder-backup')).not_to subscribe_to('template[/etc/cinder/cinder.conf]')
65 end
66
67 it 'not to upgrades mysql python package' do
68 expect(chef_run).not_to upgrade_package 'python-mysqldb'
69 end
70
71 it 'not to upgrades postgresql python packages if explicitly told' do
72 node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
73
74 expect(chef_run).not_to upgrade_package 'python-psycopg2'
75 expect(chef_run).not_to upgrade_package 'python-mysqldb'
76 end
77 end
78 end 43 end
79end 44end
diff --git a/spec/cinder_common-suse_spec.rb b/spec/cinder_common-suse_spec.rb
deleted file mode 100644
index 4164ea7..0000000
--- a/spec/cinder_common-suse_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
1# encoding: UTF-8
2#
3# Cookbook Name:: openstack-block-storage
4
5require_relative 'spec_helper'
6
7describe 'openstack-block-storage::cinder-common' do
8 describe 'suse' do
9 let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
10 let(:node) { runner.node }
11 let(:chef_run) { runner.converge(described_recipe) }
12
13 include_context 'block-storage-stubs'
14
15 it 'upgrades the openstack-cinder package' do
16 expect(chef_run).to upgrade_package 'openstack-cinder'
17 end
18 end
19end
diff --git a/spec/cinder_common_spec.rb b/spec/cinder_common_spec.rb
index 40c928f..a224659 100644
--- a/spec/cinder_common_spec.rb
+++ b/spec/cinder_common_spec.rb
@@ -66,60 +66,18 @@ describe 'openstack-block-storage::cinder-common' do
66 it 'sets cafile' do 66 it 'sets cafile' do
67 expect(chef_run).not_to render_file(file.name).with_content(/^cafile = $/) 67 expect(chef_run).not_to render_file(file.name).with_content(/^cafile = $/)
68 end 68 end
69
70 it 'sets insecure' do
71 expect(chef_run).to render_file(file.name).with_content(/^insecure = false$/)
72 end
73
74 it 'sets token hash algorithms' do
75 expect(chef_run).to render_file(file.name).with_content(/^hash_algorithms = md5$/)
76 end
77 end 69 end
78 70
79 context 'keystone authtoken attributes' do 71 context 'keystone authtoken attributes' do
80 it 'has signing_dir' do 72 it 'has signing_dir' do
81 node.set['openstack']['block-storage']['api']['auth']['cache_dir'] = 'auth_cache_dir' 73 node.set['openstack']['block-storage']['conf']['keystone_authtoken']['signing_dir'] = 'auth_cache_dir'
82 74
83 expect(chef_run).to render_file(file.name).with_content(/^signing_dir = auth_cache_dir$/) 75 expect(chef_run).to render_file(file.name).with_content(/^signing_dir = auth_cache_dir$/)
84 end 76 end
85 77
86 it 'sets memcached server(s)' do
87 node.set['openstack']['block-storage']['api']['auth']['memcached_servers'] = 'localhost:11211'
88 expect(chef_run).to render_file(file.name).with_content(/^memcached_servers = localhost:11211$/)
89 end
90
91 it 'sets memcache security strategy' do
92 node.set['openstack']['block-storage']['api']['auth']['memcache_security_strategy'] = 'MAC'
93 expect(chef_run).to render_file(file.name).with_content(/^memcache_security_strategy = MAC$/)
94 end
95
96 it 'sets memcache secret key' do
97 node.set['openstack']['block-storage']['api']['auth']['memcache_secret_key'] = '0123456789ABCDEF'
98 expect(chef_run).to render_file(file.name).with_content(/^memcache_secret_key = 0123456789ABCDEF$/)
99 end
100
101 it 'sets cafile' do
102 node.set['openstack']['block-storage']['api']['auth']['cafile'] = 'dir/to/path'
103 expect(chef_run).to render_file(file.name).with_content(%r{^cafile = dir/to/path$})
104 end
105
106 it 'sets insecure' do
107 node.set['openstack']['block-storage']['api']['auth']['insecure'] = true
108 expect(chef_run).to render_file(file.name).with_content(/^insecure = true$/)
109 end
110
111 it 'sets token hash algorithms' do
112 node.set['openstack']['block-storage']['api']['auth']['hash_algorithms'] = 'sha2'
113 expect(chef_run).to render_file(file.name).with_content(/^hash_algorithms = sha2$/)
114 end
115
116 context 'endpoint related' do 78 context 'endpoint related' do
117 it 'has auth_uri' do 79 it 'has auth_uri' do
118 expect(chef_run).to render_file(file.name).with_content(%r{^auth_uri = http://127.0.0.1:5000/v2.0$}) 80 expect(chef_run).to render_file(file.name).with_content(%r{^auth_url = http://127.0.0.1:5000/v2.0$})
119 end
120
121 it 'has identity_uri' do
122 expect(chef_run).to render_file(file.name).with_content(%r{^identity_uri = http://127.0.0.1:35357/$})
123 end 81 end
124 end 82 end
125 83
@@ -129,41 +87,32 @@ describe 'openstack-block-storage::cinder-common' do
129 expect(chef_run).not_to render_file(file.name).with_content(/^auth_version = v2.0$/) 87 expect(chef_run).not_to render_file(file.name).with_content(/^auth_version = v2.0$/)
130 end 88 end
131 89
132 it 'has auth_version when auth version is not v2.0' do
133 node.set['openstack']['block-storage']['api']['auth']['version'] = 'v3.0'
134
135 expect(chef_run).to render_file(file.name).with_content(/^auth_version = v3.0$/)
136 end
137
138 it 'has an admin tenant name' do 90 it 'has an admin tenant name' do
139 node.set['openstack']['block-storage']['service_tenant_name'] = 'tenant_name' 91 node.set['openstack']['block-storage']['conf']['keystone_authtoken']['admin_tenant_name'] = 'tenant_name'
140 92
141 expect(chef_run).to render_file(file.name).with_content(/^admin_tenant_name = tenant_name$/) 93 expect(chef_run).to render_file(file.name).with_content(/^admin_tenant_name = tenant_name$/)
142 end 94 end
143 95
144 it 'has an admin user' do 96 it 'has an admin user' do
145 node.set['openstack']['block-storage']['service_user'] = 'username' 97 node.set['openstack']['block-storage']['conf']['keystone_authtoken']['admin_user'] = 'username'
146 98
147 expect(chef_run).to render_file(file.name).with_content(/^admin_user = username$/) 99 expect(chef_run).to render_file(file.name).with_content(/^admin_user = username$/)
148 end 100 end
149 101
150 it 'has an admin password' do 102 it 'has an admin password' do
151 # (fgimenez) the get_password mocking is set in spec/spec_helper.rb 103 # (fgimenez) the get_password mocking is set in spec/spec_helper.rb
152 expect(chef_run).to render_file(file.name).with_content(/^admin_password = cinder-pass$/) 104 expect(chef_run).to render_file(file.name).with_content(/^password = cinder-pass$/)
153 end 105 end
154 end 106 end
155 107
156 context 'template contents' do 108 context 'template contents' do
157 context 'commonly named attributes' do 109 context 'commonly named attributes' do
158 %w(debug verbose host notification_driver 110 %w(debug verbose host notification_driver
159 storage_availability_zone quota_volumes quota_gigabytes quota_driver 111 osapi_volume_worker control_exchange).each do |attr_key|
160 volume_name_template snapshot_name_template osapi_volume_workers
161 use_default_quota_class quota_snapshots no_snapshot_gb_quota
162 control_exchange max_gigabytes).each do |attr_key|
163 it "has a #{attr_key} attribute" do 112 it "has a #{attr_key} attribute" do
164 node.set['openstack']['block-storage'][attr_key] = "#{attr_key}_value" 113 node.set['openstack']['block-storage']['conf']['DEFAULT'][attr_key] = "#{attr_key}_value"
165 114
166 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr_key}=#{attr_key}_value$/) 115 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr_key} = #{attr_key}_value$/)
167 end 116 end
168 end 117 end
169 end 118 end
@@ -173,89 +122,18 @@ describe 'openstack-block-storage::cinder-common' do
173 node.set['openstack']['block-storage']['backup']['enabled'] = true 122 node.set['openstack']['block-storage']['backup']['enabled'] = true
174 node.set['openstack']['block-storage']['backup']['driver'] = 'cinder.backup.drivers.swift' 123 node.set['openstack']['block-storage']['backup']['driver'] = 'cinder.backup.drivers.swift'
175 end 124 end
176
177 it 'has default attributes' do
178 %w(swift_catalog_info=object-store:swift:publicURL
179 backup_swift_auth=per_user
180 backup_swift_auth_version=1
181 backup_swift_container=volumebackups
182 backup_swift_object_size=52428800
183 backup_swift_block_size=32768
184 backup_swift_retry_attempts=3
185 backup_swift_retry_backoff=2
186 backup_swift_enable_progress_timer=True).each do |attr|
187 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}$/)
188 end
189 end
190
191 it 'has override attributes' do
192 %w(url
193 auth
194 auth_version
195 tenant
196 user
197 key
198 container
199 object_size
200 block_size
201 retry_attempts
202 retry_backoff
203 enable_progress_timer).each do |attr|
204 node.set['openstack']['block-storage']['backup']['swift'][attr] = "backup_swift_#{attr}"
205 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^backup_swift_#{attr}=backup_swift_#{attr}$/)
206 end
207 end
208
209 it 'has a custom catalog_info' do
210 node.set['openstack']['block-storage']['backup']['swift']['catalog_info'] = 'swift_catalog_info'
211 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^swift_catalog_info=swift_catalog_info$/)
212 end
213 end
214
215 context 'rdb driver' do
216 # FIXME(galstrom21): this block needs to check all of the default
217 # rdb_* configuration options
218 it 'has default rbd_* options set' do
219 node.set['openstack']['block-storage']['volume'] = {
220 'driver' => 'cinder.volume.drivers.rbd.RBDDriver'
221 }
222 expect(chef_run).to render_file(file.name).with_content(/^rbd_/)
223 expect(chef_run).not_to render_file(file.name).with_content(/^netapp_/)
224 end
225 end 125 end
226 126
227 it 'has a lock_path attribute' do 127 it 'has a lock_path attribute' do
228 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r{^lock_path=/var/lib/cinder/lock$}) 128 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r{^lock_path = /var/lib/cinder/tmp})
229 end 129 end
230 130
231 it 'does not have unique host id by default' do 131 it 'does not have unique host id by default' do
232 expect(chef_run).not_to render_config_file(file.name).with_section_content('DEFAULT', /^host=/) 132 expect(chef_run).not_to render_config_file(file.name).with_section_content('DEFAULT', /^host = /)
233 end
234
235 it 'has keymgr api_class attribute default set' do
236 expect(chef_run).to render_config_file(file.name).with_section_content('keymgr', /^api_class=cinder.keymgr.conf_key_mgr.ConfKeyManager$/)
237 end 133 end
238 134
239 it 'does not have keymgr attribute fixed_key set by default' do 135 it 'does not have keymgr attribute fixed_key set by default' do
240 expect(chef_run).not_to render_file(file.name).with_content(/^fixed_key=$/) 136 expect(chef_run).not_to render_file(file.name).with_content(/^fixed_key = $/)
241 end
242
243 it 'allow override for keymgr attribute fixed_key' do
244 chef_run.node.set['openstack']['block-storage']['keymgr']['fixed_key'] = '1111111111111111111111111111111111111111111111111111111111111111'
245 expect(chef_run).to render_config_file(file.name)\
246 .with_section_content('keymgr', /^fixed_key=1111111111111111111111111111111111111111111111111111111111111111$/)
247 end
248
249 context 'netapp driver' do
250 # FIXME(galstrom21): this block needs to check all of the default
251 # netapp_* configuration options
252 it 'has default netapp_* options set' do
253 node.set['openstack']['block-storage']['volume'] = {
254 'driver' => 'cinder.volume.drivers.netapp.NetAppISCSIDriver'
255 }
256 expect(chef_run).to render_file(file.name).with_content(/^netapp_/)
257 expect(chef_run).not_to render_file(file.name).with_content(/^rbd_/)
258 end
259 end 137 end
260 138
261 context 'syslog use' do 139 context 'syslog use' do
@@ -265,165 +143,64 @@ describe 'openstack-block-storage::cinder-common' do
265 expect(chef_run).to render_file(file.name) 143 expect(chef_run).to render_file(file.name)
266 .with_content(%r{^log_config = /etc/openstack/logging.conf$}) 144 .with_content(%r{^log_config = /etc/openstack/logging.conf$})
267 end 145 end
268
269 it 'sets the log_file value when syslog is not in use' do
270 node.set['openstack']['block-storage']['syslog']['use'] = false
271
272 expect(chef_run).to render_file(file.name)
273 .with_content(%r{^log_file = /var/log/cinder/cinder.log$})
274 end
275 end 146 end
276 147
277 it 'has a db connection attribute' do 148 it 'has a db connection attribute' do
278 node.set['openstack']['endpoints']['db']['enabled_slave'] = false
279 allow_any_instance_of(Chef::Recipe).to receive(:db_uri) 149 allow_any_instance_of(Chef::Recipe).to receive(:db_uri)
280 .and_return('sql_connection_value') 150 .and_return('sql_connection_value')
281 151
282 expect(chef_run).to render_config_file(file.name) 152 expect(chef_run).to render_config_file(file.name)
283 .with_section_content('database', /^connection=sql_connection_value$/) 153 .with_section_content('database', /^connection = sql_connection_value$/)
284 expect(chef_run).to_not render_config_file(file.name)
285 .with_section_content('database', /^slave_connection=sql_connection_value$/)
286 end 154 end
287 155
288 it 'has a slave db connection attribute' do 156 it 'has a slave db connection attribute' do
289 node.set['openstack']['endpoints']['db']['enabled_slave'] = true
290 allow_any_instance_of(Chef::Recipe).to receive(:db_uri) 157 allow_any_instance_of(Chef::Recipe).to receive(:db_uri)
291 .and_return('sql_connection_value') 158 .and_return('sql_connection_value')
292 159
293 expect(chef_run).to render_config_file(file.name) 160 expect(chef_run).to render_config_file(file.name)
294 .with_section_content('database', /^connection=sql_connection_value$/) 161 .with_section_content('database', /^connection = sql_connection_value$/)
295 expect(chef_run).to render_config_file(file.name)
296 .with_section_content('database', /^slave_connection=sql_connection_value$/)
297 end
298
299 it 'has a db backend attribute' do
300 expect(chef_run).to render_config_file(file.name).with_section_content('database', /^backend=sqlalchemy$/)
301 end 162 end
302 163
303 it 'has a volume_driver attribute' do 164 it 'has a volume_driver attribute' do
304 node.set['openstack']['block-storage']['volume']['driver'] = 'volume_driver_value' 165 node.set['openstack']['block-storage']['conf']['DEFAULT']['volume_driver'] = 'volume_driver_value'
305 expect(chef_run).to render_file(file.name).with_content(/^volume_driver=volume_driver_value$/) 166 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = volume_driver_value$/)
306 end 167 end
307 168
308 it 'has a state_path attribute' do 169 it 'has a state_path attribute' do
309 node.set['openstack']['block-storage']['volume']['state_path'] = 'state_path_value' 170 node.set['openstack']['block-storage']['conf']['DEFAULT']['state_path'] = 'state_path_value'
310 expect(chef_run).to render_file(file.name).with_content(/^state_path=state_path_value$/) 171 expect(chef_run).to render_file(file.name).with_content(/^state_path = state_path_value$/)
311 end 172 end
312 173
313 context 'glance endpoint' do 174 context 'glance endpoint' do
314 it 'has a glance_api_servers attribute' do 175 it 'has a glance_api_servers attribute' do
315 expect(chef_run).to render_file(file.name).with_content(%r{^glance_api_servers=http://127.0.0.1:9292$}) 176 expect(chef_run).to render_file(file.name).with_content(%r{^glance_api_servers = http://127.0.0.1:9292$})
316 end
317
318 it 'has glance_api_version attribute' do
319 expect(chef_run).to render_file(file.name).with_content(/^glance_api_version=1$/)
320 end
321
322 it 'has a glance_api_insecure attribute' do
323 expect(chef_run).to render_file(file.name).with_content(/^glance_api_insecure=false$/)
324 end
325
326 it 'sets insecure for glance' do
327 node.set['openstack']['block-storage']['image']['glance_api_insecure'] = true
328 expect(chef_run).to render_file(file.name).with_content(/^glance_api_insecure=true$/)
329 end
330
331 it 'has a glance_ca_certificates_file attribute' do
332 expect(chef_run).to render_file(file.name).with_content(/^glance_ca_certificates_file=$/)
333 end
334
335 it 'sets glance_ca_certificates_file attribute' do
336 node.set['openstack']['block-storage']['image']['glance_ca_certificates_file'] = 'dir/to/path'
337 expect(chef_run).to render_file(file.name).with_content(%r{^glance_ca_certificates_file=dir/to/path$})
338 end 177 end
339 178
340 it 'has a glance host attribute' do 179 it 'has a glance host attribute' do
341 expect(chef_run).to render_file(file.name).with_content(/^glance_host=127.0.0.1$/) 180 expect(chef_run).to render_file(file.name).with_content(/^glance_host = 127.0.0.1$/)
342 end 181 end
343 182
344 it 'has a glance port attribute' do 183 it 'has a glance port attribute' do
345 expect(chef_run).to render_file(file.name).with_content(/^glance_port=9292$/) 184 expect(chef_run).to render_file(file.name).with_content(/^glance_port = 9292$/)
346 end 185 end
347 end 186 end
348 187
349 it 'has a api_rate_limit attribute' do
350 node.set['openstack']['block-storage']['api']['ratelimit'] = 'api_rate_limit_value'
351 expect(chef_run).to render_file(file.name).with_content(/^api_rate_limit=api_rate_limit_value$/)
352 end
353
354 context 'cinder endpoint' do 188 context 'cinder endpoint' do
355 it 'has osapi_volume_listen set' do 189 it 'has osapi_volume_listen set' do
356 expect(chef_run).to render_file(file.name).with_content(/^osapi_volume_listen=127.0.0.1$/) 190 expect(chef_run).to render_file(file.name).with_content(/^osapi_volume_listen = 127.0.0.1$/)
357 end 191 end
358 192
359 it 'has osapi_volume_listen_port set' do 193 it 'has osapi_volume_listen_port set' do
360 expect(chef_run).to render_file(file.name).with_content(/^osapi_volume_listen_port=8776$/) 194 expect(chef_run).to render_file(file.name).with_content(/^osapi_volume_listen_port = 8776$/)
361 end
362
363 it 'has default api version set' do
364 [/^enable_v1_api=False$/,
365 /^enable_v2_api=True$/].each do |line|
366 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line)
367 end
368 end
369
370 it 'has override api version set' do
371 node.set['openstack']['block-storage']['enable_v1_api'] = 'True'
372 node.set['openstack']['block-storage']['enable_v2_api'] = 'False'
373 [/^enable_v1_api=True$/,
374 /^enable_v2_api=False$/].each do |line|
375 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line)
376 end
377 end 195 end
378 end 196 end
379
380 it 'has a rpc_backend attribute' do
381 node.set['openstack']['block_storage']['rpc_backend'] = 'rpc_backend_value'
382 expect(chef_run).to render_file(file.name).with_content(/^rpc_backend=rpc_backend_value$/)
383 end
384
385 it 'has default RPC/AMQP options set' do 197 it 'has default RPC/AMQP options set' do
386 [/^rpc_backend=cinder.openstack.common.rpc.impl_kombu$/, 198 [/^rpc_backend = rabbit/].each do |line|
387 /^rpc_thread_pool_size=64$/,
388 /^rpc_response_timeout=60$/].each do |line|
389 expect(chef_run).to render_file(file.name).with_content(line) 199 expect(chef_run).to render_file(file.name).with_content(line)
390 end 200 end
391 end 201 end
392 202
393 context 'rabbitmq as mq service' do 203 context 'rabbitmq as mq service' do
394 before do
395 node.set['openstack']['mq']['block-storage']['service_type'] = 'rabbitmq'
396 end
397
398 it 'has default RPC/AMQP options set' do
399 [/^rpc_conn_pool_size=30$/,
400 /^amqp_durable_queues=false$/,
401 /^amqp_auto_delete=false$/,
402 /^heartbeat_timeout_threshold=0$/,
403 /^heartbeat_rate=2$/].each do |line|
404 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', line)
405 end
406 end
407
408 context 'ha attributes' do
409 before do
410 node.set['openstack']['mq']['block-storage']['rabbit']['ha'] = true
411 end
412
413 it 'has a rabbit_hosts attribute' do
414 allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers)
415 .and_return('rabbit_servers_value')
416
417 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts=rabbit_servers_value$/)
418 end
419
420 %w(host port).each do |attr|
421 it "does not have rabbit_#{attr} attribute" do
422 expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=/)
423 end
424 end
425 end
426
427 context 'non ha attributes' do 204 context 'non ha attributes' do
428 before do 205 before do
429 node.set['openstack']['mq']['block-storage']['rabbit']['ha'] = false 206 node.set['openstack']['mq']['block-storage']['rabbit']['ha'] = false
@@ -431,108 +208,28 @@ describe 'openstack-block-storage::cinder-common' do
431 208
432 %w(host port).each do |attr| 209 %w(host port).each do |attr|
433 it "has rabbit_#{attr} attribute" do 210 it "has rabbit_#{attr} attribute" do
434 node.set['openstack']['mq']['block-storage']['rabbit'][attr] = "rabbit_#{attr}_value" 211 node.set['openstack']['block-storage']['conf']['oslo_messaging_rabbit']["rabbit_#{attr}"] = "rabbit_#{attr}_value"
435 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=rabbit_#{attr}_value$/) 212 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr} = rabbit_#{attr}_value$/)
436 end 213 end
437 end 214 end
438 215
439 it 'does not have a rabbit_hosts attribute' do 216 it 'does not have a rabbit_hosts attribute' do
440 expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts=/) 217 expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts = /)
441 end 218 end
442 end 219 end
443 220
444 it 'has rabbit_userid' do 221 it 'has rabbit_userid' do
445 node.set['openstack']['mq']['block-storage']['rabbit']['userid'] = 'rabbit_userid_value' 222 node.set['openstack']['mq']['block-storage']['rabbit']['userid'] = 'rabbit_userid_value'
446 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_userid=rabbit_userid_value$/) 223 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_userid = rabbit_userid_value$/)
447 end 224 end
448 225
449 it 'has rabbit_password' do 226 it 'has rabbit_password' do
450 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_password=#{test_pass}$/) 227 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_password = #{test_pass}$/)
451 end 228 end
452 229
453 it 'has rabbit_virtual_host' do 230 it 'has rabbit_virtual_host' do
454 node.set['openstack']['mq']['block-storage']['rabbit']['vhost'] = 'vhost_value' 231 node.set['openstack']['block-storage']['conf']['oslo_messaging_rabbit']['rabbit_virtual_host'] = 'vhost_value'
455 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_virtual_host=vhost_value$/) 232 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_virtual_host = vhost_value$/)
456 end
457
458 it 'does not have ssl config set' do
459 [/^rabbit_use_ssl=/,
460 /^kombu_ssl_version=/,
461 /^kombu_ssl_keyfile=/,
462 /^kombu_ssl_certfile=/,
463 /^kombu_ssl_ca_certs=/,
464 /^kombu_reconnect_delay=/,
465 /^kombu_reconnect_timeout=/].each do |line|
466 expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', line)
467 end
468 end
469
470 it 'sets ssl config' do
471 node.set['openstack']['mq']['block-storage']['rabbit']['use_ssl'] = true
472 node.set['openstack']['mq']['block-storage']['rabbit']['kombu_ssl_version'] = 'TLSv1.2'
473 node.set['openstack']['mq']['block-storage']['rabbit']['kombu_ssl_keyfile'] = 'keyfile'
474 node.set['openstack']['mq']['block-storage']['rabbit']['kombu_ssl_certfile'] = 'certfile'
475 node.set['openstack']['mq']['block-storage']['rabbit']['kombu_ssl_ca_certs'] = 'certsfile'
476 node.set['openstack']['mq']['block-storage']['rabbit']['kombu_reconnect_delay'] = 123.123
477 node.set['openstack']['mq']['block-storage']['rabbit']['kombu_reconnect_timeout'] = 123
478 [/^rabbit_use_ssl=true/,
479 /^kombu_ssl_version=TLSv1.2$/,
480 /^kombu_ssl_keyfile=keyfile$/,
481 /^kombu_ssl_certfile=certfile$/,
482 /^kombu_ssl_ca_certs=certsfile$/,
483 /^kombu_reconnect_delay=123.123$/,
484 /^kombu_reconnect_timeout=123$/].each do |line|
485 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', line)
486 end
487 end
488
489 it 'has the default rabbit_retry_interval set' do
490 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_retry_interval=1$/)
491 end
492
493 it 'has the default rabbit_max_retries set' do
494 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_max_retries=0$/)
495 end
496 end
497
498 context 'qpid as mq service' do
499 before do
500 node.set['openstack']['mq']['block-storage']['service_type'] = 'qpid'
501 end
502
503 it 'has default RPC/AMQP options set' do
504 [/^rpc_conn_pool_size=30$/,
505 /^amqp_durable_queues=false$/,
506 /^amqp_auto_delete=false$/].each do |line|
507 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', line)
508 end
509 end
510
511 %w(port username sasl_mechanisms reconnect reconnect_timeout reconnect_limit
512 reconnect_interval_min reconnect_interval_max reconnect_interval heartbeat protocol
513 tcp_nodelay).each do |attr|
514 it "has qpid_#{attr} attribute" do
515 node.set['openstack']['mq']['block-storage']['qpid'][attr] = "qpid_#{attr}_value"
516 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_#{attr}=qpid_#{attr}_value$/)
517 end
518 end
519
520 it 'has qpid_hostname' do
521 node.set['openstack']['mq']['block-storage']['qpid']['host'] = 'qpid_host_value'
522 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_hostname=qpid_host_value$/)
523 end
524
525 it 'has qpid_password' do
526 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_password=#{test_pass}$/)
527 end
528
529 it 'has default qpid topology version' do
530 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_topology_version=1$/)
531 end
532
533 it 'has qpid notification_topics' do
534 node.set['openstack']['mq']['block-storage']['qpid']['notification_topic'] = 'qpid_notification_topic_value'
535 expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^notification_topics=qpid_notification_topic_value$/)
536 end 233 end
537 end 234 end
538 235
@@ -540,20 +237,13 @@ describe 'openstack-block-storage::cinder-common' do
540 before do 237 before do
541 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMVolumeDriver' 238 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMVolumeDriver'
542 end 239 end
543
544 %w(group clear clear_size).each do |attr|
545 it "has lvm volume_#{attr} attribute" do
546 node.set['openstack']['block-storage']['volume']["volume_#{attr}"] = "volume_#{attr}_value"
547 expect(chef_run).to render_file(file.name).with_content(/^volume_#{attr}=volume_#{attr}_value$/)
548 end
549 end
550 end 240 end
551 241
552 context 'commonly named volume attributes' do 242 context 'commonly named volume attributes' do
553 %w(iscsi_ip_address iscsi_port iscsi_helper volumes_dir).each do |attr| 243 %w(iscsi_ip_address iscsi_port iscsi_helper volumes_dir).each do |attr|
554 it "has volume related #{attr} attribute" do 244 it "has volume related #{attr} attribute" do
555 node.set['openstack']['block-storage']['volume'][attr] = "common_volume_#{attr}_value" 245 node.set['openstack']['block-storage']['conf']['DEFAULT'][attr] = "common_volume_#{attr}_value"
556 expect(chef_run).to render_file(file.name).with_content(/^#{attr}=common_volume_#{attr}_value$/) 246 expect(chef_run).to render_file(file.name).with_content(/^#{attr} = common_volume_#{attr}_value$/)
557 end 247 end
558 end 248 end
559 end 249 end
@@ -562,519 +252,25 @@ describe 'openstack-block-storage::cinder-common' do
562 before do 252 before do
563 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.rbd.RBDDriver' 253 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.rbd.RBDDriver'
564 end 254 end
565
566 it 'has a rbd_pool attribute' do
567 node.set['openstack']['block-storage']['rbd']['cinder']['pool'] = 'cinder_value'
568 expect(chef_run).to render_file(file.name).with_content(/^rbd_pool=cinder_value$/)
569 end
570 it 'has a rbd_user attribute' do
571 node.set['openstack']['block-storage']['rbd']['user'] = 'rbd_user_value'
572 expect(chef_run).to render_file(file.name).with_content(/^rbd_user=rbd_user_value$/)
573 end
574 it 'has a rbd_secret_uuid attribute' do
575 node.set['openstack']['block-storage']['rbd']['secret_uuid'] = 'rbd_secret_uuid_value'
576 expect(chef_run).to render_file(file.name).with_content(/^rbd_secret_uuid=rbd_secret_uuid_value$/)
577 end
578 end 255 end
579 256
580 it 'has volume_driver attribute' do 257 it 'has volume_driver attribute' do
581 node.set['openstack']['block-storage']['volume']['driver'] = 'volume_driver_value' 258 node.set['openstack']['block-storage']['conf']['DEFAULT']['volume_driver'] = 'volume_driver_value'
582 expect(chef_run).to render_file(file.name).with_content(/^volume_driver=volume_driver_value$/) 259 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = volume_driver_value$/)
583 end 260 end
584 261
585 context 'netapp ISCSI settings' do 262 context 'netapp ISCSI settings' do
586 before do 263 before do
587 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.NetAppISCSIDriver' 264 node.set['openstack']['block-storage']['conf']['DEFAULT']['volume_driver'] = 'cinder.volume.drivers.netapp.NetAppISCSIDriver'
588 end
589
590 %w(login password).each do |attr|
591 it "has a netapp_#{attr} attribute" do
592 node.set['openstack']['block-storage']['netapp']["dfm_#{attr}"] = "dfm_#{attr}_value"
593 expect(chef_run).to render_file(file.name).with_content(/^netapp_#{attr}=dfm_#{attr}_value$/)
594 end
595 end
596
597 %w(hostname port).each do |attr|
598 it "has a netapp_server_#{attr} attribute" do
599 node.set['openstack']['block-storage']['netapp']["dfm_#{attr}"] = "dfm_#{attr}_value"
600 expect(chef_run).to render_file(file.name).with_content(/^netapp_server_#{attr}=dfm_#{attr}_value$/)
601 end
602 end
603
604 it 'has a netapp_storage_service attribute' do
605 node.set['openstack']['block-storage']['netapp']['storage_service'] = 'netapp_storage_service_value'
606 expect(chef_run).to render_file(file.name).with_content(/^netapp_storage_service=netapp_storage_service_value$/)
607 end
608 end
609
610 context 'netapp direct7 mode nfs settings' do
611 let(:hostnames) { %w(hostname1 hostname2 hostname3) }
612 before do
613 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
614 node.set['openstack']['block-storage']['netapp']['netapp_server_hostname'] = hostnames
615 end
616
617 %w(mount_point_base shares_config).each do |attr_key|
618 it "has a nfs_#{attr_key} attribute" do
619 node.set['openstack']['block-storage']['nfs'][attr_key] = "netapp_nfs_#{attr_key}_value"
620 expect(chef_run).to render_file(file.name).with_content(/^nfs_#{attr_key}=netapp_nfs_#{attr_key}_value$/)
621 end
622 end
623
624 it 'has netapp server_hostname attributes' do
625 hostnames.each do |hostname|
626 expect(chef_run).to render_file(file.name).with_content(/^netapp_server_hostname=#{hostname}$/)
627 end
628 end
629
630 it 'has a netapp_server_port attribute' do
631 node.set['openstack']['block-storage']['netapp']['netapp_server_port'] = 'netapp_server_port_value'
632 expect(chef_run).to render_file(file.name).with_content(/^netapp_server_port=netapp_server_port_value$/)
633 end
634
635 %w(login password).each do |attr|
636 it "has a netapp_#{attr} attribute" do
637 node.set['openstack']['block-storage']['netapp']["netapp_server_#{attr}"] = "netapp_#{attr}_value"
638 expect(chef_run).to render_file(file.name).with_content(/^netapp_#{attr}=netapp_#{attr}_value$/)
639 end
640 end
641
642 %w(disk_util sparsed_volumes).each do |attr|
643 it "has a nfs_#{attr} attribute" do
644 node.set['openstack']['block-storage']['nfs']["nfs_#{attr}"] = "netapp_nfs_#{attr}_value"
645 expect(chef_run).to render_file(file.name).with_content(/^nfs_#{attr}=netapp_nfs_#{attr}_value$/)
646 end
647 end 265 end
648 end 266 end
649
650 context 'ibmnas settings' do
651 before do
652 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver'
653 end
654
655 %w(mount_point_base shares_config).each do |attr|
656 it "has a ibmnas_#{attr} attribute" do
657 node.set['openstack']['block-storage']['ibmnas'][attr] = "ibmnas_#{attr}_value"
658 expect(chef_run).to render_file(file.name).with_content(/^nfs_#{attr}=ibmnas_#{attr}_value$/)
659 end
660 end
661
662 it 'has a nfs_sparsed_volumes attribute' do
663 node.set['openstack']['block-storage']['ibmnas']['nfs_sparsed_volumes'] = 'ibmnas_nfs_sparsed_volumes_value'
664 expect(chef_run).to render_file(file.name).with_content(/^nfs_sparsed_volumes=ibmnas_nfs_sparsed_volumes_value$/)
665 end
666
667 %w(nas_ip nas_login nas_ssh_port ibmnas_platform_type).each do |attr|
668 it "has a ibmnas #{attr} attribute" do
669 node.set['openstack']['block-storage']['ibmnas'][attr] = "ibmnas_#{attr}_value"
670 expect(chef_run).to render_file(file.name).with_content(/^#{attr}=ibmnas_#{attr}_value$/)
671 end
672 end
673
674 it 'has a default attributes' do
675 %w(nas_ip=127.0.0.1
676 nas_login=admin
677 nas_password=test_pass
678 nas_ssh_port=22
679 ibmnas_platform_type=v7ku
680 nfs_sparsed_volumes=true
681 nfs_mount_point_base=/mnt/cinder-volumes
682 nfs_shares_config=/etc/cinder/nfs_shares.conf).each do |attr|
683 expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/)
684 end
685 end
686 end
687
688 context 'storwize settings' do
689 before do
690 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver'
691 end
692
693 it 'has a default attribute' do
694 %w(san_ip=127.0.0.1
695 san_private_key=/v7000_rsa
696 storwize_svc_volpool_name=volpool
697 storwize_svc_vol_rsize=2
698 storwize_svc_vol_warning=0
699 storwize_svc_vol_autoexpand=true
700 storwize_svc_vol_grainsize=256
701 storwize_svc_vol_compression=false
702 storwize_svc_vol_easytier=true
703 storwize_svc_vol_iogrp=0
704 storwize_svc_flashcopy_timeout=120
705 storwize_svc_connection_protocol=iSCSI
706 storwize_svc_iscsi_chap_enabled=true
707 storwize_svc_multihostmap_enabled=true
708 storwize_svc_allow_tenant_qos=false).each do |attr|
709 expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/)
710 end
711 end
712
713 it 'has a overridden attribute' do
714 %w(san_ip
715 san_private_key
716 storwize_svc_volpool_name
717 storwize_svc_vol_rsize
718 storwize_svc_vol_warning
719 storwize_svc_vol_autoexpand
720 storwize_svc_vol_grainsize
721 storwize_svc_vol_compression
722 storwize_svc_vol_easytier
723 storwize_svc_vol_iogrp
724 storwize_svc_flashcopy_timeout
725 storwize_svc_connection_protocol
726 storwize_svc_multihostmap_enabled
727 storwize_svc_allow_tenant_qos
728 storwize_svc_stretched_cluster_partner).each do |attr|
729 node.set['openstack']['block-storage']['storwize'][attr] = "storwize_#{attr}_value"
730 expect(chef_run).to render_file(file.name).with_content(/^#{attr}=storwize_#{attr}_value$/)
731 end
732 end
733
734 context 'storwize with login and password' do
735 it 'has a login and password' do
736 node.set['openstack']['block-storage']['storwize']['san_private_key'] = ''
737 %w(san_login=admin
738 san_password=test_pass
739 san_private_key=).each do |attr|
740 expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/)
741 end
742 end
743 end
744
745 context 'storwize with iSCSI connection protocol' do
746 before do
747 node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI'
748 end
749
750 it 'has a iscsi chap enabled attribute' do
751 node.set['openstack']['block-storage']['storwize']['storwize_svc_iscsi_chap_enabled'] = 'storwize_svc_iscsi_chap_enabled_value'
752 expect(chef_run).to render_file(file.name).with_content(/^storwize_svc_iscsi_chap_enabled=storwize_svc_iscsi_chap_enabled_value$/)
753 end
754
755 it 'does not have a multipath enabled attribute' do
756 expect(chef_run).not_to render_file(file.name).with_content(/^storwize_svc_multipath_enabled=/)
757 end
758 end
759
760 context 'storwize without iSCSI connection protocol' do
761 before do
762 node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'non-iSCSI'
763 end
764
765 it 'does not have a iscsi chap enabled attribute' do
766 expect(chef_run).not_to render_file(file.name).with_content(/^storwize_svc_iscsi_enabled=/)
767 end
768
769 it 'has a multipath enabled attribute' do
770 node.set['openstack']['block-storage']['storwize']['storwize_svc_multipath_enabled'] = 'storwize_svc_multipath_enabled_value'
771 expect(chef_run).to render_file(file.name).with_content(/^storwize_svc_multipath_enabled=storwize_svc_multipath_enabled_value$/)
772 end
773 end
774 end
775
776 context 'solidfire settings' do
777 before do
778 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.solidfire.SolidFire'
779 end
780
781 it 'has solidfire sf_emulate set' do
782 node.set['openstack']['block-storage']['solidfire']['sf_emulate'] = 'test'
783 expect(chef_run).to render_file(file.name).with_content(/^sf_emulate_512=test$/)
784 end
785
786 it 'has solidfire password' do
787 expect(chef_run).to render_file(file.name).with_content(/^san_password=test_pass$/)
788 end
789
790 %w(san_login san_ip).each do |attr|
791 it "has solidfire #{attr} set" do
792 node.set['openstack']['block-storage']['solidfire'][attr] = "solidfire_#{attr}_value"
793 expect(chef_run).to render_file(file.name).with_content(/^#{attr}=solidfire_#{attr}_value$/)
794 end
795 end
796
797 it 'does not have iscsi_ip_prefix not specified' do
798 node.set['openstack']['block-storage']['solidfire']['iscsi_ip_prefix'] = nil
799 expect(chef_run).to_not render_file(file.name).with_content(/^iscsi_ip_prefix=/)
800 end
801
802 it 'does have iscsi_ip_prefix when specified' do
803 chef_run.node.set['openstack']['block-storage']['solidfire']['iscsi_ip_prefix'] = '203.0.113.*'
804 expect(chef_run).to render_file(file.name).with_content(/^iscsi_ip_prefix=203.0.113.*$/)
805 end
806 end
807
808 context 'flashsystem settings' do
809 before do
810 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.flashsystem.FlashSystemDriver'
811 end
812
813 it 'has flashsystem password' do
814 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^san_password=test_pass$/)
815 end
816
817 it 'has a default attribute' do
818 %w(san_ip=127.0.0.1
819 flashsystem_connection_protocol=FC
820 flashsystem_multihostmap_enabled=true).each do |attr|
821 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}$/)
822 end
823 end
824
825 it 'has a overridden attribute' do
826 %w(san_ip
827 flashsystem_connection_protocol
828 flashsystem_multihostmap_enabled).each do |attr|
829 node.set['openstack']['block-storage']['flashsystem'][attr] = "flashsystem_#{attr}_value"
830 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}=flashsystem_#{attr}_value$/)
831 end
832 end
833
834 context 'FlashSystem with FC connection protocol' do
835 before do
836 node.set['openstack']['block-storage']['storwize']['flashsystem_connection_protocol'] = 'FC'
837 end
838
839 it 'has a multipath enabled attribute' do
840 node.set['openstack']['block-storage']['flashsystem']['flashsystem_multipath_enabled'] = 'flashsystem_multipath_enabled_value'
841 expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^flashsystem_multipath_enabled=flashsystem_multipath_enabled_value$/)
842 end
843 end
844 end
845
846 context 'emc settings' do
847 before do
848 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
849 end
850
851 %w(iscsi_target_prefix cinder_emc_config_file).each do |attr|
852 it "has emc #{attr} set" do
853 node.set['openstack']['block-storage']['emc'][attr] = "emc_#{attr}_value"
854 expect(chef_run).to render_file(file.name).with_content(/^#{attr}=emc_#{attr}_value$/)
855 end
856 end
857 end
858
859 context 'vmware vmdk settings' do
860 before do
861 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver'
862 %w(vmware_host_ip vmware_host_username
863 vmware_api_retry_count vmware_task_poll_interval vmware_volume_folder
864 vmware_image_transfer_timeout_secs vmware_max_objects_retrieval).each do |attr|
865 node.set['openstack']['block-storage']['vmware'][attr] = "vmware_#{attr}_value"
866 end
867 end
868
869 it 'has vmware attributes set' do
870 node['openstack']['block-storage']['vmware'].each do |attr, val|
871 expect(chef_run).to render_file(file.name).with_content(/^#{attr} = #{val}$/)
872 end
873 end
874
875 it 'has password set which is from databag' do
876 expect(chef_run).to render_file(file.name).with_content(/^vmware_host_password = vmware_secret_name$/)
877 end
878
879 it 'has no wsdl_location line without the attribute' do
880 node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = nil
881 expect(chef_run).not_to render_file(file.name).with_content(/^vmware_wsdl_location = /)
882 end
883
884 it 'has wsdl_location line with attribute present' do
885 node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = 'http://127.0.0.1/wsdl'
886 expect(chef_run).to render_file(file.name).with_content(%r{^vmware_wsdl_location = http://127.0.0.1/wsdl$})
887 end
888 end
889
890 context 'gpfs settings' do
891 before do
892 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.gpfs.GPFSDriver'
893 end
894
895 %w(gpfs_mount_point_base gpfs_max_clone_depth
896 gpfs_sparse_volumes gpfs_storage_pool).each do |attr|
897 it "has gpfs #{attr} set" do
898 node.set['openstack']['block-storage']['gpfs'][attr] = "gpfs_#{attr}_value"
899 expect(chef_run).to render_file(file.name).with_content(/^#{attr} = gpfs_#{attr}_value$/)
900 end
901 end
902
903 it 'has no gpfs_images_dir line without the attribute' do
904 node.set['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = nil
905 expect(chef_run).not_to render_file(file.name).with_content(/^gpfs_images_dir = /)
906 expect(chef_run).not_to render_file(file.name).with_content(/^gpfs_images_share_mode = /)
907 end
908
909 it 'has gpfs_images_dir line with attribute present' do
910 node.set['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = 'gpfs_images_dir_value'
911 expect(chef_run).to render_file(file.name).with_content(/^gpfs_images_dir = gpfs_images_dir_value$/)
912 expect(chef_run).to render_file(file.name).with_content(/^gpfs_images_share_mode = copy_on_write$/)
913 end
914
915 it 'templates misc_cinder array correctly' do
916 node.set['openstack']['block-storage']['misc_cinder'] = ['# Comments', 'MISC=OPTION']
917 expect(chef_run).to render_file(file.name).with_content(
918 /^# Comments$/)
919 expect(chef_run).to render_file(file.name).with_content(
920 /^MISC=OPTION$/)
921 end
922 end
923
924 context 'multiple backend settings' do
925 before do
926 node.set['openstack']['block-storage']['volume']['multi_backend'] = {
927 'lvm' => {
928 'volume_driver' => 'cinder.volume.drivers.lvm.LVMVolumeDriver',
929 'volume_backend_name' => 'lvmdrv'
930 },
931 'rbd' => {
932 'volume_driver' => 'cinder.volume.drivers.rbd.RBDDriver',
933 'volume_backend_name' => 'rbddrv'
934 },
935 'netapp_iscsi' => {
936 'volume_driver' => 'cinder.volume.drivers.netapp.NetAppISCSIDriver',
937 'multi_netapp_iscsi' => 'multi-netapp'
938 },
939 'netapp_nfs' => {
940 'volume_driver' => 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver',
941 'volume_backend_name' => 'netappnfsdrv',
942 'multi_netapp_nfs' => 'multi-netapp'
943 },
944 'ibmnas' => {
945 'volume_driver' => 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver',
946 'multi_ibmnas' => 'multi-ibmnas'
947 },
948 'ibmsvc' => {
949 'volume_driver' => 'cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver',
950 'multi_ibmsvc' => 'multi-ibmsvc'
951 },
952 'solidfire' => {
953 'volume_driver' => 'cinder.volume.drivers.solidfire.SolidFire',
954 'multi_solidfire' => 'multi-solidfire'
955 },
956 'emciscsi' => {
957 'volume_driver' => 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver',
958 'multi_emciscsi' => 'multi-emciscsi'
959 },
960 'vmware' => {
961 'volume_driver' => 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver',
962 'multi_vmware' => 'multi-vmware'
963 },
964 'gpfs' => {
965 'volume_driver' => 'cinder.volume.drivers.ibm.gpfs.GPFSDriver',
966 'multi_gpfs' => 'multi-gpfs'
967 }
968 }
969 node.set['openstack']['block-storage']['volume']['volume_group'] = 'multi-lvm-group'
970 node.set['openstack']['block-storage']['volume']['default_volume_type'] = 'some-type-name'
971 node.set['openstack']['block-storage']['rbd']['cinder']['pool'] = 'multi-rbd-pool'
972 node.set['openstack']['block-storage']['netapp']['dfm_login'] = 'multi-netapp-login'
973 node.set['openstack']['block-storage']['netapp']['netapp_server_hostname'] = ['netapp-host-1', 'netapp-host-2']
974 node.set['openstack']['block-storage']['netapp']['netapp_server_port'] = 'multi-netapp-port'
975 node.set['openstack']['block-storage']['ibmnas']['shares_config'] = 'multi-ibmnas-share'
976 node.set['openstack']['block-storage']['storwize']['storwize_svc_volpool_name'] = 'multi-svc-volpool'
977 node.set['openstack']['block-storage']['solidfire']['sf_emulate'] = 'multi-sf-true'
978 node.set['openstack']['block-storage']['emc']['cinder_emc_config_file'] = 'multi-emc-conf'
979 node.set['openstack']['block-storage']['vmware']['vmware_host_ip'] = 'multi-vmware-ip'
980 node.set['openstack']['block-storage']['gpfs']['gpfs_mount_point_base'] = 'multi-gpfs-mnt'
981 end
982
983 it 'enable multiple backends' do
984 expect(chef_run).to render_file(file.name).with_content(/^enabled_backends = lvm,rbd,netapp_iscsi,netapp_nfs,ibmnas,ibmsvc,solidfire,emciscsi,vmware,gpfs$/)
985
986 expect(chef_run).to render_file(file.name).with_content(/^\[lvm\]$/)
987 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.lvm\.LVMVolumeDriver$/)
988
989 expect(chef_run).to render_file(file.name).with_content(/^\[rbd\]$/)
990 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.rbd\.RBDDriver$/)
991
992 expect(chef_run).to render_file(file.name).with_content(/^\[netapp_iscsi\]$/)
993 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.netapp\.NetAppISCSIDriver$/)
994
995 expect(chef_run).to render_file(file.name).with_content(/^netapp_server_hostname=netapp-host-1$/)
996 expect(chef_run).to render_file(file.name).with_content(/^netapp_server_hostname=netapp-host-2$/)
997 expect(chef_run).to render_file(file.name).with_content(/^\[netapp_nfs\]$/)
998 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.netapp\.nfs\.NetAppDirect7modeNfsDriver$/)
999
1000 expect(chef_run).to render_file(file.name).with_content(/^\[ibmnas\]$/)
1001 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.ibm\.ibmnas\.IBMNAS_NFSDriver$/)
1002
1003 expect(chef_run).to render_file(file.name).with_content(/^\[ibmsvc\]$/)
1004 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.ibm\.storwize_svc\.StorwizeSVCDriver$/)
1005
1006 expect(chef_run).to render_file(file.name).with_content(/^\[solidfire\]$/)
1007 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.solidfire\.SolidFire$/)
1008
1009 expect(chef_run).to render_file(file.name).with_content(/^\[emciscsi\]$/)
1010 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.emc\.emc_smis_iscsi\.EMCSMISISCSIDriver$/)
1011
1012 expect(chef_run).to render_file(file.name).with_content(/^\[vmware\]$/)
1013 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.vmware\.vmdk\.VMwareVcVmdkDriver$/)
1014
1015 expect(chef_run).to render_file(file.name).with_content(/^\[gpfs\]$/)
1016 expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.ibm\.gpfs\.GPFSDriver$/)
1017 end
1018
1019 it 'set lvm option' do
1020 expect(chef_run).to render_file(file.name).with_content(/^volume_group=multi-lvm-group$/)
1021 end
1022
1023 it 'set default_volume_type option' do
1024 expect(chef_run).to render_file(file.name).with_content(/^default_volume_type=some-type-name$/)
1025 end
1026
1027 it 'set rbd option' do
1028 expect(chef_run).to render_file(file.name).with_content(/^rbd_pool=multi-rbd-pool$/)
1029 end
1030
1031 it 'set netapp_iscsi option' do
1032 expect(chef_run).to render_file(file.name).with_content(/^netapp_login=multi-netapp-login$/)
1033 end
1034
1035 it 'set netapp_nfs option' do
1036 expect(chef_run).to render_file(file.name).with_content(/^netapp_server_port=multi-netapp-port$/)
1037 end
1038
1039 it 'set ibmnas option' do
1040 expect(chef_run).to render_file(file.name).with_content(/^nfs_shares_config=multi-ibmnas-share$/)
1041 end
1042
1043 it 'set ibmsvc option' do
1044 expect(chef_run).to render_file(file.name).with_content(/^storwize_svc_volpool_name=multi-svc-volpool$/)
1045 end
1046
1047 it 'set solidfire option' do
1048 expect(chef_run).to render_file(file.name).with_content(/^sf_emulate_512=multi-sf-true$/)
1049 end
1050
1051 it 'set emciscsi option' do
1052 expect(chef_run).to render_file(file.name).with_content(/^cinder_emc_config_file=multi-emc-conf$/)
1053 end
1054
1055 it 'set vmware option' do
1056 expect(chef_run).to render_file(file.name).with_content(/^vmware_host_ip = multi-vmware-ip$/)
1057 end
1058
1059 it 'set gpfs option' do
1060 expect(chef_run).to render_file(file.name).with_content(/^gpfs_mount_point_base = multi-gpfs-mnt$/)
1061 end
1062 end
1063
1064 it 'no multiple backends configured' do
1065 expect(chef_run).to_not render_file(file.name).with_content(/^enabled_backends = [\w\W]+$/)
1066 end
1067
1068 it 'does not set default_volume_type' do
1069 expect(chef_run).to_not render_file(file.name).with_content(/^default_volume_type=.*$/)
1070 end
1071 end 267 end
1072 end 268 end
1073 269
1074 describe '/var/lib/cinder/lock' do 270 describe '/var/lib/cinder/tmp' do
1075 let(:dir) { chef_run.directory('/var/lib/cinder/lock') } 271 let(:dir) { chef_run.directory('/var/lib/cinder/tmp') }
1076 272
1077 it 'should create the /var/lib/cinder/lock directory' do 273 it 'should create the /var/lib/cinder/tmp directory' do
1078 expect(chef_run).to create_directory(dir.name).with( 274 expect(chef_run).to create_directory(dir.name).with(
1079 user: 'cinder', 275 user: 'cinder',
1080 group: 'cinder', 276 group: 'cinder',
@@ -1095,25 +291,21 @@ describe 'openstack-block-storage::cinder-common' do
1095 end 291 end
1096 292
1097 context 'template contents' do 293 context 'template contents' do
1098 it 'shows the custom banner' do
1099 node.set['openstack']['block-storage']['custom_template_banner'] = 'banner'
1100
1101 expect(chef_run).to render_file(file.name)
1102 .with_content(/^banner$/)
1103 end
1104
1105 it 'sets the default attributes' do 294 it 'sets the default attributes' do
1106 [ 295 [
1107 %r{^filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$}, 296 %r{^filters_path = /etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$},
1108 %r{^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$}, 297 %r{^exec_dirs = /sbin,/usr/sbin,/bin,/usr/bin$},
1109 /^use_syslog=False$/, 298 /^use_syslog = false$/,
1110 /^syslog_log_facility=syslog$/, 299 /^syslog_log_facility = syslog$/,
1111 /^syslog_log_level=ERROR$/ 300 /^syslog_log_level = ERROR$/
1112 ].each do |line| 301 ].each do |line|
1113 expect(chef_run).to render_file(file.name).with_content(line) 302 expect(chef_run).to render_file(file.name).with_content(line)
1114 end 303 end
1115 end 304 end
1116 end 305 end
1117 end 306 end
307 it do
308 expect(chef_run).to run_ruby_block("delete all attributes in node['openstack']['block-storage']['conf_secrets']")
309 end
1118 end 310 end
1119end 311end
diff --git a/spec/client_spec.rb b/spec/client_spec.rb
index eae242a..c63acc9 100644
--- a/spec/client_spec.rb
+++ b/spec/client_spec.rb
@@ -8,9 +8,5 @@ describe 'openstack-block-storage::client' do
8 let(:chef_run) do 8 let(:chef_run) do
9 runner.converge(described_recipe) 9 runner.converge(described_recipe)
10 end 10 end
11
12 it 'upgrades packages' do
13 expect(chef_run).to upgrade_package('python-cinderclient')
14 end
15 end 11 end
16end 12end
diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb
index 7f0547f..2901afd 100644
--- a/spec/identity_registration_spec.rb
+++ b/spec/identity_registration_spec.rb
@@ -56,86 +56,14 @@ describe 'openstack-block-storage::identity_registration' do
56 ) 56 )
57 end 57 end
58 58
59 it 'with different admin URL' do
60 admin_url = 'https://admin.host:123/admin_path'
61 general_url = 'http://general.host:456/general_path'
62
63 # Set the general endpoint
64 node.set['openstack']['endpoints']['block-storage-api']['uri'] = general_url
65 # Set the admin endpoint override
66 node.set['openstack']['endpoints']['admin']['block-storage-api']['uri'] = admin_url
67
68 expect(chef_run).to create_endpoint_openstack_identity_register(
69 'Register Cinder V2 Volume Endpoint'
70 ).with(
71 auth_uri: 'http://127.0.0.1:35357/v2.0',
72 bootstrap_token: 'bootstrap-token',
73 service_name: 'cinderv2',
74 service_type: 'volumev2',
75 service_description: 'Cinder Volume Service V2',
76 endpoint_region: 'RegionOne',
77 endpoint_adminurl: admin_url,
78 endpoint_internalurl: general_url,
79 endpoint_publicurl: general_url
80 )
81 end
82
83 it 'with different public URL' do
84 public_url = 'https://public.host:789/public_path'
85 general_url = 'http://general.host:456/general_path'
86
87 # Set the general endpoint
88 node.set['openstack']['endpoints']['block-storage-api']['uri'] = general_url
89 # Set the public endpoint override
90 node.set['openstack']['endpoints']['public']['block-storage-api']['uri'] = public_url
91
92 expect(chef_run).to create_endpoint_openstack_identity_register(
93 'Register Cinder V2 Volume Endpoint'
94 ).with(
95 auth_uri: 'http://127.0.0.1:35357/v2.0',
96 bootstrap_token: 'bootstrap-token',
97 service_name: 'cinderv2',
98 service_type: 'volumev2',
99 service_description: 'Cinder Volume Service V2',
100 endpoint_region: 'RegionOne',
101 endpoint_adminurl: general_url,
102 endpoint_internalurl: general_url,
103 endpoint_publicurl: public_url
104 )
105 end
106
107 it 'with different internal URL' do
108 internal_url = 'http://internal.host:456/internal_path'
109 general_url = 'http://general.host:456/general_path'
110
111 # Set the general endpoint
112 node.set['openstack']['endpoints']['block-storage-api']['uri'] = general_url
113 # Set the internal endpoint override
114 node.set['openstack']['endpoints']['internal']['block-storage-api']['uri'] = internal_url
115
116 expect(chef_run).to create_endpoint_openstack_identity_register(
117 'Register Cinder V2 Volume Endpoint'
118 ).with(
119 auth_uri: 'http://127.0.0.1:35357/v2.0',
120 bootstrap_token: 'bootstrap-token',
121 service_name: 'cinderv2',
122 service_type: 'volumev2',
123 service_description: 'Cinder Volume Service V2',
124 endpoint_region: 'RegionOne',
125 endpoint_adminurl: general_url,
126 endpoint_internalurl: internal_url,
127 endpoint_publicurl: general_url
128 )
129 end
130
131 it 'with all different URLs' do 59 it 'with all different URLs' do
132 admin_url = 'https://admin.host:123/admin_path' 60 admin_url = 'https://admin.host:123/admin_path'
133 internal_url = 'http://internal.host:456/internal_path' 61 internal_url = 'http://internal.host:456/internal_path'
134 public_url = 'https://public.host:789/public_path' 62 public_url = 'https://public.host:789/public_path'
135 63
136 node.set['openstack']['endpoints']['internal']['block-storage-api']['uri'] = internal_url 64 node.set['openstack']['endpoints']['block-storage']['internal']['uri'] = internal_url
137 node.set['openstack']['endpoints']['admin']['block-storage-api']['uri'] = admin_url 65 node.set['openstack']['endpoints']['block-storage']['admin']['uri'] = admin_url
138 node.set['openstack']['endpoints']['public']['block-storage-api']['uri'] = public_url 66 node.set['openstack']['endpoints']['block-storage']['public']['uri'] = public_url
139 67
140 expect(chef_run).to create_endpoint_openstack_identity_register( 68 expect(chef_run).to create_endpoint_openstack_identity_register(
141 'Register Cinder V2 Volume Endpoint' 69 'Register Cinder V2 Volume Endpoint'
@@ -203,5 +131,35 @@ describe 'openstack-block-storage::identity_registration' do
203 role_name: 'service' 131 role_name: 'service'
204 ) 132 )
205 end 133 end
134 it do
135 expect(chef_run).to create_service_openstack_identity_register(
136 'Register Cinder V1 Volume Service'
137 ).with(
138 auth_uri: 'http://127.0.0.1:35357/v2.0',
139 bootstrap_token: 'bootstrap-token',
140 service_name: 'cinder',
141 service_type: 'volume',
142 service_description: 'Cinder Volume Service V1',
143 endpoint_region: 'RegionOne',
144 endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
145 endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
146 endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s'
147 )
148 end
149 it do
150 expect(chef_run).to create_endpoint_openstack_identity_register(
151 'Register Cinder V1 Volume Endpoint'
152 ).with(
153 auth_uri: 'http://127.0.0.1:35357/v2.0',
154 bootstrap_token: 'bootstrap-token',
155 service_name: 'cinder',
156 service_type: 'volume',
157 service_description: 'Cinder Volume Service V1',
158 endpoint_region: 'RegionOne',
159 endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
160 endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
161 endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s'
162 )
163 end
206 end 164 end
207end 165end
diff --git a/spec/scheduler-suse_spec.rb b/spec/scheduler-suse_spec.rb
deleted file mode 100644
index 791e1a1..0000000
--- a/spec/scheduler-suse_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
1# encoding: UTF-8
2#
3# Cookbook Name:: openstack-block-storage
4
5require_relative 'spec_helper'
6
7describe 'openstack-block-storage::scheduler' do
8 describe 'suse' do
9 let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
10 let(:node) { runner.node }
11 let(:chef_run) { runner.converge(described_recipe) }
12
13 include_context 'block-storage-stubs'
14
15 it 'upgrades cinder scheduler package' do
16 expect(chef_run).to upgrade_package 'openstack-cinder-scheduler'
17 end
18
19 it 'starts cinder scheduler' do
20 expect(chef_run).to start_service 'openstack-cinder-scheduler'
21 end
22
23 it 'starts cinder scheduler on boot' do
24 expect(chef_run).to enable_service 'openstack-cinder-scheduler'
25 end
26
27 it 'does not upgrade stevedore' do
28 expect(chef_run).not_to upgrade_python_pip 'stevedore'
29 end
30
31 it 'upgrades mysql python package' do
32 expect(chef_run).to upgrade_package 'python-mysql'
33 end
34
35 it 'upgrades postgresql python packages if explicitly told' do
36 node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
37
38 expect(chef_run).to upgrade_package 'python-psycopg2'
39 expect(chef_run).not_to upgrade_package 'python-mysql'
40 end
41 end
42end
diff --git a/spec/scheduler_spec.rb b/spec/scheduler_spec.rb
index 6d12195..000c942 100644
--- a/spec/scheduler_spec.rb
+++ b/spec/scheduler_spec.rb
@@ -37,46 +37,5 @@ describe 'openstack-block-storage::scheduler' do
37 expect(chef_run).to upgrade_package 'python-psycopg2' 37 expect(chef_run).to upgrade_package 'python-psycopg2'
38 expect(chef_run).not_to upgrade_package 'python-mysqldb' 38 expect(chef_run).not_to upgrade_package 'python-mysqldb'
39 end 39 end
40
41 it 'does not setup cron when no metering' do
42 expect(chef_run.cron('cinder-volume-usage-audit')).to be_nil
43 end
44
45 it 'creates cron metering default' do
46 allow_any_instance_of(Chef::Recipe).to receive(:search)
47 .with(:node, 'roles:os-block-storage-scheduler')
48 .and_return([OpenStruct.new(name: 'fauxhai.local')])
49 node.set['openstack']['telemetry'] = true
50
51 cron = chef_run.cron 'cinder-volume-usage-audit'
52 bin_str = '/usr/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log'
53 expect(cron.command).to match(/#{bin_str}/)
54 crontests = [[:minute, '00'], [:hour, '*'], [:day, '*'],
55 [:weekday, '*'], [:month, '*'], [:user, 'cinder']]
56 crontests.each do |k, v|
57 expect(cron.send(k)).to eq v
58 expect(chef_run).to create_cron('cinder-volume-usage-audit')
59 end
60 expect(cron.action).to include :create
61 end
62
63 it 'creates cron metering custom' do
64 crontests = [[:minute, '50'], [:hour, '23'], [:day, '6'],
65 [:weekday, '5'], [:month, '11'], [:user, 'foobar']]
66 allow_any_instance_of(Chef::Recipe).to receive(:search)
67 .with(:node, 'roles:os-block-storage-scheduler')
68 .and_return([OpenStruct.new(name: 'foobar')])
69 node.set['openstack']['telemetry'] = true
70 crontests.each do |k, v|
71 node.set['openstack']['block-storage']['cron'][k.to_s] = v
72 end
73 node.set['openstack']['block-storage']['user'] = 'foobar'
74
75 cron = chef_run.cron 'cinder-volume-usage-audit'
76 crontests.each do |k, v|
77 expect(cron.send(k)).to eq v
78 end
79 expect(cron.action).to include :delete
80 end
81 end 40 end
82end 41end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index ba21c6c..e22dae1 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -10,11 +10,6 @@ ChefSpec::Coverage.start! { add_filter 'openstack-block-storage' }
10require 'chef/application' 10require 'chef/application'
11 11
12LOG_LEVEL = :fatal 12LOG_LEVEL = :fatal
13SUSE_OPTS = {
14 platform: 'suse',
15 version: '11.3',
16 log_level: LOG_LEVEL
17}
18REDHAT_OPTS = { 13REDHAT_OPTS = {
19 platform: 'redhat', 14 platform: 'redhat',
20 version: '7.1', 15 version: '7.1',
@@ -95,7 +90,7 @@ def expect_runs_openstack_common_logging_recipe
95 end 90 end
96end 91end
97 92
98def expect_creates_cinder_conf(service, user, group, action = :restart) # rubocop:disable MethodLength 93def expect_creates_cinder_conf(service, user, group, action = :restart)
99 describe 'cinder.conf' do 94 describe 'cinder.conf' do
100 let(:file) { chef_run.template('/etc/cinder/cinder.conf') } 95 let(:file) { chef_run.template('/etc/cinder/cinder.conf') }
101 96
diff --git a/spec/volume-redhat_spec.rb b/spec/volume-redhat_spec.rb
index 9f433c3..60a8fff 100644
--- a/spec/volume-redhat_spec.rb
+++ b/spec/volume-redhat_spec.rb
@@ -44,159 +44,5 @@ describe 'openstack-block-storage::volume' do
44 expect(chef_run).to enable_service('target') 44 expect(chef_run).to enable_service('target')
45 end 45 end
46 end 46 end
47
48 context 'IBMNAS Driver' do
49 let(:file) { chef_run.template('/etc/cinder/nfs_shares.conf') }
50 before do
51 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver'
52 node.set['openstack']['block-storage']['ibmnas']['nas_access_ip'] = '127.0.0.1'
53 node.set['openstack']['block-storage']['ibmnas']['export'] = '/ibm/fs/export'
54 end
55
56 it 'creates IBMNAS shares_config file' do
57 expect(chef_run).to create_template(file.name).with(
58 owner: 'cinder',
59 group: 'cinder',
60 mode: '0600'
61 )
62 expect(chef_run).to render_file(file.name).with_content('127.0.0.1:/ibm/fs/export')
63 end
64
65 it 'upgrades nfs packages' do
66 expect(chef_run).to upgrade_package 'nfs-utils'
67 expect(chef_run).to upgrade_package 'nfs-utils-lib'
68 end
69
70 it 'creates the nfs mount point' do
71 expect(chef_run).to create_directory('/mnt/cinder-volumes').with(
72 owner: 'cinder',
73 group: 'cinder',
74 mode: '0755'
75 )
76 end
77 end
78
79 context 'NFS Driver' do
80 before do
81 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
82 end
83
84 it 'upgrades nfs packages' do
85 expect(chef_run).to upgrade_package('nfs-utils')
86 expect(chef_run).to upgrade_package('nfs-utils-lib')
87 end
88 end
89
90 context 'EMC ISCSI Driver' do
91 before do
92 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
93 end
94
95 it 'upgrades emc package' do
96 expect(chef_run).to upgrade_package('pywbem')
97 end
98 end
99
100 describe 'IBM GPFS volume driver' do
101 before do
102 @chef_run = ::ChefSpec::SoloRunner.new ::REDHAT_OPTS do |n|
103 n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.gpfs.GPFSDriver'
104 n.set['openstack']['block-storage']['gpfs']['gpfs_mount_point_base'] = 'volumes'
105 n.set['openstack']['block-storage']['volume']['multi_backend'] =
106 {
107 'gpfs01' => {
108 'gpfs_mount_point_base' => 'gpfs_volume01',
109 'volume_driver' => 'cinder.volume.drivers.ibm.gpfs.GPFSDriver'
110 },
111 'gpfs02' => {
112 'gpfs_mount_point_base' => 'gpfs_volume02',
113 'volume_driver' => 'cinder.volume.drivers.ibm.gpfs.GPFSDriver'
114 }
115 }
116 end
117
118 @conf = '/etc/cinder/cinder.conf'
119 @chef_run.converge 'openstack-block-storage::volume'
120 end
121
122 it 'verifies gpfs_mount_point_base' do
123 expect(@chef_run).to render_file(@conf).with_content(
124 /^gpfs_mount_point_base = volumes$/)
125 end
126
127 it 'verifies gpfs_images_dir and gpfs_images_share_mode is set with default value' do
128 @chef_run.node.set['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = 'images'
129 expect(@chef_run).to render_file(@conf).with_content(
130 /^gpfs_images_dir = images$/)
131 expect(@chef_run).to render_file(@conf).with_content(
132 /^gpfs_images_share_mode = copy_on_write$/)
133 end
134
135 it 'verifies gpfs_images_dir and gpfs_images_share_mode set correctly' do
136 @chef_run.node.set['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = 'images'
137 @chef_run.node.set['openstack']['block-storage']['gpfs']['gpfs_images_share_mode'] = 'copy'
138 expect(@chef_run).to render_file(@conf).with_content(
139 /^gpfs_images_dir = images$/)
140 expect(@chef_run).to render_file(@conf).with_content(
141 /^gpfs_images_share_mode = copy$/)
142 end
143
144 it 'verifies gpfs_sparse_volumes is default' do
145 expect(@chef_run).to render_file(@conf).with_content(
146 /^gpfs_sparse_volumes = true$/)
147 end
148
149 it 'verifies gpfs_max_clone_depth is default' do
150 expect(@chef_run).to render_file(@conf).with_content(
151 /^gpfs_max_clone_depth = 8$/)
152 end
153
154 it 'verifies gpfs_storage_pool is default' do
155 expect(@chef_run).to render_file(@conf).with_content(
156 /^gpfs_storage_pool = system$/)
157 end
158
159 it 'verifies gpfs volume directory is created with owner and mode set correctly' do
160 expect(@chef_run).to create_directory('volumes').with(
161 owner: 'cinder',
162 group: 'cinder',
163 mode: '0755'
164 )
165 end
166
167 it 'verifies mount point base is created in multi backend case' do
168 expect(@chef_run).to create_directory('gpfs_volume01').with(
169 owner: 'cinder',
170 group: 'cinder',
171 mode: '0755'
172 )
173 expect(@chef_run).to create_directory('gpfs_volume02').with(
174 owner: 'cinder',
175 group: 'cinder',
176 mode: '0755'
177 )
178 end
179 end
180
181 describe 'create_vg' do
182 let(:file) { chef_run.template('/etc/init.d/cinder-group-active') }
183 before do
184 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMVolumeDriver'
185 node.set['openstack']['block-storage']['volume']['create_volume_group'] = true
186 stub_command('vgs cinder-volumes').and_return(false)
187 end
188
189 describe 'template contents' do
190 it 'sources /etc/rc.d/init.d/functions' do
191 expect(chef_run).to render_file(file.name).with_content(%r{^\s*. /etc/rc.d/init.d/functions$})
192 end
193
194 it 'calls success and echo' do
195 [/^\s*success$/, /^\s*echo$/].each do |cmd|
196 expect(chef_run).to render_file(file.name).with_content(cmd)
197 end
198 end
199 end
200 end
201 end 47 end
202end 48end
diff --git a/spec/volume-suse_spec.rb b/spec/volume-suse_spec.rb
deleted file mode 100644
index 6e1019a..0000000
--- a/spec/volume-suse_spec.rb
+++ /dev/null
@@ -1,79 +0,0 @@
1# encoding: UTF-8
2#
3# Cookbook Name:: openstack-block-storage
4
5require_relative 'spec_helper'
6
7describe 'openstack-block-storage::volume' do
8 describe 'suse' do
9 let(:runner) { ChefSpec::SoloRunner.new(SUSE_OPTS) }
10 let(:node) { runner.node }
11 let(:chef_run) { runner.converge(described_recipe) }
12
13 include_context 'block-storage-stubs'
14
15 it 'upgrades cinder volume package' do
16 expect(chef_run).to upgrade_package('openstack-cinder-volume')
17 end
18
19 it 'upgrades qemu img package' do
20 expect(chef_run).to upgrade_package('qemu-img')
21 end
22
23 it 'upgrades mysql python package' do
24 expect(chef_run).to upgrade_package('python-mysql')
25 end
26
27 it 'upgrades postgresql python packages if explicitly told' do
28 node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
29
30 expect(chef_run).to upgrade_package('python-psycopg2')
31 expect(chef_run).not_to upgrade_package('python-mysql')
32 end
33
34 it 'upgrades cinder iscsi package' do
35 expect(chef_run).to upgrade_package('tgt')
36 end
37
38 it 'starts cinder volume' do
39 expect(chef_run).to start_service('openstack-cinder-volume')
40 end
41
42 it 'starts cinder volume on boot' do
43 expect(chef_run).to enable_service('openstack-cinder-volume')
44 end
45
46 context 'ISCSI' do
47 let(:file) { chef_run.template('/etc/tgt/targets.conf') }
48 it 'starts iscsi target on boot' do
49 expect(chef_run).to enable_service('tgtd')
50 end
51
52 it 'has suse include' do
53 expect(chef_run).to render_file(file.name).with_content('include /var/lib/cinder/volumes/*')
54 expect(chef_run).not_to render_file(file.name).with_content('include /etc/tgt/conf.d/*.conf')
55 end
56 end
57
58 context 'NFS Driver' do
59 before do
60 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
61 end
62
63 it 'installs nfs packages' do
64 expect(chef_run).to upgrade_package('nfs-utils')
65 expect(chef_run).not_to upgrade_package('nfs-utils-lib')
66 end
67 end
68
69 context 'EMC ISCSI Driver' do
70 before do
71 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
72 end
73
74 it 'installs emc packages' do
75 expect(chef_run).to upgrade_package('python-pywbem')
76 end
77 end
78 end
79end
diff --git a/spec/volume_spec.rb b/spec/volume_spec.rb
index 7cf8833..25520d3 100644
--- a/spec/volume_spec.rb
+++ b/spec/volume_spec.rb
@@ -50,168 +50,6 @@ describe 'openstack-block-storage::volume' do
50 expect(chef_run).to upgrade_package 'tgt' 50 expect(chef_run).to upgrade_package 'tgt'
51 end 51 end
52 52
53 it 'upgrades emc package' do
54 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
55
56 expect(chef_run).to upgrade_package 'python-pywbem'
57 end
58
59 context 'IBMNAS Driver' do
60 let(:file) { chef_run.template('/etc/cinder/nfs_shares.conf') }
61 before do
62 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver'
63 end
64
65 context 'IBMNAS shares_config file' do
66 it 'creates the file' do
67 expect(chef_run).to create_template(file.name).with(
68 owner: 'cinder',
69 group: 'cinder',
70 mode: '0600'
71 )
72 end
73
74 it 'sets the ibmnas access_ip attribute' do
75 node.set['openstack']['block-storage']['ibmnas']['nas_access_ip'] = '127.0.0.1'
76 node.set['openstack']['block-storage']['ibmnas']['export'] = '/ibm/fs/export'
77 expect(chef_run).to render_file(file.name).with_content('127.0.0.1:/ibm/fs/export')
78 end
79 end
80
81 it 'upgrades nfs package' do
82 expect(chef_run).to upgrade_package 'nfs-common'
83 end
84
85 it 'creates the nfs mount point' do
86 expect(chef_run).to create_directory('/mnt/cinder-volumes').with(
87 owner: 'cinder',
88 group: 'cinder',
89 mode: '0755'
90 )
91 end
92 end
93
94 context 'NetApp Driver' do
95 describe 'NFS' do
96 before do
97 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
98 end
99
100 it 'upgrades nfs package' do
101 expect(chef_run).to upgrade_package 'nfs-common'
102 end
103
104 it 'creates the nfs mount point' do
105 expect(chef_run).to create_directory '/mnt/cinder-volumes'
106 end
107
108 context 'shares config file' do
109 let(:shares_config_file) { 'nfs_shares_config_file' }
110 let(:file) { chef_run.template(shares_config_file) }
111
112 before do
113 node.set['openstack']['block-storage']['nfs']['shares_config'] = shares_config_file
114 end
115
116 it 'creates the file' do
117 node.set['openstack']['block-storage']['user'] = 'test_user'
118 node.set['openstack']['block-storage']['group'] = 'test_group'
119
120 expect(chef_run).to create_template(file.name).with(
121 owner: 'test_user',
122 group: 'test_group',
123 mode: '0600'
124 )
125 end
126
127 it 'sets netapp server hostname export settings' do
128 netapp_server_hostname = %w(hostname1 hostname2)
129 node.set['openstack']['block-storage']['netapp']['netapp_server_hostname'] = netapp_server_hostname
130 node.set['openstack']['block-storage']['netapp']['export'] = 'netapp_export_value'
131
132 netapp_server_hostname.each do |hostname|
133 expect(chef_run).to render_file(file.name).with_content(/^#{hostname}:netapp_export_value$/)
134 end
135 end
136 end
137 end
138
139 describe 'ISCSI' do
140 before do
141 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver'
142 end
143
144 it 'configures netapp dfm password' do
145 n = chef_run.node['openstack']['block-storage']['netapp']['dfm_password']
146 expect(n).to eq 'netapp-pass'
147 end
148 end
149 end
150
151 context 'Ceph (RBD) Driver' do
152 let(:file) { chef_run.template('/etc/ceph/ceph.client.cinder.keyring') }
153 before do
154 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.rbd.RBDDriver'
155 node.set['ceph']['config']['fsid'] = '00000000-0000-0000-0000-000000000000'
156 end
157
158 it 'includes the ceph recipe' do
159 expect(chef_run).to include_recipe('ceph')
160 end
161 end
162 context 'Storewize Driver' do
163 let(:file) { chef_run.template('/etc/cinder/cinder.conf') }
164 before do
165 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver'
166 end
167
168 it 'download san private key if needed' do
169 node.set['openstack']['block-storage']['storwize']['san_private_key_url'] = 'http://server/key'
170 expect(chef_run).to create_remote_file('/v7000_rsa').with(
171 source: 'http://server/key',
172 user: 'cinder',
173 group: 'cinder',
174 mode: '0400'
175 )
176 end
177
178 it 'upgrades svc package' do
179 expect(chef_run).to upgrade_package 'sysfsutils'
180 end
181
182 context 'ISCSI' do
183 before do
184 node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI'
185 end
186
187 it 'configures storewize with iscsi' do
188 # Test that the FC specific options are not set when connected via iSCSI
189 expect(chef_run).not_to render_file(file.name).with_content('storwize_svc_multipath_enabled')
190 end
191 end
192
193 context 'FC' do
194 before do
195 node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'FC'
196 end
197
198 it 'configures storewize with fc' do
199 # Test that the iSCSI specific options are not set when connected via FC
200 expect(chef_run).not_to render_file(file.name).with_content('storwize_svc_iscsi_chap_enabled')
201 end
202 end
203 end
204
205 context 'FlashSystem Driver' do
206 before do
207 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.flashsystem.FlashSystemDriver'
208 end
209
210 it 'upgrades sysfsutils package' do
211 expect(chef_run).to upgrade_package 'sysfsutils'
212 end
213 end
214
215 describe 'targets.conf' do 53 describe 'targets.conf' do
216 let(:file) { chef_run.template('/etc/tgt/targets.conf') } 54 let(:file) { chef_run.template('/etc/tgt/targets.conf') }
217 55
@@ -232,125 +70,5 @@ describe 'openstack-block-storage::volume' do
232 expect(chef_run).not_to render_file(file.name).with_content('include volumes_dir_value/*') 70 expect(chef_run).not_to render_file(file.name).with_content('include volumes_dir_value/*')
233 end 71 end
234 end 72 end
235
236 describe 'create_vg' do
237 let(:file) { chef_run.template('/etc/init.d/cinder-group-active') }
238 before do
239 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMVolumeDriver'
240 node.set['openstack']['block-storage']['volume']['create_volume_group'] = true
241 stub_command('vgs cinder-volumes').and_return(false)
242 end
243
244 it 'upgrades lvm packages' do
245 expect(chef_run).to upgrade_package 'lvm2'
246 end
247
248 it 'cinder vg active' do
249 expect(chef_run).to enable_service 'cinder-group-active'
250 end
251
252 it 'create volume group' do
253 volume_size = chef_run.node['openstack']['block-storage']['volume']['volume_group_size']
254 seek_count = volume_size.to_i * 1024
255 group_name = chef_run.node['openstack']['block-storage']['volume']['volume_group']
256 path = chef_run.node['openstack']['block-storage']['volume']['state_path']
257 vg_file = "#{path}/#{group_name}.img"
258 cmd = "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate cinder-volumes $(losetup --show -f #{vg_file})"
259 expect(chef_run).to run_execute(cmd)
260 end
261
262 it 'notifies cinder group active start' do
263 expect(file).to notify('service[cinder-group-active]').to(:start)
264 end
265
266 it 'creates cinder group active template file' do
267 expect(chef_run).to create_template(file.name)
268 end
269
270 describe 'template contents' do
271 let(:volume_group_value) { 'volume_group_value' }
272 before do
273 node.set['openstack']['block-storage']['volume']['volume_group'] = volume_group_value
274 stub_command("vgs #{volume_group_value}").and_return(true)
275 end
276
277 it 'calls vgs with the volume name attribute' do
278 expect(chef_run).to render_file(file.name).with_content(%r{vgs #{volume_group_value} > /dev/null 2>&1})
279 end
280
281 it 'calls vgcreate with the volume name and volume file attributes' do
282 node.set['openstack']['block-storage']['volume']['state_path'] = 'state_path_value'
283 volume_file = "state_path_value/#{volume_group_value}.img"
284 expect(chef_run).to render_file(file.name).with_content(/vgcreate #{volume_group_value} \$\(losetup --show -f #{volume_file}\)/)
285 end
286
287 it 'has ubuntu settings' do
288 expect(chef_run).to render_file(file.name).with_content(/^\s*echo "SUCCESS"/)
289 expect(chef_run).not_to render_file(file.name).with_content(/^\s*success$/)
290 end
291 end
292 end
293
294 describe 'create vg on block devices' do
295 before do
296 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMVolumeDriver'
297 node.set['openstack']['block-storage']['volume']['create_volume_group'] = true
298 node.set['openstack']['block-storage']['volume']['create_volume_group_type'] = 'block_devices'
299 node.set['openstack']['block-storage']['volume']['block_devices'] = '/dev/sdx /dev/sdx1'
300 stub_command('vgs cinder-volumes').and_return(false)
301 end
302
303 it 'create volume group on block devices' do
304 cmd = 'pvcreate /dev/sdx /dev/sdx1; vgcreate cinder-volumes /dev/sdx /dev/sdx1'
305 expect(chef_run).to run_execute('Create Cinder volume group with block devices').with(command: cmd)
306 end
307 end
308
309 describe 'cinder_emc_config.xml' do
310 let(:file) { chef_run.template('/etc/cinder/cinder_emc_config.xml') }
311 before do
312 node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
313 end
314
315 it 'creates cinder emc config file' do
316 expect(chef_run).to create_template(file.name).with(
317 mode: 0644
318 )
319 end
320
321 describe 'template contents' do
322 before do
323 allow_any_instance_of(Chef::Recipe).to receive(:get_password)
324 .with('user', anything)
325 .and_return('emc_test_pass')
326 end
327
328 %w(StorageType EcomServerPort EcomUserName).each do |attr|
329 it "has an emc #{attr} setting" do
330 node.set['openstack']['block-storage']['emc'][attr] = "emc_#{attr}_value"
331 expect(chef_run).to render_file(file.name).with_content(%r{^<#{attr}>emc_#{attr}_value</#{attr}>$})
332 end
333 end
334
335 it 'has a EcomServerIP' do
336 node.set['openstack']['block-storage']['emc']['EcomServerIP'] = 'emc_EcomServerIP_value'
337 expect(chef_run).to render_file(file.name).with_content(%r{^<EcomServerIp>emc_EcomServerIP_value</EcomServerIp>$})
338 end
339
340 it 'has EcomPassword' do
341 node.set['openstack']['block-storage']['emc']['EcomUserName'] = 'emc_username'
342 expect(chef_run).to render_file(file.name).with_content(%r{^<EcomPassword>emc_test_pass</EcomPassword>$})
343 end
344
345 it 'does not have MaskingView when not specified' do
346 expect(chef_run).not_to render_file(file.name).with_content(/^<MaskingView>/)
347 end
348
349 it 'has MaskingView when specified' do
350 node.set['openstack']['block-storage']['emc']['MaskingView'] = 'testMaskingView'
351 expect(chef_run).to render_file(file.name).with_content(%r{^<MaskingView>testMaskingView</MaskingView>$})
352 end
353 end
354 end
355 end 73 end
356end 74end