Chef Cookbook - OpenStack Block Storage
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cinder_common_spec.rb 48KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  1. # encoding: utf-8
  2. #
  3. # Cookbook Name:: openstack-block-storage
  4. require_relative 'spec_helper'
  5. describe 'openstack-block-storage::cinder-common' do
  6. describe 'ubuntu' do
  7. let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
  8. let(:node) { runner.node }
  9. let(:chef_run) do
  10. node.set['openstack']['mq']['host'] = '127.0.0.1'
  11. node.set['openstack']['mq']['block-storage']['rabbit']['notification_topic'] = 'rabbit_topic'
  12. runner.converge(described_recipe)
  13. end
  14. include_context 'block-storage-stubs'
  15. it 'upgrades the cinder-common package' do
  16. expect(chef_run).to upgrade_package 'cinder-common'
  17. end
  18. describe '/etc/cinder' do
  19. let(:dir) { chef_run.directory('/etc/cinder') }
  20. it 'should create the /etc/cinder directory' do
  21. expect(chef_run).to create_directory(dir.name)
  22. end
  23. it 'has proper owner' do
  24. expect(dir.owner).to eq('cinder')
  25. expect(dir.group).to eq('cinder')
  26. end
  27. it 'has proper modes' do
  28. expect(sprintf('%o', dir.mode)).to eq '750'
  29. end
  30. end
  31. describe 'cinder.conf' do
  32. let(:file) { chef_run.template('/etc/cinder/cinder.conf') }
  33. let(:test_pass) { 'test_pass' }
  34. before do
  35. allow_any_instance_of(Chef::Recipe).to receive(:get_password)
  36. .with('user', anything)
  37. .and_return(test_pass)
  38. end
  39. it 'should create the cinder.conf template' do
  40. expect(chef_run).to create_template(file.name)
  41. end
  42. it 'has proper owner' do
  43. expect(file.owner).to eq('cinder')
  44. expect(file.group).to eq('cinder')
  45. end
  46. it 'has proper modes' do
  47. expect(sprintf('%o', file.mode)).to eq '640'
  48. end
  49. context 'keystone authtoken attributes with default values' do
  50. it 'sets memcached server(s)' do
  51. expect(chef_run).not_to render_file(file.name).with_content(/^memcached_servers = $/)
  52. end
  53. it 'sets memcache security strategy' do
  54. expect(chef_run).not_to render_file(file.name).with_content(/^memcache_security_strategy = $/)
  55. end
  56. it 'sets memcache secret key' do
  57. expect(chef_run).not_to render_file(file.name).with_content(/^memcache_secret_key = $/)
  58. end
  59. it 'sets cafile' do
  60. expect(chef_run).not_to render_file(file.name).with_content(/^cafile = $/)
  61. end
  62. it 'sets insecure' do
  63. expect(chef_run).to render_file(file.name).with_content(/^insecure = false$/)
  64. end
  65. it 'sets token hash algorithms' do
  66. expect(chef_run).to render_file(file.name).with_content(/^hash_algorithms = md5$/)
  67. end
  68. end
  69. context 'keystone authtoken attributes' do
  70. it 'has signing_dir' do
  71. node.set['openstack']['block-storage']['api']['auth']['cache_dir'] = 'auth_cache_dir'
  72. expect(chef_run).to render_file(file.name).with_content(/^signing_dir = auth_cache_dir$/)
  73. end
  74. it 'sets memcached server(s)' do
  75. node.set['openstack']['block-storage']['api']['auth']['memcached_servers'] = 'localhost:11211'
  76. expect(chef_run).to render_file(file.name).with_content(/^memcached_servers = localhost:11211$/)
  77. end
  78. it 'sets memcache security strategy' do
  79. node.set['openstack']['block-storage']['api']['auth']['memcache_security_strategy'] = 'MAC'
  80. expect(chef_run).to render_file(file.name).with_content(/^memcache_security_strategy = MAC$/)
  81. end
  82. it 'sets memcache secret key' do
  83. node.set['openstack']['block-storage']['api']['auth']['memcache_secret_key'] = '0123456789ABCDEF'
  84. expect(chef_run).to render_file(file.name).with_content(/^memcache_secret_key = 0123456789ABCDEF$/)
  85. end
  86. it 'sets cafile' do
  87. node.set['openstack']['block-storage']['api']['auth']['cafile'] = 'dir/to/path'
  88. expect(chef_run).to render_file(file.name).with_content(%r{^cafile = dir/to/path$})
  89. end
  90. it 'sets insecure' do
  91. node.set['openstack']['block-storage']['api']['auth']['insecure'] = true
  92. expect(chef_run).to render_file(file.name).with_content(/^insecure = true$/)
  93. end
  94. it 'sets token hash algorithms' do
  95. node.set['openstack']['block-storage']['api']['auth']['hash_algorithms'] = 'sha2'
  96. expect(chef_run).to render_file(file.name).with_content(/^hash_algorithms = sha2$/)
  97. end
  98. context 'endpoint related' do
  99. it 'has auth_uri' do
  100. expect(chef_run).to render_file(file.name).with_content(%r(^auth_uri = http://127.0.0.1:5000/v2.0$))
  101. end
  102. it 'has identity_uri' do
  103. expect(chef_run).to render_file(file.name).with_content(%r(^identity_uri = http://127.0.0.1:35357/$))
  104. end
  105. end
  106. it 'has no auth_version when auth_version is v2.0' do
  107. node.set['openstack']['block-storage']['api']['auth']['version'] = 'v2.0'
  108. expect(chef_run).not_to render_file(file.name).with_content(/^auth_version = v2.0$/)
  109. end
  110. it 'has auth_version when auth version is not v2.0' do
  111. node.set['openstack']['block-storage']['api']['auth']['version'] = 'v3.0'
  112. expect(chef_run).to render_file(file.name).with_content(/^auth_version = v3.0$/)
  113. end
  114. it 'has an admin tenant name' do
  115. node.set['openstack']['block-storage']['service_tenant_name'] = 'tenant_name'
  116. expect(chef_run).to render_file(file.name).with_content(/^admin_tenant_name = tenant_name$/)
  117. end
  118. it 'has an admin user' do
  119. node.set['openstack']['block-storage']['service_user'] = 'username'
  120. expect(chef_run).to render_file(file.name).with_content(/^admin_user = username$/)
  121. end
  122. it 'has an admin password' do
  123. # (fgimenez) the get_password mocking is set in spec/spec_helper.rb
  124. expect(chef_run).to render_file(file.name).with_content(/^admin_password = cinder-pass$/)
  125. end
  126. end
  127. context 'template contents' do
  128. context 'commonly named attributes' do
  129. %w(debug verbose host notification_driver
  130. storage_availability_zone quota_volumes quota_gigabytes quota_driver
  131. volume_name_template snapshot_name_template osapi_volume_workers
  132. use_default_quota_class quota_snapshots no_snapshot_gb_quota
  133. control_exchange max_gigabytes).each do |attr_key|
  134. it "has a #{attr_key} attribute" do
  135. node.set['openstack']['block-storage'][attr_key] = "#{attr_key}_value"
  136. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr_key}=#{attr_key}_value$/)
  137. end
  138. end
  139. end
  140. context 'backup swift backend contents' do
  141. before do
  142. node.set['openstack']['block-storage']['backup']['enabled'] = true
  143. node.set['openstack']['block-storage']['backup']['driver'] = 'cinder.backup.drivers.swift'
  144. end
  145. it 'has default attributes' do
  146. %w(swift_catalog_info=object-store:swift:publicURL
  147. backup_swift_auth=per_user
  148. backup_swift_auth_version=1
  149. backup_swift_container=volumebackups
  150. backup_swift_object_size=52428800
  151. backup_swift_block_size=32768
  152. backup_swift_retry_attempts=3
  153. backup_swift_retry_backoff=2
  154. backup_swift_enable_progress_timer=True).each do |attr|
  155. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}$/)
  156. end
  157. end
  158. it 'has override attributes' do
  159. %w(url
  160. auth
  161. auth_version
  162. tenant
  163. user
  164. key
  165. container
  166. object_size
  167. block_size
  168. retry_attempts
  169. retry_backoff
  170. enable_progress_timer).each do |attr|
  171. node.set['openstack']['block-storage']['backup']['swift'][attr] = "backup_swift_#{attr}"
  172. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^backup_swift_#{attr}=backup_swift_#{attr}$/)
  173. end
  174. end
  175. it 'has a custom catalog_info' do
  176. node.set['openstack']['block-storage']['backup']['swift']['catalog_info'] = 'swift_catalog_info'
  177. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^swift_catalog_info=swift_catalog_info$/)
  178. end
  179. end
  180. context 'rdb driver' do
  181. # FIXME(galstrom21): this block needs to check all of the default
  182. # rdb_* configuration options
  183. it 'has default rbd_* options set' do
  184. node.set['openstack']['block-storage']['volume'] = {
  185. 'driver' => 'cinder.volume.drivers.rbd.RBDDriver'
  186. }
  187. expect(chef_run).to render_file(file.name).with_content(/^rbd_/)
  188. expect(chef_run).not_to render_file(file.name).with_content(/^netapp_/)
  189. end
  190. end
  191. it 'has a lock_path attribute' do
  192. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r(^lock_path=/var/lib/cinder/lock$))
  193. end
  194. it 'does not have unique host id by default' do
  195. expect(chef_run).not_to render_config_file(file.name).with_section_content('DEFAULT', /^host=/)
  196. end
  197. context 'netapp driver' do
  198. # FIXME(galstrom21): this block needs to check all of the default
  199. # netapp_* configuration options
  200. it 'has default netapp_* options set' do
  201. node.set['openstack']['block-storage']['volume'] = {
  202. 'driver' => 'cinder.volume.drivers.netapp.NetAppISCSIDriver'
  203. }
  204. expect(chef_run).to render_file(file.name).with_content(/^netapp_/)
  205. expect(chef_run).not_to render_file(file.name).with_content(/^rbd_/)
  206. end
  207. end
  208. context 'syslog use' do
  209. it 'sets the log_config value when syslog is in use' do
  210. node.set['openstack']['block-storage']['syslog']['use'] = true
  211. expect(chef_run).to render_file(file.name)
  212. .with_content(%r{^log_config = /etc/openstack/logging.conf$})
  213. end
  214. it 'sets the log_file value when syslog is not in use' do
  215. node.set['openstack']['block-storage']['syslog']['use'] = false
  216. expect(chef_run).to render_file(file.name)
  217. .with_content(%r{^log_file = /var/log/cinder/cinder.log$})
  218. end
  219. end
  220. it 'has a db connection attribute' do
  221. allow_any_instance_of(Chef::Recipe).to receive(:db_uri)
  222. .with('block-storage', anything, '').and_return('sql_connection_value')
  223. expect(chef_run).to render_config_file(file.name)
  224. .with_section_content('database', /^connection=sql_connection_value$/)
  225. end
  226. it 'has a db backend attribute' do
  227. expect(chef_run).to render_config_file(file.name).with_section_content('database', /^backend=sqlalchemy$/)
  228. end
  229. it 'has a volume_driver attribute' do
  230. node.set['openstack']['block-storage']['volume']['driver'] = 'volume_driver_value'
  231. expect(chef_run).to render_file(file.name).with_content(/^volume_driver=volume_driver_value$/)
  232. end
  233. it 'has a state_path attribute' do
  234. node.set['openstack']['block-storage']['volume']['state_path'] = 'state_path_value'
  235. expect(chef_run).to render_file(file.name).with_content(/^state_path=state_path_value$/)
  236. end
  237. context 'glance endpoint' do
  238. it 'has a glance_api_servers attribute' do
  239. expect(chef_run).to render_file(file.name).with_content(%r{^glance_api_servers=http://127.0.0.1:9292$})
  240. end
  241. it 'has glance_api_version attribute' do
  242. expect(chef_run).to render_file(file.name).with_content(/^glance_api_version=1$/)
  243. end
  244. it 'has a glance_api_insecure attribute' do
  245. expect(chef_run).to render_file(file.name).with_content(/^glance_api_insecure=false$/)
  246. end
  247. it 'sets insecure for glance' do
  248. node.set['openstack']['block-storage']['image']['glance_api_insecure'] = true
  249. expect(chef_run).to render_file(file.name).with_content(/^glance_api_insecure=true$/)
  250. end
  251. it 'has a glance_ca_certificates_file attribute' do
  252. expect(chef_run).to render_file(file.name).with_content(/^glance_ca_certificates_file=$/)
  253. end
  254. it 'sets glance_ca_certificates_file attribute' do
  255. node.set['openstack']['block-storage']['image']['glance_ca_certificates_file'] = 'dir/to/path'
  256. expect(chef_run).to render_file(file.name).with_content(%r{^glance_ca_certificates_file=dir/to/path$})
  257. end
  258. it 'has a glance host attribute' do
  259. expect(chef_run).to render_file(file.name).with_content(/^glance_host=127.0.0.1$/)
  260. end
  261. it 'has a glance port attribute' do
  262. expect(chef_run).to render_file(file.name).with_content(/^glance_port=9292$/)
  263. end
  264. end
  265. it 'has a api_rate_limit attribute' do
  266. node.set['openstack']['block-storage']['api']['ratelimit'] = 'api_rate_limit_value'
  267. expect(chef_run).to render_file(file.name).with_content(/^api_rate_limit=api_rate_limit_value$/)
  268. end
  269. context 'cinder endpoint' do
  270. it 'has osapi_volume_listen set' do
  271. expect(chef_run).to render_file(file.name).with_content(/^osapi_volume_listen=127.0.0.1$/)
  272. end
  273. it 'has osapi_volume_listen_port set' do
  274. expect(chef_run).to render_file(file.name).with_content(/^osapi_volume_listen_port=8776$/)
  275. end
  276. it 'has default api version set' do
  277. [/^enable_v1_api=False$/,
  278. /^enable_v2_api=True$/].each do |line|
  279. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line)
  280. end
  281. end
  282. it 'has override api version set' do
  283. node.set['openstack']['block-storage']['enable_v1_api'] = 'True'
  284. node.set['openstack']['block-storage']['enable_v2_api'] = 'False'
  285. [/^enable_v1_api=True$/,
  286. /^enable_v2_api=False$/].each do |line|
  287. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line)
  288. end
  289. end
  290. end
  291. it 'has a rpc_backend attribute' do
  292. node.set['openstack']['block_storage']['rpc_backend'] = 'rpc_backend_value'
  293. expect(chef_run).to render_file(file.name).with_content(/^rpc_backend=rpc_backend_value$/)
  294. end
  295. it 'has default RPC/AMQP options set' do
  296. [/^rpc_backend=cinder.openstack.common.rpc.impl_kombu$/,
  297. /^rpc_thread_pool_size=64$/,
  298. /^rpc_response_timeout=60$/].each do |line|
  299. expect(chef_run).to render_file(file.name).with_content(line)
  300. end
  301. end
  302. context 'rabbitmq as mq service' do
  303. before do
  304. node.set['openstack']['mq']['block-storage']['service_type'] = 'rabbitmq'
  305. end
  306. it 'has default RPC/AMQP options set' do
  307. [/^rpc_conn_pool_size=30$/,
  308. /^amqp_durable_queues=false$/,
  309. /^amqp_auto_delete=false$/].each do |line|
  310. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', line)
  311. end
  312. end
  313. context 'ha attributes' do
  314. before do
  315. node.set['openstack']['mq']['block-storage']['rabbit']['ha'] = true
  316. end
  317. it 'has a rabbit_hosts attribute' do
  318. allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers)
  319. .and_return('rabbit_servers_value')
  320. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts=rabbit_servers_value$/)
  321. end
  322. %w(host port).each do |attr|
  323. it "does not have rabbit_#{attr} attribute" do
  324. expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=/)
  325. end
  326. end
  327. end
  328. context 'non ha attributes' do
  329. before do
  330. node.set['openstack']['mq']['block-storage']['rabbit']['ha'] = false
  331. end
  332. %w(host port).each do |attr|
  333. it "has rabbit_#{attr} attribute" do
  334. node.set['openstack']['mq']['block-storage']['rabbit'][attr] = "rabbit_#{attr}_value"
  335. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=rabbit_#{attr}_value$/)
  336. end
  337. end
  338. it 'does not have a rabbit_hosts attribute' do
  339. expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts=/)
  340. end
  341. end
  342. %w(use_ssl userid).each do |attr|
  343. it "has rabbit_#{attr}" do
  344. node.set['openstack']['mq']['block-storage']['rabbit'][attr] = "rabbit_#{attr}_value"
  345. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=rabbit_#{attr}_value$/)
  346. end
  347. end
  348. it 'has rabbit_password' do
  349. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_password=#{test_pass}$/)
  350. end
  351. it 'has rabbit_virtual_host' do
  352. node.set['openstack']['mq']['block-storage']['rabbit']['vhost'] = 'vhost_value'
  353. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_virtual_host=vhost_value$/)
  354. end
  355. it 'does not have kombu ssl version set' do
  356. expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^kombu_ssl_version=TLSv1.2$/)
  357. end
  358. it 'sets kombu ssl version' do
  359. node.set['openstack']['mq']['block-storage']['rabbit']['use_ssl'] = true
  360. node.set['openstack']['mq']['block-storage']['rabbit']['kombu_ssl_version'] = 'TLSv1.2'
  361. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^kombu_ssl_version=TLSv1.2$/)
  362. end
  363. end
  364. context 'qpid as mq service' do
  365. before do
  366. node.set['openstack']['mq']['block-storage']['service_type'] = 'qpid'
  367. end
  368. it 'has default RPC/AMQP options set' do
  369. [/^rpc_conn_pool_size=30$/,
  370. /^amqp_durable_queues=false$/,
  371. /^amqp_auto_delete=false$/].each do |line|
  372. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', line)
  373. end
  374. end
  375. %w(port username sasl_mechanisms reconnect reconnect_timeout reconnect_limit
  376. reconnect_interval_min reconnect_interval_max reconnect_interval heartbeat protocol
  377. tcp_nodelay).each do |attr|
  378. it "has qpid_#{attr} attribute" do
  379. node.set['openstack']['mq']['block-storage']['qpid'][attr] = "qpid_#{attr}_value"
  380. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_#{attr}=qpid_#{attr}_value$/)
  381. end
  382. end
  383. it 'has qpid_hostname' do
  384. node.set['openstack']['mq']['block-storage']['qpid']['host'] = 'qpid_host_value'
  385. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_hostname=qpid_host_value$/)
  386. end
  387. it 'has qpid_password' do
  388. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_password=#{test_pass}$/)
  389. end
  390. it 'has default qpid topology version' do
  391. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_topology_version=1$/)
  392. end
  393. it 'has qpid notification_topics' do
  394. node.set['openstack']['mq']['block-storage']['qpid']['notification_topic'] = 'qpid_notification_topic_value'
  395. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^notification_topics=qpid_notification_topic_value$/)
  396. end
  397. end
  398. context 'lvm settings' do
  399. before do
  400. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMVolumeDriver'
  401. end
  402. %w(group clear clear_size).each do |attr|
  403. it "has lvm volume_#{attr} attribute" do
  404. node.set['openstack']['block-storage']['volume']["volume_#{attr}"] = "volume_#{attr}_value"
  405. expect(chef_run).to render_file(file.name).with_content(/^volume_#{attr}=volume_#{attr}_value$/)
  406. end
  407. end
  408. end
  409. context 'commonly named volume attributes' do
  410. %w(iscsi_ip_address iscsi_port iscsi_helper volumes_dir).each do |attr|
  411. it "has volume related #{attr} attribute" do
  412. node.set['openstack']['block-storage']['volume'][attr] = "common_volume_#{attr}_value"
  413. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=common_volume_#{attr}_value$/)
  414. end
  415. end
  416. end
  417. context 'rbd attributes' do
  418. before do
  419. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.rbd.RBDDriver'
  420. end
  421. it 'has a rbd_pool attribute' do
  422. node.set['openstack']['block-storage']['rbd']['cinder']['pool'] = 'cinder_value'
  423. expect(chef_run).to render_file(file.name).with_content(/^rbd_pool=cinder_value$/)
  424. end
  425. it 'has a rbd_user attribute' do
  426. node.set['openstack']['block-storage']['rbd']['user'] = 'rbd_user_value'
  427. expect(chef_run).to render_file(file.name).with_content(/^rbd_user=rbd_user_value$/)
  428. end
  429. it 'has a rbd_secret_uuid attribute' do
  430. node.set['openstack']['block-storage']['rbd']['secret_uuid'] = 'rbd_secret_uuid_value'
  431. expect(chef_run).to render_file(file.name).with_content(/^rbd_secret_uuid=rbd_secret_uuid_value$/)
  432. end
  433. end
  434. it 'has volume_driver attribute' do
  435. node.set['openstack']['block-storage']['volume']['driver'] = 'volume_driver_value'
  436. expect(chef_run).to render_file(file.name).with_content(/^volume_driver=volume_driver_value$/)
  437. end
  438. context 'netapp ISCSI settings' do
  439. before do
  440. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.NetAppISCSIDriver'
  441. end
  442. %w(login password).each do |attr|
  443. it "has a netapp_#{attr} attribute" do
  444. node.set['openstack']['block-storage']['netapp']["dfm_#{attr}"] = "dfm_#{attr}_value"
  445. expect(chef_run).to render_file(file.name).with_content(/^netapp_#{attr}=dfm_#{attr}_value$/)
  446. end
  447. end
  448. %w(hostname port).each do |attr|
  449. it "has a netapp_server_#{attr} attribute" do
  450. node.set['openstack']['block-storage']['netapp']["dfm_#{attr}"] = "dfm_#{attr}_value"
  451. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_#{attr}=dfm_#{attr}_value$/)
  452. end
  453. end
  454. it 'has a netapp_storage_service attribute' do
  455. node.set['openstack']['block-storage']['netapp']['storage_service'] = 'netapp_storage_service_value'
  456. expect(chef_run).to render_file(file.name).with_content(/^netapp_storage_service=netapp_storage_service_value$/)
  457. end
  458. end
  459. context 'netapp direct7 mode nfs settings' do
  460. let(:hostnames) { %w(hostname1 hostname2 hostname3) }
  461. before do
  462. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
  463. node.set['openstack']['block-storage']['netapp']['netapp_server_hostname'] = hostnames
  464. end
  465. %w(mount_point_base shares_config).each do |attr_key|
  466. it "has a nfs_#{attr_key} attribute" do
  467. node.set['openstack']['block-storage']['nfs'][attr_key] = "netapp_nfs_#{attr_key}_value"
  468. expect(chef_run).to render_file(file.name).with_content(/^nfs_#{attr_key}=netapp_nfs_#{attr_key}_value$/)
  469. end
  470. end
  471. it 'has netapp server_hostname attributes' do
  472. hostnames.each do |hostname|
  473. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_hostname=#{hostname}$/)
  474. end
  475. end
  476. it 'has a netapp_server_port attribute' do
  477. node.set['openstack']['block-storage']['netapp']['netapp_server_port'] = 'netapp_server_port_value'
  478. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_port=netapp_server_port_value$/)
  479. end
  480. %w(login password).each do |attr|
  481. it "has a netapp_#{attr} attribute" do
  482. node.set['openstack']['block-storage']['netapp']["netapp_server_#{attr}"] = "netapp_#{attr}_value"
  483. expect(chef_run).to render_file(file.name).with_content(/^netapp_#{attr}=netapp_#{attr}_value$/)
  484. end
  485. end
  486. %w(disk_util sparsed_volumes).each do |attr|
  487. it "has a nfs_#{attr} attribute" do
  488. node.set['openstack']['block-storage']['nfs']["nfs_#{attr}"] = "netapp_nfs_#{attr}_value"
  489. expect(chef_run).to render_file(file.name).with_content(/^nfs_#{attr}=netapp_nfs_#{attr}_value$/)
  490. end
  491. end
  492. end
  493. context 'ibmnas settings' do
  494. before do
  495. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver'
  496. end
  497. %w(mount_point_base shares_config).each do |attr|
  498. it "has a ibmnas_#{attr} attribute" do
  499. node.set['openstack']['block-storage']['ibmnas'][attr] = "ibmnas_#{attr}_value"
  500. expect(chef_run).to render_file(file.name).with_content(/^nfs_#{attr}=ibmnas_#{attr}_value$/)
  501. end
  502. end
  503. it 'has a nfs_sparsed_volumes attribute' do
  504. node.set['openstack']['block-storage']['ibmnas']['nfs_sparsed_volumes'] = 'ibmnas_nfs_sparsed_volumes_value'
  505. expect(chef_run).to render_file(file.name).with_content(/^nfs_sparsed_volumes=ibmnas_nfs_sparsed_volumes_value$/)
  506. end
  507. %w(nas_ip nas_login nas_ssh_port ibmnas_platform_type).each do |attr|
  508. it "has a ibmnas #{attr} attribute" do
  509. node.set['openstack']['block-storage']['ibmnas'][attr] = "ibmnas_#{attr}_value"
  510. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=ibmnas_#{attr}_value$/)
  511. end
  512. end
  513. it 'has a default attributes' do
  514. %w(nas_ip=127.0.0.1
  515. nas_login=admin
  516. nas_password=test_pass
  517. nas_ssh_port=22
  518. ibmnas_platform_type=v7ku
  519. nfs_sparsed_volumes=true
  520. nfs_mount_point_base=/mnt/cinder-volumes
  521. nfs_shares_config=/etc/cinder/nfs_shares.conf).each do |attr|
  522. expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/)
  523. end
  524. end
  525. end
  526. context 'storwize settings' do
  527. before do
  528. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver'
  529. end
  530. it 'has a default attribute' do
  531. %w(san_ip=127.0.0.1
  532. san_private_key=/v7000_rsa
  533. storwize_svc_volpool_name=volpool
  534. storwize_svc_vol_rsize=2
  535. storwize_svc_vol_warning=0
  536. storwize_svc_vol_autoexpand=true
  537. storwize_svc_vol_grainsize=256
  538. storwize_svc_vol_compression=false
  539. storwize_svc_vol_easytier=true
  540. storwize_svc_vol_iogrp=0
  541. storwize_svc_flashcopy_timeout=120
  542. storwize_svc_connection_protocol=iSCSI
  543. storwize_svc_iscsi_chap_enabled=true
  544. storwize_svc_multihostmap_enabled=true
  545. storwize_svc_allow_tenant_qos=false).each do |attr|
  546. expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/)
  547. end
  548. end
  549. it 'has a overridden attribute' do
  550. %w(san_ip
  551. san_private_key
  552. storwize_svc_volpool_name
  553. storwize_svc_vol_rsize
  554. storwize_svc_vol_warning
  555. storwize_svc_vol_autoexpand
  556. storwize_svc_vol_grainsize
  557. storwize_svc_vol_compression
  558. storwize_svc_vol_easytier
  559. storwize_svc_vol_iogrp
  560. storwize_svc_flashcopy_timeout
  561. storwize_svc_connection_protocol
  562. storwize_svc_multihostmap_enabled
  563. storwize_svc_allow_tenant_qos
  564. storwize_svc_stretched_cluster_partner).each do |attr|
  565. node.set['openstack']['block-storage']['storwize'][attr] = "storwize_#{attr}_value"
  566. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=storwize_#{attr}_value$/)
  567. end
  568. end
  569. context 'storwize with login and password' do
  570. it 'has a login and password' do
  571. node.set['openstack']['block-storage']['storwize']['san_private_key'] = ''
  572. %w(san_login=admin
  573. san_password=test_pass
  574. san_private_key=).each do |attr|
  575. expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/)
  576. end
  577. end
  578. end
  579. context 'storwize with iSCSI connection protocol' do
  580. before do
  581. node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI'
  582. end
  583. it 'has a iscsi chap enabled attribute' do
  584. node.set['openstack']['block-storage']['storwize']['storwize_svc_iscsi_chap_enabled'] = 'storwize_svc_iscsi_chap_enabled_value'
  585. expect(chef_run).to render_file(file.name).with_content(/^storwize_svc_iscsi_chap_enabled=storwize_svc_iscsi_chap_enabled_value$/)
  586. end
  587. it 'does not have a multipath enabled attribute' do
  588. expect(chef_run).not_to render_file(file.name).with_content(/^storwize_svc_multipath_enabled=/)
  589. end
  590. end
  591. context 'storwize without iSCSI connection protocol' do
  592. before do
  593. node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'non-iSCSI'
  594. end
  595. it 'does not have a iscsi chap enabled attribute' do
  596. expect(chef_run).not_to render_file(file.name).with_content(/^storwize_svc_iscsi_enabled=/)
  597. end
  598. it 'has a multipath enabled attribute' do
  599. node.set['openstack']['block-storage']['storwize']['storwize_svc_multipath_enabled'] = 'storwize_svc_multipath_enabled_value'
  600. expect(chef_run).to render_file(file.name).with_content(/^storwize_svc_multipath_enabled=storwize_svc_multipath_enabled_value$/)
  601. end
  602. end
  603. end
  604. context 'solidfire settings' do
  605. before do
  606. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.solidfire.SolidFire'
  607. end
  608. it 'has solidfire sf_emulate set' do
  609. node.set['openstack']['block-storage']['solidfire']['sf_emulate'] = 'test'
  610. expect(chef_run).to render_file(file.name).with_content(/^sf_emulate_512=test$/)
  611. end
  612. it 'has solidfire password' do
  613. expect(chef_run).to render_file(file.name).with_content(/^san_password=test_pass$/)
  614. end
  615. %w(san_login san_ip).each do |attr|
  616. it "has solidfire #{attr} set" do
  617. node.set['openstack']['block-storage']['solidfire'][attr] = "solidfire_#{attr}_value"
  618. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=solidfire_#{attr}_value$/)
  619. end
  620. end
  621. it 'does not have iscsi_ip_prefix not specified' do
  622. node.set['openstack']['block-storage']['solidfire']['iscsi_ip_prefix'] = nil
  623. expect(chef_run).to_not render_file(file.name).with_content(/^iscsi_ip_prefix=/)
  624. end
  625. it 'does have iscsi_ip_prefix when specified' do
  626. chef_run.node.set['openstack']['block-storage']['solidfire']['iscsi_ip_prefix'] = '203.0.113.*'
  627. expect(chef_run).to render_file(file.name).with_content(/^iscsi_ip_prefix=203.0.113.*$/)
  628. end
  629. end
  630. context 'flashsystem settings' do
  631. before do
  632. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.flashsystem.FlashSystemDriver'
  633. end
  634. it 'has flashsystem password' do
  635. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^san_password=test_pass$/)
  636. end
  637. it 'has a default attribute' do
  638. %w(san_ip=127.0.0.1
  639. flashsystem_connection_protocol=FC
  640. flashsystem_multihostmap_enabled=true).each do |attr|
  641. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}$/)
  642. end
  643. end
  644. it 'has a overridden attribute' do
  645. %w(san_ip
  646. flashsystem_connection_protocol
  647. flashsystem_multihostmap_enabled).each do |attr|
  648. node.set['openstack']['block-storage']['flashsystem'][attr] = "flashsystem_#{attr}_value"
  649. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}=flashsystem_#{attr}_value$/)
  650. end
  651. end
  652. context 'FlashSystem with FC connection protocol' do
  653. before do
  654. node.set['openstack']['block-storage']['storwize']['flashsystem_connection_protocol'] = 'FC'
  655. end
  656. it 'has a multipath enabled attribute' do
  657. node.set['openstack']['block-storage']['flashsystem']['flashsystem_multipath_enabled'] = 'flashsystem_multipath_enabled_value'
  658. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^flashsystem_multipath_enabled=flashsystem_multipath_enabled_value$/)
  659. end
  660. end
  661. end
  662. context 'emc settings' do
  663. before do
  664. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
  665. end
  666. %w(iscsi_target_prefix cinder_emc_config_file).each do |attr|
  667. it "has emc #{attr} set" do
  668. node.set['openstack']['block-storage']['emc'][attr] = "emc_#{attr}_value"
  669. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=emc_#{attr}_value$/)
  670. end
  671. end
  672. end
  673. context 'vmware vmdk settings' do
  674. before do
  675. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver'
  676. %w(vmware_host_ip vmware_host_username
  677. vmware_api_retry_count vmware_task_poll_interval vmware_volume_folder
  678. vmware_image_transfer_timeout_secs vmware_max_objects_retrieval).each do |attr|
  679. node.set['openstack']['block-storage']['vmware'][attr] = "vmware_#{attr}_value"
  680. end
  681. end
  682. it 'has vmware attributes set' do
  683. node['openstack']['block-storage']['vmware'].each do |attr, val|
  684. expect(chef_run).to render_file(file.name).with_content(/^#{attr} = #{val}$/)
  685. end
  686. end
  687. it 'has password set which is from databag' do
  688. expect(chef_run).to render_file(file.name).with_content(/^vmware_host_password = vmware_secret_name$/)
  689. end
  690. it 'has no wsdl_location line without the attribute' do
  691. node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = nil
  692. expect(chef_run).not_to render_file(file.name).with_content(/^vmware_wsdl_location = /)
  693. end
  694. it 'has wsdl_location line with attribute present' do
  695. node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = 'http://127.0.0.1/wsdl'
  696. expect(chef_run).to render_file(file.name).with_content(%r(^vmware_wsdl_location = http://127.0.0.1/wsdl$))
  697. end
  698. end
  699. context 'gpfs settings' do
  700. before do
  701. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.gpfs.GPFSDriver'
  702. end
  703. %w(gpfs_mount_point_base gpfs_max_clone_depth
  704. gpfs_sparse_volumes gpfs_storage_pool).each do |attr|
  705. it "has gpfs #{attr} set" do
  706. node.set['openstack']['block-storage']['gpfs'][attr] = "gpfs_#{attr}_value"
  707. expect(chef_run).to render_file(file.name).with_content(/^#{attr} = gpfs_#{attr}_value$/)
  708. end
  709. end
  710. it 'has no gpfs_images_dir line without the attribute' do
  711. node.set['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = nil
  712. expect(chef_run).not_to render_file(file.name).with_content(/^gpfs_images_dir = /)
  713. expect(chef_run).not_to render_file(file.name).with_content(/^gpfs_images_share_mode = /)
  714. end
  715. it 'has gpfs_images_dir line with attribute present' do
  716. node.set['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = 'gpfs_images_dir_value'
  717. expect(chef_run).to render_file(file.name).with_content(/^gpfs_images_dir = gpfs_images_dir_value$/)
  718. expect(chef_run).to render_file(file.name).with_content(/^gpfs_images_share_mode = copy_on_write$/)
  719. end
  720. it 'templates misc_cinder array correctly' do
  721. node.set['openstack']['block-storage']['misc_cinder'] = ['# Comments', 'MISC=OPTION']
  722. expect(chef_run).to render_file(file.name).with_content(
  723. /^# Comments$/)
  724. expect(chef_run).to render_file(file.name).with_content(
  725. /^MISC=OPTION$/)
  726. end
  727. end
  728. context 'multiple backend settings' do
  729. before do
  730. node.set['openstack']['block-storage']['volume']['multi_backend'] = {
  731. 'lvm' => {
  732. 'volume_driver' => 'cinder.volume.drivers.lvm.LVMVolumeDriver',
  733. 'volume_backend_name' => 'lvmdrv'
  734. },
  735. 'rbd' => {
  736. 'volume_driver' => 'cinder.volume.drivers.rbd.RBDDriver',
  737. 'volume_backend_name' => 'rbddrv'
  738. },
  739. 'netapp_iscsi' => {
  740. 'volume_driver' => 'cinder.volume.drivers.netapp.NetAppISCSIDriver',
  741. 'multi_netapp_iscsi' => 'multi-netapp'
  742. },
  743. 'netapp_nfs' => {
  744. 'volume_driver' => 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver',
  745. 'volume_backend_name' => 'netappnfsdrv',
  746. 'multi_netapp_nfs' => 'multi-netapp'
  747. },
  748. 'ibmnas' => {
  749. 'volume_driver' => 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver',
  750. 'multi_ibmnas' => 'multi-ibmnas'
  751. },
  752. 'ibmsvc' => {
  753. 'volume_driver' => 'cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver',
  754. 'multi_ibmsvc' => 'multi-ibmsvc'
  755. },
  756. 'solidfire' => {
  757. 'volume_driver' => 'cinder.volume.drivers.solidfire.SolidFire',
  758. 'multi_solidfire' => 'multi-solidfire'
  759. },
  760. 'emciscsi' => {
  761. 'volume_driver' => 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver',
  762. 'multi_emciscsi' => 'multi-emciscsi'
  763. },
  764. 'vmware' => {
  765. 'volume_driver' => 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver',
  766. 'multi_vmware' => 'multi-vmware'
  767. },
  768. 'gpfs' => {
  769. 'volume_driver' => 'cinder.volume.drivers.ibm.gpfs.GPFSDriver',
  770. 'multi_gpfs' => 'multi-gpfs'
  771. }
  772. }
  773. node.set['openstack']['block-storage']['volume']['volume_group'] = 'multi-lvm-group'
  774. node.set['openstack']['block-storage']['volume']['default_volume_type'] = 'some-type-name'
  775. node.set['openstack']['block-storage']['rbd']['cinder']['pool'] = 'multi-rbd-pool'
  776. node.set['openstack']['block-storage']['netapp']['dfm_login'] = 'multi-netapp-login'
  777. node.set['openstack']['block-storage']['netapp']['netapp_server_hostname'] = ['netapp-host-1', 'netapp-host-2']
  778. node.set['openstack']['block-storage']['netapp']['netapp_server_port'] = 'multi-netapp-port'
  779. node.set['openstack']['block-storage']['ibmnas']['shares_config'] = 'multi-ibmnas-share'
  780. node.set['openstack']['block-storage']['storwize']['storwize_svc_volpool_name'] = 'multi-svc-volpool'
  781. node.set['openstack']['block-storage']['solidfire']['sf_emulate'] = 'multi-sf-true'
  782. node.set['openstack']['block-storage']['emc']['cinder_emc_config_file'] = 'multi-emc-conf'
  783. node.set['openstack']['block-storage']['vmware']['vmware_host_ip'] = 'multi-vmware-ip'
  784. node.set['openstack']['block-storage']['gpfs']['gpfs_mount_point_base'] = 'multi-gpfs-mnt'
  785. end
  786. it 'enable multiple backends' do
  787. expect(chef_run).to render_file(file.name).with_content(/^enabled_backends = lvm,rbd,netapp_iscsi,netapp_nfs,ibmnas,ibmsvc,solidfire,emciscsi,vmware,gpfs$/)
  788. expect(chef_run).to render_file(file.name).with_content(/^\[lvm\]$/)
  789. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.lvm\.LVMVolumeDriver$/)
  790. expect(chef_run).to render_file(file.name).with_content(/^\[rbd\]$/)
  791. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.rbd\.RBDDriver$/)
  792. expect(chef_run).to render_file(file.name).with_content(/^\[netapp_iscsi\]$/)
  793. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.netapp\.NetAppISCSIDriver$/)
  794. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_hostname=netapp-host-1$/)
  795. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_hostname=netapp-host-2$/)
  796. expect(chef_run).to render_file(file.name).with_content(/^\[netapp_nfs\]$/)
  797. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.netapp\.nfs\.NetAppDirect7modeNfsDriver$/)
  798. expect(chef_run).to render_file(file.name).with_content(/^\[ibmnas\]$/)
  799. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.ibm\.ibmnas\.IBMNAS_NFSDriver$/)
  800. expect(chef_run).to render_file(file.name).with_content(/^\[ibmsvc\]$/)
  801. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.ibm\.storwize_svc\.StorwizeSVCDriver$/)
  802. expect(chef_run).to render_file(file.name).with_content(/^\[solidfire\]$/)
  803. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.solidfire\.SolidFire$/)
  804. expect(chef_run).to render_file(file.name).with_content(/^\[emciscsi\]$/)
  805. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.emc\.emc_smis_iscsi\.EMCSMISISCSIDriver$/)
  806. expect(chef_run).to render_file(file.name).with_content(/^\[vmware\]$/)
  807. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.vmware\.vmdk\.VMwareVcVmdkDriver$/)
  808. expect(chef_run).to render_file(file.name).with_content(/^\[gpfs\]$/)
  809. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.ibm\.gpfs\.GPFSDriver$/)
  810. end
  811. it 'set lvm option' do
  812. expect(chef_run).to render_file(file.name).with_content(/^volume_group=multi-lvm-group$/)
  813. end
  814. it 'set default_volume_type option' do
  815. expect(chef_run).to render_file(file.name).with_content(/^default_volume_type=some-type-name$/)
  816. end
  817. it 'set rbd option' do
  818. expect(chef_run).to render_file(file.name).with_content(/^rbd_pool=multi-rbd-pool$/)
  819. end
  820. it 'set netapp_iscsi option' do
  821. expect(chef_run).to render_file(file.name).with_content(/^netapp_login=multi-netapp-login$/)
  822. end
  823. it 'set netapp_nfs option' do
  824. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_port=multi-netapp-port$/)
  825. end
  826. it 'set ibmnas option' do
  827. expect(chef_run).to render_file(file.name).with_content(/^nfs_shares_config=multi-ibmnas-share$/)
  828. end
  829. it 'set ibmsvc option' do
  830. expect(chef_run).to render_file(file.name).with_content(/^storwize_svc_volpool_name=multi-svc-volpool$/)
  831. end
  832. it 'set solidfire option' do
  833. expect(chef_run).to render_file(file.name).with_content(/^sf_emulate_512=multi-sf-true$/)
  834. end
  835. it 'set emciscsi option' do
  836. expect(chef_run).to render_file(file.name).with_content(/^cinder_emc_config_file=multi-emc-conf$/)
  837. end
  838. it 'set vmware option' do
  839. expect(chef_run).to render_file(file.name).with_content(/^vmware_host_ip = multi-vmware-ip$/)
  840. end
  841. it 'set gpfs option' do
  842. expect(chef_run).to render_file(file.name).with_content(/^gpfs_mount_point_base = multi-gpfs-mnt$/)
  843. end
  844. end
  845. it 'no multiple backends configured' do
  846. expect(chef_run).to_not render_file(file.name).with_content(/^enabled_backends = [\w\W]+$/)
  847. end
  848. it 'does not set default_volume_type' do
  849. expect(chef_run).to_not render_file(file.name).with_content(/^default_volume_type=.+$/)
  850. end
  851. end
  852. end
  853. describe '/var/lib/cinder/lock' do
  854. let(:dir) { chef_run.directory('/var/lib/cinder/lock') }
  855. it 'should create the /var/lib/cinder/lock directory' do
  856. expect(chef_run).to create_directory(dir.name)
  857. end
  858. it 'has proper owner' do
  859. expect(dir.owner).to eq('cinder')
  860. expect(dir.group).to eq('cinder')
  861. end
  862. it 'has proper modes' do
  863. expect(sprintf('%o', dir.mode)).to eq '755'
  864. end
  865. end
  866. describe 'rootwrap.conf' do
  867. let(:file) { chef_run.template('/etc/cinder/rootwrap.conf') }
  868. it 'creates the /etc/cinder/rootwrap.conf file' do
  869. expect(chef_run).to create_template(file.name).with(
  870. user: 'root',
  871. group: 'root',
  872. mode: 0644
  873. )
  874. end
  875. context 'template contents' do
  876. it 'shows the custom banner' do
  877. node.set['openstack']['block-storage']['custom_template_banner'] = 'banner'
  878. expect(chef_run).to render_file(file.name)
  879. .with_content(/^banner$/)
  880. end
  881. it 'sets the default attributes' do
  882. [
  883. %r(^filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$),
  884. %r(^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$),
  885. /^use_syslog=False$/,
  886. /^syslog_log_facility=syslog$/,
  887. /^syslog_log_level=ERROR$/
  888. ].each do |line|
  889. expect(chef_run).to render_file(file.name).with_content(line)
  890. end
  891. end
  892. end
  893. end
  894. end
  895. end