Fuel Library
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.

proxy_storage_spec.rb 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. # ROLE: primary-controller
  2. # ROLE: controller
  3. require 'spec_helper'
  4. require 'shared-examples'
  5. manifest = 'swift/proxy_storage.pp'
  6. describe manifest do
  7. shared_examples 'catalog' do
  8. workers_max = Noop.hiera 'workers_max'
  9. role = Noop.hiera 'role'
  10. storage_hash = Noop.hiera_hash 'storage'
  11. swift_hash = Noop.hiera_hash 'swift'
  12. rabbit_hash = Noop.hiera_structure 'rabbit', {}
  13. network_scheme = Noop.hiera_hash 'network_scheme'
  14. let(:memcached_servers) { Noop.hiera 'memcached_servers' }
  15. management_vip = Noop.hiera('management_vip')
  16. swift_operator_roles = storage_hash.fetch('swift_operator_roles', ['admin', 'SwiftOperator', '_member_'])
  17. ring_part_power = swift_hash.fetch('ring_part_power', 10)
  18. ring_min_part_hours = Noop.hiera 'swift_ring_min_part_hours', 1
  19. deploy_swift_proxy = Noop.hiera('deploy_swift_proxy', true)
  20. deploy_swift_storage = Noop.hiera('deploy_swift_storage', true)
  21. swift_proxies_num = (Noop.hiera('swift_proxies')).size
  22. let(:transport_url) { Noop.hiera 'transport_url', 'rabbit://guest:password@127.0.0.1:5672/' }
  23. network_scheme = Noop.hiera_hash 'network_scheme'
  24. internal_virtual_ip = Noop.hiera_structure('network_metadata/vips/management/ipaddr')
  25. if swift_proxies_num < 2
  26. ring_replicas = 2
  27. else
  28. ring_replicas = 3
  29. end
  30. let (:storage_nets){
  31. Noop.puppet_function 'get_routable_networks_for_network_role', network_scheme, 'swift/replication', ' '
  32. }
  33. let (:mgmt_nets){
  34. Noop.puppet_function 'get_routable_networks_for_network_role', network_scheme, 'swift/api', ' '
  35. }
  36. let (:bind_to_one) {
  37. api_net = Noop.puppet_function 'get_network_role_property', 'swift/api', 'network'
  38. Noop.puppet_function 'has_ip_in_network', internal_virtual_ip, api_net
  39. }
  40. let(:ssl_hash) { Noop.hiera_hash 'use_ssl', {} }
  41. let(:public_ssl_hash) { Noop.hiera_hash 'public_ssl', {} }
  42. let(:internal_auth_protocol) { Noop.puppet_function 'get_ssl_property',ssl_hash,{},'keystone','internal','protocol','http' }
  43. let(:internal_auth_address) { Noop.puppet_function 'get_ssl_property',ssl_hash,{},'keystone','internal','hostname',[Noop.hiera('service_endpoint', ''), management_vip] }
  44. let(:admin_auth_protocol) { Noop.puppet_function 'get_ssl_property',ssl_hash,{},'keystone','admin','protocol','http' }
  45. let(:admin_auth_address) { Noop.puppet_function 'get_ssl_property',ssl_hash,{},'keystone','admin','hostname',[Noop.hiera('service_endpoint', ''), management_vip] }
  46. let(:auth_uri) { "#{internal_auth_protocol}://#{internal_auth_address}:5000/" }
  47. let(:identity_uri) { "#{admin_auth_protocol}://#{admin_auth_address}:35357/" }
  48. let(:proxy_port) { Noop.hiera 'proxy_port', '8080' }
  49. let(:swift_api_ipaddr) { Noop.puppet_function 'get_network_role_property', 'swift/api', 'ipaddr' }
  50. let(:swift_internal_protocol) { Noop.puppet_function 'get_ssl_property',ssl_hash,{},'swift','internal','protocol','http' }
  51. let(:swift_interal_address) { Noop.puppet_function 'get_ssl_property',ssl_hash,{},'swift','internal','hostname',[swift_api_ipaddr, management_vip] }
  52. let(:swift_public_protocol) { Noop.puppet_function 'get_ssl_property',ssl_hash,public_ssl_hash,'swift','public','protocol','http' }
  53. let(:swift_public_address) { Noop.puppet_function 'get_ssl_property',ssl_hash,public_ssl_hash,'swift','public','hostname',[Noop.hiera('public_vip')] }
  54. let(:swift_url_base) {"#{swift_public_protocol}:"}
  55. # Swift
  56. if !(storage_hash['images_ceph'] and storage_hash['objects_ceph'])
  57. swift_partition = Noop.hiera 'swift_partition'
  58. if role == 'primary-controller'
  59. ['account', 'object', 'container'].each do | ring |
  60. it "should run rebalancing swift #{ring} ring" do
  61. should contain_exec("rebalance_#{ring}").with(
  62. 'command' => "swift-ring-builder /etc/swift/#{ring}.builder rebalance",
  63. 'user' => 'swift',
  64. 'returns' => [0,1],
  65. )
  66. should contain_exec("create_#{ring}").with(
  67. 'command' => "swift-ring-builder /etc/swift/#{ring}.builder create #{ring_part_power} #{ring_replicas} #{ring_min_part_hours}",
  68. 'user' => 'swift',
  69. )
  70. end
  71. end
  72. ['account', 'object', 'container'].each do | ring |
  73. it "should define swift::ringbuilder::rebalance[#{ring}] before swift proxy service" do
  74. should contain_swift__ringbuilder__rebalance(ring).that_comes_before('Service[swift-proxy-server]')
  75. end
  76. end
  77. ['account', 'object', 'container'].each do | ring |
  78. ['account', 'object', 'container'].each do | storage |
  79. it "should define swift::ringbuilder::rebalance[#{ring}] before swift::storage::generic[#{storage}]" do
  80. # expect(graph).to ensure_transitive_dependency("Swift::Ringbuilder::Rebalance[#{ring}]",
  81. # "Swift::Storage::Generic[#{storage}]")
  82. end
  83. end
  84. end
  85. end
  86. it 'should declare swift::proxy::cache class with correct memcache_servers parameter' do
  87. should contain_class('swift::proxy::cache').with(
  88. 'memcache_servers' => memcached_servers,
  89. )
  90. end
  91. it 'should declare class swift::proxy::keystone with correct operator_roles parameter' do
  92. should contain_class('swift::proxy::keystone').with(
  93. 'operator_roles' => swift_operator_roles,
  94. )
  95. end
  96. it 'should configure proxy workers' do
  97. fallback_workers = [[facts[:processorcount].to_i, 2].max, workers_max.to_i].min
  98. workers = swift_hash.fetch('workers', fallback_workers)
  99. should contain_class('swift::proxy').with(
  100. 'workers' => workers)
  101. end
  102. it 'should declare swift::proxy class with 4 processess on 4 CPU & 32G system' do
  103. should contain_class('swift::proxy').with(
  104. 'workers' => '4',
  105. )
  106. end
  107. if !swift_partition
  108. swift_partition = '/var/lib/glance/node'
  109. it 'should allow swift user to write into /var/lib/glance directory' do
  110. should contain_file('/var/lib/glance').with(
  111. 'ensure' => 'directory',
  112. 'group' => 'glance',
  113. ).that_requires('Package[swift]')
  114. end
  115. end
  116. it 'should disable mount check for swift devices' do
  117. should contain_class('swift::storage::all').with('mount_check' => false)
  118. end
  119. it 'should configure swift on separate partition' do
  120. should contain_file(swift_partition).with(
  121. 'ensure' => 'directory',
  122. 'owner' => 'swift',
  123. 'group' => 'swift',
  124. )
  125. end
  126. if deploy_swift_proxy
  127. it 'should configure proxy workers' do
  128. fallback_workers = [[facts[:processorcount].to_i, 2].max, workers_max.to_i].min
  129. workers = swift_hash.fetch('workers', fallback_workers)
  130. should contain_class('swift::proxy').with(
  131. 'workers' => workers)
  132. end
  133. it 'should declare swift::proxy class with 4 processess on 4 CPU & 32G system' do
  134. should contain_class('swift::proxy').with(
  135. 'workers' => '4',
  136. )
  137. end
  138. it 'should contain correct transport url' do
  139. should contain_class('openstack_tasks::swift::parts::proxy').with(
  140. :transport_url => transport_url
  141. )
  142. end
  143. it 'should contain correct swift url base' do
  144. should contain_class('openstack_tasks::swift::parts::proxy').with(
  145. :swift_url_base => swift_url_base
  146. )
  147. end
  148. it 'should contain memcached params' do
  149. should contain_class('openstack_tasks::swift::parts::proxy').with(
  150. :memcached_servers => memcached_servers
  151. )
  152. end
  153. it 'should configure health check service correctly' do
  154. if !bind_to_one
  155. should_not contain_class('openstack_tasks::swift:::parts::status').with(
  156. :endpoint => "#{swift_internal_protocol}://#{swift_internal_address}:#{proxy_port}",
  157. :scan_target => "#{internal_auth_address}:5000",
  158. :only_from => "127.0.0.1 240.0.0.2 #{storage_nets} #{mgmt_nets}",
  159. :con_timeout => 5
  160. ).that_comes_before('Class[swift::dispersion]')
  161. else
  162. should_not contain_class('openstack_tasks::swift::parts:status')
  163. end
  164. end
  165. it 'should contain valid auth uris' do
  166. should contain_class('swift::proxy::authtoken').with(
  167. 'auth_uri' => auth_uri,
  168. 'identity_uri' => identity_uri,
  169. )
  170. end
  171. it 'should contain container_sync class' do
  172. should contain_class('swift::proxy::container_sync')
  173. end
  174. if Noop.hiera 'is_primary_swift_proxy'
  175. it 'should contain swift backups section in rsync conf' do
  176. should contain_rsync__server__module('swift_backups').with(
  177. 'path' => '/etc/swift/backups',
  178. 'lock_file' => '/var/lock/swift_backups.lock',
  179. 'uid' => 'swift',
  180. 'gid' => 'swift',
  181. 'incoming_chmod' => false,
  182. 'outgoing_chmod' => false,
  183. 'max_connections' => '5',
  184. 'read_only' => true,
  185. )
  186. end
  187. end
  188. end
  189. if deploy_swift_storage
  190. it 'should disable swift-container-reconciler service' do
  191. should contain_service('swift-container-reconciler').with(
  192. 'ensure' => 'stopped',
  193. 'enable' => 'false',
  194. ).that_requires('Package[swift-container]')
  195. end
  196. it 'should disable swift-object-reconstructor service' do
  197. should contain_service('swift-object-reconstructor').with(
  198. 'ensure' => 'stopped',
  199. 'enable' => 'false',
  200. ).that_requires('Package[swift-object]')
  201. end
  202. end
  203. if deploy_swift_proxy or deploy_swift_storage
  204. realm1_key = Noop.hiera('swift_realm1_key', 'realm1key')
  205. it 'should contain swift_container-sync-realms config' do
  206. should contain_swift_container_sync_realms_config('realm1/key').with_value(realm1_key)
  207. should contain_swift_container_sync_realms_config('realm1/cluster_name1').with_value("#{swift_public_protocol}://#{swift_public_address}:8080/v1")
  208. end
  209. end
  210. end
  211. end
  212. test_ubuntu_and_centos manifest
  213. end