1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
require 'spec_helper'
describe 'vswitch::ovs' do
shared_examples_for 'vswitch::ovs' do
context 'default parameters' do
it 'contains the ovs class' do
is_expected.to contain_class('vswitch::ovs')
end
it 'clears hw-offload option' do
is_expected.to contain_vs_config('other_config:hw-offload').with(
:ensure => 'absent', :restart => true, :wait => true,
)
end
it 'configures disable_emc option to false' do
is_expected.to contain_vs_config('other_config:emc-insert-inv-prob').with(
:ensure => 'absent', :wait => false
)
end
it 'clears vlan-limit option' do
is_expected.to contain_vs_config('other_config:vlan-limit').with(
:value => nil, :wait => true,
)
end
it 'configures service' do
is_expected.to contain_service('openvswitch').with(
:ensure => true,
:enable => true,
:name => platform_params[:ovs_service_name],
:tag => 'openvswitch'
)
end
it 'install package' do
is_expected.to contain_package('openvswitch').with(
:name => platform_params[:ovs_package_name],
:ensure => 'present',
:before => 'Service[openvswitch]',
:tag => 'openvswitch'
)
end
it 'restarts the service when needed' do
is_expected.to contain_exec('restart openvswitch').with(
:path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'],
:command => ['systemctl', '-q', 'restart', "#{platform_params[:ovs_service_name]}.service"],
:refreshonly => true
)
end
end
context 'custom parameters' do
let :params do
{
:package_ensure => 'latest',
:enable_hw_offload => true,
:disable_emc => true,
:vlan_limit => 2,
}
end
it 'installs correct package' do
is_expected.to contain_package('openvswitch').with(
:name => platform_params[:ovs_package_name],
:ensure => 'latest',
:before => 'Service[openvswitch]',
:tag => 'openvswitch'
)
end
it 'configures hw-offload option' do
is_expected.to contain_vs_config('other_config:hw-offload').with(
:value => true, :restart => true, :wait => true,
)
end
it 'configures disable_emc option' do
is_expected.to contain_vs_config('other_config:emc-insert-inv-prob').with(
:value => 0, :wait => false,
)
end
it 'configures vlan-limit option' do
is_expected.to contain_vs_config('other_config:vlan-limit').with(
:value => 2, :wait => true,
)
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({ :ovs_version => '1.4.2' }))
end
let (:platform_params) do
case facts[:os]['family']
when 'Debian'
if facts[:os]['name'] == 'Debian'
{
:ovs_package_name => 'openvswitch-switch',
:ovs_service_name => 'openvswitch-switch',
}
elsif facts[:os]['name'] == 'Ubuntu'
{
:ovs_package_name => 'openvswitch-switch',
:ovs_service_name => 'openvswitch-switch',
}
end
when 'RedHat'
{
:ovs_package_name => 'openvswitch',
:ovs_service_name => 'openvswitch',
}
end
end
it_behaves_like "vswitch::ovs"
end
end
end
|