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 47KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068
  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 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_file(file.name).with_content(/^#{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. context 'netapp driver' do
  195. # FIXME(galstrom21): this block needs to check all of the default
  196. # netapp_* configuration options
  197. it 'has default netapp_* options set' do
  198. node.set['openstack']['block-storage']['volume'] = {
  199. 'driver' => 'cinder.volume.drivers.netapp.NetAppISCSIDriver'
  200. }
  201. expect(chef_run).to render_file(file.name).with_content(/^netapp_/)
  202. expect(chef_run).not_to render_file(file.name).with_content(/^rbd_/)
  203. end
  204. end
  205. context 'syslog use' do
  206. it 'sets the log_config value when syslog is in use' do
  207. node.set['openstack']['block-storage']['syslog']['use'] = true
  208. expect(chef_run).to render_file(file.name)
  209. .with_content(%r{^log_config = /etc/openstack/logging.conf$})
  210. end
  211. it 'sets the log_file value when syslog is not in use' do
  212. node.set['openstack']['block-storage']['syslog']['use'] = false
  213. expect(chef_run).to render_file(file.name)
  214. .with_content(%r{^log_file = /var/log/cinder/cinder.log$})
  215. end
  216. end
  217. it 'has a db connection attribute' do
  218. allow_any_instance_of(Chef::Recipe).to receive(:db_uri)
  219. .with('block-storage', anything, '').and_return('sql_connection_value')
  220. expect(chef_run).to render_config_file(file.name)
  221. .with_section_content('database', /^connection=sql_connection_value$/)
  222. end
  223. it 'has a db backend attribute' do
  224. expect(chef_run).to render_config_file(file.name).with_section_content('database', /^backend=sqlalchemy$/)
  225. end
  226. it 'has a volume_driver attribute' do
  227. node.set['openstack']['block-storage']['volume']['driver'] = 'volume_driver_value'
  228. expect(chef_run).to render_file(file.name).with_content(/^volume_driver=volume_driver_value$/)
  229. end
  230. it 'has a state_path attribute' do
  231. node.set['openstack']['block-storage']['volume']['state_path'] = 'state_path_value'
  232. expect(chef_run).to render_file(file.name).with_content(/^state_path=state_path_value$/)
  233. end
  234. context 'glance endpoint' do
  235. it 'has a glance_api_servers attribute' do
  236. expect(chef_run).to render_file(file.name).with_content(%r{^glance_api_servers=http://127.0.0.1:9292$})
  237. end
  238. it 'has glance_api_version attribute' do
  239. expect(chef_run).to render_file(file.name).with_content(/^glance_api_version=1$/)
  240. end
  241. it 'has a glance_api_insecure attribute' do
  242. expect(chef_run).to render_file(file.name).with_content(/^glance_api_insecure=false$/)
  243. end
  244. it 'sets insecure for glance' do
  245. node.set['openstack']['block-storage']['image']['glance_api_insecure'] = true
  246. expect(chef_run).to render_file(file.name).with_content(/^glance_api_insecure=true$/)
  247. end
  248. it 'has a glance_ca_certificates_file attribute' do
  249. expect(chef_run).to render_file(file.name).with_content(/^glance_ca_certificates_file=$/)
  250. end
  251. it 'sets glance_ca_certificates_file attribute' do
  252. node.set['openstack']['block-storage']['image']['glance_ca_certificates_file'] = 'dir/to/path'
  253. expect(chef_run).to render_file(file.name).with_content(%r{^glance_ca_certificates_file=dir/to/path$})
  254. end
  255. it 'has a glance host attribute' do
  256. expect(chef_run).to render_file(file.name).with_content(/^glance_host=127.0.0.1$/)
  257. end
  258. it 'has a glance port attribute' do
  259. expect(chef_run).to render_file(file.name).with_content(/^glance_port=9292$/)
  260. end
  261. end
  262. it 'has a api_rate_limit attribute' do
  263. node.set['openstack']['block-storage']['api']['ratelimit'] = 'api_rate_limit_value'
  264. expect(chef_run).to render_file(file.name).with_content(/^api_rate_limit=api_rate_limit_value$/)
  265. end
  266. context 'cinder endpoint' do
  267. it 'has osapi_volume_listen set' do
  268. expect(chef_run).to render_file(file.name).with_content(/^osapi_volume_listen=127.0.0.1$/)
  269. end
  270. it 'has osapi_volume_listen_port set' do
  271. expect(chef_run).to render_file(file.name).with_content(/^osapi_volume_listen_port=8776$/)
  272. end
  273. it 'has default api version set' do
  274. [/^enable_v1_api=false$/,
  275. /^enable_v2_api=true$/].each do |line|
  276. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line)
  277. end
  278. end
  279. end
  280. it 'has a rpc_backend attribute' do
  281. node.set['openstack']['block_storage']['rpc_backend'] = 'rpc_backend_value'
  282. expect(chef_run).to render_file(file.name).with_content(/^rpc_backend=rpc_backend_value$/)
  283. end
  284. it 'has default RPC/AMQP options set' do
  285. [/^rpc_backend=cinder.openstack.common.rpc.impl_kombu$/,
  286. /^rpc_thread_pool_size=64$/,
  287. /^rpc_response_timeout=60$/].each do |line|
  288. expect(chef_run).to render_file(file.name).with_content(line)
  289. end
  290. end
  291. context 'rabbitmq as mq service' do
  292. before do
  293. node.set['openstack']['mq']['block-storage']['service_type'] = 'rabbitmq'
  294. end
  295. it 'has default RPC/AMQP options set' do
  296. [/^rpc_conn_pool_size=30$/,
  297. /^amqp_durable_queues=false$/,
  298. /^amqp_auto_delete=false$/].each do |line|
  299. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', line)
  300. end
  301. end
  302. context 'ha attributes' do
  303. before do
  304. node.set['openstack']['mq']['block-storage']['rabbit']['ha'] = true
  305. end
  306. it 'has a rabbit_hosts attribute' do
  307. allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers)
  308. .and_return('rabbit_servers_value')
  309. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts=rabbit_servers_value$/)
  310. end
  311. %w(host port).each do |attr|
  312. it "does not have rabbit_#{attr} attribute" do
  313. expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=/)
  314. end
  315. end
  316. end
  317. context 'non ha attributes' do
  318. before do
  319. node.set['openstack']['mq']['block-storage']['rabbit']['ha'] = false
  320. end
  321. %w(host port).each do |attr|
  322. it "has rabbit_#{attr} attribute" do
  323. node.set['openstack']['mq']['block-storage']['rabbit'][attr] = "rabbit_#{attr}_value"
  324. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=rabbit_#{attr}_value$/)
  325. end
  326. end
  327. it 'does not have a rabbit_hosts attribute' do
  328. expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_hosts=/)
  329. end
  330. end
  331. %w(use_ssl userid).each do |attr|
  332. it "has rabbit_#{attr}" do
  333. node.set['openstack']['mq']['block-storage']['rabbit'][attr] = "rabbit_#{attr}_value"
  334. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_#{attr}=rabbit_#{attr}_value$/)
  335. end
  336. end
  337. it 'has rabbit_password' do
  338. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_password=#{test_pass}$/)
  339. end
  340. it 'has rabbit_virtual_host' do
  341. node.set['openstack']['mq']['block-storage']['rabbit']['vhost'] = 'vhost_value'
  342. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^rabbit_virtual_host=vhost_value$/)
  343. end
  344. it 'does not have kombu ssl version set' do
  345. expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^kombu_ssl_version=TLSv1.2$/)
  346. end
  347. it 'sets kombu ssl version' do
  348. node.set['openstack']['mq']['block-storage']['rabbit']['use_ssl'] = true
  349. node.set['openstack']['mq']['block-storage']['rabbit']['kombu_ssl_version'] = 'TLSv1.2'
  350. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', /^kombu_ssl_version=TLSv1.2$/)
  351. end
  352. end
  353. context 'qpid as mq service' do
  354. before do
  355. node.set['openstack']['mq']['block-storage']['service_type'] = 'qpid'
  356. end
  357. it 'has default RPC/AMQP options set' do
  358. [/^rpc_conn_pool_size=30$/,
  359. /^amqp_durable_queues=false$/,
  360. /^amqp_auto_delete=false$/].each do |line|
  361. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', line)
  362. end
  363. end
  364. %w(port username sasl_mechanisms reconnect reconnect_timeout reconnect_limit
  365. reconnect_interval_min reconnect_interval_max reconnect_interval heartbeat protocol
  366. tcp_nodelay).each do |attr|
  367. it "has qpid_#{attr} attribute" do
  368. node.set['openstack']['mq']['block-storage']['qpid'][attr] = "qpid_#{attr}_value"
  369. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_#{attr}=qpid_#{attr}_value$/)
  370. end
  371. end
  372. it 'has qpid_hostname' do
  373. node.set['openstack']['mq']['block-storage']['qpid']['host'] = 'qpid_host_value'
  374. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_hostname=qpid_host_value$/)
  375. end
  376. it 'has qpid_password' do
  377. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_password=#{test_pass}$/)
  378. end
  379. it 'has default qpid topology version' do
  380. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^qpid_topology_version=1$/)
  381. end
  382. it 'has qpid notification_topics' do
  383. node.set['openstack']['mq']['block-storage']['qpid']['notification_topic'] = 'qpid_notification_topic_value'
  384. expect(chef_run).to render_config_file(file.name).with_section_content('oslo_messaging_qpid', /^notification_topics=qpid_notification_topic_value$/)
  385. end
  386. end
  387. context 'lvm settings' do
  388. before do
  389. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMVolumeDriver'
  390. end
  391. %w(group clear clear_size).each do |attr|
  392. it "has lvm volume_#{attr} attribute" do
  393. node.set['openstack']['block-storage']['volume']["volume_#{attr}"] = "volume_#{attr}_value"
  394. expect(chef_run).to render_file(file.name).with_content(/^volume_#{attr}=volume_#{attr}_value$/)
  395. end
  396. end
  397. end
  398. context 'commonly named volume attributes' do
  399. %w(iscsi_ip_address iscsi_port iscsi_helper volumes_dir).each do |attr|
  400. it "has volume related #{attr} attribute" do
  401. node.set['openstack']['block-storage']['volume'][attr] = "common_volume_#{attr}_value"
  402. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=common_volume_#{attr}_value$/)
  403. end
  404. end
  405. end
  406. context 'rbd attributes' do
  407. before do
  408. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.rbd.RBDDriver'
  409. end
  410. it 'has a rbd_pool attribute' do
  411. node.set['openstack']['block-storage']['rbd']['cinder']['pool'] = 'cinder_value'
  412. expect(chef_run).to render_file(file.name).with_content(/^rbd_pool=cinder_value$/)
  413. end
  414. it 'has a rbd_user attribute' do
  415. node.set['openstack']['block-storage']['rbd']['user'] = 'rbd_user_value'
  416. expect(chef_run).to render_file(file.name).with_content(/^rbd_user=rbd_user_value$/)
  417. end
  418. it 'has a rbd_secret_uuid attribute' do
  419. node.set['openstack']['block-storage']['rbd']['secret_uuid'] = 'rbd_secret_uuid_value'
  420. expect(chef_run).to render_file(file.name).with_content(/^rbd_secret_uuid=rbd_secret_uuid_value$/)
  421. end
  422. end
  423. it 'has volume_driver attribute' do
  424. node.set['openstack']['block-storage']['volume']['driver'] = 'volume_driver_value'
  425. expect(chef_run).to render_file(file.name).with_content(/^volume_driver=volume_driver_value$/)
  426. end
  427. context 'netapp ISCSI settings' do
  428. before do
  429. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.NetAppISCSIDriver'
  430. end
  431. %w(login password).each do |attr|
  432. it "has a netapp_#{attr} attribute" do
  433. node.set['openstack']['block-storage']['netapp']["dfm_#{attr}"] = "dfm_#{attr}_value"
  434. expect(chef_run).to render_file(file.name).with_content(/^netapp_#{attr}=dfm_#{attr}_value$/)
  435. end
  436. end
  437. %w(hostname port).each do |attr|
  438. it "has a netapp_server_#{attr} attribute" do
  439. node.set['openstack']['block-storage']['netapp']["dfm_#{attr}"] = "dfm_#{attr}_value"
  440. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_#{attr}=dfm_#{attr}_value$/)
  441. end
  442. end
  443. it 'has a netapp_storage_service attribute' do
  444. node.set['openstack']['block-storage']['netapp']['storage_service'] = 'netapp_storage_service_value'
  445. expect(chef_run).to render_file(file.name).with_content(/^netapp_storage_service=netapp_storage_service_value$/)
  446. end
  447. end
  448. context 'netapp direct7 mode nfs settings' do
  449. let(:hostnames) { %w(hostname1 hostname2 hostname3) }
  450. before do
  451. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
  452. node.set['openstack']['block-storage']['netapp']['netapp_server_hostname'] = hostnames
  453. end
  454. %w(mount_point_base shares_config).each do |attr_key|
  455. it "has a nfs_#{attr_key} attribute" do
  456. node.set['openstack']['block-storage']['nfs'][attr_key] = "netapp_nfs_#{attr_key}_value"
  457. expect(chef_run).to render_file(file.name).with_content(/^nfs_#{attr_key}=netapp_nfs_#{attr_key}_value$/)
  458. end
  459. end
  460. it 'has netapp server_hostname attributes' do
  461. hostnames.each do |hostname|
  462. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_hostname=#{hostname}$/)
  463. end
  464. end
  465. it 'has a netapp_server_port attribute' do
  466. node.set['openstack']['block-storage']['netapp']['netapp_server_port'] = 'netapp_server_port_value'
  467. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_port=netapp_server_port_value$/)
  468. end
  469. %w(login password).each do |attr|
  470. it "has a netapp_#{attr} attribute" do
  471. node.set['openstack']['block-storage']['netapp']["netapp_server_#{attr}"] = "netapp_#{attr}_value"
  472. expect(chef_run).to render_file(file.name).with_content(/^netapp_#{attr}=netapp_#{attr}_value$/)
  473. end
  474. end
  475. %w(disk_util sparsed_volumes).each do |attr|
  476. it "has a nfs_#{attr} attribute" do
  477. node.set['openstack']['block-storage']['nfs']["nfs_#{attr}"] = "netapp_nfs_#{attr}_value"
  478. expect(chef_run).to render_file(file.name).with_content(/^nfs_#{attr}=netapp_nfs_#{attr}_value$/)
  479. end
  480. end
  481. end
  482. context 'ibmnas settings' do
  483. before do
  484. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver'
  485. end
  486. %w(mount_point_base shares_config).each do |attr|
  487. it "has a ibmnas_#{attr} attribute" do
  488. node.set['openstack']['block-storage']['ibmnas'][attr] = "ibmnas_#{attr}_value"
  489. expect(chef_run).to render_file(file.name).with_content(/^nfs_#{attr}=ibmnas_#{attr}_value$/)
  490. end
  491. end
  492. it 'has a nfs_sparsed_volumes attribute' do
  493. node.set['openstack']['block-storage']['ibmnas']['nfs_sparsed_volumes'] = 'ibmnas_nfs_sparsed_volumes_value'
  494. expect(chef_run).to render_file(file.name).with_content(/^nfs_sparsed_volumes=ibmnas_nfs_sparsed_volumes_value$/)
  495. end
  496. %w(nas_ip nas_login nas_ssh_port ibmnas_platform_type).each do |attr|
  497. it "has a ibmnas #{attr} attribute" do
  498. node.set['openstack']['block-storage']['ibmnas'][attr] = "ibmnas_#{attr}_value"
  499. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=ibmnas_#{attr}_value$/)
  500. end
  501. end
  502. it 'has a default attributes' do
  503. %w(nas_ip=127.0.0.1
  504. nas_login=admin
  505. nas_password=test_pass
  506. nas_ssh_port=22
  507. ibmnas_platform_type=v7ku
  508. nfs_sparsed_volumes=true
  509. nfs_mount_point_base=/mnt/cinder-volumes
  510. nfs_shares_config=/etc/cinder/nfs_shares.conf).each do |attr|
  511. expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/)
  512. end
  513. end
  514. end
  515. context 'storwize settings' do
  516. before do
  517. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver'
  518. end
  519. it 'has a default attribute' do
  520. %w(san_ip=127.0.0.1
  521. san_private_key=/v7000_rsa
  522. storwize_svc_volpool_name=volpool
  523. storwize_svc_vol_rsize=2
  524. storwize_svc_vol_warning=0
  525. storwize_svc_vol_autoexpand=true
  526. storwize_svc_vol_grainsize=256
  527. storwize_svc_vol_compression=false
  528. storwize_svc_vol_easytier=true
  529. storwize_svc_vol_iogrp=0
  530. storwize_svc_flashcopy_timeout=120
  531. storwize_svc_connection_protocol=iSCSI
  532. storwize_svc_iscsi_chap_enabled=true
  533. storwize_svc_multihostmap_enabled=true
  534. storwize_svc_allow_tenant_qos=false).each do |attr|
  535. expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/)
  536. end
  537. end
  538. it 'has a overridden attribute' do
  539. %w(san_ip
  540. san_private_key
  541. storwize_svc_volpool_name
  542. storwize_svc_vol_rsize
  543. storwize_svc_vol_warning
  544. storwize_svc_vol_autoexpand
  545. storwize_svc_vol_grainsize
  546. storwize_svc_vol_compression
  547. storwize_svc_vol_easytier
  548. storwize_svc_vol_iogrp
  549. storwize_svc_flashcopy_timeout
  550. storwize_svc_connection_protocol
  551. storwize_svc_multihostmap_enabled
  552. storwize_svc_allow_tenant_qos
  553. storwize_svc_stretched_cluster_partner).each do |attr|
  554. node.set['openstack']['block-storage']['storwize'][attr] = "storwize_#{attr}_value"
  555. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=storwize_#{attr}_value$/)
  556. end
  557. end
  558. context 'storwize with login and password' do
  559. it 'has a login and password' do
  560. node.set['openstack']['block-storage']['storwize']['san_private_key'] = ''
  561. %w(san_login=admin
  562. san_password=test_pass
  563. san_private_key=).each do |attr|
  564. expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/)
  565. end
  566. end
  567. end
  568. context 'storwize with iSCSI connection protocol' do
  569. before do
  570. node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI'
  571. end
  572. it 'has a iscsi chap enabled attribute' do
  573. node.set['openstack']['block-storage']['storwize']['storwize_svc_iscsi_chap_enabled'] = 'storwize_svc_iscsi_chap_enabled_value'
  574. expect(chef_run).to render_file(file.name).with_content(/^storwize_svc_iscsi_chap_enabled=storwize_svc_iscsi_chap_enabled_value$/)
  575. end
  576. it 'does not have a multipath enabled attribute' do
  577. expect(chef_run).not_to render_file(file.name).with_content(/^storwize_svc_multipath_enabled=/)
  578. end
  579. end
  580. context 'storwize without iSCSI connection protocol' do
  581. before do
  582. node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'non-iSCSI'
  583. end
  584. it 'does not have a iscsi chap enabled attribute' do
  585. expect(chef_run).not_to render_file(file.name).with_content(/^storwize_svc_iscsi_enabled=/)
  586. end
  587. it 'has a multipath enabled attribute' do
  588. node.set['openstack']['block-storage']['storwize']['storwize_svc_multipath_enabled'] = 'storwize_svc_multipath_enabled_value'
  589. expect(chef_run).to render_file(file.name).with_content(/^storwize_svc_multipath_enabled=storwize_svc_multipath_enabled_value$/)
  590. end
  591. end
  592. end
  593. context 'solidfire settings' do
  594. before do
  595. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.solidfire.SolidFire'
  596. end
  597. it 'has solidfire sf_emulate set' do
  598. node.set['openstack']['block-storage']['solidfire']['sf_emulate'] = 'test'
  599. expect(chef_run).to render_file(file.name).with_content(/^sf_emulate_512=test$/)
  600. end
  601. it 'has solidfire password' do
  602. expect(chef_run).to render_file(file.name).with_content(/^san_password=test_pass$/)
  603. end
  604. %w(san_login san_ip).each do |attr|
  605. it "has solidfire #{attr} set" do
  606. node.set['openstack']['block-storage']['solidfire'][attr] = "solidfire_#{attr}_value"
  607. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=solidfire_#{attr}_value$/)
  608. end
  609. end
  610. it 'does not have iscsi_ip_prefix not specified' do
  611. node.set['openstack']['block-storage']['solidfire']['iscsi_ip_prefix'] = nil
  612. expect(chef_run).to_not render_file(file.name).with_content(/^iscsi_ip_prefix=/)
  613. end
  614. it 'does have iscsi_ip_prefix when specified' do
  615. chef_run.node.set['openstack']['block-storage']['solidfire']['iscsi_ip_prefix'] = '203.0.113.*'
  616. expect(chef_run).to render_file(file.name).with_content(/^iscsi_ip_prefix=203.0.113.*$/)
  617. end
  618. end
  619. context 'flashsystem settings' do
  620. before do
  621. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.flashsystem.FlashSystemDriver'
  622. end
  623. it 'has flashsystem password' do
  624. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^san_password=test_pass$/)
  625. end
  626. it 'has a default attribute' do
  627. %w(san_ip=127.0.0.1
  628. flashsystem_connection_protocol=FC
  629. flashsystem_multihostmap_enabled=true).each do |attr|
  630. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}$/)
  631. end
  632. end
  633. it 'has a overridden attribute' do
  634. %w(san_ip
  635. flashsystem_connection_protocol
  636. flashsystem_multihostmap_enabled).each do |attr|
  637. node.set['openstack']['block-storage']['flashsystem'][attr] = "flashsystem_#{attr}_value"
  638. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^#{attr}=flashsystem_#{attr}_value$/)
  639. end
  640. end
  641. context 'FlashSystem with FC connection protocol' do
  642. before do
  643. node.set['openstack']['block-storage']['storwize']['flashsystem_connection_protocol'] = 'FC'
  644. end
  645. it 'has a multipath enabled attribute' do
  646. node.set['openstack']['block-storage']['flashsystem']['flashsystem_multipath_enabled'] = 'flashsystem_multipath_enabled_value'
  647. expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', /^flashsystem_multipath_enabled=flashsystem_multipath_enabled_value$/)
  648. end
  649. end
  650. end
  651. context 'emc settings' do
  652. before do
  653. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver'
  654. end
  655. %w(iscsi_target_prefix cinder_emc_config_file).each do |attr|
  656. it "has emc #{attr} set" do
  657. node.set['openstack']['block-storage']['emc'][attr] = "emc_#{attr}_value"
  658. expect(chef_run).to render_file(file.name).with_content(/^#{attr}=emc_#{attr}_value$/)
  659. end
  660. end
  661. end
  662. context 'vmware vmdk settings' do
  663. before do
  664. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver'
  665. %w(vmware_host_ip vmware_host_username
  666. vmware_api_retry_count vmware_task_poll_interval vmware_volume_folder
  667. vmware_image_transfer_timeout_secs vmware_max_objects_retrieval).each do |attr|
  668. node.set['openstack']['block-storage']['vmware'][attr] = "vmware_#{attr}_value"
  669. end
  670. end
  671. it 'has vmware attributes set' do
  672. node['openstack']['block-storage']['vmware'].each do |attr, val|
  673. expect(chef_run).to render_file(file.name).with_content(/^#{attr} = #{val}$/)
  674. end
  675. end
  676. it 'has password set which is from databag' do
  677. expect(chef_run).to render_file(file.name).with_content(/^vmware_host_password = vmware_secret_name$/)
  678. end
  679. it 'has no wsdl_location line without the attribute' do
  680. node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = nil
  681. expect(chef_run).not_to render_file(file.name).with_content(/^vmware_wsdl_location = /)
  682. end
  683. it 'has wsdl_location line with attribute present' do
  684. node.set['openstack']['block-storage']['vmware']['vmware_wsdl_location'] = 'http://127.0.0.1/wsdl'
  685. expect(chef_run).to render_file(file.name).with_content(%r(^vmware_wsdl_location = http://127.0.0.1/wsdl$))
  686. end
  687. end
  688. context 'gpfs settings' do
  689. before do
  690. node.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.ibm.gpfs.GPFSDriver'
  691. end
  692. %w(gpfs_mount_point_base gpfs_max_clone_depth
  693. gpfs_sparse_volumes gpfs_storage_pool).each do |attr|
  694. it "has gpfs #{attr} set" do
  695. node.set['openstack']['block-storage']['gpfs'][attr] = "gpfs_#{attr}_value"
  696. expect(chef_run).to render_file(file.name).with_content(/^#{attr} = gpfs_#{attr}_value$/)
  697. end
  698. end
  699. it 'has no gpfs_images_dir line without the attribute' do
  700. node.set['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = nil
  701. expect(chef_run).not_to render_file(file.name).with_content(/^gpfs_images_dir = /)
  702. expect(chef_run).not_to render_file(file.name).with_content(/^gpfs_images_share_mode = /)
  703. end
  704. it 'has gpfs_images_dir line with attribute present' do
  705. node.set['openstack']['block-storage']['gpfs']['gpfs_images_dir'] = 'gpfs_images_dir_value'
  706. expect(chef_run).to render_file(file.name).with_content(/^gpfs_images_dir = gpfs_images_dir_value$/)
  707. expect(chef_run).to render_file(file.name).with_content(/^gpfs_images_share_mode = copy_on_write$/)
  708. end
  709. it 'templates misc_cinder array correctly' do
  710. node.set['openstack']['block-storage']['misc_cinder'] = ['# Comments', 'MISC=OPTION']
  711. expect(chef_run).to render_file(file.name).with_content(
  712. /^# Comments$/)
  713. expect(chef_run).to render_file(file.name).with_content(
  714. /^MISC=OPTION$/)
  715. end
  716. end
  717. context 'multiple backend settings' do
  718. before do
  719. node.set['openstack']['block-storage']['volume']['multi_backend'] = {
  720. 'lvm' => {
  721. 'volume_driver' => 'cinder.volume.drivers.lvm.LVMVolumeDriver',
  722. 'volume_backend_name' => 'lvmdrv'
  723. },
  724. 'rbd' => {
  725. 'volume_driver' => 'cinder.volume.drivers.rbd.RBDDriver',
  726. 'volume_backend_name' => 'rbddrv'
  727. },
  728. 'netapp_iscsi' => {
  729. 'volume_driver' => 'cinder.volume.drivers.netapp.NetAppISCSIDriver',
  730. 'multi_netapp_iscsi' => 'multi-netapp'
  731. },
  732. 'netapp_nfs' => {
  733. 'volume_driver' => 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver',
  734. 'volume_backend_name' => 'netappnfsdrv',
  735. 'multi_netapp_nfs' => 'multi-netapp'
  736. },
  737. 'ibmnas' => {
  738. 'volume_driver' => 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver',
  739. 'multi_ibmnas' => 'multi-ibmnas'
  740. },
  741. 'ibmsvc' => {
  742. 'volume_driver' => 'cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver',
  743. 'multi_ibmsvc' => 'multi-ibmsvc'
  744. },
  745. 'solidfire' => {
  746. 'volume_driver' => 'cinder.volume.drivers.solidfire.SolidFire',
  747. 'multi_solidfire' => 'multi-solidfire'
  748. },
  749. 'emciscsi' => {
  750. 'volume_driver' => 'cinder.volume.drivers.emc.emc_smis_iscsi.EMCSMISISCSIDriver',
  751. 'multi_emciscsi' => 'multi-emciscsi'
  752. },
  753. 'vmware' => {
  754. 'volume_driver' => 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver',
  755. 'multi_vmware' => 'multi-vmware'
  756. },
  757. 'gpfs' => {
  758. 'volume_driver' => 'cinder.volume.drivers.ibm.gpfs.GPFSDriver',
  759. 'multi_gpfs' => 'multi-gpfs'
  760. }
  761. }
  762. node.set['openstack']['block-storage']['volume']['volume_group'] = 'multi-lvm-group'
  763. node.set['openstack']['block-storage']['volume']['default_volume_type'] = 'some-type-name'
  764. node.set['openstack']['block-storage']['rbd']['cinder']['pool'] = 'multi-rbd-pool'
  765. node.set['openstack']['block-storage']['netapp']['dfm_login'] = 'multi-netapp-login'
  766. node.set['openstack']['block-storage']['netapp']['netapp_server_hostname'] = ['netapp-host-1', 'netapp-host-2']
  767. node.set['openstack']['block-storage']['netapp']['netapp_server_port'] = 'multi-netapp-port'
  768. node.set['openstack']['block-storage']['ibmnas']['shares_config'] = 'multi-ibmnas-share'
  769. node.set['openstack']['block-storage']['storwize']['storwize_svc_volpool_name'] = 'multi-svc-volpool'
  770. node.set['openstack']['block-storage']['solidfire']['sf_emulate'] = 'multi-sf-true'
  771. node.set['openstack']['block-storage']['emc']['cinder_emc_config_file'] = 'multi-emc-conf'
  772. node.set['openstack']['block-storage']['vmware']['vmware_host_ip'] = 'multi-vmware-ip'
  773. node.set['openstack']['block-storage']['gpfs']['gpfs_mount_point_base'] = 'multi-gpfs-mnt'
  774. end
  775. it 'enable multiple backends' do
  776. expect(chef_run).to render_file(file.name).with_content(/^enabled_backends = lvm,rbd,netapp_iscsi,netapp_nfs,ibmnas,ibmsvc,solidfire,emciscsi,vmware,gpfs$/)
  777. expect(chef_run).to render_file(file.name).with_content(/^\[lvm\]$/)
  778. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.lvm\.LVMVolumeDriver$/)
  779. expect(chef_run).to render_file(file.name).with_content(/^\[rbd\]$/)
  780. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.rbd\.RBDDriver$/)
  781. expect(chef_run).to render_file(file.name).with_content(/^\[netapp_iscsi\]$/)
  782. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.netapp\.NetAppISCSIDriver$/)
  783. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_hostname=netapp-host-1$/)
  784. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_hostname=netapp-host-2$/)
  785. expect(chef_run).to render_file(file.name).with_content(/^\[netapp_nfs\]$/)
  786. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.netapp\.nfs\.NetAppDirect7modeNfsDriver$/)
  787. expect(chef_run).to render_file(file.name).with_content(/^\[ibmnas\]$/)
  788. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.ibm\.ibmnas\.IBMNAS_NFSDriver$/)
  789. expect(chef_run).to render_file(file.name).with_content(/^\[ibmsvc\]$/)
  790. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.ibm\.storwize_svc\.StorwizeSVCDriver$/)
  791. expect(chef_run).to render_file(file.name).with_content(/^\[solidfire\]$/)
  792. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.solidfire\.SolidFire$/)
  793. expect(chef_run).to render_file(file.name).with_content(/^\[emciscsi\]$/)
  794. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.emc\.emc_smis_iscsi\.EMCSMISISCSIDriver$/)
  795. expect(chef_run).to render_file(file.name).with_content(/^\[vmware\]$/)
  796. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.vmware\.vmdk\.VMwareVcVmdkDriver$/)
  797. expect(chef_run).to render_file(file.name).with_content(/^\[gpfs\]$/)
  798. expect(chef_run).to render_file(file.name).with_content(/^volume_driver = cinder\.volume\.drivers\.ibm\.gpfs\.GPFSDriver$/)
  799. end
  800. it 'set lvm option' do
  801. expect(chef_run).to render_file(file.name).with_content(/^volume_group=multi-lvm-group$/)
  802. end
  803. it 'set default_volume_type option' do
  804. expect(chef_run).to render_file(file.name).with_content(/^default_volume_type=some-type-name$/)
  805. end
  806. it 'set rbd option' do
  807. expect(chef_run).to render_file(file.name).with_content(/^rbd_pool=multi-rbd-pool$/)
  808. end
  809. it 'set netapp_iscsi option' do
  810. expect(chef_run).to render_file(file.name).with_content(/^netapp_login=multi-netapp-login$/)
  811. end
  812. it 'set netapp_nfs option' do
  813. expect(chef_run).to render_file(file.name).with_content(/^netapp_server_port=multi-netapp-port$/)
  814. end
  815. it 'set ibmnas option' do
  816. expect(chef_run).to render_file(file.name).with_content(/^nfs_shares_config=multi-ibmnas-share$/)
  817. end
  818. it 'set ibmsvc option' do
  819. expect(chef_run).to render_file(file.name).with_content(/^storwize_svc_volpool_name=multi-svc-volpool$/)
  820. end
  821. it 'set solidfire option' do
  822. expect(chef_run).to render_file(file.name).with_content(/^sf_emulate_512=multi-sf-true$/)
  823. end
  824. it 'set emciscsi option' do
  825. expect(chef_run).to render_file(file.name).with_content(/^cinder_emc_config_file=multi-emc-conf$/)
  826. end
  827. it 'set vmware option' do
  828. expect(chef_run).to render_file(file.name).with_content(/^vmware_host_ip = multi-vmware-ip$/)
  829. end
  830. it 'set gpfs option' do
  831. expect(chef_run).to render_file(file.name).with_content(/^gpfs_mount_point_base = multi-gpfs-mnt$/)
  832. end
  833. end
  834. it 'no multiple backends configured' do
  835. expect(chef_run).to_not render_file(file.name).with_content(/^enabled_backends = [\w\W]+$/)
  836. end
  837. it 'does not set default_volume_type' do
  838. expect(chef_run).to_not render_file(file.name).with_content(/^default_volume_type=.+$/)
  839. end
  840. end
  841. end
  842. describe '/var/lib/cinder/lock' do
  843. let(:dir) { chef_run.directory('/var/lib/cinder/lock') }
  844. it 'should create the /var/lib/cinder/lock directory' do
  845. expect(chef_run).to create_directory(dir.name)
  846. end
  847. it 'has proper owner' do
  848. expect(dir.owner).to eq('cinder')
  849. expect(dir.group).to eq('cinder')
  850. end
  851. it 'has proper modes' do
  852. expect(sprintf('%o', dir.mode)).to eq '755'
  853. end
  854. end
  855. describe 'rootwrap.conf' do
  856. let(:file) { chef_run.template('/etc/cinder/rootwrap.conf') }
  857. it 'creates the /etc/cinder/rootwrap.conf file' do
  858. expect(chef_run).to create_template(file.name).with(
  859. user: 'root',
  860. group: 'root',
  861. mode: 0644
  862. )
  863. end
  864. context 'template contents' do
  865. it 'shows the custom banner' do
  866. node.set['openstack']['block-storage']['custom_template_banner'] = 'banner'
  867. expect(chef_run).to render_file(file.name)
  868. .with_content(/^banner$/)
  869. end
  870. it 'sets the default attributes' do
  871. [
  872. %r(^filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap$),
  873. %r(^exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin$),
  874. /^use_syslog=False$/,
  875. /^syslog_log_facility=syslog$/,
  876. /^syslog_log_level=ERROR$/
  877. ].each do |line|
  878. expect(chef_run).to render_file(file.name).with_content(line)
  879. end
  880. end
  881. end
  882. end
  883. end
  884. end