Files
puppet-neutron/spec/classes/neutron_plugins_ml2_networking_ansible_spec.rb
Derek Higgins 0ea6a7a5d1 Allow the networking_ansible plugin to set manage_vlans
This is required if neworks already exist and the driver
doesn't need too (or can't) create them.

Change-Id: Iff08440feb5727d436514ceaf072faed7fcdf763
2018-10-24 06:42:01 -04:00

86 lines
3.0 KiB
Ruby

require 'spec_helper'
describe 'neutron::plugins::ml2::networking_ansible' do
let :default_params do
{ :package_ensure => 'present',
}
end
let :test_facts do
{ :operatingsystem => 'default',
:operatingsystemrelease => 'default'
}
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',
'manage_vlans' => false},}
}
end
shared_examples_for 'networking-ansible ml2 plugin' do
let :p do
default_params.merge(params)
end
it { is_expected.to contain_class('neutron::params') }
it 'installs networking-ansible python2-networking-ansible package' do
is_expected.to contain_package('python2-networking-ansible').with(
:name => platform_params[:networking_ansible_package],
:ensure => p[:package_ensure],
:tag => ['openstack', 'neutron-package'],
)
is_expected.to contain_package('python2-networking-ansible').that_requires('Anchor[neutron::install::begin]')
is_expected.to contain_package('python2-networking-ansible').that_notifies('Anchor[neutron::install::end]')
end
it {
params[:host_configs].each do |host_config|
is_expected.to contain_neutron__plugins__ml2__networking_ansible_host(host_config.first)
is_expected.to contain_neutron_plugin_ml2('ansible:host1/ansible_ssh_pass').with_value('password1')
is_expected.to contain_neutron_plugin_ml2('ansible:host1/ansible_ssh_private_key_file').with_value(nil)
is_expected.to contain_neutron_plugin_ml2('ansible:host2/ansible_ssh_private_key_file').with_value('/path/to/key')
is_expected.to contain_neutron_plugin_ml2('ansible:host2/ansible_ssh_pass').with_value(nil)
is_expected.to contain_neutron_plugin_ml2('ansible:host1/manage_vlans').with_value(nil)
is_expected.to 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
is_expected.to raise_error(Puppet::Error, /Unsupported osfamily.*/)
end
end
end
end
end