puppet-neutron/spec/classes/neutron_plugins_ml2_networking_ansible_spec.rb
Takashi Kajinami 90277442a1 Add missing dependencies about ml2 plugins
neutron::plugins::ml2::netwokring_ansible should be applied after
neutron::plugins::ml2, otherwise purge_config can remove the parameters
unexpectedly.
Also, all plugin packages should be install before configuration
completes, otherwise these packages can be missing when actual
code should be referred.

Change-Id: Ide4e65b6deac381df954341adbb804c9432d8643
2020-05-05 14:42:45 +09:00

90 lines
3.2 KiB
Ruby

require 'spec_helper'
describe 'neutron::plugins::ml2::networking_ansible' do
let :default_params do
{
:package_ensure => 'present',
}
end
let :params do
{ :host_configs => {
'host1' => { 'ansible_network_os' => 'junos',
'ansible_host' => '10.0.0.1',
'ansible_user' => 'ansible',
'ansible_ssh_pass' => 'password1' },
'host2' => { 'ansible_network_os' => 'junos',
'ansible_host' => '10.0.0.1',
'ansible_user' => 'ansible',
'ansible_ssh_private_key_file' => '/path/to/key',
'mac' => '01:23:45:67:89:AB',
'manage_vlans' => false},},
:coordination_uri => 'etcd://127.0.0.1:2379'
}
end
shared_examples 'networking-ansible ml2 plugin' do
let :p do
default_params.merge(params)
end
it { should contain_class('neutron::params') }
it 'installs networking-ansible python2-networking-ansible package' do
should contain_package('python2-networking-ansible').with(
:name => platform_params[:networking_ansible_package],
:ensure => p[:package_ensure],
:tag => ['openstack', 'neutron-plugin-ml2-package'],
)
should contain_package('python2-networking-ansible').that_requires('Anchor[neutron::install::begin]')
should contain_package('python2-networking-ansible').that_notifies('Anchor[neutron::config::end]')
end
it 'should configure non-host config' do
should contain_neutron_plugin_ml2('ml2_ansible/coordination_uri').with_value('etcd://127.0.0.1:2379')
end
it {
params[:host_configs].each do |host_config|
should contain_neutron__plugins__ml2__networking_ansible_host(host_config.first)
should contain_neutron_plugin_ml2('ansible:host1/ansible_ssh_pass').with_value('password1')
should contain_neutron_plugin_ml2('ansible:host1/ansible_ssh_private_key_file').with_value(nil)
should contain_neutron_plugin_ml2('ansible:host2/ansible_ssh_private_key_file').with_value('/path/to/key')
should contain_neutron_plugin_ml2('ansible:host2/ansible_ssh_pass').with_value(nil)
should contain_neutron_plugin_ml2('ansible:host1/mac').with_value(nil)
should contain_neutron_plugin_ml2('ansible:host2/mac').with_value('01:23:45:67:89:AB')
should contain_neutron_plugin_ml2('ansible:host1/manage_vlans').with_value(nil)
should contain_neutron_plugin_ml2('ansible:host2/manage_vlans').with_value(false)
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_ansible_package => 'python2-networking-ansible'}
end
end
case facts[:osfamily]
when 'RedHat'
it_behaves_like 'networking-ansible ml2 plugin'
when facts[:osfamily] != 'RedHat'
it 'fails with unsupported osfamily' do
should raise_error(Puppet::Error, /Unsupported osfamily.*/)
end
end
end
end
end