-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvswitch_dpdk_spec.rb
121 lines (107 loc) · 3.64 KB
/
vswitch_dpdk_spec.rb
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
require 'spec_helper'
describe 'vswitch::dpdk' do
let :default_params do {
:package_ensure => 'present',
:core_list => '1,2',
:memory_channels => '2',
}
end
shared_examples_for 'vswitch::dpdk on Debian' do
let(:params) { default_params }
context 'basic parameters' do
it_raises 'a Puppet::Error', /Debian not yet supported for dpdk/
end
end
shared_examples_for 'vswitch::dpdk on RedHat' do
let(:params) { default_params }
context 'basic parameters' do
it 'include the class' do
is_expected.to contain_class('vswitch::dpdk')
end
it 'contains params' do
is_expected.to contain_class('vswitch::params')
end
it 'configures service' do
is_expected.to contain_service('openvswitch').with(
:ensure => true,
:enable => true,
:name => platform_params[:ovs_service_name],
:hasstatus => platform_params[:service_hasstatus],
:status => platform_params[:service_status],
)
end
it 'install package' do
is_expected.to contain_package(platform_params[:ovs_dpdk_package_name]).with(
:name => platform_params[:ovs_dpdk_package_name],
:ensure => params[:package_ensure],
:before => 'Service[openvswitch]',
)
end
it 'should have dpdk driver modules file' do
is_expected.to contain_kmod__load('vfio-pci')
end
it 'configures dpdk options for ovs' do
is_expected.to contain_dpdk_options('/etc/sysconfig/openvswitch').with(
:path => '/etc/sysconfig/openvswitch',
:core_list => params[:core_list],
:memory_channels => params[:memory_channels],
:before => 'Service[openvswitch]',
)
end
end
context 'when passing socket mem' do
before :each do
params.merge!(:socket_mem => '1024')
end
it 'configures dpdk options with socket memory' do
is_expected.to contain_dpdk_options('/etc/sysconfig/openvswitch').with(
:path => '/etc/sysconfig/openvswitch',
:core_list => params[:core_list],
:memory_channels => params[:memory_channels],
:socket_memory => params[:socket_mem],
:before => 'Service[openvswitch]',
)
end
end
context 'when providing valid driver type facts' do
before :each do
params.merge!(:driver_type => 'test')
facts.merge!({ :pci_address_driver_test => '0000:00:05.0,0000:00:05.1' })
end
it 'configures dpdk options with pci address for driver test' do
is_expected.to contain_dpdk_options('/etc/sysconfig/openvswitch').with(
:path => '/etc/sysconfig/openvswitch',
:core_list => params[:core_list],
:memory_channels => params[:memory_channels],
:socket_memory => params[:socket_mem],
:pci_list => '0000:00:05.0,0000:00:05.1',
:before => 'Service[openvswitch]',
)
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[:osfamily]
when 'Debian'
{
# not supported
}
when 'RedHat'
{
:ovs_dpdk_package_name => 'openvswitch',
:ovs_service_name => 'openvswitch',
:provider => 'ovs_redhat',
}
end
end
it_behaves_like "vswitch::dpdk on #{facts[:osfamily]}"
end
end
end