nova_cells_spec.rb 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #
  2. # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
  3. #
  4. # Author: Emilien Macchi <emilien.macchi@enovance.com>
  5. # Francois Charlier <francois.charlier@enovance.com>
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  8. # not use this file except in compliance with the License. You may obtain
  9. # a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. # License for the specific language governing permissions and limitations
  17. # under the License.
  18. #
  19. # Unit tests for nova::cells class
  20. #
  21. require 'spec_helper'
  22. describe 'nova::cells' do
  23. let :pre_condition do
  24. "include nova"
  25. end
  26. let :default_params do
  27. {:enabled => true,
  28. :bandwidth_update_interval => '600',
  29. :call_timeout => '60',
  30. :capabilities => ['hypervisor=xenserver;kvm','os=linux;windows'],
  31. :db_check_interval => '60',
  32. :instance_updated_at_threshold => '3600',
  33. :instance_update_num_instances => '1',
  34. :max_hop_count => '10',
  35. :mute_child_interval => '300',
  36. :mute_weight_multiplier => '-10.0',
  37. :mute_weight_value => '1000.0',
  38. :ram_weight_multiplier => '10.0',
  39. :reserve_percent => '10.0',
  40. :rpc_driver_queue_base => 'cells.intercell',
  41. :scheduler_filter_classes => 'nova.cells.filters.all_filters',
  42. :scheduler => 'nova.cells.scheduler.CellsScheduler',
  43. :scheduler_retries => '10',
  44. :scheduler_retry_delay => '2',
  45. :scheduler_weight_classes => 'nova.cells.weights.all_weighers',
  46. :weight_offset => '1.0',
  47. :weight_scale => '1.0'}
  48. end
  49. shared_examples_for 'nova-cells' do
  50. it { is_expected.to contain_class('nova::params') }
  51. it 'installs nova-cells package' do
  52. is_expected.to contain_package('nova-cells').with(
  53. :ensure => 'present',
  54. :name => platform_params[:cells_package_name],
  55. :tag => ['openstack', 'nova-package']
  56. )
  57. end
  58. it 'configures nova-cells service' do
  59. is_expected.to contain_service('nova-cells').with(
  60. :ensure => 'running',
  61. :name => platform_params[:cells_service_name],
  62. :tag => 'nova-service'
  63. )
  64. end
  65. it 'configures cell' do
  66. is_expected.to contain_nova_config('cells/bandwidth_update_interval').with(:value => '600')
  67. is_expected.to contain_nova_config('cells/call_timeout').with(:value => '60')
  68. is_expected.to contain_nova_config('cells/capabilities').with(:value => 'hypervisor=xenserver;kvm,os=linux;windows')
  69. is_expected.to contain_nova_config('cells/db_check_interval').with(:value => '60')
  70. is_expected.to contain_nova_config('cells/instance_updated_at_threshold').with(:value => '3600')
  71. is_expected.to contain_nova_config('cells/instance_update_num_instances').with(:value => '1')
  72. is_expected.to contain_nova_config('cells/max_hop_count').with(:value => '10')
  73. is_expected.to contain_nova_config('cells/mute_child_interval').with(:value => '300')
  74. is_expected.to contain_nova_config('cells/mute_weight_multiplier').with(:value => '-10.0')
  75. is_expected.to contain_nova_config('cells/mute_weight_value').with(:value => '1000.0')
  76. is_expected.to contain_nova_config('cells/ram_weight_multiplier').with(:value => '10.0')
  77. is_expected.to contain_nova_config('cells/reserve_percent').with(:value => '10.0')
  78. is_expected.to contain_nova_config('cells/rpc_driver_queue_base').with(:value => 'cells.intercell')
  79. is_expected.to contain_nova_config('cells/scheduler_filter_classes').with(:value => 'nova.cells.filters.all_filters')
  80. is_expected.to contain_nova_config('cells/scheduler_retries').with(:value => '10')
  81. is_expected.to contain_nova_config('cells/scheduler_retry_delay').with(:value => '2')
  82. is_expected.to contain_nova_config('cells/scheduler_weight_classes').with(:value => 'nova.cells.weights.all_weighers')
  83. is_expected.to contain_nova_config('cells/scheduler').with(:value => 'nova.cells.scheduler.CellsScheduler')
  84. end
  85. end
  86. shared_examples_for 'a parent cell' do
  87. let :params do
  88. { :enabled => true,
  89. :cell_type => 'parent',
  90. :cell_name => 'mommy' }
  91. end
  92. let :expected_params do
  93. default_params.merge(params)
  94. end
  95. it { is_expected.to contain_nova_config('cells/name').with_value(expected_params[:cell_name]) }
  96. it { is_expected.to contain_nova_config('DEFAULT/compute_api_class').with_value('nova.compute.cells_api.ComputeCellsAPI')}
  97. it { is_expected.to contain_nova_config('cells/cell_type').with_value('api')}
  98. it_configures 'nova-cells'
  99. end
  100. shared_examples_for 'a parent cell with manage_service as false' do
  101. let :params do
  102. { :enabled => true,
  103. :manage_service => false,
  104. :cell_type => 'parent',
  105. :cell_name => 'mommy' }
  106. end
  107. let :expected_params do
  108. default_params.merge(params)
  109. end
  110. it { is_expected.to contain_service(platform_params[:cells_service_name]).without_ensure }
  111. end
  112. shared_examples_for 'a child cell' do
  113. let :params do
  114. { :enabled => true,
  115. :cell_type => 'child',
  116. :cell_name => 'henry' }
  117. end
  118. let :expected_params do
  119. default_params.merge(params)
  120. end
  121. it { is_expected.to contain_nova_config('cells/name').with_value(expected_params[:cell_name]) }
  122. it { is_expected.to contain_nova_config('cells/cell_type').with_value('compute')}
  123. it_configures 'nova-cells'
  124. end
  125. on_supported_os({
  126. :supported_os => OSDefaults.get_supported_os
  127. }).each do |os,facts|
  128. context "on #{os}" do
  129. let (:facts) do
  130. facts.merge!(OSDefaults.get_facts())
  131. end
  132. case facts[:osfamily]
  133. when 'Debian'
  134. let (:platform_params) do
  135. {
  136. :cells_package_name => 'nova-cells',
  137. :cells_service_name => 'nova-cells'
  138. }
  139. end
  140. it_configures 'a parent cell with manage_service as false'
  141. when 'RedHat'
  142. let (:platform_params) do
  143. {
  144. :cells_package_name => 'openstack-nova-cells',
  145. :cells_service_name => 'openstack-nova-cells'
  146. }
  147. end
  148. end
  149. it_configures 'a parent cell'
  150. it_configures 'a child cell'
  151. end
  152. end
  153. end