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

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