try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / nova / spec / classes / nova_cells_spec.rb
1 #
2 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 #         François 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
22 require 'spec_helper'
23
24 describe 'nova::cells' do
25
26   let :pre_condition do
27     "include nova"
28   end
29
30   let :default_params do
31     {:enabled                       => true,
32      :bandwidth_update_interval     => '600',
33      :call_timeout                  => '60',
34      :capabilities                  => ['hypervisor=xenserver;kvm','os=linux;windows'],
35      :db_check_interval             => '60',
36      :driver                        => 'nova.cells.rpc_driver.CellsRPCDriver',
37      :instance_updated_at_threshold => '3600',
38      :instance_update_num_instances => '1',
39      :manager                       => 'nova.cells.manager.CellsManager',
40      :max_hop_count                 => '10',
41      :mute_child_interval           => '300',
42      :mute_weight_multiplier        => '-10.0',
43      :mute_weight_value             => '1000.0',
44      :ram_weight_multiplier         => '10.0',
45      :reserve_percent               => '10.0',
46      :rpc_driver_queue_base         => 'cells.intercell',
47      :scheduler_filter_classes      => 'nova.cells.filters.all_filters',
48      :scheduler                     => 'nova.cells.scheduler.CellsScheduler',
49      :scheduler_retries             => '10',
50      :scheduler_retry_delay         => '2',
51      :scheduler_weight_classes      => 'nova.cells.weights.all_weighers',
52      :weight_offset                 => '1.0',
53      :weight_scale                  => '1.0'}
54   end
55
56   shared_examples_for 'nova-cells' do
57
58     it { should contain_class('nova::params') }
59
60     it 'installs nova-cells package' do
61       should contain_package('nova-cells').with(
62         :ensure => 'present',
63         :name   => platform_params[:cells_package_name],
64         :tag    => ['openstack', 'nova']
65       )
66     end
67
68     it 'configures nova-cells service' do
69       should contain_service('nova-cells').with(
70         :ensure     => 'running',
71         :name       => platform_params[:cells_service_name]
72       )
73     end
74
75     it 'configures cell' do
76       should contain_nova_config('cells/bandwidth_update_interval').with(:value => '600')
77       should contain_nova_config('cells/call_timeout').with(:value => '60')
78       should contain_nova_config('cells/capabilities').with(:value => 'hypervisor=xenserver;kvm,os=linux;windows')
79       should contain_nova_config('cells/db_check_interval').with(:value => '60')
80       should contain_nova_config('cells/driver').with(:value => 'nova.cells.rpc_driver.CellsRPCDriver')
81       should contain_nova_config('cells/instance_updated_at_threshold').with(:value => '3600')
82       should contain_nova_config('cells/instance_update_num_instances').with(:value => '1')
83       should contain_nova_config('cells/manager').with(:value => 'nova.cells.manager.CellsManager')
84       should contain_nova_config('cells/max_hop_count').with(:value => '10')
85       should contain_nova_config('cells/mute_child_interval').with(:value => '300')
86       should contain_nova_config('cells/mute_weight_multiplier').with(:value => '-10.0')
87       should contain_nova_config('cells/mute_weight_value').with(:value => '1000.0')
88       should contain_nova_config('cells/ram_weight_multiplier').with(:value => '10.0')
89       should contain_nova_config('cells/reserve_percent').with(:value => '10.0')
90       should contain_nova_config('cells/rpc_driver_queue_base').with(:value => 'cells.intercell')
91       should contain_nova_config('cells/scheduler_filter_classes').with(:value => 'nova.cells.filters.all_filters')
92       should contain_nova_config('cells/scheduler_retries').with(:value => '10')
93       should contain_nova_config('cells/scheduler_retry_delay').with(:value => '2')
94       should contain_nova_config('cells/scheduler_weight_classes').with(:value => 'nova.cells.weights.all_weighers')
95       should contain_nova_config('cells/scheduler').with(:value => 'nova.cells.scheduler.CellsScheduler')
96     end
97   end
98
99   shared_examples_for 'a parent cell' do
100     let :params do
101       { :enabled   => true,
102         :cell_type => 'parent',
103         :cell_name => 'mommy' }
104     end
105     let :expected_params do
106       default_params.merge(params)
107     end
108     it { should contain_nova_config('cells/name').with_value(expected_params[:cell_name]) }
109     it { should contain_nova_config('DEFAULT/compute_api_class').with_value('nova.compute.cells_api.ComputeCellsAPI')}
110     it { should contain_nova_config('cells/cell_type').with_value('api')}
111     it_configures 'nova-cells'
112   end
113
114   shared_examples_for 'a parent cell with manage_service as false' do
115     let :params do
116       { :enabled   => true,
117         :manage_service => false,
118         :cell_type => 'parent',
119         :cell_name => 'mommy' }
120     end
121     let :expected_params do
122       default_params.merge(params)
123     end
124     it { should contain_service(platform_params[:cells_service_name]).without_ensure }
125   end
126
127   shared_examples_for 'a child cell' do
128     let :params do
129       { :enabled   => true,
130         :cell_type => 'child',
131         :cell_name => 'henry' }
132     end
133     let :expected_params do
134       default_params.merge(params)
135     end
136     it { should contain_nova_config('cells/name').with_value(expected_params[:cell_name]) }
137     it { should contain_nova_config('DEFAULT/quota_driver').with_value('nova.quota.NoopQuotaDriver')}
138     it { should contain_nova_config('cells/cell_type').with_value('compute')}
139     it_configures 'nova-cells'
140   end
141
142
143   context 'on Debian platforms' do
144     let :facts do
145       { :osfamily => 'Debian' }
146     end
147
148     let :platform_params do
149       {
150         :cells_package_name => 'nova-cells',
151         :cells_service_name => 'nova-cells'
152       }
153     end
154
155     it_configures 'a parent cell'
156     it_configures 'a parent cell with manage_service as false'
157     it_configures 'a child cell'
158   end
159
160   context 'on RedHat platforms' do
161     let :facts do
162       { :osfamily => 'RedHat' }
163     end
164
165     let :platform_params do
166       {
167         :cells_package_name => 'openstack-nova-cells',
168         :cells_service_name => 'openstack-nova-cells'
169       }
170     end
171
172     it_configures 'a parent cell'
173     it_configures 'a child cell'
174   end
175
176 end