Improve unit test coverage for neutron manifests
Add some missing tests for module import or step switching to have better test coverage. Also, add tests for tripleo::profile::base::neutron:server, which is not tested by serverspec currently. Change-Id: I4ff1d0856158c206996548bacd4616cb9abc4ef5
This commit is contained in:
parent
bbef575f01
commit
f2a38f6abd
@ -24,11 +24,20 @@ describe 'tripleo::profile::base::neutron::dhcp' do
|
||||
facts.merge!({ :step => params[:step] })
|
||||
end
|
||||
|
||||
context 'with defaults for all parameters' do
|
||||
let(:params) { { :step => 4 } }
|
||||
|
||||
context 'with step less than 4' do
|
||||
let(:params) { { :step => 3 } }
|
||||
it 'should do nothing' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::dhcp')
|
||||
is_expected.to_not contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to_not contain_class('neutron::agents::dhcp')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with step 4 and later' do
|
||||
let(:params) { { :step => 4 } }
|
||||
it 'should trigger complete configuration' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::dhcp')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to contain_class('neutron::agents::dhcp')
|
||||
end
|
||||
end
|
||||
|
@ -24,11 +24,20 @@ describe 'tripleo::profile::base::neutron::l3' do
|
||||
facts.merge!({ :step => params[:step] })
|
||||
end
|
||||
|
||||
context 'with defaults for all parameters' do
|
||||
let(:params) { { :step => 4 } }
|
||||
|
||||
context 'with step less than 4' do
|
||||
let(:params) { { :step => 3 } }
|
||||
it 'should do nothing' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::l3')
|
||||
is_expected.to_not contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to_not contain_class('neutron::agents::l3')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with step 4 and later' do
|
||||
let(:params) { { :step => 4 } }
|
||||
it 'should trigger complete configuration' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::l3')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to contain_class('neutron::agents::l3')
|
||||
end
|
||||
end
|
||||
|
@ -24,15 +24,23 @@ describe 'tripleo::profile::base::neutron::ovs' do
|
||||
facts.merge!({ :step => params[:step] })
|
||||
end
|
||||
|
||||
context 'with defaults for all parameters' do
|
||||
let(:params) { { :step => 3 } }
|
||||
|
||||
it 'should do nothing in step 3' do
|
||||
context 'with step less than 5 and defaults for all parameters' do
|
||||
let(:params) { { :step => 4 } }
|
||||
it 'should do nothing' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to_not contain_class('neutron::agents::ml2::ovs')
|
||||
is_expected.not_to contain_file('/var/lib/vhostuser_sockets')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with step 5 and defaults for all parameters' do
|
||||
let(:params) { { :step => 5 } }
|
||||
it 'should trigger complete configuration except for vhostuser sockets' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to contain_class('neutron::agents::ml2::ovs')
|
||||
is_expected.not_to contain_file('/var/lib/vhostuser_sockets')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'tripleo::profile::base::neutron::ovs with vhostuser_socketdir' do
|
||||
|
187
spec/classes/tripleo_profile_base_neutron_server_spec.rb
Normal file
187
spec/classes/tripleo_profile_base_neutron_server_spec.rb
Normal file
@ -0,0 +1,187 @@
|
||||
#
|
||||
# Copyright (C) 2019 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::neutron::server' do
|
||||
shared_examples_for 'tripleo::profile::base::neutron::server' do
|
||||
before :each do
|
||||
facts.merge!({ :step => params[:step] })
|
||||
end
|
||||
|
||||
let(:pre_condition) do
|
||||
<<-eos
|
||||
class { '::tripleo::profile::base::neutron':
|
||||
oslomsg_rpc_hosts => [ 'localhost' ],
|
||||
oslomsg_rpc_username => 'neutron',
|
||||
oslomsg_rpc_password => 'foo'
|
||||
}
|
||||
eos
|
||||
end
|
||||
|
||||
context 'with step less than 3' do
|
||||
let(:params) { {
|
||||
:step => 1,
|
||||
:bootstrap_node => 'node.example.com',
|
||||
} }
|
||||
it 'should od nothing' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::server')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::authtoken')
|
||||
is_expected.to_not contain_class('tripleo::profile::base::apache')
|
||||
is_expected.to_not contain_class('neutron::server::notifications')
|
||||
is_expected.to_not contain_class('neutron::server')
|
||||
is_expected.to_not contain_class('neutron::quota')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with step 3 on bootstrap node' do
|
||||
let(:params) { {
|
||||
:step => 3,
|
||||
:bootstrap_node => 'node.example.com',
|
||||
} }
|
||||
it 'should trigger apache configuration' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::server')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::authtoken')
|
||||
is_expected.to contain_class('tripleo::profile::base::apache')
|
||||
is_expected.to_not contain_class('neutron::server::notifications')
|
||||
is_expected.to_not contain_class('neutron::server')
|
||||
is_expected.to_not contain_class('neutron::quota')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with step 3 not on bootstrap node' do
|
||||
let(:params) { {
|
||||
:step => 3,
|
||||
:bootstrap_node => 'other.example.com',
|
||||
} }
|
||||
it 'should do nothing' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::server')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::authtoken')
|
||||
is_expected.to_not contain_class('tripleo::profile::base::apache')
|
||||
is_expected.to_not contain_class('neutron::server::notifications')
|
||||
is_expected.to_not contain_class('neutron::server')
|
||||
is_expected.to_not contain_class('neutron::quota')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with step 4 on bootstrap node' do
|
||||
let(:params) { {
|
||||
:step => 4,
|
||||
:bootstrap_node => 'node.example.com',
|
||||
} }
|
||||
it 'should trigger complete configuration' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::server')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::authtoken')
|
||||
is_expected.to contain_class('tripleo::profile::base::apache')
|
||||
is_expected.to contain_class('neutron::server::notifications')
|
||||
is_expected.to contain_class('neutron::server').with(
|
||||
:sync_db => true,
|
||||
:l3_ha => false,
|
||||
)
|
||||
is_expected.to contain_class('neutron::quota')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with step 4 not on bootstrap node' do
|
||||
let(:params) { {
|
||||
:step => 4,
|
||||
:bootstrap_node => 'other.example.com',
|
||||
} }
|
||||
it 'should trigger apache configuration' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::server')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::authtoken')
|
||||
is_expected.to contain_class('tripleo::profile::base::apache')
|
||||
is_expected.to_not contain_class('neutron::server::notifications')
|
||||
is_expected.to_not contain_class('neutron::server')
|
||||
is_expected.to_not contain_class('neutron::quota')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with step 5 not on bootstrap nodes' do
|
||||
let(:params) { {
|
||||
:step => 5,
|
||||
:bootstrap_node => 'other.example.com',
|
||||
} }
|
||||
it 'should trigger complete configuration' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::server')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron::authtoken')
|
||||
is_expected.to contain_class('tripleo::profile::base::apache')
|
||||
is_expected.to contain_class('neutron::server::notifications')
|
||||
is_expected.to contain_class('neutron::server').with(
|
||||
:sync_db => false,
|
||||
:l3_ha => false,
|
||||
)
|
||||
is_expected.to contain_class('neutron::quota')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with multiple l3 nods' do
|
||||
let(:params) { {
|
||||
:step => 5,
|
||||
:bootstrap_node => 'node.example.com',
|
||||
:l3_nodes => ['netcont1.localdomain', 'netcont2.localdomain', 'netcont3.localdomain'],
|
||||
} }
|
||||
it 'should enable l3_ha' do
|
||||
is_expected.to contain_class('neutron::server').with(
|
||||
:l3_ha => true,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with multiple l3 nods and dvr enabled' do
|
||||
let(:params) { {
|
||||
:step => 5,
|
||||
:bootstrap_node => 'node.example.com',
|
||||
:l3_nodes => ['netcont1.localdomain', 'netcont2.localdomain', 'netcont3.localdomain'],
|
||||
:dvr_enabled => true
|
||||
} }
|
||||
it 'should disable l3_ha' do
|
||||
is_expected.to contain_class('neutron::server').with(
|
||||
:l3_ha => false,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with l3_ha_override passed' do
|
||||
let(:params) { {
|
||||
:step => 5,
|
||||
:bootstrap_node => 'node.example.com',
|
||||
:l3_ha_override => 'true'
|
||||
} }
|
||||
it 'should enable l3_ha' do
|
||||
is_expected.to contain_class('neutron::server').with(
|
||||
:l3_ha => true,
|
||||
)
|
||||
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::neutron::server'
|
||||
end
|
||||
end
|
||||
end
|
@ -17,49 +17,72 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'tripleo::profile::base::neutron' do
|
||||
let :params do
|
||||
{ :step => 5,
|
||||
:oslomsg_notify_password => 'foobar',
|
||||
:oslomsg_rpc_password => 'foobar'
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'tripleo::profile::base::neutron' do
|
||||
before :each do
|
||||
facts.merge!({ :step => params[:step] })
|
||||
end
|
||||
|
||||
context 'when no dhcp agents per network set' do
|
||||
before do
|
||||
params.merge!({
|
||||
:dhcp_nodes => ['netcont1.localdomain', 'netcont2.localdomain', 'netcont3.localdomain']
|
||||
})
|
||||
end
|
||||
it 'should equal the number of dhcp agents' do
|
||||
is_expected.to contain_class('neutron').with(:dhcp_agents_per_network => 3)
|
||||
context 'with step less than 3' do
|
||||
let(:params) { { :step => 1 } }
|
||||
it 'should od nothing' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to_not contain_class('neutron')
|
||||
is_expected.to_not contain_class('neutron::config')
|
||||
is_expected.to_not contain_class('neutron::logging')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dhcp agents per network is set' do
|
||||
before do
|
||||
params.merge!({
|
||||
context 'with step 3' do
|
||||
let(:params) { {
|
||||
:step => 3,
|
||||
:oslomsg_rpc_hosts => [ '192.168.0.1' ],
|
||||
:oslomsg_rpc_username => 'neutron1',
|
||||
:oslomsg_rpc_password => 'foo',
|
||||
:oslomsg_rpc_port => '1234',
|
||||
:oslomsg_notify_hosts => [ '192.168.0.2' ],
|
||||
:oslomsg_notify_username => 'neutron2',
|
||||
:oslomsg_notify_password => 'baa',
|
||||
:oslomsg_notify_port => '5678',
|
||||
:dhcp_agents_per_network => 2
|
||||
})
|
||||
} }
|
||||
it 'should trigger complete configuration' do
|
||||
is_expected.to contain_class('tripleo::profile::base::neutron')
|
||||
is_expected.to contain_class('neutron').with(
|
||||
:default_transport_url => 'rabbit://neutron1:foo@192.168.0.1:1234/?ssl=0',
|
||||
:notification_transport_url => 'rabbit://neutron2:baa@192.168.0.2:5678/?ssl=0',
|
||||
:dhcp_agents_per_network => 2
|
||||
)
|
||||
is_expected.to contain_class('neutron::config')
|
||||
is_expected.to contain_class('neutron::logging')
|
||||
end
|
||||
it 'should set the value' do
|
||||
is_expected.to contain_class('neutron').with(:dhcp_agents_per_network => 2)
|
||||
end
|
||||
|
||||
context 'when not dhcp agents per network is set' do
|
||||
let(:params) { {
|
||||
:step => 3,
|
||||
:oslomsg_rpc_password => 'foo',
|
||||
:oslomsg_notify_password => 'baa',
|
||||
:dhcp_nodes => ['netcont1.localdomain', 'netcont2.localdomain', 'netcont3.localdomain']
|
||||
} }
|
||||
it 'should equal the number of dhcp agents' do
|
||||
is_expected.to contain_class('neutron').with(
|
||||
:dhcp_agents_per_network => 3
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dhcp agents per network is greater than number of agents' do
|
||||
before do
|
||||
params.merge!({
|
||||
let(:params) { {
|
||||
:step => 3,
|
||||
:oslomsg_rpc_password => 'foo',
|
||||
:oslomsg_notify_password => 'baa',
|
||||
:dhcp_nodes => ['netcont1.localdomain', 'netcont2.localdomain'],
|
||||
:dhcp_agents_per_network => 5
|
||||
})
|
||||
end
|
||||
} }
|
||||
it 'should set value and complain about not enough agents' do
|
||||
is_expected.to contain_class('neutron').with(:dhcp_agents_per_network => 5)
|
||||
is_expected.to contain_class('neutron').with(
|
||||
:dhcp_agents_per_network => 5
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
1
spec/fixtures/hieradata/default.yaml
vendored
1
spec/fixtures/hieradata/default.yaml
vendored
@ -91,6 +91,7 @@ horizon_node_names:
|
||||
#Neutron related
|
||||
neutron::rabbit_password: 'password'
|
||||
neutron::keystone::authtoken::password: 'password'
|
||||
neutron::server::notifications::password: 'password'
|
||||
# oslo.messaging related
|
||||
oslo_messaging_rpc_password: 'password'
|
||||
oslo_messaging_notify_password: 'password'
|
||||
|
Loading…
Reference in New Issue
Block a user