2 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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
18 # Unit tests for neutron::agents::vpnaas class
23 describe 'neutron::agents::vpnaas' do
26 "class { 'neutron': rabbit_password => 'passw0rd' }"
33 let :default_params do
34 { :package_ensure => 'present',
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'
43 shared_examples_for 'neutron vpnaas agent' do
45 default_params.merge(params)
48 it { should contain_class('neutron::params') }
50 it_configures 'openswan vpnaas_driver'
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');
59 context 'with external_network_bridge as br-ex' do
62 :external_network_bridge => 'br-ex'
66 it 'configures vpnaas_agent.ini' do
67 should contain_neutron_vpnaas_agent_config('DEFAULT/external_network_bridge').with_value(p[:external_network_bridge]);
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]
77 should contain_package('neutron').with_before(/Package\[neutron-vpnaas-agent\]/)
78 should contain_package('neutron-vpnaas-agent').with_before(/Neutron_vpnaas_agent_config\[.+\]/)
80 should contain_package('neutron').with_before(/Neutron_vpnaas_agent_config\[.+\]/)
84 it 'configures neutron vpnaas agent service' do
85 should contain_service('neutron-vpnaas-service').with(
86 :name => platform_params[:vpnaas_agent_service],
89 :require => 'Class[Neutron]'
93 context 'with manage_service as false' do
95 params.merge!(:manage_service => false)
97 it 'should not start/stop service' do
98 should contain_service('neutron-vpnaas-service').without_ensure
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]')
108 should contain_package('openswan').with(
109 :ensure => 'present',
110 :name => platform_params[:openswan_package]
115 context 'on Debian platforms' do
117 { :osfamily => 'Debian' }
120 let :platform_params do
121 { :openswan_package => 'openswan',
122 :vpnaas_agent_package => 'neutron-vpn-agent',
123 :vpnaas_agent_service => 'neutron-vpn-agent' }
126 it_configures 'neutron vpnaas agent'
129 context 'on RedHat 6 platforms' do
131 { :osfamily => 'RedHat',
132 :operatingsystemrelease => '6.5',
133 :operatingsystemmajrelease => 6 }
136 let :platform_params do
137 { :openswan_package => 'openswan',
138 :vpnaas_agent_package => 'openstack-neutron-vpn-agent',
139 :vpnaas_agent_service => 'neutron-vpn-agent'}
142 it_configures 'neutron vpnaas agent'
145 context 'on RedHat 7 platforms' do
147 { :osfamily => 'RedHat',
148 :operatingsystemrelease => '7.1.2',
149 :operatingsystemmajrelease => 7 }
152 let :platform_params do
153 { :openswan_package => 'libreswan',
154 :vpnaas_agent_package => 'openstack-neutron-vpn-agent',
155 :vpnaas_agent_service => 'neutron-vpn-agent'}
158 it_configures 'neutron vpnaas agent'