From 25aeba0702c300b0cb345aa1798de80d6a71713d Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Sat, 4 Jan 2014 16:17:00 +0100 Subject: [PATCH] add unit tests for network controller Signed-off-by: Emilien Macchi --- manifests/network/controller.pp | 6 +- .../privatecloud_network_controller_spec.rb | 94 +++++++++++++++++++ 2 files changed, 97 insertions(+), 3 deletions(-) diff --git a/manifests/network/controller.pp b/manifests/network/controller.pp index 29664a03..ca4bdb08 100644 --- a/manifests/network/controller.pp +++ b/manifests/network/controller.pp @@ -32,9 +32,9 @@ class privatecloud::network::controller( $encoded_password = uriescape($neutron_db_password) class { 'neutron::server': - auth_password => $os_params::ks_neutron_password, - auth_host => $os_params::ks_keystone_admin_host, - auth_port => $os_params::ks_keystone_public_port, + auth_password => $ks_neutron_password, + auth_host => $ks_keystone_admin_host, + auth_port => $ks_keystone_public_port, connection => "mysql://${encoded_user}:${encoded_password}@${neutron_db_host}/neutron?charset=utf8", api_workers => $::processorcount } diff --git a/spec/classes/privatecloud_network_controller_spec.rb b/spec/classes/privatecloud_network_controller_spec.rb index e69de29b..aa907faa 100644 --- a/spec/classes/privatecloud_network_controller_spec.rb +++ b/spec/classes/privatecloud_network_controller_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::controller class +# + +require 'spec_helper' + +describe 'privatecloud::network::controller' do + + shared_examples_for 'openstack network controller' 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_db_host => '10.0.0.1', + :neutron_db_user => 'neutron', + :neutron_db_password => 'secrete', + :ks_neutron_password => 'secrete', + :ks_keystone_admin_host => '10.0.0.1', + :ks_keystone_public_port => '5000', + :api_eth => '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' + + ) + should contain_class('neutron::agents::ovs').with( + :enable_tunneling => true, + :local_ip => '10.0.1.1' + ) + end + + it 'configure neutron server' do + should contain_class('neutron::server').with( + :auth_password => 'secrete', + :auth_host => '10.0.0.1', + :auth_port => '5000', + :connection => 'mysql://neutron:secrete@10.0.0.1/neutron?charset=utf8', + :api_workers => '2' + ) + end + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian', + :processorcount => '2' } + end + + it_configures 'openstack network controller' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat', + :processorcount => '2' } + end + + it_configures 'openstack network controller' + end + +end