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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
|
require 'spec_helper'
describe 'ovn::controller' do
let :params do
{
:ovn_remote => 'tcp:x.x.x.x:5000',
:ovn_encap_ip => '1.2.3.4',
}
end
shared_examples_for 'ovn controller' do
it 'includes controller' do
is_expected.to contain_class('ovn::controller')
end
it 'starts controller' do
is_expected.to contain_service('controller').with(
:ensure => true,
:name => platform_params[:ovn_controller_service_name],
:enable => true,
)
end
it 'installs controller package' do
is_expected.to contain_package('ovn-controller').with(
:ensure => 'present',
:name => platform_params[:ovn_controller_package_name],
:notify => 'Service[controller]'
)
end
it 'creates systemd conf' do
is_expected.to contain_augeas('config-ovn-controller').with({
:context => platform_params[:ovn_controller_context],
:changes => "set " + platform_params[:ovn_controller_opts_envvar_name] + " '\"\"'",
})
end
context 'with required parameters' do
it 'configures ovsdb' do
is_expected.to contain_vs_config('external_ids:ovn-remote').with(
:value => params[:ovn_remote],
)
is_expected.to contain_vs_config('external_ids:ovn-encap-type').with(
:value => 'geneve',
)
is_expected.to contain_vs_config('external_ids:ovn-encap-ip').with(
:value => params[:ovn_encap_ip],
)
is_expected.to contain_vs_config('external_ids:hostname').with(
:value => 'foo.example.com',
)
is_expected.to contain_vs_config('external_ids:ovn-bridge').with(
:value => 'br-int',
)
is_expected.to contain_vs_config('external_ids:ovn-cms-options').with(
:ensure => 'absent',
)
is_expected.to contain_vs_config('external_ids:ovn-encap-tos').with(
:ensure => 'absent',
)
is_expected.to contain_vs_config('external_ids:ovn-remote-probe-interval').with(
:value => 60000,
)
is_expected.to contain_vs_config('external_ids:ovn-openflow-probe-interval').with(
:value => 60,
)
is_expected.to contain_vs_config('external_ids:ovn-monitor-all').with(
:value => false,
)
is_expected.to contain_vs_config('external_ids:ovn-transport-zones').with(
:ensure => 'absent'
)
is_expected.to contain_vs_config('external_ids:ovn-match-northd-version').with(
:value => false,
)
is_expected.to contain_vs_config('external_ids:ovn-chassis-mac-mappings').with(
:ensure => 'absent'
)
is_expected.to contain_vs_config('external_ids:ovn-ofctrl-wait-before-clear').with(
:value => 8000
)
end
it 'configures bridge mappings' do
is_expected.to contain_vs_config('external_ids:ovn-bridge-mappings').with(
:ensure => 'absent'
)
end
end
context 'with parameters' do
before do
params.merge!({
:ovn_encap_type => 'vxlan',
:ovn_encap_tos => 0,
:ovn_bridge_mappings => ['physnet-1:br-1'],
:ovn_bridge => 'br-custom',
:bridge_interface_mappings => ['br-1:eth1'],
:hostname => 'server1.example.com',
:ovn_cms_options => ['cms_option1', 'cms_option2:foo'],
:ovn_remote_probe_interval => 30000,
:ovn_openflow_probe_interval => 8,
:ovn_monitor_all => true,
:ovn_transport_zones => ['tz1'],
:enable_ovn_match_northd => false,
:ovn_chassis_mac_map => ['physnet1:aa:bb:cc:dd:ee:ff',
'physnet2:bb:aa:cc:dd:ee:ff'],
:ovn_ofctrl_wait_before_clear => 9000
})
end
it 'configures ovsdb' do
is_expected.to contain_vs_config('external_ids:ovn-remote').with(
:value => params[:ovn_remote],
)
is_expected.to contain_vs_config('external_ids:ovn-encap-type').with(
:value => params[:ovn_encap_type],
)
is_expected.to contain_vs_config('external_ids:ovn-encap-ip').with(
:value => params[:ovn_encap_ip],
)
is_expected.to contain_vs_config('external_ids:hostname').with(
:value => 'server1.example.com',
)
is_expected.to contain_vs_config('external_ids:ovn-bridge').with(
:value => params[:ovn_bridge],
)
is_expected.to contain_vs_config('external_ids:ovn-cms-options').with(
:value => 'cms_option1,cms_option2:foo',
)
is_expected.to contain_vs_config('external_ids:ovn-encap-tos').with(
:value => 0,
)
is_expected.to contain_vs_config('external_ids:ovn-remote-probe-interval').with(
:value => params[:ovn_remote_probe_interval],
)
is_expected.to contain_vs_config('external_ids:ovn-openflow-probe-interval').with(
:value => params[:ovn_openflow_probe_interval],
)
is_expected.to contain_vs_config('external_ids:ovn-monitor-all').with(
:value => params[:ovn_monitor_all],
)
is_expected.to contain_vs_config('external_ids:ovn-transport-zones').with(
:value => params[:ovn_transport_zones],
)
is_expected.to contain_vs_config('external_ids:ovn-match-northd-version').with(
:value => params[:enable_ovn_match_northd],
)
is_expected.to contain_vs_config('external_ids:ovn-chassis-mac-mappings').with(
:value => 'physnet1:aa:bb:cc:dd:ee:ff,physnet2:bb:aa:cc:dd:ee:ff',
)
is_expected.to contain_vs_config('external_ids:ovn-ofctrl-wait-before-clear').with(
:value => params[:ovn_ofctrl_wait_before_clear],
)
end
it 'configures bridge mappings' do
is_expected.to contain_vs_config('external_ids:ovn-bridge-mappings').with(
:value => 'physnet-1:br-1',
)
params[:ovn_bridge_mappings].each do |mapping|
is_expected.to contain_ovn__controller__bridge(mapping).with(
:before => 'Service[controller]',
:require => 'Service[openvswitch]'
)
end
params[:bridge_interface_mappings].each do |mapping|
is_expected.to contain_ovn__controller__port(mapping).with(
:before => 'Service[controller]',
:require => 'Service[openvswitch]'
)
end
end
end
context 'when ovn_chassis_mac_map is a hash' do
before :each do
params.merge!({
:ovn_chassis_mac_map => {
'physnet1' => 'aa:bb:cc:dd:ee:ff',
'physnet2' => 'bb:aa:cc:dd:ee:ff' }
})
end
it 'configures ovsdb' do
is_expected.to contain_vs_config('external_ids:ovn-chassis-mac-mappings').with(
:value => 'physnet1:aa:bb:cc:dd:ee:ff,physnet2:bb:aa:cc:dd:ee:ff',
)
end
end
context 'when setting mac_table_size' do
before :each do
params.merge!({
:ovn_bridge_mappings => ['physnet-1:br-1'],
:mac_table_size => 20000
})
end
it 'configures mac_table_size' do
params[:ovn_bridge_mappings].each do |mapping|
is_expected.to contain_ovn__controller__bridge(mapping).with(
:mac_table_size => 20000,
:before => 'Service[controller]',
:require => 'Service[openvswitch]'
)
end
end
end
context 'when manage_ovs_bridge is false' do
before :each do
params.merge!({
:ovn_bridge_mappings => ['physnet-1:br-1'],
:bridge_interface_mappings => ['br-1:eth1'],
:manage_ovs_bridge => false,
})
end
it 'does not manage ovs bridge' do
params[:ovn_bridge_mappings].each do |mapping|
is_expected.to_not contain_ovn__controller__bridge(mapping)
end
params[:bridge_interface_mappings].each do |mapping|
is_expected.to_not contain_ovn__controller__port(mapping)
end
end
end
context 'with ovn controller ssl' do
before :each do
params.merge!({
:ovn_controller_ssl_key => '/path/to/key.pem',
:ovn_controller_ssl_cert => '/path/to/cert.pem',
:ovn_controller_ssl_ca_cert => '/path/to/cacert.pem',
})
end
it 'creates systemd conf' do
is_expected.to contain_augeas('config-ovn-controller').with({
:context => platform_params[:ovn_controller_context],
:changes => "set " + platform_params[:ovn_controller_opts_envvar_name] + " '\"" +
"--ovn-controller-ssl-key=/path/to/key.pem --ovn-controller-ssl-cert=/path/to/cert.pem --ovn-controller-ssl-ca-cert=/path/to/cacert.pem" +
"\"'",
})
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
case facts[:os]['family']
when 'Debian'
let :platform_params do
{
:ovn_controller_package_name => 'ovn-host',
:ovn_controller_service_name => 'ovn-host',
:ovn_controller_context => '/files/etc/default/ovn-host',
:ovn_controller_opts_envvar_name => 'OVN_CTL_OPTS'
}
end
it_behaves_like 'ovn controller'
when 'RedHat'
let :platform_params do
{
:ovn_controller_package_name => 'openvswitch-ovn-host',
:ovn_controller_service_name => 'ovn-controller',
:ovn_controller_context => '/files/etc/sysconfig/ovn-controller',
:ovn_controller_opts_envvar_name => 'OVN_CONTROLLER_OPTS'
}
end
it_behaves_like 'ovn controller'
end
end
end
end
|