1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
13 # Unit tests for neutron::server::notifications class
18 describe 'neutron::server::notifications' do
20 'define keystone_user ($name) {}'
23 let :default_params do
25 :notify_nova_on_port_status_changes => true,
26 :notify_nova_on_port_data_changes => true,
27 :send_events_interval => '2',
28 :nova_url => 'http://127.0.0.1:8774/v2',
29 :nova_admin_auth_url => 'http://127.0.0.1:35357/v2.0',
30 :nova_admin_username => 'nova',
31 :nova_admin_tenant_name => 'services',
32 :nova_region_name => 'RegionOne'
38 :nova_admin_password => 'secrete',
39 :nova_admin_tenant_id => 'UUID'
43 shared_examples_for 'neutron server notifications' do
45 default_params.merge(params)
48 it 'configure neutron.conf' do
49 should contain_neutron_config('DEFAULT/notify_nova_on_port_status_changes').with_value(true)
50 should contain_neutron_config('DEFAULT/notify_nova_on_port_data_changes').with_value(true)
51 should contain_neutron_config('DEFAULT/send_events_interval').with_value('2')
52 should contain_neutron_config('DEFAULT/nova_url').with_value('http://127.0.0.1:8774/v2')
53 should contain_neutron_config('DEFAULT/nova_admin_auth_url').with_value('http://127.0.0.1:35357/v2.0')
54 should contain_neutron_config('DEFAULT/nova_admin_username').with_value('nova')
55 should contain_neutron_config('DEFAULT/nova_admin_password').with_value('secrete')
56 should contain_neutron_config('DEFAULT/nova_admin_password').with_secret( true )
57 should contain_neutron_config('DEFAULT/nova_region_name').with_value('RegionOne')
58 should contain_neutron_config('DEFAULT/nova_admin_tenant_id').with_value('UUID')
61 context 'when overriding parameters' do
64 :notify_nova_on_port_status_changes => false,
65 :notify_nova_on_port_data_changes => false,
66 :send_events_interval => '10',
67 :nova_url => 'http://nova:8774/v3',
68 :nova_admin_auth_url => 'http://keystone:35357/v2.0',
69 :nova_admin_username => 'joe',
70 :nova_region_name => 'MyRegion',
71 :nova_admin_tenant_id => 'UUID2'
74 it 'should configure neutron server with overrided parameters' do
75 should contain_neutron_config('DEFAULT/notify_nova_on_port_status_changes').with_value(false)
76 should contain_neutron_config('DEFAULT/notify_nova_on_port_data_changes').with_value(false)
77 should contain_neutron_config('DEFAULT/send_events_interval').with_value('10')
78 should contain_neutron_config('DEFAULT/nova_url').with_value('http://nova:8774/v3')
79 should contain_neutron_config('DEFAULT/nova_admin_auth_url').with_value('http://keystone:35357/v2.0')
80 should contain_neutron_config('DEFAULT/nova_admin_username').with_value('joe')
81 should contain_neutron_config('DEFAULT/nova_admin_password').with_value('secrete')
82 should contain_neutron_config('DEFAULT/nova_admin_password').with_secret( true )
83 should contain_neutron_config('DEFAULT/nova_region_name').with_value('MyRegion')
84 should contain_neutron_config('DEFAULT/nova_admin_tenant_id').with_value('UUID2')
88 context 'when no nova_admin_password is specified' do
90 params.merge!(:nova_admin_password => '')
92 it 'should fail to configure neutron server' do
93 expect { subject }.to raise_error(Puppet::Error, /nova_admin_password must be set./)
97 context 'when no nova_admin_tenant_id and nova_admin_tenant_name specified' do
100 :nova_admin_tenant_id => '',
101 :nova_admin_tenant_name => ''
104 it 'should fail to configure neutron server' do
105 expect { subject }.to raise_error(Puppet::Error, /You must provide either nova_admin_tenant_name or nova_admin_tenant_id./)
109 context 'when providing a tenant name' do
112 :nova_admin_tenant_id => '',
113 :nova_admin_tenant_name => 'services'
116 it 'should configure nova admin tenant id' do
117 should contain_nova_admin_tenant_id_setter('nova_admin_tenant_id').with(
118 :ensure => 'present',
119 :tenant_name => 'services',
120 :auth_url => 'http://127.0.0.1:35357/v2.0',
121 :auth_password => 'secrete',
122 :auth_tenant_name => 'services'
128 context 'on Debian platforms' do
130 { :osfamily => 'Debian' }
133 let :platform_params do
137 it_configures 'neutron server notifications'
140 context 'on RedHat platforms' do
142 { :osfamily => 'RedHat' }
145 let :platform_params do
149 it_configures 'neutron server notifications'