puppet-neutron/spec/classes/neutron_agents_ml2_networking_baremetal_spec.rb
Takashi Kajinami dfeccd6749 Deprecate domain_id parameters
Currently we set both domain_name and domain_id for some configuration
files, but it makes it difficult for operators to use their original
domain because they should update both parameters correctly.

Because it's redundant to required both name and id set, this patch
deprecates all domain_id parameters, so that operator needs to set
their domain name, which is predictable, before creating actual domain.

Change-Id: Id96ab9af7ac5776d5a0000889d26e494c68d9376
2020-04-21 22:07:07 +09:00

119 lines
4.9 KiB
Ruby

require 'spec_helper'
describe 'neutron::agents::ml2::networking_baremetal' do
let :default_params do
{
:enabled => true,
:manage_service => true,
:package_ensure => 'present',
:auth_type => 'password',
:auth_url => 'http://127.0.0.1:5000',
:username => 'ironic',
:project_domain_name => 'Default',
:project_name => 'services',
:user_domain_name => 'Default',
:purge_config => false,
}
end
let :params do
{
:password => 'passw0rd',
}
end
shared_examples 'networking-baremetal ironic-neutron-agent with ml2 plugin' do
let :p do
default_params.merge(params)
end
it { should contain_class('neutron::params') }
it 'passes purge to resource' do
should contain_resources('ironic_neutron_agent_config').with({
:purge => false
})
end
it 'configures /etc/neutron/plugins/ml2/ironic_neutron_agent.ini' do
should contain_ironic_neutron_agent_config('ironic/auth_strategy').with_value('<SERVICE DEFAULT>')
should contain_ironic_neutron_agent_config('ironic/ironic_url').with_value('<SERVICE DEFAULT>')
should contain_ironic_neutron_agent_config('ironic/cafile').with_value('<SERVICE DEFAULT>')
should contain_ironic_neutron_agent_config('ironic/certfile').with_value('<SERVICE DEFAULT>')
should contain_ironic_neutron_agent_config('ironic/keyfile').with_value('<SERVICE DEFAULT>')
should contain_ironic_neutron_agent_config('ironic/auth_type').with_value(p[:auth_type])
should contain_ironic_neutron_agent_config('ironic/auth_url').with_value(p[:auth_url])
should contain_ironic_neutron_agent_config('ironic/username').with_value(p[:username])
should contain_ironic_neutron_agent_config('ironic/password').with_value(p[:password])
should contain_ironic_neutron_agent_config('ironic/project_domain_name').with_value(p[:project_domain_name])
should contain_ironic_neutron_agent_config('ironic/project_name').with_value(p[:project_name])
should contain_ironic_neutron_agent_config('ironic/user_domain_name').with_value(p[:user_domain_name])
should contain_ironic_neutron_agent_config('ironic/region_name').with_value('<SERVICE DEFAULT>')
should contain_ironic_neutron_agent_config('ironic/retry_interval').with_value('<SERVICE DEFAULT>')
should contain_ironic_neutron_agent_config('ironic/max_retries').with_value('<SERVICE DEFAULT>')
end
it 'installs ironic-neutron-agent agent package' do
should contain_package('python2-ironic-neutron-agent').with(
:name => platform_params[:networking_baremetal_agent_package],
:ensure => p[:package_ensure],
:tag => ['openstack', 'neutron-package'],
)
should contain_package('python2-ironic-neutron-agent').that_requires('Anchor[neutron::install::begin]')
should contain_package('python2-ironic-neutron-agent').that_notifies('Anchor[neutron::install::end]')
end
it 'configures networking-baremetal ironic-neutron-agent service' do
should contain_service('ironic-neutron-agent-service').with(
:name => platform_params[:networking_baremetal_agent_service],
:enable => true,
:ensure => 'running',
:tag => 'neutron-service',
)
should contain_service('ironic-neutron-agent-service').that_subscribes_to('Anchor[neutron::service::begin]')
should contain_service('ironic-neutron-agent-service').that_notifies('Anchor[neutron::service::end]')
end
context 'with enabled as false' do
before :each do
params.merge!(:enabled => false)
end
it 'should not start service' do
should contain_service('ironic-neutron-agent-service').with(
:name => platform_params[:networking_baremetal_agent_service],
:enable => false,
:ensure => 'stopped',
:tag => 'neutron-service',
)
should contain_service('ironic-neutron-agent-service').that_subscribes_to('Anchor[neutron::service::begin]')
should contain_service('ironic-neutron-agent-service').that_notifies('Anchor[neutron::service::end]')
end
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
let (:platform_params) do
case facts[:osfamily]
when 'RedHat'
{ :networking_baremetal_agent_package => 'python2-ironic-neutron-agent',
:networking_baremetal_agent_service => 'ironic-neutron-agent' }
end
end
case facts[:osfamily]
when 'RedHat'
it_behaves_like 'networking-baremetal ironic-neutron-agent with ml2 plugin'
when facts[:osfamily] != 'RedHat'
it 'fails with unsupported osfamily' do
should raise_error(Puppet::Error, /Unsupported osfamily.*/)
end
end
end
end
end