improve unit tests

Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
Emilien Macchi 2014-01-11 13:19:28 -05:00
parent bde476d757
commit 85acd41e41
6 changed files with 112 additions and 10 deletions

View File

@ -13,6 +13,7 @@ fixtures:
'apache': 'git://github.com/puppetlabs/puppetlabs-apache.git'
'concat': 'git://github.com/puppetlabs/puppetlabs-concat.git'
'haproxy': 'git://github.com/puppetlabs/puppetlabs-haproxy.git'
'keepalived': 'git://github.com/puppetlabs/puppetlabs-keepalived.git'
'firewall': 'git://github.com/puppetlabs/puppetlabs-firewall.git'
'mongodb': 'git://github.com/puppetlabs/puppetlabs-mongodb.git'
'mysql':

View File

@ -27,19 +27,15 @@ class privatecloud::loadbalancer(
$nova_api = true,
$ec2_api = true,
$metadata_api = true,
$spice_api = true,
$swift_api = true,
$keystone_api_admin = true,
$keystone_api = true,
$horizon = true,
$spice = true,
$haproxy_auth = $os_params::haproxy_auth,
$keepalived_email = $os_params::keepalived_email,
$keepalived_interface = $os_params::keepalived_interface,
$keepalived_ipvs = [ $os_params::openstack_vip, $os_params::mysql_vip ],
$keepalived_localhost_ip = $os_params::keepalived_localhost_ip,
$keepalived_smtp = $os_params::keepalived_smtp,
$ks_cinder_ceilometer_port = $os_params::ks_ceilometer_public_port,
$ks_cinder_public_port = $os_params::ks_cinder_public_port,
$ks_ceilometer_public_port = $os_params::ks_ceilometer_public_port,
$ks_ec2_public_port = $os_params::ks_ec2_public_port,
@ -61,10 +57,7 @@ class privatecloud::loadbalancer(
class { 'haproxy': }
class { 'keepalived':
notification_email_to => $keepalived_email,
smtp_server => $keepalived_smtp,
}
class { 'keepalived': }
keepalived::vrrp_script { 'haproxy':
name_is_process => true

View File

@ -59,6 +59,16 @@ describe 'privatecloud::compute::hypervisor' do
should contain_nova_config('DEFAULT/resume_guests_state_on_host_boot').with('value' => true)
end
it 'insert and activate nbd module' do
should contain_exec('insert_module_nbd').with('command' => '/bin/echo "nbd" > /etc/modules', 'unless' => '/bin/grep "nbd" /etc/modules')
should contain_exec('/sbin/modprobe nbd').with('unless' => '/bin/grep -q "^nbd " "/proc/modules"')
end
it 'start and stop isci service' do
should contain_exec('/etc/init.d/open-iscsi start').with('onlyif' => '/bin/grep "GenerateName=yes" /etc/iscsi/initiatorname.iscsi')
should contain_exec('/etc/init.d/open-iscsi stop').with('refreshonly' => true)
end
it 'configure nova-compute' do
should contain_class('nova::compute').with(
:enabled => true,

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
#
# Unit tests for privatecloud::compute::hypervisor class
# Unit tests for privatecloud::database::sql class
#
require 'spec_helper'

View File

@ -0,0 +1,98 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# 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::loadbalancer class
#
require 'spec_helper'
describe 'privatecloud::loadbalancer' do
shared_examples_for 'openstack loadbalancer' do
let :params do
{ :ceilometer_api => true,
:cinder_api => true,
:glance_api => true,
:neutron_api => true,
:heat_api => true,
:heat_cfn_api => true,
:heat_cloudwatch_api => true,
:nova_api => true,
:ec2_api => true,
:metadata_api => true,
:swift_api => true,
:keystone_api_admin => true,
:keystone_api => true,
:horizon => true,
:spice => true,
:haproxy_auth => 'root:secrete',
:keepalived_interface => 'eth0',
:keepalived_ipvs => ['10.0.0.1', '10.0.0.2'],
:keepalived_localhost_ip => '127.0.0.1',
:horizon_port => '80',
:spice_port => '6082',
:openstack_vip => '10.0.0.3',
:mysql_vip => '10.0.0.4',
:ks_ceilometer_public_port => '8777',
:ks_nova_public_port => '8774',
:ks_ec2_public_port => '8773',
:ks_metadata_public_port => '8777',
:ks_glance_public_port => '9292',
:ks_swift_public_port => '8080',
:ks_keystone_public_port => '5000',
:ks_keystone_admin_port => '35357',
:ks_cinder_public_port => '8776',
:ks_neutron_public_port => '9696',
:ks_heat_public_port => '8004',
:ks_heat_cfn_public_port => '8000',
:ks_heat_cloudwatch_public_port => '8003' }
end
it 'configure haproxy server' do
should contain_class('haproxy')
end
it 'configure keepalived server' do
should contain_class('keepalived')
end
it 'configure haproxy vrrp script' do
should contain_keepalived_vrrp_script('haproxy').with(
:name_is_process => true
)
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian',
:concat_basedir => '/var/lib/puppet/concat' }
end
it_configures 'openstack loadbalancer'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat',
:concat_basedir => '/var/lib/puppet/concat' }
end
it_configures 'openstack loadbalancer'
end
end

View File

@ -41,7 +41,7 @@ describe 'privatecloud::network::dhcp' do
:allow_overlapping_ips => true,
:dhcp_agents_per_network => '2',
:verbose => true,
:debug => true,
:debug => false,
:rabbit_user => 'neutron',
:rabbit_hosts => ['10.0.0.1'],
:rabbit_password => 'secrete',