From f5285a27f279dde5241dbf03f41b9e412de23360 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Fri, 3 Jan 2014 15:54:29 +0100 Subject: [PATCH] unit test for compute controller - add unit tests for compute controller - delete unit test of compute class (useless) Signed-off-by: Emilien Macchi --- manifests/compute/controller.pp | 16 ++-- .../privatecloud_compute_controller_spec.rb | 78 +++++++++++++++++++ spec/classes/privatecloud_compute_spec.rb | 66 ---------------- 3 files changed, 86 insertions(+), 74 deletions(-) create mode 100644 spec/classes/privatecloud_compute_controller_spec.rb delete mode 100644 spec/classes/privatecloud_compute_spec.rb diff --git a/manifests/compute/controller.pp b/manifests/compute/controller.pp index 1325a327..cb4bed0a 100644 --- a/manifests/compute/controller.pp +++ b/manifests/compute/controller.pp @@ -23,7 +23,7 @@ class privatecloud::compute::controller( $api_eth = $os_params::api_eth, ){ - include 'privatecloud::compute' + # include 'privatecloud::compute' class { [ 'nova::scheduler', @@ -35,13 +35,13 @@ class privatecloud::compute::controller( enabled => true, } - class { 'nova::api': - enabled => true, - auth_host => $ks_keystone_internal_host, - admin_password => $ks_nova_password, - api_bind_address => $api_eth, - neutron_metadata_proxy_shared_secret => $neutron_metadata_proxy_shared_secret, - } + class { 'nova::api': + enabled => true, + auth_host => $ks_keystone_internal_host, + admin_password => $ks_nova_password, + api_bind_address => $api_eth, + neutron_metadata_proxy_shared_secret => $neutron_metadata_proxy_shared_secret, + } @@haproxy::balancermember{"${::fqdn}-compute_api_ec2": listening_service => 'ec2_api_cluster', diff --git a/spec/classes/privatecloud_compute_controller_spec.rb b/spec/classes/privatecloud_compute_controller_spec.rb new file mode 100644 index 00000000..f0064437 --- /dev/null +++ b/spec/classes/privatecloud_compute_controller_spec.rb @@ -0,0 +1,78 @@ +# +# 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::compute::controller class +# + +require 'spec_helper' + +describe 'privatecloud::compute::controller' do + + shared_examples_for 'openstack compute controller' do + + let :pre_condition do + "class { 'privatecloud::compute': + nova_db_host => '10.0.0.1', + nova_db_user => 'nova', + nova_db_password => 'secrete', + rabbit_hosts => ['10.0.0.1'], + rabbit_password => 'secrete', + ks_glance_internal_host => '10.0.0.1', + glance_port => '9292', + verbose => true, + debug => true }" + end + + let :params do + { :ks_keystone_internal_host => '10.0.0.1', + :ks_nova_password => 'secrete', + :api_eth => '10.0.0.1', + :neutron_metadata_proxy_shared_secret => 'secrete' } + end + + it 'configure compute controller' do + should contain_class('nova::scheduler').with(:enabled => true) + should contain_class('nova::cert').with(:enabled => true) + should contain_class('nova::consoleauth').with(:enabled => true) + should contain_class('nova::conductor').with(:enabled => true) + should contain_class('nova::spicehtml5proxy').with(:enabled => true) + should contain_class('nova::api').with( + :enabled => true, + :auth_host => '10.0.0.1', + :admin_password => 'secrete', + :api_bind_address => '10.0.0.1', + :neutron_metadata_proxy_shared_secret => 'secrete' + ) + end + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian' } + end + + it_configures 'openstack compute controller' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat' } + end + +#TODO(Emilien) Problem with Spice: http://paste.openstack.org/show/pxIyzg5gqeJVR2nUPtoB/ +# it_configures 'openstack compute controller' + end + +end diff --git a/spec/classes/privatecloud_compute_spec.rb b/spec/classes/privatecloud_compute_spec.rb deleted file mode 100644 index 857afc12..00000000 --- a/spec/classes/privatecloud_compute_spec.rb +++ /dev/null @@ -1,66 +0,0 @@ -# -# 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::compute class -# - -require 'spec_helper' - -describe 'privatecloud::compute' do - - shared_examples_for 'openstack compute class' do - - let :params do - { :nova_db_host => '10.0.0.1', - :nova_db_user => 'nova', - :nova_db_password => 'secrete', - :rabbit_hosts => ['10.0.0.1'], - :rabbit_password => 'secrete', - :ks_glance_internal_host => '10.0.0.1', - :glance_port => '9292', - :verbose => true, - :debug => true } - end - - it 'configure compute class' do - should contain_class('nova').with( - :database_connection => 'mysql://nova:secrete@10.0.0.1/nova?charset=utf8', - :rabbit_userid => 'nova', - :rabbit_hosts => '10.0.0.1', - :rabbit_password => 'secrete', - :glance_api_servers => 'http://10.0.0.1:9292', - :verbose => true, - :debug => true - ) - end - end - - context 'on Debian platforms' do - let :facts do - { :osfamily => 'Debian' } - end - - it_configures 'openstack compute class' - end - - context 'on RedHat platforms' do - let :facts do - { :osfamily => 'RedHat' } - end - - it_configures 'openstack compute class' - end - -end