diff options
Diffstat (limited to 'spec/classes')
25 files changed, 1506 insertions, 93 deletions
diff --git a/spec/classes/tripleo_firewall_spec.rb b/spec/classes/tripleo_firewall_spec.rb index 3116a51..92b51e5 100644 --- a/spec/classes/tripleo_firewall_spec.rb +++ b/spec/classes/tripleo_firewall_spec.rb @@ -34,35 +34,65 @@ describe 'tripleo::firewall' do end it 'configure basic pre firewall rules' do - is_expected.to contain_firewall('000 accept related established rules').with( + is_expected.to contain_firewall('000 accept related established rules ipv4').with( :proto => 'all', :state => ['RELATED', 'ESTABLISHED'], :action => 'accept', ) - is_expected.to contain_firewall('001 accept all icmp').with( + is_expected.to contain_firewall('000 accept related established rules ipv6').with( + :proto => 'all', + :state => ['RELATED', 'ESTABLISHED'], + :action => 'accept', + :provider => 'ip6tables', + ) + is_expected.to contain_firewall('001 accept all icmp ipv4').with( :proto => 'icmp', :action => 'accept', :state => ['NEW'], ) - is_expected.to contain_firewall('002 accept all to lo interface').with( + is_expected.to contain_firewall('001 accept all icmp ipv6').with( + :proto => 'ipv6-icmp', + :action => 'accept', + :state => ['NEW'], + :provider => 'ip6tables', + ) + is_expected.to contain_firewall('002 accept all to lo interface ipv4').with( :proto => 'all', :iniface => 'lo', :action => 'accept', :state => ['NEW'], ) - is_expected.to contain_firewall('003 accept ssh').with( + is_expected.to contain_firewall('002 accept all to lo interface ipv6').with( + :proto => 'all', + :iniface => 'lo', + :action => 'accept', + :state => ['NEW'], + :provider => 'ip6tables', + ) + is_expected.to contain_firewall('003 accept ssh ipv4').with( :dport => '22', :proto => 'tcp', :action => 'accept', :state => ['NEW'], ) + is_expected.to contain_firewall('003 accept ssh ipv6').with( + :dport => '22', + :proto => 'tcp', + :action => 'accept', + :state => ['NEW'], + :provider => 'ip6tables', + ) end it 'configure basic post firewall rules' do - is_expected.to contain_firewall('999 drop all').with( + is_expected.to contain_firewall('999 drop all ipv4').with( :proto => 'all', :action => 'drop', - :source => '0.0.0.0/0', + ) + is_expected.to contain_firewall('999 drop all ipv6').with( + :proto => 'all', + :action => 'drop', + :provider => 'ip6tables', ) end end @@ -74,44 +104,71 @@ describe 'tripleo::firewall' do :firewall_rules => { '300 add custom application 1' => {'port' => '999', 'proto' => 'udp', 'action' => 'accept'}, '301 add custom application 2' => {'port' => '8081', 'proto' => 'tcp', 'action' => 'accept'}, - '302 fwd custom cidr 1' => {'chain' => 'FORWARD', 'destination' => '192.0.2.0/24'}, + '302 fwd custom cidr 1' => {'port' => 'all', 'chain' => 'FORWARD', 'destination' => '192.0.2.0/24'}, '303 add custom application 3' => {'dport' => '8081', 'proto' => 'tcp', 'action' => 'accept'}, '304 add custom application 4' => {'sport' => '1000', 'proto' => 'tcp', 'action' => 'accept'}, - '305 add gre rule' => {'proto' => 'gre'} + '305 add gre rule' => {'proto' => 'gre'}, + '306 add custom cidr 2' => {'port' => 'all', 'destination' => '::1/24'}, } ) end it 'configure custom firewall rules' do - is_expected.to contain_firewall('300 add custom application 1').with( + is_expected.to contain_firewall('300 add custom application 1 ipv4').with( :port => '999', :proto => 'udp', :action => 'accept', :state => ['NEW'], ) - is_expected.to contain_firewall('301 add custom application 2').with( + is_expected.to contain_firewall('301 add custom application 2 ipv4').with( :port => '8081', :proto => 'tcp', :action => 'accept', :state => ['NEW'], ) - is_expected.to contain_firewall('302 fwd custom cidr 1').with( + is_expected.to contain_firewall('302 fwd custom cidr 1 ipv4').with( :chain => 'FORWARD', - :destination => '192.0.2.0/24', + :proto => 'tcp', + :destination => '192.0.2.0/24', ) - is_expected.to contain_firewall('303 add custom application 3').with( + is_expected.to_not contain_firewall('302 fwd custom cidr 1 ipv6') + is_expected.to contain_firewall('303 add custom application 3 ipv4').with( :dport => '8081', :proto => 'tcp', :action => 'accept', :state => ['NEW'], ) - is_expected.to contain_firewall('304 add custom application 4').with( + is_expected.to contain_firewall('304 add custom application 4 ipv4').with( :sport => '1000', :proto => 'tcp', :action => 'accept', :state => ['NEW'], ) - is_expected.to contain_firewall('305 add gre rule').without(:state) + is_expected.to contain_firewall('304 add custom application 4 ipv6').with( + :sport => '1000', + :proto => 'tcp', + :action => 'accept', + :state => ['NEW'], + ) + is_expected.to contain_firewall('305 add gre rule ipv4').without(:state) + is_expected.to contain_firewall('306 add custom cidr 2 ipv6').with( + :proto => 'tcp', + :destination => '::1/24', + :action => 'accept', + :provider => 'ip6tables', + ) + end + end + + context 'with TCP rule without port or dport or sport specified' do + before :each do + params.merge!( + :manage_firewall => true, + :firewall_rules => { + '500 wrong tcp rule' => {'proto' => 'tcp', 'action' => 'accept'}, + } + ) end + it_raises 'a Puppet::Error', /500 wrong tcp rule firewall rule cannot be created. TCP or UDP rules for INPUT or OUTPUT need port or sport or dport./ end end diff --git a/spec/classes/tripleo_midonet_agent_spec.rb b/spec/classes/tripleo_midonet_agent_spec.rb deleted file mode 100644 index 73d90b6..0000000 --- a/spec/classes/tripleo_midonet_agent_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -# -# Copyright (C) 2015 Midokura SARL -# -# 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 the midonet agent - -require 'spec_helper' - -describe 'tripleo::network::midonet::agent' do - - shared_examples_for 'tripleo::network::midonet::agent' do - - let :params do - { - :zookeeper_servers => ['192.168.2.2', '192.168.2.3'], - :cassandra_seeds => ['192.168.2.2', '192.168.2.3'] - } - end - - it 'should stop openvswitch' do - is_expected.to contain_service('openvswitch').with( - :ensure => 'stopped', - :enable => false - ) - end - - it 'should run the agent with a list of maps' do - is_expected.to contain_class('midonet::midonet_agent').with( - :zk_servers => [{'ip' => '192.168.2.2', - 'port' => 2181}, - {'ip' => '192.168.2.3', - 'port' => 2181}], - :cassandra_seeds => ['192.168.2.2','192.168.2.3'] - ) - end - end - - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts.merge({}) - end - - it_behaves_like 'tripleo::network::midonet::agent' - end - end -end diff --git a/spec/classes/tripleo_profile_base_ceilometer_api_spec.rb b/spec/classes/tripleo_profile_base_ceilometer_api_spec.rb index 935e9e8..acc9b51 100644 --- a/spec/classes/tripleo_profile_base_ceilometer_api_spec.rb +++ b/spec/classes/tripleo_profile_base_ceilometer_api_spec.rb @@ -34,7 +34,7 @@ describe 'tripleo::profile::base::ceilometer::api' do context 'with step 4' do let(:params) { { - :step => 4, + :step => 4, } } it 'should trigger complete configuration' do diff --git a/spec/classes/tripleo_profile_base_ceph_mds_spec.rb b/spec/classes/tripleo_profile_base_ceph_mds_spec.rb new file mode 100644 index 0000000..a129103 --- /dev/null +++ b/spec/classes/tripleo_profile_base_ceph_mds_spec.rb @@ -0,0 +1,59 @@ +# +# Copyright (C) 2016 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::ceph::mds' do + shared_examples_for 'tripleo::profile::base::ceph::mds' do + let (:pre_condition) do + <<-eof + class { '::tripleo::profile::base::ceph': + step => #{params[:step]} + } + eof + end + + context 'with step less than 3' do + let(:params) { { :step => 2 } } + it 'should do nothing' do + is_expected.to contain_class('tripleo::profile::base::ceph') + is_expected.to_not contain_class('ceph::profile::mds') + end + end + + context 'with step 3' do + let(:params) { { + :step => 3, + } } + + it 'should include mds configuration' do + is_expected.to contain_class('tripleo::profile::base::ceph') + is_expected.to contain_class('ceph::profile::mds') + end + end + + end + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::ceph::mds' + end + end +end diff --git a/spec/classes/tripleo_profile_base_ceph_rgw_spec.rb b/spec/classes/tripleo_profile_base_ceph_rgw_spec.rb index 88f971b..4ebf521 100644 --- a/spec/classes/tripleo_profile_base_ceph_rgw_spec.rb +++ b/spec/classes/tripleo_profile_base_ceph_rgw_spec.rb @@ -85,6 +85,17 @@ describe 'tripleo::profile::base::ceph::rgw' do ) end end + + context 'with step 4 and keystone v3' do + let(:params) { default_params.merge({ :step => 4, :rgw_keystone_version => 'v3' }) } + it 'should include rgw configuration' do + is_expected.to contain_ceph__rgw__keystone('radosgw.gateway').with( + :rgw_keystone_accepted_roles => ["admin", "_member_", "Member"], + :use_pki => false, + :rgw_keystone_url => 'url' + ) + end + end end on_supported_os.each do |os, facts| diff --git a/spec/classes/tripleo_profile_base_cinder_api_spec.rb b/spec/classes/tripleo_profile_base_cinder_api_spec.rb index a0c607d..6a36632 100644 --- a/spec/classes/tripleo_profile_base_cinder_api_spec.rb +++ b/spec/classes/tripleo_profile_base_cinder_api_spec.rb @@ -30,7 +30,6 @@ describe 'tripleo::profile::base::cinder::api' do is_expected.to contain_class('tripleo::profile::base::cinder') is_expected.to_not contain_class('cinder::api') is_expected.to_not contain_class('cinder::ceilometer') - is_expected.to_not contain_class('cinder::glance') end end @@ -43,7 +42,6 @@ describe 'tripleo::profile::base::cinder::api' do it 'should trigger complete configuration' do is_expected.to contain_class('cinder::api') is_expected.to contain_class('cinder::ceilometer') - is_expected.to contain_class('cinder::glance') end end @@ -56,7 +54,6 @@ describe 'tripleo::profile::base::cinder::api' do it 'should not trigger any configuration' do is_expected.to_not contain_class('cinder::api') is_expected.to_not contain_class('cinder::ceilometer') - is_expected.to_not contain_class('cinder::glance') end end @@ -68,7 +65,6 @@ describe 'tripleo::profile::base::cinder::api' do it 'should trigger complete configuration' do is_expected.to contain_class('cinder::api') is_expected.to contain_class('cinder::ceilometer') - is_expected.to contain_class('cinder::glance') end end end diff --git a/spec/classes/tripleo_profile_base_cinder_scaleio_spec.rb b/spec/classes/tripleo_profile_base_cinder_scaleio_spec.rb new file mode 100644 index 0000000..0f12b0a --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_scaleio_spec.rb @@ -0,0 +1,58 @@ +# +# Copyright (C) 2016 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::cinder::volume::scaleio' do + shared_examples_for 'tripleo::profile::base::cinder::volume::scaleio' do + before :each do + facts.merge!({ :step => params[:step] }) + end + + context 'with step less than 4' do + let(:params) { { :step => 3 } } + + it 'should do nothing' do + is_expected.to contain_class('tripleo::profile::base::cinder::volume::scaleio') + is_expected.to contain_class('tripleo::profile::base::cinder::volume') + is_expected.to contain_class('tripleo::profile::base::cinder') + is_expected.to_not contain_cinder__backend__scaleio('tripleo_scaleio') + end + end + + context 'with step 4' do + let(:params) { { + :step => 4, + } } + + it 'should trigger complete configuration' do + # TODO(aschultz): check hiera parameters + is_expected.to contain_cinder__backend__scaleio('tripleo_scaleio') + end + end + end + + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::cinder::volume::scaleio' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_spec.rb b/spec/classes/tripleo_profile_base_cinder_spec.rb index 6a36152..81fa047 100644 --- a/spec/classes/tripleo_profile_base_cinder_spec.rb +++ b/spec/classes/tripleo_profile_base_cinder_spec.rb @@ -24,6 +24,7 @@ describe 'tripleo::profile::base::cinder' do is_expected.to contain_class('tripleo::profile::base::cinder') is_expected.to_not contain_class('cinder') is_expected.to_not contain_class('cinder::config') + is_expected.to_not contain_class('cinder::glance') is_expected.to_not contain_class('cinder:::cron::db_purge') end end @@ -41,6 +42,7 @@ describe 'tripleo::profile::base::cinder' do :rabbit_hosts => params[:rabbit_hosts].map{ |h| "#{h}:#{params[:rabbit_port]}" } ) is_expected.to contain_class('cinder::config') + is_expected.to contain_class('cinder::glance') is_expected.to_not contain_class('cinder::cron::db_purge') end end @@ -54,6 +56,7 @@ describe 'tripleo::profile::base::cinder' do it 'should not trigger any configuration' do is_expected.to_not contain_class('cinder') is_expected.to_not contain_class('cinder::config') + is_expected.to_not contain_class('cinder::glance') is_expected.to_not contain_class('cinder:::cron::db_purge') end end @@ -71,6 +74,7 @@ describe 'tripleo::profile::base::cinder' do :rabbit_hosts => params[:rabbit_hosts].map{ |h| "#{h}:#{params[:rabbit_port]}" } ) is_expected.to contain_class('cinder::config') + is_expected.to contain_class('cinder::glance') is_expected.to_not contain_class('cinder:::cron::db_purge') end end @@ -87,6 +91,7 @@ describe 'tripleo::profile::base::cinder' do :rabbit_hosts => params[:rabbit_hosts].map{ |h| "#{h}:5672" } ) is_expected.to contain_class('cinder::config') + is_expected.to contain_class('cinder::glance') is_expected.to contain_class('cinder::cron::db_purge') end end @@ -104,6 +109,7 @@ describe 'tripleo::profile::base::cinder' do :rabbit_hosts => params[:rabbit_hosts].map{ |h| "#{h}:5672" } ) is_expected.to contain_class('cinder::config') + is_expected.to contain_class('cinder::glance') is_expected.to_not contain_class('cinder::cron::db_purge') end end diff --git a/spec/classes/tripleo_profile_base_cinder_volume_eqlx_spec.rb b/spec/classes/tripleo_profile_base_cinder_volume_dellps_spec.rb index 1a188aa..313b87c 100644 --- a/spec/classes/tripleo_profile_base_cinder_volume_eqlx_spec.rb +++ b/spec/classes/tripleo_profile_base_cinder_volume_dellps_spec.rb @@ -16,8 +16,8 @@ require 'spec_helper' -describe 'tripleo::profile::base::cinder::volume::eqlx' do - shared_examples_for 'tripleo::profile::base::cinder::volume::eqlx' do +describe 'tripleo::profile::base::cinder::volume::dellps' do + shared_examples_for 'tripleo::profile::base::cinder::volume::dellps' do before :each do facts.merge!({ :step => params[:step] }) end @@ -26,10 +26,10 @@ describe 'tripleo::profile::base::cinder::volume::eqlx' do let(:params) { { :step => 3 } } it 'should do nothing' do - is_expected.to contain_class('tripleo::profile::base::cinder::volume::eqlx') + is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellps') is_expected.to contain_class('tripleo::profile::base::cinder::volume') is_expected.to contain_class('tripleo::profile::base::cinder') - is_expected.to_not contain_cinder__backend__eqlx('tripleo_eqlx') + is_expected.to_not contain_cinder__backend__eqlx('tripleo_dellps') end end @@ -40,7 +40,7 @@ describe 'tripleo::profile::base::cinder::volume::eqlx' do it 'should trigger complete configuration' do # TODO(aschultz): check hiera parameters - is_expected.to contain_cinder__backend__eqlx('tripleo_eqlx') + is_expected.to contain_cinder__backend__eqlx('tripleo_dellps') end end end @@ -52,7 +52,7 @@ describe 'tripleo::profile::base::cinder::volume::eqlx' do facts.merge({ :hostname => 'node.example.com' }) end - it_behaves_like 'tripleo::profile::base::cinder::volume::eqlx' + it_behaves_like 'tripleo::profile::base::cinder::volume::dellps' end end end diff --git a/spec/classes/tripleo_profile_base_cinder_volume_spec.rb b/spec/classes/tripleo_profile_base_cinder_volume_spec.rb index e0ec9de..f4501c8 100644 --- a/spec/classes/tripleo_profile_base_cinder_volume_spec.rb +++ b/spec/classes/tripleo_profile_base_cinder_volume_spec.rb @@ -74,21 +74,21 @@ describe 'tripleo::profile::base::cinder::volume' do end end - context 'with only eqlx' do + context 'with only dellps' do before :each do params.merge!({ - :cinder_enable_eqlx_backend => true, + :cinder_enable_dellps_backend => true, :cinder_enable_iscsi_backend => false, }) end - it 'should configure only eqlx' do - is_expected.to contain_class('tripleo::profile::base::cinder::volume::eqlx') + it 'should configure only dellps' do + is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellps') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::iscsi') is_expected.to contain_class('tripleo::profile::base::cinder::volume') is_expected.to contain_class('tripleo::profile::base::cinder') is_expected.to contain_class('cinder::volume') is_expected.to contain_class('cinder::backends').with( - :enabled_backends => ['tripleo_eqlx'] + :enabled_backends => ['tripleo_dellps'] ) end end @@ -160,7 +160,7 @@ describe 'tripleo::profile::base::cinder::volume' do it 'should configure only user backend' do is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::iscsi') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::dellsc') - is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::eqlx') + is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::dellps') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::netapp') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::nfs') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::rbd') @@ -178,7 +178,7 @@ describe 'tripleo::profile::base::cinder::volume' do params.merge!({ :cinder_enable_iscsi_backend => true, :cinder_enable_dellsc_backend => true, - :cinder_enable_eqlx_backend => true, + :cinder_enable_dellps_backend => true, :cinder_enable_netapp_backend => true, :cinder_enable_nfs_backend => true, :cinder_enable_rbd_backend => true, @@ -187,7 +187,7 @@ describe 'tripleo::profile::base::cinder::volume' do it 'should configure all backends' do is_expected.to contain_class('tripleo::profile::base::cinder::volume::iscsi') is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellsc') - is_expected.to contain_class('tripleo::profile::base::cinder::volume::eqlx') + is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellps') is_expected.to contain_class('tripleo::profile::base::cinder::volume::netapp') is_expected.to contain_class('tripleo::profile::base::cinder::volume::nfs') is_expected.to contain_class('tripleo::profile::base::cinder::volume::rbd') @@ -195,7 +195,7 @@ describe 'tripleo::profile::base::cinder::volume' do is_expected.to contain_class('tripleo::profile::base::cinder') is_expected.to contain_class('cinder::volume') is_expected.to contain_class('cinder::backends').with( - :enabled_backends => ['tripleo_iscsi', 'tripleo_ceph', 'tripleo_eqlx', + :enabled_backends => ['tripleo_iscsi', 'tripleo_ceph', 'tripleo_dellps', 'tripleo_dellsc', 'tripleo_netapp','tripleo_nfs'] ) end diff --git a/spec/classes/tripleo_profile_base_nova_api_spec.rb b/spec/classes/tripleo_profile_base_nova_api_spec.rb new file mode 100644 index 0000000..2072438 --- /dev/null +++ b/spec/classes/tripleo_profile_base_nova_api_spec.rb @@ -0,0 +1,137 @@ +# +# Copyright (C) 2017 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::nova::api' do + shared_examples_for 'tripleo::profile::base::nova::api' do + let(:pre_condition) do + <<-eos + class { '::tripleo::profile::base::nova': + step => #{params[:step]}, + messaging_hosts => [ 'localhost' ], + messaging_username => 'nova', + messaging_password => 'foo' + } +eos + end + + context 'with step less than 3' do + let(:params) { { + :step => 1, + } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::api') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to_not contain_class('nova::keystone::authtoken') + is_expected.to_not contain_class('nova::api') + is_expected.to_not contain_class('nova::wsgi::apache_api') + is_expected.to_not contain_class('nova::network::neutron') + } + end + + context 'with step 3 on bootstrap node' do + let(:params) { { + :step => 3, + :bootstrap_node => 'node.example.com', + } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::api') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova::cell_v2::simple_setup') + is_expected.to contain_class('nova::keystone::authtoken') + is_expected.to contain_class('nova::api') + is_expected.to_not contain_class('nova::wsgi::apache_api') + is_expected.to contain_class('nova::network::neutron') + } + end + + context 'with step 3 on bootstrap node' do + let(:params) { { + :step => 3, + :bootstrap_node => 'node.example.com', + } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::api') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova::cell_v2::simple_setup') + is_expected.to contain_class('nova::keystone::authtoken') + is_expected.to contain_class('nova::api') + is_expected.to_not contain_class('nova::wsgi::apache_api') + is_expected.to contain_class('nova::network::neutron') + } + end + + context 'with step 4 not on bootstrap node' do + let(:params) { { + :step => 4, + :bootstrap_node => 'other.example.com', + } } + + it { + is_expected.to_not contain_class('nova::db::sync_cell_v2') + is_expected.to contain_class('nova::keystone::authtoken') + is_expected.to contain_class('nova::api') + is_expected.to_not contain_class('nova::wsgi::apache_api') + is_expected.to contain_class('nova::network::neutron') + } + end + + context 'with step 4 not on bootstrap node' do + let(:params) { { + :step => 4, + :bootstrap_node => 'other.example.com', + :nova_api_wsgi_enabled => true, + } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::api') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to_not contain_class('nova::db::sync_cell_v2') + is_expected.to contain_class('nova::keystone::authtoken') + is_expected.to contain_class('nova::api') + is_expected.to contain_class('nova::wsgi::apache_api') + is_expected.to contain_class('nova::network::neutron') + } + end + + context 'with step 5' do + let(:params) { { + :step => 5, + :bootstrap_node => 'other.example.com', + } } + + it { + is_expected.to contain_class('nova::cron::archive_deleted_rows') + } + end + + end + + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::nova::api' + end + end +end diff --git a/spec/classes/tripleo_profile_base_nova_compute_ironic_spec.rb b/spec/classes/tripleo_profile_base_nova_compute_ironic_spec.rb new file mode 100644 index 0000000..2155695 --- /dev/null +++ b/spec/classes/tripleo_profile_base_nova_compute_ironic_spec.rb @@ -0,0 +1,67 @@ +# +# Copyright (C) 2017 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::nova::compute::ironic' do + shared_examples_for 'tripleo::profile::base::nova::compute::ironic' do + + context 'with step less than 4' do + let(:params) { { :step => 1, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::compute::ironic') + is_expected.to_not contain_class('tripleo::profile::base::nova') + is_expected.to_not contain_class('nova::compute::ironic') + is_expected.to_not contain_class('nova::network::neutron') + } + end + + context 'with step 4' do + let(:pre_condition) do + <<-eos + class { '::tripleo::profile::base::nova': + step => #{params[:step]}, + messaging_hosts => [ '127.0.0.1' ], + } + class { '::tripleo::profile::base::nova::compute': + step => #{params[:step]}, + } +eos + end + + let(:params) { { :step => 4, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::compute::ironic') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova::compute::ironic') + is_expected.to contain_class('nova::network::neutron') + } + end + end + + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::nova::compute::ironic' + end + end +end diff --git a/spec/classes/tripleo_profile_base_nova_compute_libvirt_spec.rb b/spec/classes/tripleo_profile_base_nova_compute_libvirt_spec.rb new file mode 100644 index 0000000..0b33123 --- /dev/null +++ b/spec/classes/tripleo_profile_base_nova_compute_libvirt_spec.rb @@ -0,0 +1,69 @@ +# +# Copyright (C) 2017 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::nova::compute::libvirt' do + shared_examples_for 'tripleo::profile::base::nova::compute::libvirt' do + + context 'with step less than 4' do + let(:params) { { :step => 1, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::compute::libvirt') + is_expected.to_not contain_class('tripleo::profile::base::nova') + is_expected.to_not contain_class('tripleo::profile::base::nova::compute') + is_expected.to_not contain_class('nova::compute::libvirt') + is_expected.to_not contain_class('nova::compute::libvirt::qemu') + } + end + + context 'with step 4' do + let(:pre_condition) do + <<-eos + class { '::tripleo::profile::base::nova': + step => #{params[:step]}, + messaging_hosts => [ '127.0.0.1' ], + } + class { '::tripleo::profile::base::nova::compute': + step => #{params[:step]}, + } +eos + end + + let(:params) { { :step => 4, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::compute::libvirt') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('tripleo::profile::base::nova::compute') + is_expected.to contain_class('nova::compute::libvirt') + is_expected.to contain_class('nova::compute::libvirt::qemu') + } + end + end + + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::nova::compute::libvirt' + end + end +end diff --git a/spec/classes/tripleo_profile_base_nova_compute_spec.rb b/spec/classes/tripleo_profile_base_nova_compute_spec.rb new file mode 100644 index 0000000..a6fdbd6 --- /dev/null +++ b/spec/classes/tripleo_profile_base_nova_compute_spec.rb @@ -0,0 +1,87 @@ +# +# Copyright (C) 2017 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::nova::compute' do + shared_examples_for 'tripleo::profile::base::nova::compute' do + + context 'with step less than 5' do + let(:params) { { :step => 1, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::compute') + is_expected.to_not contain_class('tripleo::profile::base::nova') + is_expected.to_not contain_class('nova::compute') + is_expected.to_not contain_class('nova::network::neutron') + is_expected.to_not contain_exec('reset-iscsi-initiator-name') + is_expected.to_not contain_file('/etc/iscsi/.initiator_reset') + } + end + + context 'with step 5' do + let(:pre_condition) do + <<-eos + class { '::tripleo::profile::base::nova': + step => #{params[:step]}, + messaging_hosts => [ '127.0.0.1' ], + } +eos + end + + context 'default params' do + let(:params) { { :step => 4, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::compute') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova::compute') + is_expected.to contain_class('nova::network::neutron') + is_expected.to contain_exec('reset-iscsi-initiator-name') + is_expected.to contain_file('/etc/iscsi/.initiator_reset') + is_expected.to_not contain_package('nfs-utils') + } + end + + context 'cinder nfs backend' do + let(:params) { { :step => 4, :cinder_nfs_backend => true } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::compute') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova::compute') + is_expected.to contain_class('nova::network::neutron') + is_expected.to contain_exec('reset-iscsi-initiator-name') + is_expected.to contain_file('/etc/iscsi/.initiator_reset') + is_expected.to contain_package('nfs-utils') + } + end + end + end + + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::nova::compute' + end + end +end diff --git a/spec/classes/tripleo_profile_base_nova_conductor_spec.rb b/spec/classes/tripleo_profile_base_nova_conductor_spec.rb new file mode 100644 index 0000000..8cdf8b0 --- /dev/null +++ b/spec/classes/tripleo_profile_base_nova_conductor_spec.rb @@ -0,0 +1,61 @@ +# +# Copyright (C) 2017 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::nova::conductor' do + shared_examples_for 'tripleo::profile::base::nova::conductor' do + let(:pre_condition) do + <<-eos + class { '::tripleo::profile::base::nova': + step => #{params[:step]}, + messaging_hosts => [ '127.0.0.1' ], + } +eos + end + + context 'with step less than 4' do + let(:params) { { :step => 1, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::conductor') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to_not contain_class('nova::conductor') + } + end + + context 'with step 4' do + let(:params) { { :step => 4, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::conductor') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova::conductor') + } + end + end + + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::nova::conductor' + end + end +end diff --git a/spec/classes/tripleo_profile_base_nova_consoleauth_spec.rb b/spec/classes/tripleo_profile_base_nova_consoleauth_spec.rb new file mode 100644 index 0000000..e8a2dff --- /dev/null +++ b/spec/classes/tripleo_profile_base_nova_consoleauth_spec.rb @@ -0,0 +1,62 @@ +# +# Copyright (C) 2017 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::nova::consoleauth' do + shared_examples_for 'tripleo::profile::base::nova::consoleauth' do + + context 'with step less than 4' do + let(:params) { { :step => 1, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::consoleauth') + is_expected.to_not contain_class('tripleo::profile::base::nova') + is_expected.to_not contain_class('nova::consoleauth') + } + end + + context 'with step 4' do + let(:pre_condition) do + <<-eos + class { '::tripleo::profile::base::nova': + step => #{params[:step]}, + messaging_hosts => [ '127.0.0.1' ], + } +eos + end + + let(:params) { { :step => 4, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::consoleauth') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova::consoleauth') + } + end + end + + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::nova::consoleauth' + end + end +end diff --git a/spec/classes/tripleo_profile_base_nova_libvirt_spec.rb b/spec/classes/tripleo_profile_base_nova_libvirt_spec.rb new file mode 100644 index 0000000..d263a74 --- /dev/null +++ b/spec/classes/tripleo_profile_base_nova_libvirt_spec.rb @@ -0,0 +1,68 @@ +# +# Copyright (C) 2017 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::nova::libvirt' do + shared_examples_for 'tripleo::profile::base::nova::libvirt' do + + context 'with step less than 4' do + let(:params) { { :step => 1, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::libvirt') + is_expected.to_not contain_class('tripleo::profile::base::nova') + is_expected.to_not contain_class('nova::compute::libvirt::services') + is_expected.to_not contain_file('/etclibvirt/qemu/networks/autostart/default.xml') + is_expected.to_not contain_file('/etclibvirt/qemu/networks/default.xml') + is_expected.to_not contain_exec('libvirt-default-net-destroy') + } + end + + context 'with step 4' do + let(:pre_condition) do + <<-eos + class { '::tripleo::profile::base::nova': + step => #{params[:step]}, + messaging_hosts => [ '127.0.0.1' ], + } +eos + end + + let(:params) { { :step => 4, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::libvirt') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova::compute::libvirt::services') + is_expected.to contain_file('/etc/libvirt/qemu/networks/autostart/default.xml').with_ensure('absent') + is_expected.to contain_file('/etc/libvirt/qemu/networks/default.xml').with_ensure('absent') + is_expected.to contain_exec('libvirt-default-net-destroy') + } + end + end + + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::nova::libvirt' + end + end +end diff --git a/spec/classes/tripleo_profile_base_nova_scheduler_spec.rb b/spec/classes/tripleo_profile_base_nova_scheduler_spec.rb new file mode 100644 index 0000000..87783c1 --- /dev/null +++ b/spec/classes/tripleo_profile_base_nova_scheduler_spec.rb @@ -0,0 +1,64 @@ +# +# Copyright (C) 2017 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::nova::scheduler' do + shared_examples_for 'tripleo::profile::base::nova::scheduler' do + + context 'with step less than 4' do + let(:params) { { :step => 1, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::scheduler') + is_expected.to_not contain_class('tripleo::profile::base::nova') + is_expected.to_not contain_class('nova::scheduler') + is_expected.to_not contain_class('nova::scheduler::filter') + } + end + + context 'with step 4' do + let(:pre_condition) do + <<-eos + class { '::tripleo::profile::base::nova': + step => #{params[:step]}, + messaging_hosts => [ '127.0.0.1' ], + } +eos + end + + let(:params) { { :step => 4, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::scheduler') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova::scheduler') + is_expected.to contain_class('nova::scheduler::filter') + } + end + end + + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::nova::scheduler' + end + end +end diff --git a/spec/classes/tripleo_profile_base_nova_spec.rb b/spec/classes/tripleo_profile_base_nova_spec.rb new file mode 100644 index 0000000..68b01e9 --- /dev/null +++ b/spec/classes/tripleo_profile_base_nova_spec.rb @@ -0,0 +1,135 @@ +# +# Copyright (C) 2017 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::nova' do + shared_examples_for 'tripleo::profile::base::nova' do + + context 'with step less than 3' do + let(:params) { { + :step => 1, + :messaging_hosts => [ 'localhost' ], + :messaging_password => 'foo' + } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to_not contain_class('nova') + is_expected.to_not contain_class('nova::config') + is_expected.to_not contain_class('nova::cache') + } + end + + context 'with step 3 on bootstrap node' do + let(:params) { { + :step => 3, + :bootstrap_node => 'node.example.com', + :messaging_hosts => [ 'localhost' ], + :messaging_username => 'nova', + :messaging_password => 'foo', + } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova').with( + :default_transport_url => 'rabbit://nova:foo@localhost:5672/?ssl=0' + ) + is_expected.to contain_class('nova::config') + is_expected.to contain_class('nova::placement') + is_expected.to contain_class('nova::cache').with( + :enabled => true, + :backend => 'oslo_cache.memcache_pool', + :memcache_servers => ['127.0.0.1:11211'] + ) + } + end + + context 'with step 3 not on bootstrap node' do + let(:params) { { + :step => 3, + :bootstrap_node => 'other.example.com', + :messaging_hosts => [ 'localhost' ], + :messaging_password => 'foo' + } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to_not contain_class('nova') + is_expected.to_not contain_class('nova::config') + is_expected.to_not contain_class('nova::cache') + is_expected.to_not contain_class('nova::placement') + } + end + + context 'with step 4' do + let(:params) { { + :step => 4, + :bootstrap_node => 'other.example.com', + :messaging_hosts => [ 'localhost' ], + :messaging_password => 'foo', + } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova') + is_expected.to contain_class('nova::config') + is_expected.to contain_class('nova::cache') + is_expected.to contain_class('nova::placement') + is_expected.to_not contain_class('nova::migration::libvirt') + } + end + + context 'with step 4 with libvirt' do + let(:pre_condition) { + 'include ::nova::compute::libvirt::services' + } + let(:params) { { + :step => 4, + :libvirt_enabled => true, + :manage_migration => true, + :nova_compute_enabled => true, + :bootstrap_node => 'node.example.com', + :messaging_hosts => [ 'localhost' ], + :messaging_password => 'foo', + } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova') + is_expected.to contain_class('nova::config') + is_expected.to contain_class('nova::placement') + is_expected.to contain_class('nova::cache') + is_expected.to contain_class('nova::migration::libvirt').with( + :configure_libvirt => params[:libvirt_enabled], + :configure_nova => params[:nova_compute_enabled] + ) + } + end + + end + + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::nova' + end + end +end diff --git a/spec/classes/tripleo_profile_base_nova_vncproxy_spec.rb b/spec/classes/tripleo_profile_base_nova_vncproxy_spec.rb new file mode 100644 index 0000000..f077875 --- /dev/null +++ b/spec/classes/tripleo_profile_base_nova_vncproxy_spec.rb @@ -0,0 +1,62 @@ +# +# Copyright (C) 2017 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::nova::vncproxy' do + shared_examples_for 'tripleo::profile::base::nova::vncproxy' do + + context 'with step less than 4' do + let(:params) { { :step => 1, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::vncproxy') + is_expected.to_not contain_class('tripleo::profile::base::nova') + is_expected.to_not contain_class('nova::vncproxy') + } + end + + context 'with step 4' do + let(:pre_condition) do + <<-eos + class { '::tripleo::profile::base::nova': + step => #{params[:step]}, + messaging_hosts => [ '127.0.0.1' ], + } +eos + end + + let(:params) { { :step => 4, } } + + it { + is_expected.to contain_class('tripleo::profile::base::nova::vncproxy') + is_expected.to contain_class('tripleo::profile::base::nova') + is_expected.to contain_class('nova::vncproxy') + } + end + end + + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::nova::vncproxy' + end + end +end diff --git a/spec/classes/tripleo_profile_base_octavia_api_spec.rb b/spec/classes/tripleo_profile_base_octavia_api_spec.rb new file mode 100644 index 0000000..e94e00c --- /dev/null +++ b/spec/classes/tripleo_profile_base_octavia_api_spec.rb @@ -0,0 +1,138 @@ +# +# Copyright (C) 2016 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::octavia::api' do + + let :params do + { :step => 5, + :bootstrap_node => 'notbootstrap.example.com' + } + end + + shared_examples_for 'tripleo::profile::base::octavia::api' do + before :each do + facts.merge!({ :step => params[:step] }) + end + + let(:pre_condition) do + <<-eos + class { 'tripleo::profile::base::octavia' : + step => #{params[:step]}, + rabbit_user => 'bugs', + rabbit_password => 'rabbits_R_c00l', + rabbit_hosts => ['hole.field.com'] + } + class { 'octavia::db::mysql': + password => 'some_password' + } + class { 'octavia::keystone::authtoken': + password => 'some_password' + } +eos + end + + context 'with step less than 3 on bootstrap' do + before do + params.merge!({ + :step => 2, + :bootstrap_node => 'node.example.com' + }) + end + + it 'should not do anything' do + is_expected.to_not contain_class('octavia::api') + end + end + + context 'with step less than 3 on non-bootstrap' do + before do + params.merge!({ :step => 2 }) + end + + it 'should not do anything' do + is_expected.to_not contain_class('octavia::api') + end + end + + context 'with step 3 on bootstrap node' do + before do + params.merge!({ + :step => 3, + :bootstrap_node => 'node.example.com' + }) + end + + it 'should should start configurating database' do + is_expected.to_not contain_class('octavia::api') + end + end + + context 'with step 3 on non-bootstrap node' do + before do + params.merge!({ :step => 3 }) + end + + it 'should do nothing' do + is_expected.to_not contain_class('octavia::api') + end + end + + context 'with step 4 on bootstrap node' do + before do + params.merge!({ + :step => 4, + :bootstrap_node => 'node.example.com' + }) + end + + it 'should should sync database' do + is_expected.to contain_class('octavia::api').with(:sync_db => true) + end + end + + context 'with step 4 on non-bootstrap node' do + before do + params.merge!({ :step => 4 }) + end + + it 'should do nothing' do + is_expected.to_not contain_class('octavia::api') + end + end + + context 'with step 5 on non-bootstrap node' do + before do + params.merge!({ :step => 5 }) + end + + it 'should do nothing' do + is_expected.to contain_class('octavia::api').with(:sync_db => false) + end + end + end + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + it_behaves_like 'tripleo::profile::base::octavia::api' + end + end +end + diff --git a/spec/classes/tripleo_profile_base_octavia_spec.rb b/spec/classes/tripleo_profile_base_octavia_spec.rb new file mode 100644 index 0000000..89820ef --- /dev/null +++ b/spec/classes/tripleo_profile_base_octavia_spec.rb @@ -0,0 +1,119 @@ +# +# Copyright (C) 2016 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::octavia' do + + let :params do + { :rabbit_hosts => ['some.server.com'], + :step => 5 + } + end + + shared_examples_for 'tripleo::profile::base::octavia' do + + context 'with step less than 3' do + before do + params.merge!({ :step => 2 }) + end + + it 'should not do anything' do + is_expected.to_not contain_class('octavia') + is_expected.to_not contain_class('octavia::config') + end + end + + context 'with step 3' do + before do + params.merge!({ :step => 3 }) + end + + it 'should provide basic initialization' do + is_expected.to contain_class('octavia').with( + :default_transport_url => 'rabbit://some.server.com:5672/' + ) + is_expected.to contain_class('octavia::config') + end + end + + context 'with multiple hosts' do + before do + params.merge!({ :rabbit_hosts => ['some.server.com', 'someother.server.com'] }) + end + + it 'should construct a multihost URL' do + is_expected.to contain_class('octavia').with( + :default_transport_url => 'rabbit://some.server.com:5672,someother.server.com:5672/' + ) + end + end + + context 'with username provided' do + before do + params.merge!({ :rabbit_user => 'bunny' }) + end + + it 'should construct URL with username' do + is_expected.to contain_class('octavia').with( + :default_transport_url => 'rabbit://bunny@some.server.com:5672/' + ) + end + end + + context 'with username and password provided' do + before do + params.merge!( + { :rabbit_user => 'bunny', + :rabbit_password => 'carrot' + } + ) + end + + it 'should construct URL with username and password' do + is_expected.to contain_class('octavia').with( + :default_transport_url => 'rabbit://bunny:carrot@some.server.com:5672/' + ) + end + end + + context 'with multiple hosts and user info provided' do + before do + params.merge!( + { :rabbit_hosts => ['some.server.com', 'someother.server.com'], + :rabbit_user => 'bunny', + :rabbit_password => 'carrot' + } + ) + end + + it 'should distributed user info across hosts URL' do + is_expected.to contain_class('octavia').with( + :default_transport_url => 'rabbit://bunny:carrot@some.server.com:5672,bunny:carrot@someother.server.com:5672/' + ) + end + end + end + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({}) + end + it_behaves_like 'tripleo::profile::base::octavia' + end + end +end diff --git a/spec/classes/tripleo_profile_base_sshd_spec.rb b/spec/classes/tripleo_profile_base_sshd_spec.rb new file mode 100644 index 0000000..210b41c --- /dev/null +++ b/spec/classes/tripleo_profile_base_sshd_spec.rb @@ -0,0 +1,30 @@ +# Copyright 2016 Red Hat, Inc. +# All Rights Reserved. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::sshd' do + + context 'with banner configured' do + it do + is_expected.to contain_file('/etc/issue').with({ + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0600', + }) + end + end +end diff --git a/spec/classes/tripleo_profile_pacemaker_ceph_rbdmirror_spec.rp b/spec/classes/tripleo_profile_pacemaker_ceph_rbdmirror_spec.rp new file mode 100644 index 0000000..4df0a09 --- /dev/null +++ b/spec/classes/tripleo_profile_pacemaker_ceph_rbdmirror_spec.rp @@ -0,0 +1,64 @@ +# +# Copyright (C) 2016 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::profile::pacemaker::ceph::rbdmirror' do + shared_examples_for 'tripleo::profile::pacemaker::ceph::rbdmirror' do + let (:pre_condition) do + <<-eof + class { '::tripleo::profile::base::ceph': + step => #{params[:step]} + } + eof + end + + context 'with step less than 3' do + let(:params) { { :step => 2 } } + it 'should do nothing' do + is_expected.to contain_class('tripleo::profile::base::ceph') + is_expected.to_not contain_class('ceph::mirror') + end + end + + context 'with step 3 and client_name' do + let(:params) { { + :step => 3, + :client_name => 'myname', + } } + + it 'should include rbdmirror configuration' do + is_expected.to contain_class('tripleo::profile::base::ceph') + is_expected.to contain_class('ceph::rbdmirror').with( + :rbd_mirror_enable => false, + :rbd_mirror_ensure => 'stopped', + ) + is_expected.to contain_class('pacemaker::resource::service') + end + end + + end + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::pacemaker::ceph::rbdmirror' + end + end +end diff --git a/spec/classes/tripleo_ui_spec.rb b/spec/classes/tripleo_ui_spec.rb new file mode 100644 index 0000000..f3a4f25 --- /dev/null +++ b/spec/classes/tripleo_ui_spec.rb @@ -0,0 +1,121 @@ +# +# Copyright (C) 2016 Red Hat, Inc. +# +# 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. +# + +require 'spec_helper' + +describe 'tripleo::ui' do + shared_examples_for 'tripleo::ui' do + let(:pre_condition) do + 'include ::apache' + end + + context 'with required parameters' do + let(:params) { { + :servername => facts[:hostname], + :bind_host => '127.0.0.1', + :endpoint_proxy_keystone => 'http://127.0.0.1:5000', + :endpoint_proxy_zaqar => 'ws://127.0.0.1:9000/zaqar', + :endpoint_proxy_heat => 'http://127.0.0.1:8004', + :endpoint_proxy_ironic => 'http://127.0.0.1:6385', + :endpoint_proxy_mistral => 'http://127.0.0.1:8989', + :endpoint_proxy_swift => 'http://127.0.0.1:8080', + :endpoint_config_keystone => 'https://127.0.0.1:443/keystone/v2.0', + :endpoint_config_zaqar => 'wss://127.0.0.1:443/zaqar', + :endpoint_config_heat => 'https://127.0.0.1:443/heat/v1/%(tenant_id)s', + :endpoint_config_ironic => 'https://127.0.0.1:443/ironic', + :endpoint_config_mistral => 'https://127.0.0.1:443/mistral/v2', + :endpoint_config_swift => 'https://127.0.0.1:443/swift/v1/AUTH_%(tenant_id)s' + } } + + it 'should configure tripleo ui' do + is_expected.to contain_class('tripleo::ui') + is_expected.to contain_apache__vhost('tripleo-ui').with( + :ensure => 'present', + :servername => facts[:hostname], + :ip => '127.0.0.1', + :port => 3000, + :docroot => '/var/www/openstack-tripleo-ui/dist', + :options => [ 'Indexes', 'FollowSymLinks' ], + :fallbackresource => '/index.html' + ) + is_expected.to contain_file('/etc/httpd/conf.d/openstack-tripleo-ui.conf').with_content(/cleaned by Puppet/) + is_expected.to contain_file('/var/www/openstack-tripleo-ui/dist/tripleo_ui_config.js') + .with_content(/'keystone': 'https:\/\/127.0.0.1:443\/keystone\/v2.0'/) + .with_content(/'heat': 'https:\/\/127.0.0.1:443\/heat\/v1\/%\(tenant_id\)s'/) + .with_content(/'zaqar-websocket': 'wss:\/\/127.0.0.1:443\/zaqar'/) + .with_content(/'ironic': 'https:\/\/127.0.0.1:443\/ironic'/) + .with_content(/'mistral': 'https:\/\/127.0.0.1:443\/mistral\/v2'/) + .with_content(/'swift': 'https:\/\/127.0.0.1:443\/swift\/v1\/AUTH_%\(tenant_id\)s'/) + .with_content(/'zaqar_default_queue': 'tripleo'/) + end + end + + context 'with all parameters' do + let(:params) { { + :servername => 'custom.example.com', + :bind_host => '127.0.0.2', + :ui_port => 3001, + :endpoint_proxy_keystone => 'http://127.0.0.1:5000', + :endpoint_proxy_zaqar => 'ws://127.0.0.1:9000/zaqar', + :endpoint_proxy_heat => 'http://127.0.0.1:8004', + :endpoint_proxy_ironic => 'http://127.0.0.1:6385', + :endpoint_proxy_mistral => 'http://127.0.0.1:8989', + :endpoint_proxy_swift => 'http://127.0.0.1:8080', + :endpoint_config_keystone => 'https://127.0.0.1:443/keystone/v2.0', + :endpoint_config_zaqar => 'wss://127.0.0.1:443/zaqar', + :endpoint_config_heat => 'https://127.0.0.1:443/heat/v1/%(tenant_id)s', + :endpoint_config_ironic => 'https://127.0.0.1:443/ironic', + :endpoint_config_mistral => 'https://127.0.0.1:443/mistral/v2', + :endpoint_config_swift => 'https://127.0.0.1:443/swift/v1/AUTH_%(tenant_id)s', + :zaqar_default_queue => 'tripleo' + } } + + it 'should configure tripleo ui' do + is_expected.to contain_class('tripleo::ui') + is_expected.to contain_apache__vhost('tripleo-ui').with( + :ensure => 'present', + :servername => 'custom.example.com', + :ip => '127.0.0.2', + :port => 3001, + :docroot => '/var/www/openstack-tripleo-ui/dist', + :options => [ 'Indexes', 'FollowSymLinks' ], + :fallbackresource => '/index.html' + ) + is_expected.to contain_file('/etc/httpd/conf.d/openstack-tripleo-ui.conf').with_content(/cleaned by Puppet/) + is_expected.to contain_file('/var/www/openstack-tripleo-ui/dist/tripleo_ui_config.js') + .with_content(/'keystone': 'https:\/\/127.0.0.1:443\/keystone\/v2.0'/) + .with_content(/'heat': 'https:\/\/127.0.0.1:443\/heat\/v1\/%\(tenant_id\)s'/) + .with_content(/'zaqar-websocket': 'wss:\/\/127.0.0.1:443\/zaqar'/) + .with_content(/'ironic': 'https:\/\/127.0.0.1:443\/ironic'/) + .with_content(/'mistral': 'https:\/\/127.0.0.1:443\/mistral\/v2'/) + .with_content(/'swift': 'https:\/\/127.0.0.1:443\/swift\/v1\/AUTH_%\(tenant_id\)s'/) + .with_content(/'zaqar_default_queue': 'tripleo'/) + end + end + + end + + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::ui' + end + end +end |