nova_metadata_novajoin_api_spec.rb 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. require 'spec_helper'
  2. describe 'nova::metadata::novajoin::api' do
  3. let :facts do
  4. @default_facts.merge(
  5. {
  6. :osfamily => 'RedHat',
  7. :processorcount => '7',
  8. :fqdn => "undercloud.example.com",
  9. :operatingsystemrelease => '7.0',
  10. }
  11. )
  12. end
  13. let :default_params do
  14. {
  15. :bind_address => '127.0.0.1',
  16. :api_paste_config => '/etc/nova/join-api-paste.ini',
  17. :auth_strategy => '<SERVICE DEFAULT>',
  18. :auth_type => 'password',
  19. :cacert => '/etc/ipa/ca.crt',
  20. :connect_retries => '<SERVICE DEFAULT>',
  21. :debug => '<SERVICE DEFAULT>',
  22. :enabled => true,
  23. :enable_ipa_client_install => true,
  24. :ensure_package => 'present',
  25. :join_listen_port => '<SERVICE DEFAULT>',
  26. :keytab => '/etc/nova/krb5.keytab',
  27. :log_dir => '/var/log/novajoin',
  28. :manage_service => true,
  29. :nova_user => 'nova',
  30. :project_domain_name => 'default',
  31. :project_name => 'service',
  32. :user_domain_id => 'default',
  33. :ipa_domain => 'EXAMPLE.COM',
  34. :keystone_auth_url => 'https://keystone.example.com:35357',
  35. :nova_password => 'my_secret_password',
  36. :transport_url => 'rabbit:rabbit_pass@rabbit_host',
  37. }
  38. end
  39. [{},
  40. {
  41. :bind_address => '0.0.0.0',
  42. :api_paste_config => '/etc/nova/join-api-paste.ini',
  43. :auth_strategy => 'noauth2',
  44. :auth_type => 'password',
  45. :cacert => '/etc/ipa/ca.crt',
  46. :connect_retries => 2,
  47. :debug => true,
  48. :enabled => false,
  49. :enable_ipa_client_install => false,
  50. :ensure_package => 'present',
  51. :join_listen_port => '9921',
  52. :keytab => '/etc/krb5.conf',
  53. :log_dir => '/var/log/novajoin',
  54. :manage_service => true,
  55. :nova_user => 'nova1',
  56. :project_domain_name => 'default',
  57. :project_name => 'service',
  58. :user_domain_id => 'default',
  59. :ipa_domain => 'EXAMPLE2.COM',
  60. :keystone_auth_url => 'https://keystone2.example.com:35357',
  61. :nova_password => 'my_secret_password2',
  62. :transport_url => 'rabbit:rabbit_pass2@rabbit_host',
  63. }
  64. ].each do |param_set|
  65. describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
  66. let :param_hash do
  67. default_params.merge(param_set)
  68. end
  69. let :params do
  70. param_hash
  71. end
  72. let :pre_condition do
  73. 'class { "::ipaclient": password => "join_otp", }'
  74. end
  75. it { is_expected.to contain_service('novajoin-server').with(
  76. 'ensure' => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running': 'stopped',
  77. 'enable' => param_hash[:enabled],
  78. 'hasstatus' => true,
  79. 'hasrestart' => true,
  80. 'tag' => 'openstack',
  81. ) }
  82. it { is_expected.to contain_service('novajoin-notify').with(
  83. 'ensure' => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running': 'stopped',
  84. 'enable' => param_hash[:enabled],
  85. 'hasstatus' => true,
  86. 'hasrestart' => true,
  87. 'tag' => 'openstack',
  88. ) }
  89. it 'is_expected.to configure default parameters' do
  90. is_expected.to contain_novajoin_config('DEFAULT/join_listen').with_value(param_hash[:bind_address])
  91. is_expected.to contain_novajoin_config('DEFAULT/api_paste_config').with_value(param_hash[:api_paste_config])
  92. is_expected.to contain_novajoin_config('DEFAULT/auth_strategy').with_value(param_hash[:auth_strategy])
  93. is_expected.to contain_novajoin_config('DEFAULT/cacert').with_value(param_hash[:cacert])
  94. is_expected.to contain_novajoin_config('DEFAULT/connect_retries').with_value(param_hash[:connect_retries])
  95. is_expected.to contain_novajoin_config('DEFAULT/debug').with_value(param_hash[:debug])
  96. is_expected.to contain_novajoin_config('DEFAULT/join_listen_port').with_value(param_hash[:join_listen_port])
  97. is_expected.to contain_novajoin_config('DEFAULT/keytab').with_value(param_hash[:keytab])
  98. is_expected.to contain_novajoin_config('DEFAULT/log_dir').with_value(param_hash[:log_dir])
  99. is_expected.to contain_novajoin_config('DEFAULT/domain').with_value(param_hash[:ipa_domain])
  100. is_expected.to contain_novajoin_config('DEFAULT/transport_url').with_value(param_hash[:transport_url])
  101. end
  102. it 'is_expected.to configure service credentials' do
  103. is_expected.to contain_novajoin_config('service_credentials/auth_type').with_value(param_hash[:auth_type])
  104. is_expected.to contain_novajoin_config('service_credentials/auth_url').with_value(param_hash[:keystone_auth_url])
  105. is_expected.to contain_novajoin_config('service_credentials/password').with_value(param_hash[:nova_password])
  106. is_expected.to contain_novajoin_config('service_credentials/project_name').with_value(param_hash[:project_name])
  107. is_expected.to contain_novajoin_config('service_credentials/user_domain_id').with_value(param_hash[:user_domain_id])
  108. is_expected.to contain_novajoin_config('service_credentials/project_domain_name').with_value(param_hash[:project_domain_name])
  109. is_expected.to contain_novajoin_config('service_credentials/username').with_value(param_hash[:nova_user])
  110. end
  111. it 'is_expected.to get service user keytab' do
  112. is_expected.to contain_exec('get-service-user-keytab').with(
  113. 'command' => "/usr/bin/kinit -kt /etc/krb5.keytab && ipa-getkeytab -s `grep xmlrpc_uri /etc/ipa/default.conf | cut -d/ -f3` \
  114. -p nova/undercloud.example.com -k #{param_hash[:keytab]}",
  115. )
  116. end
  117. it { is_expected.to contain_file("#{param_hash[:keytab]}").with(
  118. 'owner' => "#{param_hash[:nova_user]}",
  119. 'require' => 'Exec[get-service-user-keytab]',
  120. )}
  121. end
  122. end
  123. describe 'with disabled service managing' do
  124. let :facts do
  125. OSDefaults.get_facts({
  126. :osfamily => 'RedHat',
  127. :operatingsystem => 'RedHat',
  128. :operatingsystemrelease => '7.0',
  129. })
  130. end
  131. let :params do
  132. {
  133. :manage_service => false,
  134. :enabled => false,
  135. :ipa_domain => 'EXAMPLE.COM',
  136. :nova_password => 'my_secret_password',
  137. :transport_url => 'rabbit:rabbit_pass@rabbit_host',
  138. }
  139. end
  140. let :pre_condition do
  141. 'class { "::ipaclient": password => "join_otp", }'
  142. end
  143. it { is_expected.to contain_service('novajoin-server').with(
  144. 'ensure' => nil,
  145. 'enable' => false,
  146. 'hasstatus' => true,
  147. 'hasrestart' => true,
  148. 'tag' => 'openstack',
  149. ) }
  150. it { is_expected.to contain_service('novajoin-notify').with(
  151. 'ensure' => nil,
  152. 'enable' => false,
  153. 'hasstatus' => true,
  154. 'hasrestart' => true,
  155. 'tag' => 'openstack',
  156. ) }
  157. end
  158. describe 'on RedHat platforms' do
  159. let :facts do
  160. OSDefaults.get_facts({
  161. :osfamily => 'RedHat',
  162. :operatingsystem => 'RedHat',
  163. :operatingsystemrelease => '7.0',
  164. })
  165. end
  166. let(:params) { default_params }
  167. let :pre_condition do
  168. 'class { "::ipaclient": password => "join_otp", }'
  169. end
  170. it { is_expected.to contain_package('python-novajoin').with(
  171. :tag => ['openstack', 'novajoin-package'],
  172. )}
  173. end
  174. end