try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / spec / classes / neutron_server_notifications_spec.rb
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
4 #
5 #      http://www.apache.org/licenses/LICENSE-2.0
6 #
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
11 # under the License.
12 #
13 # Unit tests for neutron::server::notifications class
14 #
15
16 require 'spec_helper'
17
18 describe 'neutron::server::notifications' do
19     let :pre_condition do
20         'define keystone_user ($name) {}'
21     end
22
23     let :default_params do
24         {
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'
33         }
34     end
35
36     let :params do
37         {
38             :nova_admin_password  => 'secrete',
39             :nova_admin_tenant_id => 'UUID'
40         }
41     end
42
43     shared_examples_for 'neutron server notifications' do
44         let :p do
45             default_params.merge(params)
46         end
47
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')
59         end
60
61         context 'when overriding parameters' do
62             before :each do
63                 params.merge!(
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'
72                 )
73             end
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')
85             end
86         end
87
88         context 'when no nova_admin_password is specified' do
89             before :each do
90                 params.merge!(:nova_admin_password => '')
91             end
92             it 'should fail to configure neutron server' do
93                 expect { subject }.to raise_error(Puppet::Error, /nova_admin_password must be set./)
94             end
95         end
96
97         context 'when no nova_admin_tenant_id and nova_admin_tenant_name specified' do
98             before :each do
99                 params.merge!(
100                   :nova_admin_tenant_id   => '',
101                   :nova_admin_tenant_name => ''
102                 )
103             end
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./)
106             end
107         end
108
109         context 'when providing a tenant name' do
110             before :each do
111                 params.merge!(
112                   :nova_admin_tenant_id   => '',
113                   :nova_admin_tenant_name => 'services'
114                 )
115             end
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'
123               )
124             end
125         end
126     end
127
128     context 'on Debian platforms' do
129         let :facts do
130             { :osfamily => 'Debian' }
131         end
132
133         let :platform_params do
134             {}
135         end
136
137         it_configures 'neutron server notifications'
138     end
139
140     context 'on RedHat platforms' do
141         let :facts do
142             { :osfamily => 'RedHat' }
143         end
144
145         let :platform_params do
146             {}
147         end
148
149         it_configures 'neutron server notifications'
150     end
151
152 end