try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / spec / classes / neutron_agents_vpnaas_spec.rb
1 #
2 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17 #
18 # Unit tests for neutron::agents::vpnaas class
19 #
20
21 require 'spec_helper'
22
23 describe 'neutron::agents::vpnaas' do
24
25   let :pre_condition do
26     "class { 'neutron': rabbit_password => 'passw0rd' }"
27   end
28
29   let :params do
30     {}
31   end
32
33   let :default_params do
34     { :package_ensure              => 'present',
35       :enabled                     => true,
36       :vpn_device_driver           => 'neutron.services.vpn.device_drivers.ipsec.OpenSwanDriver',
37       :interface_driver            => 'neutron.agent.linux.interface.OVSInterfaceDriver',
38       :ipsec_status_check_interval => '60'
39     }
40   end
41
42
43   shared_examples_for 'neutron vpnaas agent' do
44     let :p do
45       default_params.merge(params)
46     end
47
48     it { should contain_class('neutron::params') }
49
50     it_configures 'openswan vpnaas_driver'
51
52     it 'configures vpnaas_agent.ini' do
53       should contain_neutron_vpnaas_agent_config('vpnagent/vpn_device_driver').with_value(p[:vpn_device_driver]);
54       should contain_neutron_vpnaas_agent_config('ipsec/ipsec_status_check_interval').with_value(p[:ipsec_status_check_interval]);
55       should contain_neutron_vpnaas_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]);
56       should contain_neutron_vpnaas_agent_config('DEFAULT/external_network_bridge').with_ensure('absent');
57     end
58
59     context 'with external_network_bridge as br-ex' do
60       before do
61       params.merge!(
62         :external_network_bridge => 'br-ex'
63       )
64       end
65
66       it 'configures vpnaas_agent.ini' do
67         should contain_neutron_vpnaas_agent_config('DEFAULT/external_network_bridge').with_value(p[:external_network_bridge]);
68       end
69     end
70
71     it 'installs neutron vpnaas agent package' do
72       if platform_params.has_key?(:vpnaas_agent_package)
73         should contain_package('neutron-vpnaas-agent').with(
74           :name   => platform_params[:vpnaas_agent_package],
75           :ensure => p[:package_ensure]
76         )
77         should contain_package('neutron').with_before(/Package\[neutron-vpnaas-agent\]/)
78         should contain_package('neutron-vpnaas-agent').with_before(/Neutron_vpnaas_agent_config\[.+\]/)
79       else
80         should contain_package('neutron').with_before(/Neutron_vpnaas_agent_config\[.+\]/)
81       end
82     end
83
84     it 'configures neutron vpnaas agent service' do
85       should contain_service('neutron-vpnaas-service').with(
86         :name    => platform_params[:vpnaas_agent_service],
87         :enable  => true,
88         :ensure  => 'running',
89         :require => 'Class[Neutron]'
90       )
91     end
92
93     context 'with manage_service as false' do
94       before :each do
95         params.merge!(:manage_service => false)
96       end
97       it 'should not start/stop service' do
98         should contain_service('neutron-vpnaas-service').without_ensure
99       end
100     end
101   end
102
103   shared_examples_for 'openswan vpnaas_driver' do
104     it 'installs openswan packages' do
105       if platform_params.has_key?(:vpnaas_agent_package)
106         should contain_package('openswan').with_before('Package[neutron-vpnaas-agent]')
107       end
108       should contain_package('openswan').with(
109         :ensure => 'present',
110         :name   => platform_params[:openswan_package]
111       )
112     end
113   end
114
115   context 'on Debian platforms' do
116     let :facts do
117       { :osfamily => 'Debian' }
118     end
119
120     let :platform_params do
121       { :openswan_package     => 'openswan',
122         :vpnaas_agent_package => 'neutron-vpn-agent',
123         :vpnaas_agent_service => 'neutron-vpn-agent' }
124     end
125
126     it_configures 'neutron vpnaas agent'
127   end
128
129   context 'on RedHat 6 platforms' do
130     let :facts do
131       { :osfamily                  => 'RedHat',
132         :operatingsystemrelease    => '6.5',
133         :operatingsystemmajrelease => 6 }
134     end
135
136     let :platform_params do
137       { :openswan_package     => 'openswan',
138         :vpnaas_agent_package => 'openstack-neutron-vpn-agent',
139         :vpnaas_agent_service => 'neutron-vpn-agent'}
140     end
141
142     it_configures 'neutron vpnaas agent'
143   end
144
145   context 'on RedHat 7 platforms' do
146     let :facts do
147       { :osfamily                  => 'RedHat',
148         :operatingsystemrelease    => '7.1.2',
149         :operatingsystemmajrelease => 7 }
150     end
151
152     let :platform_params do
153       { :openswan_package     => 'libreswan',
154         :vpnaas_agent_package => 'openstack-neutron-vpn-agent',
155         :vpnaas_agent_service => 'neutron-vpn-agent'}
156     end
157
158     it_configures 'neutron vpnaas agent'
159   end
160 end