From b516ae7649328b9bb9e3cdab78f1a1e9d6a1d9bf Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Sat, 4 Jan 2014 17:44:48 +0100 Subject: [PATCH] network: unit test full coverage Signed-off-by: Emilien Macchi --- manifests/network/vpn.pp | 4 +- .../privatecloud_network_compute_spec.rb | 94 ++++++++++++++++ .../privatecloud_network_controller_spec.rb | 10 +- .../classes/privatecloud_network_dhcp_spec.rb | 90 ++++++++++++++++ spec/classes/privatecloud_network_l3_spec.rb | 92 ++++++++++++++++ .../privatecloud_network_lbaas_spec.rb | 90 ++++++++++++++++ .../privatecloud_network_metadata_spec.rb | 102 ++++++++++++++++++ spec/classes/privatecloud_network_vpn_spec.rb | 84 +++++++++++++++ 8 files changed, 562 insertions(+), 4 deletions(-) diff --git a/manifests/network/vpn.pp b/manifests/network/vpn.pp index 6432d9d5..4956ac24 100644 --- a/manifests/network/vpn.pp +++ b/manifests/network/vpn.pp @@ -16,9 +16,7 @@ # Network VPNaaS node # -class privatecloud::network::vpn( - $debug = $os_params::debug -) { +class privatecloud::network::vpn{ include 'privatecloud::network' diff --git a/spec/classes/privatecloud_network_compute_spec.rb b/spec/classes/privatecloud_network_compute_spec.rb index e69de29b..69ab54a1 100644 --- a/spec/classes/privatecloud_network_compute_spec.rb +++ b/spec/classes/privatecloud_network_compute_spec.rb @@ -0,0 +1,94 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for privatecloud::network::compute class +# + +require 'spec_helper' + +describe 'privatecloud::network::compute' do + + shared_examples_for 'openstack network compute' do + + let :pre_condition do + "class { 'privatecloud::network': + rabbit_hosts => ['10.0.0.1'], + rabbit_password => 'secrete', + tunnel_eth => '10.0.1.1', + api_eth => '10.0.0.1', + verbose => true, + debug => true }" + end + + let :params do + { :neutron_protocol => 'http', + :neutron_endpoint => '10.0.0.1', + :neutron_password => 'secrete' } + end + + it 'configure neutron common' do + should contain_class('neutron').with( + :allow_overlapping_ips => true, + :dhcp_agents_per_network => '2', + :verbose => true, + :debug => true, + :rabbit_user => 'neutron', + :rabbit_hosts => ['10.0.0.1'], + :rabbit_password => 'secrete', + :rabbit_virtual_host => '/', + :bind_host => '10.0.0.1', + :core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin', + :service_plugins => ['neutron.services.loadbalancer.plugin.LoadBalancerPlugin','neutron.services.metering.metering_plugin.MeteringPlugin','neutron.services.l3_router.l3_router_plugin.L3RouterPlugin'] + + ) + should contain_class('neutron::agents::ovs').with( + :enable_tunneling => true, + :local_ip => '10.0.1.1' + ) + should contain_class('neutron::plugins::ml2').with( + :type_drivers => ['gre'], + :tenant_network_types => ['gre'], + :mechanism_drivers => ['openvswitch'], + :tunnel_id_ranges => ['1:10000'] + ) + should contain_neutron_plugin_ml2('securitygroup/firewall_driver').with_value(true) + end + + it 'configure neutron on compute node' do + should contain_class('nova::network::neutron').with( + :neutron_admin_password => 'secrete', + :neutron_admin_auth_url => 'http://10.0.0.1:35357/v2.0', + :neutron_url => 'http://10.0.0.1:9696' + ) + end + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'openstack network compute' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + + it_configures 'openstack network compute' + end + +end diff --git a/spec/classes/privatecloud_network_controller_spec.rb b/spec/classes/privatecloud_network_controller_spec.rb index aa907faa..b7772d4e 100644 --- a/spec/classes/privatecloud_network_controller_spec.rb +++ b/spec/classes/privatecloud_network_controller_spec.rb @@ -53,13 +53,21 @@ describe 'privatecloud::network::controller' do :rabbit_password => 'secrete', :rabbit_virtual_host => '/', :bind_host => '10.0.0.1', - :core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin' + :core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin', + :service_plugins => ['neutron.services.loadbalancer.plugin.LoadBalancerPlugin','neutron.services.metering.metering_plugin.MeteringPlugin','neutron.services.l3_router.l3_router_plugin.L3RouterPlugin'] ) should contain_class('neutron::agents::ovs').with( :enable_tunneling => true, :local_ip => '10.0.1.1' ) + should contain_class('neutron::plugins::ml2').with( + :type_drivers => ['gre'], + :tenant_network_types => ['gre'], + :mechanism_drivers => ['openvswitch'], + :tunnel_id_ranges => ['1:10000'] + ) + should contain_neutron_plugin_ml2('securitygroup/firewall_driver').with_value(true) end it 'configure neutron server' do diff --git a/spec/classes/privatecloud_network_dhcp_spec.rb b/spec/classes/privatecloud_network_dhcp_spec.rb index e69de29b..e7df8f7f 100644 --- a/spec/classes/privatecloud_network_dhcp_spec.rb +++ b/spec/classes/privatecloud_network_dhcp_spec.rb @@ -0,0 +1,90 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for privatecloud::network::dhcp class +# + +require 'spec_helper' + +describe 'privatecloud::network::dhcp' do + + shared_examples_for 'openstack network dhcp' do + + let :pre_condition do + "class { 'privatecloud::network': + rabbit_hosts => ['10.0.0.1'], + rabbit_password => 'secrete', + tunnel_eth => '10.0.1.1', + api_eth => '10.0.0.1', + verbose => true, + debug => true }" + end + + let :params do + { :debug => true } + end + + it 'configure neutron common' do + should contain_class('neutron').with( + :allow_overlapping_ips => true, + :dhcp_agents_per_network => '2', + :verbose => true, + :debug => true, + :rabbit_user => 'neutron', + :rabbit_hosts => ['10.0.0.1'], + :rabbit_password => 'secrete', + :rabbit_virtual_host => '/', + :bind_host => '10.0.0.1', + :core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin', + :service_plugins => ['neutron.services.loadbalancer.plugin.LoadBalancerPlugin','neutron.services.metering.metering_plugin.MeteringPlugin','neutron.services.l3_router.l3_router_plugin.L3RouterPlugin'] + + ) + should contain_class('neutron::agents::ovs').with( + :enable_tunneling => true, + :local_ip => '10.0.1.1' + ) + should contain_class('neutron::plugins::ml2').with( + :type_drivers => ['gre'], + :tenant_network_types => ['gre'], + :mechanism_drivers => ['openvswitch'], + :tunnel_id_ranges => ['1:10000'] + ) + should contain_neutron_plugin_ml2('securitygroup/firewall_driver').with_value(true) + end + + it 'configure neutron dhcp' do + should contain_class('neutron::agents::dhcp').with( + :debug => true + ) + end + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'openstack network dhcp' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + + it_configures 'openstack network dhcp' + end + +end diff --git a/spec/classes/privatecloud_network_l3_spec.rb b/spec/classes/privatecloud_network_l3_spec.rb index e69de29b..a8b90b19 100644 --- a/spec/classes/privatecloud_network_l3_spec.rb +++ b/spec/classes/privatecloud_network_l3_spec.rb @@ -0,0 +1,92 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for privatecloud::network::l3 class +# + +require 'spec_helper' + +describe 'privatecloud::network::l3' do + + shared_examples_for 'openstack network l3' do + + let :pre_condition do + "class { 'privatecloud::network': + rabbit_hosts => ['10.0.0.1'], + rabbit_password => 'secrete', + tunnel_eth => '10.0.1.1', + api_eth => '10.0.0.1', + verbose => true, + debug => true }" + end + + let :params do + { :debug => true, + :external_int => 'eth1' } + end + + it 'configure neutron common' do + should contain_class('neutron').with( + :allow_overlapping_ips => true, + :dhcp_agents_per_network => '2', + :verbose => true, + :debug => true, + :rabbit_user => 'neutron', + :rabbit_hosts => ['10.0.0.1'], + :rabbit_password => 'secrete', + :rabbit_virtual_host => '/', + :bind_host => '10.0.0.1', + :core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin', + :service_plugins => ['neutron.services.loadbalancer.plugin.LoadBalancerPlugin','neutron.services.metering.metering_plugin.MeteringPlugin','neutron.services.l3_router.l3_router_plugin.L3RouterPlugin'] + + ) + should contain_class('neutron::agents::ovs').with( + :enable_tunneling => true, + :local_ip => '10.0.1.1' + ) + should contain_class('neutron::plugins::ml2').with( + :type_drivers => ['gre'], + :tenant_network_types => ['gre'], + :mechanism_drivers => ['openvswitch'], + :tunnel_id_ranges => ['1:10000'] + ) + should contain_neutron_plugin_ml2('securitygroup/firewall_driver').with_value(true) + end + + it 'configure neutron l3' do + should contain_class('neutron::agents::l3').with( + :debug => true, + :handle_internal_only_routers => false + ) + end + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'openstack network l3' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + + it_configures 'openstack network l3' + end + +end diff --git a/spec/classes/privatecloud_network_lbaas_spec.rb b/spec/classes/privatecloud_network_lbaas_spec.rb index e69de29b..59a9f9c2 100644 --- a/spec/classes/privatecloud_network_lbaas_spec.rb +++ b/spec/classes/privatecloud_network_lbaas_spec.rb @@ -0,0 +1,90 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for privatecloud::network::lbaas class +# + +require 'spec_helper' + +describe 'privatecloud::network::lbaas' do + + shared_examples_for 'openstack network lbaas' do + + let :pre_condition do + "class { 'privatecloud::network': + rabbit_hosts => ['10.0.0.1'], + rabbit_password => 'secrete', + tunnel_eth => '10.0.1.1', + api_eth => '10.0.0.1', + verbose => true, + debug => true }" + end + + let :params do + { :debug => 'true' } + end + + it 'configure neutron common' do + should contain_class('neutron').with( + :allow_overlapping_ips => true, + :dhcp_agents_per_network => '2', + :verbose => true, + :debug => true, + :rabbit_user => 'neutron', + :rabbit_hosts => ['10.0.0.1'], + :rabbit_password => 'secrete', + :rabbit_virtual_host => '/', + :bind_host => '10.0.0.1', + :core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin', + :service_plugins => ['neutron.services.loadbalancer.plugin.LoadBalancerPlugin','neutron.services.metering.metering_plugin.MeteringPlugin','neutron.services.l3_router.l3_router_plugin.L3RouterPlugin'] + + ) + should contain_class('neutron::agents::ovs').with( + :enable_tunneling => true, + :local_ip => '10.0.1.1' + ) + should contain_class('neutron::plugins::ml2').with( + :type_drivers => ['gre'], + :tenant_network_types => ['gre'], + :mechanism_drivers => ['openvswitch'], + :tunnel_id_ranges => ['1:10000'] + ) + should contain_neutron_plugin_ml2('securitygroup/firewall_driver').with_value(true) + end + + it 'configure neutron lbaas' do + should contain_class('neutron::agents::lbaas').with( + :debug => true + ) + end + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'openstack network lbaas' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + + it_configures 'openstack network lbaas' + end + +end diff --git a/spec/classes/privatecloud_network_metadata_spec.rb b/spec/classes/privatecloud_network_metadata_spec.rb index e69de29b..b641fbe5 100644 --- a/spec/classes/privatecloud_network_metadata_spec.rb +++ b/spec/classes/privatecloud_network_metadata_spec.rb @@ -0,0 +1,102 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for privatecloud::network::metadata class +# + +require 'spec_helper' + +describe 'privatecloud::network::metadata' do + + shared_examples_for 'openstack network metadata' do + + let :pre_condition do + "class { 'privatecloud::network': + rabbit_hosts => ['10.0.0.1'], + rabbit_password => 'secrete', + tunnel_eth => '10.0.1.1', + api_eth => '10.0.0.1', + verbose => true, + debug => true }" + end + + let :params do + { :debug => true, + :enabled => true, + :neutron_metadata_proxy_shared_secret => 'secrete', + :ks_neutron_password => 'secrete', + :ks_nova_internal_host => '10.0.0.1', + :ks_keystone_admin_proto => 'http', + :ks_keystone_admin_port => '35357', + :ks_keystone_admin_host => '10.0.0.1' } + end + + it 'configure neutron common' do + should contain_class('neutron').with( + :allow_overlapping_ips => true, + :dhcp_agents_per_network => '2', + :verbose => true, + :debug => true, + :rabbit_user => 'neutron', + :rabbit_hosts => ['10.0.0.1'], + :rabbit_password => 'secrete', + :rabbit_virtual_host => '/', + :bind_host => '10.0.0.1', + :core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin', + :service_plugins => ['neutron.services.loadbalancer.plugin.LoadBalancerPlugin','neutron.services.metering.metering_plugin.MeteringPlugin','neutron.services.l3_router.l3_router_plugin.L3RouterPlugin'] + + ) + should contain_class('neutron::agents::ovs').with( + :enable_tunneling => true, + :local_ip => '10.0.1.1' + ) + should contain_class('neutron::plugins::ml2').with( + :type_drivers => ['gre'], + :tenant_network_types => ['gre'], + :mechanism_drivers => ['openvswitch'], + :tunnel_id_ranges => ['1:10000'] + ) + should contain_neutron_plugin_ml2('securitygroup/firewall_driver').with_value(true) + end + + it 'configure neutron metadata' do + should contain_class('neutron::agents::metadata').with( + :debug => true, + :enabled => true, + :shared_secret => 'secrete', + :metadata_ip => '10.0.0.1', + :auth_url => 'http://10.0.0.1:35357/v2.0', + :auth_password => 'secrete' + ) + end + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'openstack network metadata' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + + it_configures 'openstack network metadata' + end + +end diff --git a/spec/classes/privatecloud_network_vpn_spec.rb b/spec/classes/privatecloud_network_vpn_spec.rb index e69de29b..76f4bb10 100644 --- a/spec/classes/privatecloud_network_vpn_spec.rb +++ b/spec/classes/privatecloud_network_vpn_spec.rb @@ -0,0 +1,84 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for privatecloud::network::vpnaas class +# + +require 'spec_helper' + +describe 'privatecloud::network::vpn' do + + shared_examples_for 'openstack network vpnaas' do + + let :pre_condition do + "class { 'privatecloud::network': + rabbit_hosts => ['10.0.0.1'], + rabbit_password => 'secrete', + tunnel_eth => '10.0.1.1', + api_eth => '10.0.0.1', + verbose => true, + debug => true }" + end + + it 'configure neutron common' do + should contain_class('neutron').with( + :allow_overlapping_ips => true, + :dhcp_agents_per_network => '2', + :verbose => true, + :debug => true, + :rabbit_user => 'neutron', + :rabbit_hosts => ['10.0.0.1'], + :rabbit_password => 'secrete', + :rabbit_virtual_host => '/', + :bind_host => '10.0.0.1', + :core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin', + :service_plugins => ['neutron.services.loadbalancer.plugin.LoadBalancerPlugin','neutron.services.metering.metering_plugin.MeteringPlugin','neutron.services.l3_router.l3_router_plugin.L3RouterPlugin'] + + ) + should contain_class('neutron::agents::ovs').with( + :enable_tunneling => true, + :local_ip => '10.0.1.1' + ) + should contain_class('neutron::plugins::ml2').with( + :type_drivers => ['gre'], + :tenant_network_types => ['gre'], + :mechanism_drivers => ['openvswitch'], + :tunnel_id_ranges => ['1:10000'] + ) + should contain_neutron_plugin_ml2('securitygroup/firewall_driver').with_value(true) + end + + it 'configure neutron vpnaas' do + should contain_class('neutron::agents::vpnaas') + end + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'openstack network vpnaas' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + + it_configures 'openstack network vpnaas' + end + +end