diff --git a/spec/classes/tripleo_profile_base_octavia_api_spec.rb b/spec/classes/tripleo_profile_base_octavia_api_spec.rb index 2378b5c98..602fa351f 100644 --- a/spec/classes/tripleo_profile_base_octavia_api_spec.rb +++ b/spec/classes/tripleo_profile_base_octavia_api_spec.rb @@ -18,12 +18,6 @@ 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] }) @@ -44,110 +38,134 @@ eos end context 'with step less than 3 on bootstrap' do - before do - params.merge!({ - :step => 2, - :bootstrap_node => 'node.example.com' - }) - end + let(:params) { { + :step => 2, + :bootstrap_node => 'node.example.com' + } } it 'should not do anything' do is_expected.to_not contain_class('octavia::api') + is_expected.to_not contain_class('octavia::controller') is_expected.to_not contain_class('octavia::healthcheck') + is_expected.to_not contain_class('tripleo::profile::base::apache') + is_expected.to_not contain_class('octavia::wsgi::apache') end end context 'with step less than 3 on non-bootstrap' do - before do - params.merge!({ :step => 2 }) - end + let(:params) { { + :step => 2, + :bootstrap_node => 'other.example.com' + } } it 'should not do anything' do is_expected.to_not contain_class('octavia::api') + is_expected.to_not contain_class('octavia::controller') is_expected.to_not contain_class('octavia::healthcheck') + is_expected.to_not contain_class('tripleo::profile::base::apache') + is_expected.to_not contain_class('octavia::wsgi::apache') end end context 'with step 3 on bootstrap node' do - before do - params.merge!({ - :step => 3, - :bootstrap_node => 'node.example.com' - }) - end + let(:params) { { + :step => 3, + :bootstrap_node => 'node.example.com' + } } it 'should should start configurating database' do is_expected.to_not contain_class('octavia::api') + is_expected.to_not contain_class('octavia::controller') is_expected.to_not contain_class('octavia::healthcheck') + is_expected.to_not contain_class('tripleo::profile::base::apache') + is_expected.to_not contain_class('octavia::wsgi::apache') end end context 'with step 3 on non-bootstrap node' do - before do - params.merge!({ :step => 3 }) - end + let(:params) { { + :step => 3, + :bootstrap_node => 'other.example.com' + } } it 'should do nothing' do is_expected.to_not contain_class('octavia::api') + is_expected.to_not contain_class('octavia::controller') is_expected.to_not contain_class('octavia::healthcheck') + is_expected.to_not contain_class('tripleo::profile::base::apache') + is_expected.to_not contain_class('octavia::wsgi::apache') end end context 'with step 4 on bootstrap node' do - before do - params.merge!({ - :step => 4, - :bootstrap_node => 'node.example.com' - }) - end + let(:params) { { + :step => 4, + :bootstrap_node => 'node.example.com' + } } - it 'should should sync database' do + it 'should apply configurations with syncing database' do is_expected.to contain_class('octavia::api').with(:sync_db => true) + is_expected.to contain_class('octavia::controller') is_expected.to contain_class('octavia::healthcheck') + is_expected.to contain_class('tripleo::profile::base::apache') + is_expected.to contain_class('octavia::wsgi::apache') end end context 'with step 4 on non-bootstrap node' do - before do - params.merge!({ :step => 4 }) - end + let(:params) { { + :step => 4, + :bootstrap_node => 'other.example.com' + } } it 'should do nothing' do is_expected.to_not contain_class('octavia::api') + is_expected.to_not contain_class('octavia::controller') is_expected.to_not contain_class('octavia::healthcheck') + is_expected.to_not contain_class('tripleo::profile::base::apache') + is_expected.to_not contain_class('octavia::wsgi::apache') end end context 'with step 5 on non-bootstrap node' do - before do - params.merge!({ :step => 5 }) - end + let(:params) { { + :step => 5, + :bootstrap_node => 'other.example.com' + } } - it 'should do nothing' do + it 'should apply configurations without syncing database' do is_expected.to contain_class('octavia::api').with(:sync_db => false) + is_expected.to contain_class('octavia::controller') is_expected.to contain_class('octavia::healthcheck') + is_expected.to contain_class('tripleo::profile::base::apache') + is_expected.to contain_class('octavia::wsgi::apache') end end context 'Configure internal TLS' do - before do - params.merge!({ - :step => 5, - :bootstrap_node => 'node.example.com', - :enable_internal_tls => true, - :octavia_network => 'octavia-net', - :certificates_specs => { - 'httpd-octavia-net' => { - 'hostname' => 'somehost', - 'service_certificate' => '/foo.pem', - 'service_key' => '/foo.key', - }, + let(:params) { { + :step => 5, + :bootstrap_node => 'other.example.com', + :enable_internal_tls => true, + :octavia_network => 'octavia-net', + :certificates_specs => { + 'httpd-octavia-net' => { + 'hostname' => 'somehost', + 'service_certificate' => '/foo.pem', + 'service_key' => '/foo.key', }, - }) - end + }, + } } + it { is_expected.to contain_class('octavia::api') + is_expected.to contain_class('octavia::controller') is_expected.to contain_class('octavia::healthcheck') + is_expected.to contain_class('tripleo::profile::base::apache') + is_expected.to contain_class('octavia::wsgi::apache').with( + :ssl_cert => '/foo.pem', + :ssl_key => '/foo.key', + ) } end end diff --git a/spec/classes/tripleo_profile_base_octavia_health_manager_spec.rb b/spec/classes/tripleo_profile_base_octavia_health_manager_spec.rb new file mode 100644 index 000000000..fc5146af5 --- /dev/null +++ b/spec/classes/tripleo_profile_base_octavia_health_manager_spec.rb @@ -0,0 +1,83 @@ +# +# Copyright (C) 2021 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::health_manager' do + + let :params do + { :step => 5 } + end + + shared_examples_for 'tripleo::profile::base::octavia::health_manager' do + + before :each do + facts.merge!({ :step => params[:step] }) + end + + let(:pre_condition) do + <<-eos + class { 'tripleo::profile::base::octavia' : + step => #{params[:step]}, + oslomsg_rpc_username => 'bugs', + oslomsg_rpc_password => 'rabbits_R_c00l', + oslomsg_rpc_hosts => ['hole.field.com'] + } +eos + end + + context 'with step less than 5' do + before do + params.merge!({ :step => 4 }) + end + + it 'should not do anything' do + is_expected.to_not contain_class('octavia::controller') + is_expected.to_not contain_class('octavia::nova') + is_expected.to_not contain_class('octavia::health_manager') + is_expected.to_not contain_class('octavia::certificates') + is_expected.to_not contain_class('octavia::neutron') + is_expected.to_not contain_class('octavia::glance') + is_expected.to_not contain_class('octavia::cinder') + end + end + + context 'with step 5' do + before do + params.merge!({ :step => 5 }) + end + + it 'should do the full configuration' do + is_expected.to contain_class('octavia::controller') + is_expected.to contain_class('octavia::nova') + is_expected.to contain_class('octavia::health_manager') + is_expected.to contain_class('octavia::certificates') + is_expected.to contain_class('octavia::neutron') + is_expected.to contain_class('octavia::glance') + is_expected.to contain_class('octavia::cinder') + 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::health_manager' + end + end +end diff --git a/spec/classes/tripleo_profile_base_octavia_housekeeping_spec.rb b/spec/classes/tripleo_profile_base_octavia_housekeeping_spec.rb new file mode 100644 index 000000000..bda852427 --- /dev/null +++ b/spec/classes/tripleo_profile_base_octavia_housekeeping_spec.rb @@ -0,0 +1,83 @@ +# +# Copyright (C) 2021 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::housekeeping' do + + let :params do + { :step => 5 } + end + + shared_examples_for 'tripleo::profile::base::octavia::housekeeping' do + + before :each do + facts.merge!({ :step => params[:step] }) + end + + let(:pre_condition) do + <<-eos + class { 'tripleo::profile::base::octavia' : + step => #{params[:step]}, + oslomsg_rpc_username => 'bugs', + oslomsg_rpc_password => 'rabbits_R_c00l', + oslomsg_rpc_hosts => ['hole.field.com'] + } +eos + end + + context 'with step less than 5' do + before do + params.merge!({ :step => 4 }) + end + + it 'should not do anything' do + is_expected.to_not contain_class('octavia::controller') + is_expected.to_not contain_class('octavia::nova') + is_expected.to_not contain_class('octavia::housekeeping') + is_expected.to_not contain_class('octavia::certificates') + is_expected.to_not contain_class('octavia::neutron') + is_expected.to_not contain_class('octavia::glance') + is_expected.to_not contain_class('octavia::cinder') + end + end + + context 'with step 5' do + before do + params.merge!({ :step => 5 }) + end + + it 'should do the full configuration' do + is_expected.to contain_class('octavia::controller') + is_expected.to contain_class('octavia::nova') + is_expected.to contain_class('octavia::housekeeping') + is_expected.to contain_class('octavia::certificates') + is_expected.to contain_class('octavia::neutron') + is_expected.to contain_class('octavia::glance') + is_expected.to contain_class('octavia::cinder') + 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::housekeeping' + end + end +end diff --git a/spec/classes/tripleo_profile_base_octavia_worker_spec.rb b/spec/classes/tripleo_profile_base_octavia_worker_spec.rb new file mode 100644 index 000000000..d7ece7540 --- /dev/null +++ b/spec/classes/tripleo_profile_base_octavia_worker_spec.rb @@ -0,0 +1,83 @@ +# +# Copyright (C) 2021 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::worker' do + + let :params do + { :step => 5 } + end + + shared_examples_for 'tripleo::profile::base::octavia::worker' do + + before :each do + facts.merge!({ :step => params[:step] }) + end + + let(:pre_condition) do + <<-eos + class { 'tripleo::profile::base::octavia' : + step => #{params[:step]}, + oslomsg_rpc_username => 'bugs', + oslomsg_rpc_password => 'rabbits_R_c00l', + oslomsg_rpc_hosts => ['hole.field.com'] + } +eos + end + + context 'with step less than 5' do + before do + params.merge!({ :step => 4 }) + end + + it 'should not do anything' do + is_expected.to_not contain_class('octavia::controller') + is_expected.to_not contain_class('octavia::nova') + is_expected.to_not contain_class('octavia::worker') + is_expected.to_not contain_class('octavia::certificates') + is_expected.to_not contain_class('octavia::neutron') + is_expected.to_not contain_class('octavia::glance') + is_expected.to_not contain_class('octavia::cinder') + end + end + + context 'with step 5' do + before do + params.merge!({ :step => 5 }) + end + + it 'should do the full configuration' do + is_expected.to contain_class('octavia::controller') + is_expected.to contain_class('octavia::nova') + is_expected.to contain_class('octavia::worker') + is_expected.to contain_class('octavia::certificates') + is_expected.to contain_class('octavia::neutron') + is_expected.to contain_class('octavia::glance') + is_expected.to contain_class('octavia::cinder') + 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::worker' + end + end +end diff --git a/spec/fixtures/hieradata/default.yaml b/spec/fixtures/hieradata/default.yaml index 9965d2c11..bb7c7db57 100644 --- a/spec/fixtures/hieradata/default.yaml +++ b/spec/fixtures/hieradata/default.yaml @@ -144,7 +144,9 @@ placement::keystone::authtoken::password: 'password' memcached_node_names: - 'controller-1' # octavia related items +octavia_api_short_bootstrap_node_name: node octavia::keystone::authtoken::password: 'password' +octavia::health_manager::heartbeat_key: 'key' # horizon related horizon_short_bootstrap_node_name: node horizon::secret_key: 'secrete'