diff options
Diffstat (limited to 'spec/classes')
40 files changed, 2172 insertions, 243 deletions
diff --git a/spec/classes/tripleo_cluster_cassandra_spec.rb b/spec/classes/tripleo_cluster_cassandra_spec.rb deleted file mode 100644 index 3f7d471..0000000 --- a/spec/classes/tripleo_cluster_cassandra_spec.rb +++ /dev/null @@ -1,54 +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 cassandra service - -require 'spec_helper' - -describe 'tripleo::cluster::cassandra' do - - shared_examples_for 'tripleo::cluster::cassandra' do - - let :params do - { - :cassandra_servers => ['192.168.2.2', '192.168.2.3'], - :cassandra_ip => '192.168.2.2' - } - end - - it 'should configure cassandra' do - is_expected.to contain_class('cassandra').with( - :seeds => ['192.168.2.2', '192.168.2.3'], - :listen_address => '192.168.2.2', - :storage_port => 7000, - :ssl_storage_port => 7001, - :native_transport_port => 9042, - :rpc_port => 9160 - ) - - end - end - - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts.merge({}) - end - - it_behaves_like 'tripleo::cluster::cassandra' - end - end - -end diff --git a/spec/classes/tripleo_cluster_zookeeper_spec.rb b/spec/classes/tripleo_cluster_zookeeper_spec.rb deleted file mode 100644 index fc003b6..0000000 --- a/spec/classes/tripleo_cluster_zookeeper_spec.rb +++ /dev/null @@ -1,86 +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 zookeeper service - -require 'spec_helper' - -describe 'tripleo::cluster::zookeeper' do - - shared_examples_for 'tripleo::cluster::zookeeper' do - let :params do - { - :zookeeper_server_ips => ['23.43.2.34', '23.43.2.35', '24.43.2.36'], - :zookeeper_hostnames => ['host1.midonet', 'host2.midonet', 'host3.midonet'] - } - end - - context 'on host1' do - before :each do - facts.merge!({ :hostname => 'host1.midonet'}) - params.merge!({ :zookeeper_client_ip => '23.43.2.34' }) - end - - it 'should call zookeeper using id==1' do - is_expected.to contain_class('zookeeper').with( - :servers => ['23.43.2.34', '23.43.2.35', '24.43.2.36'], - :client_ip => '23.43.2.34', - :id => 1 - ) - end - end - - context 'on host2' do - before :each do - facts.merge!({ :hostname => 'host2.midonet'}) - params.merge!({ :zookeeper_client_ip => '23.43.2.35' }) - end - - it 'should call zookeeper using id==1' do - is_expected.to contain_class('zookeeper').with( - :servers => ['23.43.2.34', '23.43.2.35', '24.43.2.36'], - :client_ip => '23.43.2.35', - :id => 2 - ) - end - end - - context 'on host3' do - before :each do - facts.merge!({ :hostname => 'host3.midonet'}) - params.merge!({ :zookeeper_client_ip => '23.43.2.36' }) - end - - it 'should call zookeeper using id==1' do - is_expected.to contain_class('zookeeper').with( - :servers => ['23.43.2.34', '23.43.2.35', '24.43.2.36'], - :client_ip => '23.43.2.36', - :id => 3 - ) - end - - end - end - - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts.merge({}) - end - - it_behaves_like 'tripleo::cluster::zookeeper' - end - end -end 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_api_spec.rb b/spec/classes/tripleo_midonet_api_spec.rb deleted file mode 100644 index 25b375b..0000000 --- a/spec/classes/tripleo_midonet_api_spec.rb +++ /dev/null @@ -1,76 +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 api - -require 'spec_helper' - -describe 'tripleo::network::midonet::api' do - - shared_examples_for 'tripleo::midonet::api' do - - let :params do - { - :zookeeper_servers => ['192.168.2.1', '192.168.2.2'], - :vip => '192.23.0.2', - :keystone_ip => '192.23.0.2', - :keystone_admin_token => 'admin_token', - :admin_password => 'admin_password', - :bind_address => '192.23.0.65' - } - end - - it 'should call api configuration' do - is_expected.to contain_class('midonet::midonet_api::run').with( - :zk_servers => [{'ip' => '192.168.2.1', 'port' => 2181}, - {'ip' => '192.168.2.2', 'port' => 2181}], - :keystone_auth => true, - :tomcat_package => 'tomcat', - :vtep => false, - :api_ip => '192.23.0.2', - :api_port => '8081', - :keystone_host => '192.23.0.2', - :keystone_port => 35357, - :keystone_admin_token => 'admin_token', - :keystone_tenant_name => 'admin', - :catalina_base => '/usr/share/tomcat', - :bind_address => '192.23.0.65' - ) - end - - it 'should install the cli' do - is_expected.to contain_class('midonet::midonet_cli').with( - :api_endpoint => 'http://192.23.0.2:8081/midonet-api', - :username => 'admin', - :password => 'admin_password', - :tenant_name => 'admin' - ) - end - - end - - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts.merge({ - :augeasversion => '1.0.0' - }) - end - - it_behaves_like 'tripleo::midonet::api' - end - end - -end diff --git a/spec/classes/tripleo_profile_base_aodh_api_spec.rb b/spec/classes/tripleo_profile_base_aodh_api_spec.rb index 63dbe71..22f26cf 100644 --- a/spec/classes/tripleo_profile_base_aodh_api_spec.rb +++ b/spec/classes/tripleo_profile_base_aodh_api_spec.rb @@ -19,7 +19,7 @@ require 'spec_helper' describe 'tripleo::profile::base::aodh::api' do shared_examples_for 'tripleo::profile::base::aodh::api' do let(:pre_condition) do - "class { '::tripleo::profile::base::aodh': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] }" + "class { '::tripleo::profile::base::aodh': step => #{params[:step]}, rabbit_hosts => ['localhost.localdomain'] }" end context 'with step less than 4' do diff --git a/spec/classes/tripleo_profile_base_aodh_evaluator_spec.rb b/spec/classes/tripleo_profile_base_aodh_evaluator_spec.rb index 5ac7971..495794d 100644 --- a/spec/classes/tripleo_profile_base_aodh_evaluator_spec.rb +++ b/spec/classes/tripleo_profile_base_aodh_evaluator_spec.rb @@ -19,7 +19,7 @@ require 'spec_helper' describe 'tripleo::profile::base::aodh::evaluator' do shared_examples_for 'tripleo::profile::base::aodh::evaluator' do let(:pre_condition) do - "class { '::tripleo::profile::base::aodh': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] }" + "class { '::tripleo::profile::base::aodh': step => #{params[:step]}, rabbit_hosts => ['localhost.localdomain'] }" end context 'with step less than 4' do diff --git a/spec/classes/tripleo_profile_base_aodh_listener_spec.rb b/spec/classes/tripleo_profile_base_aodh_listener_spec.rb index da1305f..022ee5c 100644 --- a/spec/classes/tripleo_profile_base_aodh_listener_spec.rb +++ b/spec/classes/tripleo_profile_base_aodh_listener_spec.rb @@ -19,7 +19,7 @@ require 'spec_helper' describe 'tripleo::profile::base::aodh::listener' do shared_examples_for 'tripleo::profile::base::aodh::listener' do let(:pre_condition) do - "class { '::tripleo::profile::base::aodh': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] }" + "class { '::tripleo::profile::base::aodh': step => #{params[:step]}, rabbit_hosts => ['localhost.localdomain'] }" end context 'with step less than 4' do diff --git a/spec/classes/tripleo_profile_base_aodh_notifier_spec.rb b/spec/classes/tripleo_profile_base_aodh_notifier_spec.rb index 1b74a68..f2116ca 100644 --- a/spec/classes/tripleo_profile_base_aodh_notifier_spec.rb +++ b/spec/classes/tripleo_profile_base_aodh_notifier_spec.rb @@ -19,7 +19,7 @@ require 'spec_helper' describe 'tripleo::profile::base::aodh::notifier' do shared_examples_for 'tripleo::profile::base::aodh::notifier' do let(:pre_condition) do - "class { '::tripleo::profile::base::aodh': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] }" + "class { '::tripleo::profile::base::aodh': step => #{params[:step]}, rabbit_hosts => ['localhost.localdomain'] }" end context 'with step less than 4' do diff --git a/spec/classes/tripleo_profile_base_aodh_spec.rb b/spec/classes/tripleo_profile_base_aodh_spec.rb index dd6554e..3befa23 100644 --- a/spec/classes/tripleo_profile_base_aodh_spec.rb +++ b/spec/classes/tripleo_profile_base_aodh_spec.rb @@ -34,7 +34,7 @@ describe 'tripleo::profile::base::aodh' do let(:params) { { :step => 3, :bootstrap_node => 'node.example.com', - :rabbit_hosts => ['127.0.0.1', '127.0.0.2'] + :rabbit_hosts => ['localhost1.localdomain', 'localhost2.localdomain'] } } it 'should trigger complete configuration' do @@ -67,7 +67,7 @@ describe 'tripleo::profile::base::aodh' do let(:params) { { :step => 4, :bootstrap_node => 'somethingelse.example.com', - :rabbit_hosts => ['127.0.0.1', '127.0.0.2'] + :rabbit_hosts => ['localhost1.localdomain', 'localhost2.localdomain'] } } it 'should trigger aodh configuration without mysql grant' do diff --git a/spec/classes/tripleo_profile_base_ceilometer_api_spec.rb b/spec/classes/tripleo_profile_base_ceilometer_api_spec.rb index 256b756..2887d32 100644 --- a/spec/classes/tripleo_profile_base_ceilometer_api_spec.rb +++ b/spec/classes/tripleo_profile_base_ceilometer_api_spec.rb @@ -19,7 +19,7 @@ require 'spec_helper' describe 'tripleo::profile::base::ceilometer::api' do shared_examples_for 'tripleo::profile::base::ceilometer::api' do let(:pre_condition) do - "class { '::tripleo::profile::base::ceilometer': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] }" + "class { '::tripleo::profile::base::ceilometer': step => #{params[:step]}, rabbit_hosts => ['localhost.localdomain'] }" end context 'with step less than 4' do @@ -32,9 +32,10 @@ describe 'tripleo::profile::base::ceilometer::api' do end end - context 'with step 4' do + context 'with step 4 and enable_legacy_api' do let(:params) { { - :step => 4, + :step => 4, + :enable_legacy_api => true, } } it 'should trigger complete configuration' do @@ -42,6 +43,17 @@ describe 'tripleo::profile::base::ceilometer::api' do is_expected.to contain_class('ceilometer::wsgi::apache') end end + + context 'with step 4 and default enable_legacy_api' do + let(:params) { { + :step => 4, + } } + + it 'should do nothing' do + is_expected.to_not contain_class('ceilometer::api') + is_expected.to_not contain_class('ceilometer::wsgi::apache') + end + end end diff --git a/spec/classes/tripleo_profile_base_ceilometer_collector_spec.rb b/spec/classes/tripleo_profile_base_ceilometer_collector_spec.rb index 718c700..2e4b50a 100644 --- a/spec/classes/tripleo_profile_base_ceilometer_collector_spec.rb +++ b/spec/classes/tripleo_profile_base_ceilometer_collector_spec.rb @@ -19,7 +19,7 @@ require 'spec_helper' describe 'tripleo::profile::base::ceilometer::collector' do shared_examples_for 'tripleo::profile::base::ceilometer::collector' do let(:pre_condition) do - "class { '::tripleo::profile::base::ceilometer': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] }" + "class { '::tripleo::profile::base::ceilometer': step => #{params[:step]}, rabbit_hosts => ['localhost.localdomain'] }" end context 'with step 3 on bootstrap node with mongodb' do diff --git a/spec/classes/tripleo_profile_base_ceilometer_expirer_spec.rb b/spec/classes/tripleo_profile_base_ceilometer_expirer_spec.rb index bbef431..c13f3c8 100644 --- a/spec/classes/tripleo_profile_base_ceilometer_expirer_spec.rb +++ b/spec/classes/tripleo_profile_base_ceilometer_expirer_spec.rb @@ -19,7 +19,7 @@ require 'spec_helper' describe 'tripleo::profile::base::ceilometer::expirer' do shared_examples_for 'tripleo::profile::base::ceilometer::expirer' do let(:pre_condition) do - "class { '::tripleo::profile::base::ceilometer': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] }" + "class { '::tripleo::profile::base::ceilometer': step => #{params[:step]}, rabbit_hosts => ['localhost.localdomain'] }" end context 'with step less than 4' do diff --git a/spec/classes/tripleo_profile_base_ceilometer_spec.rb b/spec/classes/tripleo_profile_base_ceilometer_spec.rb index 5510f4b..075aff8 100644 --- a/spec/classes/tripleo_profile_base_ceilometer_spec.rb +++ b/spec/classes/tripleo_profile_base_ceilometer_spec.rb @@ -30,7 +30,7 @@ describe 'tripleo::profile::base::ceilometer' do context 'with step 3' do let(:params) { { :step => 3, - :rabbit_hosts => ['127.0.0.1', '127.0.0.2'] + :rabbit_hosts => ['localhost1.localdomain', 'localhost2.localdomain'] } } 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 new file mode 100644 index 0000000..a0c607d --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_api_spec.rb @@ -0,0 +1,86 @@ +# +# 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::api' do + shared_examples_for 'tripleo::profile::base::cinder::api' do + let(:pre_condition) do + "class { '::tripleo::profile::base::cinder': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] }" + end + + context 'with step less than 3' do + let(:params) { { :step => 1 } } + + it 'should do nothing' do + is_expected.to contain_class('tripleo::profile::base::cinder::api') + 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 + + context 'with step 3 on bootstrap node' do + let(:params) { { + :step => 3, + :bootstrap_node => 'node.example.com', + } } + + 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 + + context 'with step 3 not on bootstrap node' do + let(:params) { { + :step => 3, + :bootstrap_node => 'other.example.com', + } } + + 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 + + context 'with step 4' do + let(:params) { { + :step => 4, + } } + + 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 + + + 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::api' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_backup_ceph_spec.rb b/spec/classes/tripleo_profile_base_cinder_backup_ceph_spec.rb new file mode 100644 index 0000000..46c3d15 --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_backup_ceph_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::cinder::backup::ceph' do + shared_examples_for 'tripleo::profile::base::cinder::backup::ceph' do + let(:pre_condition) do + <<-EOF + class { '::tripleo::profile::base::cinder': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] } + class { '::tripleo::profile::base::cinder::backup': step => #{params[:step]} } + EOF + 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::backup::ceph') + is_expected.to contain_class('tripleo::profile::base::cinder::backup') + is_expected.to_not contain_class('cinder::backup::ceph') + end + end + + context 'with step 4' do + let(:params) { { + :step => 4, + } } + + it 'should trigger complete configuration' do + is_expected.to contain_class('cinder::backup::ceph') + 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::backup::ceph' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_backup_spec.rb b/spec/classes/tripleo_profile_base_cinder_backup_spec.rb new file mode 100644 index 0000000..0e15c9a --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_backup_spec.rb @@ -0,0 +1,56 @@ +# +# 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::backup' do + shared_examples_for 'tripleo::profile::base::cinder::backup' do + let(:pre_condition) do + "class { '::tripleo::profile::base::cinder': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] }" + 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::backup') + is_expected.to contain_class('tripleo::profile::base::cinder') + is_expected.to_not contain_class('cinder::backup') + end + end + + context 'with step 4' do + let(:params) { { + :step => 4, + } } + + it 'should trigger complete configuration' do + is_expected.to contain_class('cinder::backup') + 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::backup' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_backup_swift_spec.rb b/spec/classes/tripleo_profile_base_cinder_backup_swift_spec.rb new file mode 100644 index 0000000..2c9d71f --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_backup_swift_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::cinder::backup::swift' do + shared_examples_for 'tripleo::profile::base::cinder::backup::swift' do + let(:pre_condition) do + <<-EOF + class { '::tripleo::profile::base::cinder': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] } + class { '::tripleo::profile::base::cinder::backup': step => #{params[:step]} } + EOF + 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::backup::swift') + is_expected.to contain_class('tripleo::profile::base::cinder::backup') + is_expected.to_not contain_class('cinder::backup::swift') + end + end + + context 'with step 4' do + let(:params) { { + :step => 4, + } } + + it 'should trigger complete configuration' do + is_expected.to contain_class('cinder::backup::swift') + 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::backup::swift' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_scheduler_spec.rb b/spec/classes/tripleo_profile_base_cinder_scheduler_spec.rb new file mode 100644 index 0000000..cd044ee --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_scheduler_spec.rb @@ -0,0 +1,56 @@ +# +# 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::scheduler' do + shared_examples_for 'tripleo::profile::base::cinder::scheduler' do + let(:pre_condition) do + "class { '::tripleo::profile::base::cinder': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] }" + 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::scheduler') + is_expected.to contain_class('tripleo::profile::base::cinder') + is_expected.to_not contain_class('cinder::scheduler') + end + end + + context 'with step 4' do + let(:params) { { + :step => 4, + } } + + it 'should trigger complete configuration' do + is_expected.to contain_class('cinder::scheduler') + 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::scheduler' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_spec.rb b/spec/classes/tripleo_profile_base_cinder_spec.rb new file mode 100644 index 0000000..6a36152 --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_spec.rb @@ -0,0 +1,122 @@ +# +# 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' do + shared_examples_for 'tripleo::profile::base::cinder' do + context 'with step less than 3' do + let(:params) { { :step => 1 } } + it 'should do nothing' 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:::cron::db_purge') + end + end + + context 'with step 3 on bootstrap node' do + let(:params) { { + :step => 3, + :bootstrap_node => 'node.example.com', + :rabbit_hosts => ['127.0.0.1', '127.0.0.2'], + :rabbit_port => '1234' + } } + + it 'should trigger complete configuration' do + is_expected.to contain_class('cinder').with( + :rabbit_hosts => params[:rabbit_hosts].map{ |h| "#{h}:#{params[:rabbit_port]}" } + ) + is_expected.to contain_class('cinder::config') + is_expected.to_not contain_class('cinder::cron::db_purge') + end + end + + context 'with step 3 not on bootstrap node' do + let(:params) { { + :step => 3, + :bootstrap_node => 'soemthingelse.example.com' + } } + + 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:::cron::db_purge') + end + end + + context 'with step 4 on other node' do + let(:params) { { + :step => 4, + :bootstrap_node => 'somethingelse.example.com', + :rabbit_hosts => ['127.0.0.1', '127.0.0.2'], + :rabbit_port => '5672' + } } + + it 'should trigger cinder configuration without mysql grant' do + is_expected.to contain_class('cinder').with( + :rabbit_hosts => params[:rabbit_hosts].map{ |h| "#{h}:#{params[:rabbit_port]}" } + ) + is_expected.to contain_class('cinder::config') + is_expected.to_not contain_class('cinder:::cron::db_purge') + end + end + + context 'with step 5' do + let(:params) { { + :step => 5, + :bootstrap_node => 'node.example.com', + :rabbit_hosts => ['127.0.0.1', '127.0.0.2'] + } } + + it 'should trigger complete configuration' do + is_expected.to contain_class('cinder').with( + :rabbit_hosts => params[:rabbit_hosts].map{ |h| "#{h}:5672" } + ) + is_expected.to contain_class('cinder::config') + is_expected.to contain_class('cinder::cron::db_purge') + end + end + + context 'with step 5 without db_purge' do + let(:params) { { + :step => 5, + :bootstrap_node => 'node.example.com', + :rabbit_hosts => ['127.0.0.1', '127.0.0.2'], + :cinder_enable_db_purge => false + } } + + it 'should trigger complete configuration' do + is_expected.to contain_class('cinder').with( + :rabbit_hosts => params[:rabbit_hosts].map{ |h| "#{h}:5672" } + ) + is_expected.to contain_class('cinder::config') + is_expected.to_not contain_class('cinder::cron::db_purge') + 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' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_volume_dellsc_spec.rb b/spec/classes/tripleo_profile_base_cinder_volume_dellsc_spec.rb new file mode 100644 index 0000000..328e886 --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_volume_dellsc_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::dellsc' do + shared_examples_for 'tripleo::profile::base::cinder::volume::dellsc' 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::dellsc') + 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__dellsc_iscsi('tripleo_dellsc') + 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__dellsc_iscsi('tripleo_dellsc') + 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::dellsc' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_volume_eqlx_spec.rb b/spec/classes/tripleo_profile_base_cinder_volume_eqlx_spec.rb new file mode 100644 index 0000000..1a188aa --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_volume_eqlx_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::eqlx' do + shared_examples_for 'tripleo::profile::base::cinder::volume::eqlx' 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::eqlx') + 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') + 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__eqlx('tripleo_eqlx') + 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::eqlx' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_volume_iscsi_spec.rb b/spec/classes/tripleo_profile_base_cinder_volume_iscsi_spec.rb new file mode 100644 index 0000000..65bf3dc --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_volume_iscsi_spec.rb @@ -0,0 +1,85 @@ +# +# 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::iscsi' do + shared_examples_for 'tripleo::profile::base::cinder::volume::iscsi' do + before :each do + facts.merge!({ :step => params[:step] }) + end + + context 'with step less than 4' do + let(:params) { { + :cinder_iscsi_address => '127.0.0.1', + :step => 3 + } } + + it 'should do nothing' do + is_expected.to 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_not contain_class('cinder::setup_test_volume') + is_expected.to_not contain_cinder__backend__iscsi('tripleo_iscsi') + end + end + + context 'with step 4' do + let(:params) { { + :cinder_iscsi_address => '127.0.0.1', + :step => 4, + } } + + context 'with defaults' do + it 'should trigger complete configuration' do + is_expected.to contain_class('cinder::setup_test_volume').with( + :size => '10280M' + ) + is_expected.to contain_cinder__backend__iscsi('tripleo_iscsi').with( + :iscsi_ip_address => '127.0.0.1', + :iscsi_helper => 'tgtadm', + :iscsi_protocol => 'iscsi' + ) + end + end + + context 'with ipv6 address' do + before :each do + params.merge!({ :cinder_iscsi_address => 'fe80::fc54:ff:fe9e:7846' }) + end + it 'should trigger complete configuration' do + is_expected.to contain_class('cinder::setup_test_volume').with( + :size => '10280M' + ) + is_expected.to contain_cinder__backend__iscsi('tripleo_iscsi').with( + :iscsi_ip_address => '[fe80::fc54:ff:fe9e:7846]' + ) + end + 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::iscsi' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_volume_netapp_spec.rb b/spec/classes/tripleo_profile_base_cinder_volume_netapp_spec.rb new file mode 100644 index 0000000..732720e --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_volume_netapp_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::netapp' do + shared_examples_for 'tripleo::profile::base::cinder::volume::netapp' 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::netapp') + 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__netapp('tripleo_netapp') + end + end + + context 'with step 4' do + let(:params) { { + :step => 4, + } } + + it 'should trigger complete configuration' do + # TODO(aschultz): check parameters via hiera + is_expected.to contain_cinder__backend__netapp('tripleo_netapp') + 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::netapp' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_volume_nfs_spec.rb b/spec/classes/tripleo_profile_base_cinder_volume_nfs_spec.rb new file mode 100644 index 0000000..194a70d --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_volume_nfs_spec.rb @@ -0,0 +1,88 @@ +# +# 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::nfs' do + shared_examples_for 'tripleo::profile::base::cinder::volume::nfs' do + before :each do + facts.merge!({ :step => params[:step] }) + end + + context 'with step less than 4' do + let(:params) { { + :cinder_nfs_servers => ['127.0.0.1'], + :step => 3 + } } + + it 'should do nothing' do + is_expected.to contain_class('tripleo::profile::base::cinder::volume::nfs') + 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__nfs('tripleo_nfs') + end + end + + context 'with step 4' do + let(:params) { { + :cinder_nfs_servers => ['127.0.0.1'], + :step => 4, + } } + + context 'with defaults' do + it 'should trigger complete configuration' do + is_expected.to contain_cinder__backend__nfs('tripleo_nfs').with( + :nfs_servers => ['127.0.0.1'], + :nfs_mount_options => '', + :nfs_shares_config => '/etc/cinder/shares-nfs.conf' + ) + end + end + + context 'with selinux' do + before :each do + facts.merge!({ :selinux => 'true' }) + end + it 'should configure selinux' do + is_expected.to contain_selboolean('virt_use_nfs').with( + :value => 'on', + :persistent => true, + ) + end + end + + context 'without selinux' do + before :each do + facts.merge!({ :selinux => 'false' }) + end + it 'should configure selinux' do + is_expected.to_not contain_selboolean('virt_use_nfs') + end + 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::nfs' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_volume_rbd_spec.rb b/spec/classes/tripleo_profile_base_cinder_volume_rbd_spec.rb new file mode 100644 index 0000000..559b836 --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_volume_rbd_spec.rb @@ -0,0 +1,83 @@ +# +# 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::rbd' do + shared_examples_for 'tripleo::profile::base::cinder::volume::rbd' 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::rbd') + 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__rbd('tripleo_ceph') + end + end + + context 'with step 4' do + let(:params) { { + :step => 4, + } } + + context 'with defaults' do + it 'should trigger complete configuration' do + is_expected.to contain_cinder__backend__rbd('tripleo_ceph').with( + :backend_host => 'hostgroup', + :rbd_pool => 'volumes', + :rbd_user => 'openstack', + ) + end + end + + context 'with customizations' do + before :each do + params.merge!({ + :backend_name => 'poodles', + :cinder_rbd_backend_host => 'fe80::fc54:ff:fe9e:7846', + :cinder_rbd_pool_name => 'poolname', + :cinder_rbd_secret_uuid => 'secretuuid', + :cinder_rbd_user_name => 'kcatsnepo' + }) + end + it 'should trigger complete configuration' do + is_expected.to contain_cinder__backend__rbd('poodles').with( + :backend_host => 'fe80::fc54:ff:fe9e:7846', + :rbd_pool => 'poolname', + :rbd_user => 'kcatsnepo', + :rbd_secret_uuid => 'secretuuid' + ) + end + 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::rbd' + 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 new file mode 100644 index 0000000..e0ec9de --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_volume_spec.rb @@ -0,0 +1,216 @@ +# +# 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' do + + shared_examples_for 'tripleo::profile::base::cinder::volume' do + # this hack allows hiera('step') to work as the spec hiera config will + # allow any included modules to automagically get the right step from + # hiera. (╯°□°)╯︵ ┻━┻ + before :each do + facts.merge!({ :step => params[:step] }) + end + + let(:pre_condition) do + "class { '::tripleo::profile::base::cinder': step => #{params[:step]}, rabbit_hosts => ['127.0.0.1'] }" + 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') + is_expected.to contain_class('tripleo::profile::base::cinder') + is_expected.to_not contain_class('cinder::volume') + end + end + + context 'with step 4' do + let(:params) { { :step => 4 } } + + context 'with defaults' do + it 'should configure iscsi' do + is_expected.to 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_iscsi'] + ) + end + end + + context 'with only dellsc' do + before :each do + params.merge!({ + :cinder_enable_dellsc_backend => true, + :cinder_enable_iscsi_backend => false, + }) + end + it 'should configure only dellsc' do + is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellsc') + 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_dellsc'] + ) + end + end + + context 'with only eqlx' do + before :each do + params.merge!({ + :cinder_enable_eqlx_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') + 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'] + ) + end + end + + context 'with only netapp' do + before :each do + params.merge!({ + :cinder_enable_netapp_backend => true, + :cinder_enable_iscsi_backend => false, + }) + end + it 'should configure only netapp' do + is_expected.to contain_class('tripleo::profile::base::cinder::volume::netapp') + 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_netapp'] + ) + end + end + + context 'with only nfs' do + before :each do + params.merge!({ + :cinder_enable_nfs_backend => true, + :cinder_enable_iscsi_backend => false, + }) + end + it 'should configure only nfs' do + is_expected.to contain_class('tripleo::profile::base::cinder::volume::nfs') + 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_nfs'] + ) + end + end + + context 'with only rbd' do + before :each do + params.merge!({ + :cinder_enable_rbd_backend => true, + :cinder_enable_iscsi_backend => false, + }) + end + it 'should configure only ceph' do + is_expected.to contain_class('tripleo::profile::base::cinder::volume::rbd') + 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_ceph'] + ) + end + end + + context 'with only user backend' do + before :each do + params.merge!({ + :cinder_enable_iscsi_backend => false, + :cinder_user_enabled_backends => 'poodles' + }) + end + 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::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') + 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 => ['poodles'] + ) + end + end + + context 'with all tripleo backends' do + before :each do + params.merge!({ + :cinder_enable_iscsi_backend => true, + :cinder_enable_dellsc_backend => true, + :cinder_enable_eqlx_backend => true, + :cinder_enable_netapp_backend => true, + :cinder_enable_nfs_backend => true, + :cinder_enable_rbd_backend => true, + }) + end + 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::netapp') + is_expected.to contain_class('tripleo::profile::base::cinder::volume::nfs') + is_expected.to contain_class('tripleo::profile::base::cinder::volume::rbd') + 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_iscsi', 'tripleo_ceph', 'tripleo_eqlx', + 'tripleo_dellsc', 'tripleo_netapp','tripleo_nfs'] + ) + end + 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' + end + end +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..4aa7367 --- /dev/null +++ b/spec/classes/tripleo_profile_base_nova_api_spec.rb @@ -0,0 +1,122 @@ +# +# 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') + #TODO(emilien): enable it again when it's fixed upstream in nova + # https://bugs.launchpad.net/tripleo/+bug/1649341 + # is_expected.to contain_class('nova::db::sync_cell_v2').with( + # :transport_url => 'rabbit://nova:foo@localhost:5672/?ssl=0') + # 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 3 not on bootstrap node' do + let(:params) { { + :step => 3, + :bootstrap_node => 'other.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_not contain_class('nova::db::sync_cell_v2') + 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 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 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..a0b2387 --- /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 4' 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 4' 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..8ba78af --- /dev/null +++ b/spec/classes/tripleo_profile_base_nova_spec.rb @@ -0,0 +1,131 @@ +# +# 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::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') + } + 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_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::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_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_ui_spec.rb b/spec/classes/tripleo_ui_spec.rb new file mode 100644 index 0000000..588a944 --- /dev/null +++ b/spec/classes/tripleo_ui_spec.rb @@ -0,0 +1,99 @@ +# +# 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', + :keystone_url => 'http://127.0.0.1:5000/' + } } + + 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": "http:\/\/127.0.0.1:5000\/"/) + .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, + :keystone_url => 'http://127.0.0.1:1111/', + :heat_url => 'http://127.0.0.1:2222/', + :ironic_url => 'http://127.0.0.1:3333/', + :mistral_url => 'http://127.0.0.1:4444/', + :swift_url => 'http://127.0.0.1:5555/', + :zaqar_websocket_url => 'http://127.0.0.1:6666/', + :zaqar_default_queue => 'myqueue' + } } + + 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": "http:\/\/127.0.0.1:1111\/"/) + .with_content(/"heat": "http:\/\/127.0.0.1:2222\/"/) + .with_content(/"ironic": "http:\/\/127.0.0.1:3333\/"/) + .with_content(/"mistral": "http:\/\/127.0.0.1:4444\/"/) + .with_content(/"swift": "http:\/\/127.0.0.1:5555\/"/) + .with_content(/"zaqar-websocket": "http:\/\/127.0.0.1:6666\/"/) + .with_content(/"zaqar_default_queue": "myqueue"/) + 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 |