OpenStack Heat Puppet Module
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.

heat_init_spec.rb 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. require 'spec_helper'
  2. describe 'heat' do
  3. let :pre_condition do
  4. "class { '::heat::keystone::authtoken':
  5. password => 'secretpassword',
  6. }"
  7. end
  8. let :params do
  9. {
  10. :package_ensure => 'present',
  11. :database_connection => 'mysql+pymysql://user@host/database',
  12. :database_idle_timeout => 3600,
  13. :flavor => 'keystone',
  14. :heat_clients_url => '<SERVICE DEFAULT>',
  15. :purge_config => false,
  16. :yaql_limit_iterators => 400,
  17. :yaql_memory_quota => 20000,
  18. }
  19. end
  20. shared_examples_for 'heat' do
  21. context 'with a normal setup' do
  22. it_configures 'a heat base installation'
  23. it_configures 'configures default rabbitmq parameters'
  24. end
  25. context 'with HA support' do
  26. it_configures 'configures rabbit with HA and durable'
  27. end
  28. context 'with rabbit heartbeat configured' do
  29. before { params.merge!(
  30. :rabbit_heartbeat_timeout_threshold => '60',
  31. :rabbit_heartbeat_rate => '10' ) }
  32. it_configures 'a heat base installation'
  33. it_configures 'rabbit with heartbeat configured'
  34. end
  35. it_configures 'with SSL enabled with kombu'
  36. it_configures 'with SSL enabled without kombu'
  37. it_configures 'with SSL disabled'
  38. it_configures 'with SSL wrongly configured'
  39. it_configures 'with enable_stack_adopt and enable_stack_abandon set'
  40. it_configures 'with overridden transport_url parameter'
  41. it_configures 'with notification_driver set to a string'
  42. context 'with amqp messaging' do
  43. it_configures 'amqp support'
  44. end
  45. end
  46. shared_examples_for 'a heat base installation' do
  47. it { is_expected.to contain_class('heat::params') }
  48. it 'installs heat common package' do
  49. is_expected.to contain_package('heat-common').with(
  50. :ensure => 'present',
  51. :name => platform_params[:common_package_name],
  52. :tag => ['openstack', 'heat-package'],
  53. )
  54. end
  55. it 'passes purge to resource' do
  56. is_expected.to contain_resources('heat_config').with({
  57. :purge => false
  58. })
  59. end
  60. it 'has db_sync enabled' do
  61. is_expected.to contain_class('heat::db::sync')
  62. end
  63. it 'configures host' do
  64. is_expected.to contain_heat_config('DEFAULT/host').with_value('<SERVICE DEFAULT>')
  65. end
  66. it 'configures default transport_url' do
  67. is_expected.to contain_heat_config('DEFAULT/transport_url').with_value('<SERVICE DEFAULT>')
  68. is_expected.to contain_heat_config('DEFAULT/rpc_response_timeout').with_value('<SERVICE DEFAULT>')
  69. is_expected.to contain_heat_config('DEFAULT/control_exchange').with_value('<SERVICE DEFAULT>')
  70. end
  71. it 'configures max_template_size' do
  72. is_expected.to contain_heat_config('DEFAULT/max_template_size').with_value('<SERVICE DEFAULT>')
  73. end
  74. it 'configures max_json_body_size' do
  75. is_expected.to contain_heat_config('DEFAULT/max_json_body_size').with_value('<SERVICE DEFAULT>')
  76. end
  77. it 'configures project_domain_*' do
  78. is_expected.to contain_heat_config('trustee/project_domain_name').with_value( 'Default' )
  79. end
  80. it 'configures user_domain_*' do
  81. is_expected.to contain_heat_config('trustee/user_domain_name').with_value( 'Default' )
  82. end
  83. it 'configures auth_type' do
  84. is_expected.to contain_heat_config('trustee/auth_type').with_value( 'password' )
  85. end
  86. it 'configures auth_url' do
  87. is_expected.to contain_heat_config('trustee/auth_url').with_value( 'http://127.0.0.1:5000/' )
  88. end
  89. it 'configures username' do
  90. is_expected.to contain_heat_config('trustee/username').with_value( 'heat' )
  91. end
  92. it 'configures ' do
  93. is_expected.to contain_heat_config('trustee/password').with_secret( true )
  94. end
  95. it 'configures endpoint_type for clients' do
  96. is_expected.to contain_heat_config('clients/endpoint_type').with_value( '<SERVICE DEFAULT>' )
  97. end
  98. it 'configures keystone_ec2_uri' do
  99. is_expected.to contain_heat_config('ec2authtoken/auth_uri').with_value( '<SERVICE DEFAULT>' )
  100. end
  101. it 'configures yaql_limit_iterators' do
  102. is_expected.to contain_heat_config('yaql/limit_iterators').with_value( params[:yaql_limit_iterators] )
  103. end
  104. it 'configures yaql_memory_quota' do
  105. is_expected.to contain_heat_config('yaql/memory_quota').with_value( params[:yaql_memory_quota] )
  106. end
  107. it { is_expected.to contain_heat_config('paste_deploy/flavor').with_value('keystone') }
  108. it 'configures notification_driver' do
  109. is_expected.to contain_heat_config('oslo_messaging_notifications/transport_url').with_value('<SERVICE DEFAULT>')
  110. is_expected.to contain_heat_config('oslo_messaging_notifications/driver').with_value('<SERVICE DEFAULT>')
  111. is_expected.to contain_heat_config('oslo_messaging_notifications/topics').with_value('<SERVICE DEFAULT>')
  112. end
  113. it 'sets default value for http_proxy_to_wsgi middleware' do
  114. is_expected.to contain_oslo__middleware('heat_config').with(
  115. :enable_proxy_headers_parsing => '<SERVICE DEFAULT>',
  116. )
  117. end
  118. it 'sets clients_heat url' do
  119. is_expected.to contain_heat_config('clients_heat/url').with_value('<SERVICE DEFAULT>')
  120. end
  121. end
  122. shared_examples_for 'configures default rabbitmq parameters' do
  123. it 'configures rabbit' do
  124. is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('<SERVICE DEFAULT>')
  125. is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_failover_strategy').with_value('<SERVICE DEFAULT>')
  126. is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_compression').with_value('<SERVICE DEFAULT>')
  127. is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('<SERVICE DEFAULT>')
  128. is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_rate').with_value('<SERVICE DEFAULT>')
  129. is_expected.to contain_oslo__messaging__rabbit('heat_config').with(
  130. :rabbit_use_ssl => '<SERVICE DEFAULT>',
  131. :kombu_ssl_ca_certs => '<SERVICE DEFAULT>',
  132. :kombu_ssl_certfile => '<SERVICE DEFAULT>',
  133. :kombu_ssl_keyfile => '<SERVICE DEFAULT>',
  134. :kombu_ssl_version => '<SERVICE DEFAULT>',
  135. )
  136. end
  137. it { is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('<SERVICE DEFAULT>') }
  138. it { is_expected.to contain_heat_config('DEFAULT/rpc_response_timeout').with_value('<SERVICE DEFAULT>') }
  139. it { is_expected.to contain_heat_config('oslo_messaging_rabbit/amqp_durable_queues').with_value('<SERVICE DEFAULT>') }
  140. end
  141. shared_examples_for 'configures rabbit with HA and durable' do
  142. before do
  143. params.merge!( :rabbit_ha_queues => true,
  144. :amqp_durable_queues => true )
  145. end
  146. it { is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(true) }
  147. it { is_expected.to contain_heat_config('oslo_messaging_rabbit/amqp_durable_queues').with_value(true) }
  148. end
  149. shared_examples_for 'rabbit with heartbeat configured' do
  150. it 'configures rabbit' do
  151. is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('<SERVICE DEFAULT>')
  152. is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_failover_strategy').with_value('<SERVICE DEFAULT>')
  153. is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_compression').with_value('<SERVICE DEFAULT>')
  154. is_expected.to contain_oslo__messaging__rabbit('heat_config').with(
  155. :rabbit_use_ssl => '<SERVICE DEFAULT>',
  156. :kombu_ssl_ca_certs => '<SERVICE DEFAULT>',
  157. :kombu_ssl_certfile => '<SERVICE DEFAULT>',
  158. :kombu_ssl_keyfile => '<SERVICE DEFAULT>',
  159. :kombu_ssl_version => '<SERVICE DEFAULT>',
  160. )
  161. end
  162. it { is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60') }
  163. it { is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10') }
  164. end
  165. shared_examples_for 'with SSL enabled with kombu' do
  166. before do
  167. params.merge!(
  168. :rabbit_use_ssl => true,
  169. :kombu_ssl_ca_certs => '/path/to/ssl/ca/certs',
  170. :kombu_ssl_certfile => '/path/to/ssl/cert/file',
  171. :kombu_ssl_keyfile => '/path/to/ssl/keyfile',
  172. :kombu_ssl_version => 'TLSv1'
  173. )
  174. end
  175. it { is_expected.to contain_oslo__messaging__rabbit('heat_config').with(
  176. :rabbit_use_ssl => true,
  177. :kombu_ssl_ca_certs => '/path/to/ssl/ca/certs',
  178. :kombu_ssl_certfile => '/path/to/ssl/cert/file',
  179. :kombu_ssl_keyfile => '/path/to/ssl/keyfile',
  180. :kombu_ssl_version => 'TLSv1'
  181. )}
  182. end
  183. shared_examples_for 'with SSL enabled without kombu' do
  184. before do
  185. params.merge!(
  186. :rabbit_use_ssl => true
  187. )
  188. end
  189. it { is_expected.to contain_oslo__messaging__rabbit('heat_config').with(
  190. :rabbit_use_ssl => true,
  191. )}
  192. end
  193. shared_examples_for 'with SSL disabled' do
  194. before do
  195. params.merge!(
  196. :rabbit_use_ssl => false,
  197. )
  198. end
  199. it { is_expected.to contain_oslo__messaging__rabbit('heat_config').with(
  200. :rabbit_use_ssl => false,
  201. )}
  202. end
  203. shared_examples_for 'with SSL wrongly configured' do
  204. before do
  205. params.merge!(
  206. :rabbit_use_ssl => false
  207. )
  208. end
  209. context 'without required parameters' do
  210. context 'with rabbit_use_ssl => false and kombu_ssl_ca_certs parameter' do
  211. before { params.merge!(:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs')}
  212. it_raises 'a Puppet::Error', /The kombu_ssl_ca_certs parameter requires rabbit_use_ssl to be set to true/
  213. end
  214. context 'with rabbit_use_ssl => false and kombu_ssl_certfile parameter' do
  215. before { params.merge!(:kombu_ssl_certfile => '/path/to/ssl/cert/file')}
  216. it_raises 'a Puppet::Error', /The kombu_ssl_certfile parameter requires rabbit_use_ssl to be set to true/
  217. end
  218. context 'with rabbit_use_ssl => false and kombu_ssl_keyfile parameter' do
  219. before { params.merge!(:kombu_ssl_keyfile => '/path/to/ssl/keyfile')}
  220. it_raises 'a Puppet::Error', /The kombu_ssl_keyfile parameter requires rabbit_use_ssl to be set to true/
  221. end
  222. end
  223. end
  224. shared_examples_for 'with heat_clients_endpoint_type set' do
  225. before do
  226. params.merge!(
  227. :heat_clients_endpoint_type => 'internal',
  228. )
  229. end
  230. it do
  231. is_expected.to contain_heat_config('clients/endpoint_type').with_value('internal')
  232. end
  233. end
  234. shared_examples_for 'with ec2authtoken auth uri set' do
  235. before do
  236. params.merge!(
  237. :keystone_ec2_uri => 'http://1.2.3.4:5000/v2.0/ec2tokens'
  238. )
  239. end
  240. it do
  241. is_expected.to contain_heat_config('ec2authtoken/auth_uri').with_value('http://1.2.3.4:5000/v2.0/ec2tokens')
  242. end
  243. end
  244. shared_examples_for 'with region_name set' do
  245. before do
  246. params.merge!(
  247. :region_name => "East",
  248. )
  249. end
  250. it 'has region_name set when specified' do
  251. is_expected.to contain_heat_config('DEFAULT/region_name_for_services').with_value('East')
  252. end
  253. end
  254. shared_examples_for 'without region_name set' do
  255. it 'doesnt have region_name set by default' do
  256. is_expected.to contain_heat_config('DEFAULT/region_name_for_services').with_value('<SERVICE DEFAULT>')
  257. end
  258. end
  259. shared_examples_for "with custom keystone project_domain_* and user_domain_*" do
  260. before do
  261. params.merge!({
  262. :keystone_project_domain_name => 'domain1',
  263. :keystone_user_domain_name => 'domain1',
  264. })
  265. end
  266. it 'configures project_domain_* and user_domain_*' do
  267. is_expected.to contain_heat_config('trustee/project_domain_name').with_value("domain1");
  268. is_expected.to contain_heat_config('trustee/user_domain_name').with_value("domain1");
  269. end
  270. end
  271. shared_examples_for "with enable_stack_adopt and enable_stack_abandon set" do
  272. before do
  273. params.merge!({
  274. :enable_stack_adopt => true,
  275. :enable_stack_abandon => true,
  276. })
  277. end
  278. it 'sets enable_stack_adopt and enable_stack_abandon' do
  279. is_expected.to contain_heat_config('DEFAULT/enable_stack_adopt').with_value(true);
  280. is_expected.to contain_heat_config('DEFAULT/enable_stack_abandon').with_value(true);
  281. end
  282. end
  283. shared_examples_for 'with overridden transport_url parameter' do
  284. before do
  285. params.merge!(
  286. :default_transport_url => 'rabbit://rabbit_user:password@localhost:5673',
  287. :rpc_response_timeout => '120',
  288. :control_exchange => 'heat',
  289. )
  290. end
  291. it 'configures transport_url' do
  292. is_expected.to contain_heat_config('DEFAULT/transport_url').with_value('rabbit://rabbit_user:password@localhost:5673')
  293. is_expected.to contain_heat_config('DEFAULT/rpc_response_timeout').with_value('120')
  294. is_expected.to contain_heat_config('DEFAULT/control_exchange').with_value('heat')
  295. end
  296. end
  297. shared_examples_for 'with notification_driver set to a string' do
  298. before do
  299. params.merge!(
  300. :notification_transport_url => 'rabbit://rabbit_user:password@localhost:5673',
  301. :notification_driver => 'bar.foo.rpc_notifier',
  302. :notification_topics => 'messagingv2',
  303. )
  304. end
  305. it 'has notification_driver set when specified' do
  306. is_expected.to contain_heat_config('oslo_messaging_notifications/transport_url').with_value('rabbit://rabbit_user:password@localhost:5673')
  307. is_expected.to contain_heat_config('oslo_messaging_notifications/driver').with_value('bar.foo.rpc_notifier')
  308. is_expected.to contain_heat_config('oslo_messaging_notifications/topics').with_value('messagingv2')
  309. end
  310. end
  311. shared_examples_for 'amqp support' do
  312. context 'with default parameters' do
  313. it { is_expected.to contain_heat_config('oslo_messaging_amqp/server_request_prefix').with_value('<SERVICE DEFAULT>') }
  314. it { is_expected.to contain_heat_config('oslo_messaging_amqp/broadcast_prefix').with_value('<SERVICE DEFAULT>') }
  315. it { is_expected.to contain_heat_config('oslo_messaging_amqp/group_request_prefix').with_value('<SERVICE DEFAULT>') }
  316. it { is_expected.to contain_heat_config('oslo_messaging_amqp/container_name').with_value('<SERVICE DEFAULT>') }
  317. it { is_expected.to contain_heat_config('oslo_messaging_amqp/idle_timeout').with_value('<SERVICE DEFAULT>') }
  318. it { is_expected.to contain_heat_config('oslo_messaging_amqp/trace').with_value('<SERVICE DEFAULT>') }
  319. it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_ca_file').with_value('<SERVICE DEFAULT>') }
  320. it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_cert_file').with_value('<SERVICE DEFAULT>') }
  321. it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_key_file').with_value('<SERVICE DEFAULT>') }
  322. it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_key_password').with_value('<SERVICE DEFAULT>') }
  323. it { is_expected.to contain_heat_config('oslo_messaging_amqp/allow_insecure_clients').with_value('<SERVICE DEFAULT>') }
  324. it { is_expected.to contain_heat_config('oslo_messaging_amqp/sasl_mechanisms').with_value('<SERVICE DEFAULT>') }
  325. it { is_expected.to contain_heat_config('oslo_messaging_amqp/sasl_config_dir').with_value('<SERVICE DEFAULT>') }
  326. it { is_expected.to contain_heat_config('oslo_messaging_amqp/sasl_config_name').with_value('<SERVICE DEFAULT>') }
  327. it { is_expected.to contain_heat_config('oslo_messaging_amqp/username').with_value('<SERVICE DEFAULT>') }
  328. it { is_expected.to contain_heat_config('oslo_messaging_amqp/password').with_value('<SERVICE DEFAULT>') }
  329. end
  330. context 'with overridden amqp parameters' do
  331. before { params.merge!(
  332. :amqp_idle_timeout => '60',
  333. :amqp_trace => true,
  334. :amqp_ssl_ca_file => '/path/to/ca.cert',
  335. :amqp_ssl_cert_file => '/path/to/certfile',
  336. :amqp_ssl_key_file => '/path/to/key',
  337. :amqp_username => 'amqp_user',
  338. :amqp_password => 'password',
  339. ) }
  340. it { is_expected.to contain_heat_config('oslo_messaging_amqp/server_request_prefix').with_value('<SERVICE DEFAULT>') }
  341. it { is_expected.to contain_heat_config('oslo_messaging_amqp/broadcast_prefix').with_value('<SERVICE DEFAULT>') }
  342. it { is_expected.to contain_heat_config('oslo_messaging_amqp/group_request_prefix').with_value('<SERVICE DEFAULT>') }
  343. it { is_expected.to contain_heat_config('oslo_messaging_amqp/container_name').with_value('<SERVICE DEFAULT>') }
  344. it { is_expected.to contain_heat_config('oslo_messaging_amqp/idle_timeout').with_value('60') }
  345. it { is_expected.to contain_heat_config('oslo_messaging_amqp/trace').with_value('true') }
  346. it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_ca_file').with_value('/path/to/ca.cert') }
  347. it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_cert_file').with_value('/path/to/certfile') }
  348. it { is_expected.to contain_heat_config('oslo_messaging_amqp/ssl_key_file').with_value('/path/to/key') }
  349. it { is_expected.to contain_heat_config('oslo_messaging_amqp/allow_insecure_clients').with_value('<SERVICE DEFAULT>') }
  350. it { is_expected.to contain_heat_config('oslo_messaging_amqp/sasl_mechanisms').with_value('<SERVICE DEFAULT>') }
  351. it { is_expected.to contain_heat_config('oslo_messaging_amqp/sasl_config_dir').with_value('<SERVICE DEFAULT>') }
  352. it { is_expected.to contain_heat_config('oslo_messaging_amqp/sasl_config_name').with_value('<SERVICE DEFAULT>') }
  353. it { is_expected.to contain_heat_config('oslo_messaging_amqp/username').with_value('amqp_user') }
  354. it { is_expected.to contain_heat_config('oslo_messaging_amqp/password').with_value('password') }
  355. end
  356. end
  357. on_supported_os({
  358. :supported_os => OSDefaults.get_supported_os
  359. }).each do |os,facts|
  360. context "on #{os}" do
  361. let (:facts) do
  362. facts.merge!(OSDefaults.get_facts())
  363. end
  364. let :platform_params do
  365. case facts[:osfamily]
  366. when 'Debian'
  367. { :common_package_name => 'heat-common' }
  368. when 'RedHat'
  369. { :common_package_name => 'openstack-heat-common' }
  370. end
  371. end
  372. it_behaves_like 'heat'
  373. end
  374. end
  375. end