3 describe 'neutron::server' do
6 "class { 'neutron': rabbit_password => 'passw0rd' }"
10 { :auth_password => 'passw0rd',
11 :auth_user => 'neutron' }
14 let :default_params do
15 { :package_ensure => 'present',
17 :auth_type => 'keystone',
18 :auth_host => 'localhost',
19 :auth_port => '35357',
20 :auth_tenant => 'services',
21 :auth_user => 'neutron',
22 :database_connection => 'sqlite:////var/lib/neutron/ovs.sqlite',
23 :database_max_retries => '10',
24 :database_idle_timeout => '3600',
25 :database_retry_interval => '10',
26 :database_min_pool_size => '1',
27 :database_max_pool_size => '10',
28 :database_max_overflow => '20',
30 :agent_down_time => '75',
31 :router_scheduler_driver => 'neutron.scheduler.l3_agent_scheduler.ChanceScheduler',
32 :router_distributed => false,
34 :max_l3_agents_per_router => '3',
35 :min_l3_agents_per_router => '2',
36 :l3_ha_net_cidr => '169.254.192.0/18'
40 shared_examples_for 'a neutron server' do
42 default_params.merge(params)
45 it 'should perform default database configuration of' do
46 should contain_neutron_config('database/connection').with_value(p[:database_connection])
47 should contain_neutron_config('database/connection').with_secret( true )
48 should contain_neutron_config('database/max_retries').with_value(p[:database_max_retries])
49 should contain_neutron_config('database/idle_timeout').with_value(p[:database_idle_timeout])
50 should contain_neutron_config('database/retry_interval').with_value(p[:database_retry_interval])
51 should contain_neutron_config('database/min_pool_size').with_value(p[:database_min_pool_size])
52 should contain_neutron_config('database/max_pool_size').with_value(p[:database_max_pool_size])
53 should contain_neutron_config('database/max_overflow').with_value(p[:database_max_overflow])
56 it { should contain_class('neutron::params') }
57 it { should contain_class('neutron::policy') }
59 it 'configures authentication middleware' do
60 should contain_neutron_api_config('filter:authtoken/auth_host').with_value(p[:auth_host]);
61 should contain_neutron_api_config('filter:authtoken/auth_port').with_value(p[:auth_port]);
62 should contain_neutron_api_config('filter:authtoken/admin_tenant_name').with_value(p[:auth_tenant]);
63 should contain_neutron_api_config('filter:authtoken/admin_user').with_value(p[:auth_user]);
64 should contain_neutron_api_config('filter:authtoken/admin_password').with_value(p[:auth_password]);
65 should contain_neutron_api_config('filter:authtoken/admin_password').with_secret( true )
66 should contain_neutron_api_config('filter:authtoken/auth_admin_prefix').with(:ensure => 'absent')
67 should contain_neutron_api_config('filter:authtoken/auth_uri').with_value("http://localhost:5000/");
70 it 'installs neutron server package' do
71 if platform_params.has_key?(:server_package)
72 should contain_package('neutron-server').with(
73 :name => platform_params[:server_package],
74 :ensure => p[:package_ensure]
76 should contain_package('neutron-server').with_before(/Neutron_api_config\[.+\]/)
77 should contain_package('neutron-server').with_before(/Neutron_config\[.+\]/)
78 should contain_package('neutron-server').with_before(/Service\[neutron-server\]/)
80 should contain_package('neutron').with_before(/Neutron_api_config\[.+\]/)
84 it 'configures neutron server service' do
85 should contain_service('neutron-server').with(
86 :name => platform_params[:server_service],
89 :require => 'Class[Neutron]'
91 should_not contain_exec('neutron-db-sync')
92 should contain_neutron_api_config('filter:authtoken/auth_admin_prefix').with(
95 should contain_neutron_config('DEFAULT/api_workers').with_value(facts[:processorcount])
96 should contain_neutron_config('DEFAULT/rpc_workers').with_value(facts[:processorcount])
97 should contain_neutron_config('DEFAULT/agent_down_time').with_value(p[:agent_down_time])
98 should contain_neutron_config('DEFAULT/router_scheduler_driver').with_value(p[:router_scheduler_driver])
101 context 'with manage_service as false' do
103 params.merge!(:manage_service => false)
105 it 'should not start/stop service' do
106 should contain_service('neutron-server').without_ensure
110 context 'with DVR enabled' do
112 params.merge!(:router_distributed => true)
114 it 'should enable DVR' do
115 should contain_neutron_config('DEFAULT/router_distributed').with_value(true)
119 context 'with HA routers enabled' do
121 params.merge!(:l3_ha => true)
123 it 'should enable HA routers' do
124 should contain_neutron_config('DEFAULT/l3_ha').with_value(true)
125 should contain_neutron_config('DEFAULT/max_l3_agents_per_router').with_value('3')
126 should contain_neutron_config('DEFAULT/min_l3_agents_per_router').with_value('2')
127 should contain_neutron_config('DEFAULT/l3_ha_net_cidr').with_value('169.254.192.0/18')
131 context 'with HA routers disabled' do
133 params.merge!(:l3_ha => false)
135 it 'should disable HA routers' do
136 should contain_neutron_config('DEFAULT/l3_ha').with_value(false)
140 context 'with HA routers enabled with unlimited l3 agents per router' do
142 params.merge!(:l3_ha => true,
143 :max_l3_agents_per_router => '0' )
145 it 'should enable HA routers' do
146 should contain_neutron_config('DEFAULT/max_l3_agents_per_router').with_value('0')
150 context 'with HA routers enabled and wrong parameters' do
152 params.merge!(:l3_ha => true,
153 :max_l3_agents_per_router => '2',
154 :min_l3_agents_per_router => '3' )
156 it 'should fail to configure HA routerd' do
157 expect { subject }.to raise_error(Puppet::Error, /min_l3_agents_per_router should be less than or equal to max_l3_agents_per_router./)
162 shared_examples_for 'a neutron server with auth_admin_prefix set' do
163 [ '/keystone', '/keystone/admin', '' ].each do |auth_admin_prefix|
164 describe "with keystone_auth_admin_prefix containing incorrect value #{auth_admin_prefix}" do
167 :auth_admin_prefix => auth_admin_prefix,
171 should contain_neutron_api_config('filter:authtoken/auth_admin_prefix').with(
172 :value => params[:auth_admin_prefix]
179 shared_examples_for 'a neutron server with some incorrect auth_admin_prefix set' do
180 [ '/keystone/', 'keystone/', 'keystone' ].each do |auth_admin_prefix|
181 describe "with keystone_auth_admin_prefix containing incorrect value #{auth_admin_prefix}" do
184 :auth_admin_prefix => auth_admin_prefix,
189 should contain_neutron_api_config('filter:authtoken/auth_admin_prefix')
190 }.to raise_error(Puppet::Error, /validate_re\(\): "#{auth_admin_prefix}" does not match/)
196 shared_examples_for 'a neutron server with broken authentication' do
198 params.delete(:auth_password)
200 it_raises 'a Puppet::Error', /auth_password must be set/
203 shared_examples_for 'a neutron server with removed log_dir parameter' do
204 before { params.merge!({ :log_dir => '/var/log/neutron' })}
205 it_raises 'a Puppet::Error', /log_dir parameter is removed/
208 shared_examples_for 'a neutron server with removed log_file parameter' do
209 before { params.merge!({ :log_file => '/var/log/neutron/blah.log' })}
210 it_raises 'a Puppet::Error', /log_file parameter is removed/
213 shared_examples_for 'a neutron server without database synchronization' do
219 it 'should exec neutron-db-sync' do
220 should contain_exec('neutron-db-sync').with(
221 :command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head',
223 :before => 'Service[neutron-server]',
224 :require => 'Neutron_config[database/connection]',
230 shared_examples_for 'a neutron server with deprecated parameters' do
232 context 'first generation' do
235 :sql_connection => 'sqlite:////var/lib/neutron/ovs-deprecated_parameter.sqlite',
236 :database_connection => 'sqlite:////var/lib/neutron/ovs-IGNORED_parameter.sqlite',
237 :sql_max_retries => 20,
238 :database_max_retries => 90,
239 :sql_idle_timeout => 21,
240 :database_idle_timeout => 91,
241 :sql_reconnect_interval => 22,
242 :database_retry_interval => 92,
246 it 'configures database connection with deprecated parameters' do
247 should contain_neutron_config('database/connection').with_value(params[:sql_connection])
248 should contain_neutron_config('database/max_retries').with_value(params[:sql_max_retries])
249 should contain_neutron_config('database/idle_timeout').with_value(params[:sql_idle_timeout])
250 should contain_neutron_config('database/retry_interval').with_value(params[:sql_reconnect_interval])
254 context 'second generation' do
257 :connection => 'sqlite:////var/lib/neutron/ovs-deprecated_parameter.sqlite',
258 :database_connection => 'sqlite:////var/lib/neutron/ovs-IGNORED_parameter.sqlite',
260 :database_max_retries => 90,
262 :database_idle_timeout => 91,
263 :retry_interval => 22,
264 :database_retry_interval => 92,
268 it 'configures database connection with deprecated parameters' do
269 should contain_neutron_config('database/connection').with_value(params[:connection])
270 should contain_neutron_config('database/max_retries').with_value(params[:max_retries])
271 should contain_neutron_config('database/idle_timeout').with_value(params[:idle_timeout])
272 should contain_neutron_config('database/retry_interval').with_value(params[:retry_interval])
277 shared_examples_for 'a neutron server with database_connection specified' do
280 :database_connection => 'sqlite:////var/lib/neutron/ovs-TEST_parameter.sqlite'
283 it 'configures database connection' do
284 should contain_neutron_config('database/connection').with_value(params[:database_connection])
288 describe "with custom keystone auth_uri" do
290 { :osfamily => 'RedHat' }
294 :auth_uri => 'https://foo.bar:1234/',
297 it 'configures auth_uri' do
298 should contain_neutron_api_config('filter:authtoken/auth_uri').with_value("https://foo.bar:1234/");
302 context 'on Debian platforms' do
304 { :osfamily => 'Debian',
305 :processorcount => '2' }
308 let :platform_params do
309 { :server_package => 'neutron-server',
310 :server_service => 'neutron-server' }
313 it_configures 'a neutron server'
314 it_configures 'a neutron server with broken authentication'
315 it_configures 'a neutron server with auth_admin_prefix set'
316 it_configures 'a neutron server with some incorrect auth_admin_prefix set'
317 it_configures 'a neutron server with deprecated parameters'
318 it_configures 'a neutron server with database_connection specified'
319 it_configures 'a neutron server without database synchronization'
320 it_configures 'a neutron server with removed log_file parameter'
321 it_configures 'a neutron server with removed log_dir parameter'
324 context 'on RedHat platforms' do
326 { :osfamily => 'RedHat',
327 :processorcount => '2' }
330 let :platform_params do
331 { :server_service => 'neutron-server' }
334 it_configures 'a neutron server'
335 it_configures 'a neutron server with broken authentication'
336 it_configures 'a neutron server with auth_admin_prefix set'
337 it_configures 'a neutron server with some incorrect auth_admin_prefix set'
338 it_configures 'a neutron server with deprecated parameters'
339 it_configures 'a neutron server with database_connection specified'
340 it_configures 'a neutron server without database synchronization'
341 it_configures 'a neutron server with removed log_file parameter'
342 it_configures 'a neutron server with removed log_dir parameter'