cisco_node_utils 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +43 -1
- data/README.md +4 -4
- data/docs/README-maintainers.md +1 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +20 -0
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +20 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_multicast.yaml +12 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_multisite.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_stormcontrol.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/interface_evpn_multisite.yaml +17 -0
- data/lib/cisco_node_utils/cmd_ref/ip_multicast.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +21 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +7 -0
- data/lib/cisco_node_utils/evpn_multicast.rb +66 -0
- data/lib/cisco_node_utils/evpn_multisite.rb +96 -0
- data/lib/cisco_node_utils/evpn_stormcontrol.rb +84 -0
- data/lib/cisco_node_utils/feature.rb +19 -0
- data/lib/cisco_node_utils/interface.rb +2 -1
- data/lib/cisco_node_utils/interface_evpn_multisite.rb +63 -0
- data/lib/cisco_node_utils/ip_multicast.rb +86 -0
- data/lib/cisco_node_utils/version.rb +2 -2
- data/lib/cisco_node_utils/vrf_af.rb +56 -5
- data/lib/cisco_node_utils/vxlan_vtep.rb +24 -0
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +21 -0
- data/tests/ciscotest.rb +36 -3
- data/tests/tacacs_server.yaml.example +1 -1
- data/tests/test_bgp_af.rb +1 -1
- data/tests/test_bgp_neighbor.rb +15 -0
- data/tests/test_bgp_neighbor_af.rb +27 -0
- data/tests/test_evpn_multicast.rb +65 -0
- data/tests/test_evpn_multisite.rb +70 -0
- data/tests/test_evpn_stormcontrol.rb +56 -0
- data/tests/test_feature.rb +6 -1
- data/tests/test_interface_evpn_multisite.rb +59 -0
- data/tests/test_ip_multicast.rb +69 -0
- data/tests/test_node_ext.rb +3 -2
- data/tests/test_radius_global.rb +7 -5
- data/tests/test_router_ospf_vrf.rb +2 -0
- data/tests/test_stp_global.rb +7 -0
- data/tests/test_tacacs_global.rb +10 -7
- data/tests/test_vrf_af.rb +52 -1
- data/tests/test_vxlan_vtep.rb +23 -0
- data/tests/test_vxlan_vtep_vni.rb +31 -0
- data/tests/yum_package.yaml +10 -0
- metadata +18 -3
data/tests/ciscotest.rb
CHANGED
@@ -83,9 +83,10 @@ class CiscoTestCase < TestCase
|
|
83
83
|
@@node.cache_auto = true
|
84
84
|
# Record the platform we're running on
|
85
85
|
puts "\nNode under test:"
|
86
|
-
puts " - name
|
87
|
-
puts " - type
|
88
|
-
puts " - image
|
86
|
+
puts " - name - #{@@node.host_name}"
|
87
|
+
puts " - type - #{@@node.product_id}"
|
88
|
+
puts " - image - #{@@node.system}"
|
89
|
+
puts " - version - #{@@node.os_version}\n\n"
|
89
90
|
end
|
90
91
|
@@node
|
91
92
|
rescue Cisco::AuthenticationFailed
|
@@ -226,6 +227,38 @@ class CiscoTestCase < TestCase
|
|
226
227
|
skip(msg) if Utils.image_version?(Regexp.new(pattern))
|
227
228
|
end
|
228
229
|
|
230
|
+
def step_unless_legacy_defect(pattern, msg)
|
231
|
+
if pattern.is_a?(String)
|
232
|
+
pattern = [pattern]
|
233
|
+
elsif !pattern.is_a?(Array)
|
234
|
+
fail 'Argument: pattern must be a String or Array object'
|
235
|
+
end
|
236
|
+
pattern.each do |pat|
|
237
|
+
if Utils.image_version?(Regexp.new(pat))
|
238
|
+
puts "Skip Step: Defect in legacy image: [#{msg}]"
|
239
|
+
return false
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def step_unless_version_unsupported(pattern)
|
245
|
+
if pattern.is_a?(String)
|
246
|
+
pattern = [pattern]
|
247
|
+
elsif !pattern.is_a?(Array)
|
248
|
+
fail 'Argument: pattern must be a String or Array object'
|
249
|
+
end
|
250
|
+
pattern.each do |pat|
|
251
|
+
if Utils.image_version?(Regexp.new(pat))
|
252
|
+
puts "Skip Step: Feature not supported in this image version: [#{Platform.image_version}]"
|
253
|
+
return false
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def virtual_platform?
|
259
|
+
node.product_id[/N9K-NXOSV|N9K-9000v/] ? true : false
|
260
|
+
end
|
261
|
+
|
229
262
|
def interfaces
|
230
263
|
unless @@interfaces
|
231
264
|
# Build the platform_info, used for interface lookup
|
data/tests/test_bgp_af.rb
CHANGED
@@ -170,7 +170,7 @@ class TestBgpAF < CiscoTestCase
|
|
170
170
|
# triggers a version check below.
|
171
171
|
if expect == :runtime
|
172
172
|
case Platform.image_version
|
173
|
-
when /8.0|8.1|8.2|F3.2/
|
173
|
+
when /8.0|8.1|8.2|8.3|F3.2/
|
174
174
|
expect = :success
|
175
175
|
expect = :runtime if test == :additional_paths_receive && Platform.image_version[/8.0|8.1/]
|
176
176
|
when /I5.2|I5.3|I6/
|
data/tests/test_bgp_neighbor.rb
CHANGED
@@ -578,4 +578,19 @@ class TestBgpNeighbor < CiscoTestCase
|
|
578
578
|
neighbor.destroy
|
579
579
|
end
|
580
580
|
end
|
581
|
+
|
582
|
+
def test_peer_type
|
583
|
+
skip("#{node.product_id} doesn't support this feature") unless
|
584
|
+
node.product_id[/N9K.*EX/]
|
585
|
+
%w(default test_vrf).each do |vrf|
|
586
|
+
neighbor = RouterBgpNeighbor.new(ASN, vrf, ADDR)
|
587
|
+
check = ['fabric-border-leaf', 'fabric-external',
|
588
|
+
neighbor.default_peer_type]
|
589
|
+
check.each do |val|
|
590
|
+
neighbor.peer_type = val
|
591
|
+
assert_equal(val, neighbor.peer_type)
|
592
|
+
end
|
593
|
+
neighbor.destroy
|
594
|
+
end
|
595
|
+
end
|
581
596
|
end
|
@@ -751,4 +751,31 @@ class TestBgpNeighborAF < CiscoTestCase
|
|
751
751
|
assert_equal(af.default_weight, af.weight,
|
752
752
|
"Test 3. #{dbg} Failed to remove weight")
|
753
753
|
end
|
754
|
+
|
755
|
+
def test_rewrite_evpn_rt_asn
|
756
|
+
skip("#{node.product_id} doesn't support this feature") unless
|
757
|
+
node.product_id[/N9K.*EX/]
|
758
|
+
af_args = @@matrix[:evpn]
|
759
|
+
# clean_af needs true since rewrite_rt_asn is ebgp only
|
760
|
+
af, dbg = clean_af(af_args, true)
|
761
|
+
rewrite_evpn_rt_asn(af, dbg)
|
762
|
+
end
|
763
|
+
|
764
|
+
def rewrite_evpn_rt_asn(af, dbg)
|
765
|
+
# eBGP only
|
766
|
+
af.rewrite_evpn_rt_asn = true
|
767
|
+
assert(af.rewrite_evpn_rt_asn,
|
768
|
+
"Test 1. #{dbg} Did not set true")
|
769
|
+
|
770
|
+
af.rewrite_evpn_rt_asn = false
|
771
|
+
refute(af.rewrite_evpn_rt_asn,
|
772
|
+
"Test 2. #{dbg} Did not set false")
|
773
|
+
|
774
|
+
af.rewrite_evpn_rt_asn = true
|
775
|
+
|
776
|
+
def_val = af.default_rewrite_evpn_rt_asn
|
777
|
+
af.rewrite_evpn_rt_asn = def_val
|
778
|
+
assert_equal(def_val, af.rewrite_evpn_rt_asn,
|
779
|
+
"Test 3. #{dbg} Did not set to default")
|
780
|
+
end
|
754
781
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Evpn Multicast Unit Tests
|
2
|
+
#
|
3
|
+
# Rahul Shenoy, January, 2018
|
4
|
+
#
|
5
|
+
# Copyright (c) 2018 Cisco and/or its affiliates.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative 'ciscotest'
|
20
|
+
require_relative '../lib/cisco_node_utils/evpn_multicast'
|
21
|
+
require_relative '../lib/cisco_node_utils/feature'
|
22
|
+
|
23
|
+
# TestEvpnMulticast - Minitest for EvpnMulticast class
|
24
|
+
class TestEvpnMulticast < CiscoTestCase
|
25
|
+
@skip_unless_supported = 'evpn_multicast'
|
26
|
+
|
27
|
+
def setup
|
28
|
+
# Disable feature ngmvpn before each test to
|
29
|
+
# ensure we are starting with a clean slate for each test.
|
30
|
+
super
|
31
|
+
skip_incompat_version?('feature', 'ngmvpn')
|
32
|
+
config_no_warn('no feature ngmvpn')
|
33
|
+
config_no_warn('no advertise evpn multicast')
|
34
|
+
end
|
35
|
+
|
36
|
+
def teardown
|
37
|
+
# disable feature ngmvpn and advertise evpn multicast
|
38
|
+
# after each test
|
39
|
+
config_no_warn('no feature ngmvpn')
|
40
|
+
config_no_warn('no advertise evpn multicast')
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_create_and_destroy
|
45
|
+
mc = EvpnMulticast.new
|
46
|
+
assert_equal('advertise evpn multicast', mc.multicast,
|
47
|
+
'Error: failed to enable evpn multicast')
|
48
|
+
assert(Feature.ngmvpn_enabled?,
|
49
|
+
'Error: failed to enable feature ngmvpn')
|
50
|
+
mc.destroy
|
51
|
+
assert_equal('', mc.multicast,
|
52
|
+
'Error: failed to disable evpn multicast')
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_multicast
|
56
|
+
mc = EvpnMulticast.new
|
57
|
+
mc.multicast = false
|
58
|
+
assert_equal('', mc.multicast,
|
59
|
+
'Error: failed to disable evpn multicast')
|
60
|
+
mc.multicast = true
|
61
|
+
assert_equal('advertise evpn multicast', mc.multicast,
|
62
|
+
'Error: failed to enable evpn multicast')
|
63
|
+
mc.destroy
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Evpn Multisite Unit Tests
|
2
|
+
#
|
3
|
+
# Rahul Shenoy, October, 2017
|
4
|
+
#
|
5
|
+
# Copyright (c) 2017 Cisco and/or its affiliates.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative 'ciscotest'
|
20
|
+
require_relative '../lib/cisco_node_utils/evpn_multisite'
|
21
|
+
|
22
|
+
# TestEvpnMultisite - Minitest for EvpnMultisite class
|
23
|
+
class TestEvpnMultisite < CiscoTestCase
|
24
|
+
@skip_unless_supported = 'evpn_multisite'
|
25
|
+
|
26
|
+
def setup
|
27
|
+
# Disable feature nv overlay before each test to
|
28
|
+
# ensure we are starting with a clean slate for each test.
|
29
|
+
super
|
30
|
+
skip("#{node.product_id} doesn't support this feature") unless
|
31
|
+
node.product_id[/N9K.*EX/]
|
32
|
+
config('no feature nv overlay')
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_create_and_destroy
|
36
|
+
ms = EvpnMultisite.new(100)
|
37
|
+
ms_id = ms.multisite
|
38
|
+
assert_equal('100', ms_id,
|
39
|
+
'Error: failed to create multisite border-gateway 100')
|
40
|
+
ms.destroy
|
41
|
+
ms_id = ms.multisite
|
42
|
+
assert_nil(ms_id, 'Error: failed to destroy multisite border-gateway 100')
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_delay_restore
|
46
|
+
ms = EvpnMultisite.new(100)
|
47
|
+
ms.delay_restore = 31
|
48
|
+
assert_equal('31', ms.delay_restore,
|
49
|
+
'multisite border-gateway delay_restore should be 31')
|
50
|
+
ms.delay_restore = 1000
|
51
|
+
assert_equal('1000', ms.delay_restore,
|
52
|
+
'multisite border-gateway delay_restore should be 1000')
|
53
|
+
ms.destroy
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_update_multisiteid
|
57
|
+
ms = EvpnMultisite.new(100)
|
58
|
+
ms.delay_restore = 50
|
59
|
+
assert_equal('100', ms.multisite,
|
60
|
+
'Error: failed to create multisite border-gateway 100')
|
61
|
+
assert_equal('50', ms.delay_restore,
|
62
|
+
'multisite border-gateway delay_restore should be 50')
|
63
|
+
ms.multisite = 200
|
64
|
+
assert_equal('200', ms.multisite,
|
65
|
+
'Error: failed to create multisite border-gateway 200')
|
66
|
+
assert_equal('50', ms.delay_restore,
|
67
|
+
'multisite border-gateway delay_restore should be 50')
|
68
|
+
ms.destroy
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Evpn Stormcontrol Unit Tests
|
2
|
+
#
|
3
|
+
# Rahul Shenoy, October, 2017
|
4
|
+
#
|
5
|
+
# Copyright (c) 2017 Cisco and/or its affiliates.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative 'ciscotest'
|
20
|
+
require_relative '../lib/cisco_node_utils/evpn_stormcontrol'
|
21
|
+
|
22
|
+
# TestEvpnStormcontrol - Minitest for EvpnStormcontrol class
|
23
|
+
class TestEvpnStormcontrol < CiscoTestCase
|
24
|
+
@skip_unless_supported = 'evpn_stormcontrol'
|
25
|
+
|
26
|
+
def setup
|
27
|
+
# Ensure we are starting with a clean slate for each test.
|
28
|
+
super
|
29
|
+
skip("#{node.product_id} doesn't support this feature") unless
|
30
|
+
node.product_id[/N9K.*EX/]
|
31
|
+
config('no evpn storm-control broadcast level 50')
|
32
|
+
config('no evpn storm-control multicast level 50')
|
33
|
+
config('no evpn storm-control unicast level 50')
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_create_and_destroy
|
37
|
+
sc = EvpnStormcontrol.new('broadcast', 50)
|
38
|
+
sc_level = sc.level
|
39
|
+
assert_equal('50', sc_level,
|
40
|
+
'Error: failed to configure evpn storm-control broadcast ' \
|
41
|
+
'level 50')
|
42
|
+
sc.destroy
|
43
|
+
sc_level = sc.level
|
44
|
+
assert_nil(sc_level, 'Error: failed to destroy storm-control config')
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_update_level
|
48
|
+
sc = EvpnStormcontrol.new('multicast', 50)
|
49
|
+
assert_equal('50', sc.level,
|
50
|
+
'Error: multicast storm-control level should be 50')
|
51
|
+
sc.level = 51
|
52
|
+
assert_equal('51', sc.level,
|
53
|
+
'Error: failed to create multisite border-gateway 200')
|
54
|
+
sc.destroy
|
55
|
+
end
|
56
|
+
end
|
data/tests/test_feature.rb
CHANGED
@@ -31,7 +31,6 @@ class TestFeature < CiscoTestCase
|
|
31
31
|
'no feature bgp',
|
32
32
|
'no feature dhcp',
|
33
33
|
'no feature fabric forwarding',
|
34
|
-
'no feature-set fex',
|
35
34
|
'no feature hsrp',
|
36
35
|
'no feature itd',
|
37
36
|
'no feature nv overlay',
|
@@ -42,6 +41,11 @@ class TestFeature < CiscoTestCase
|
|
42
41
|
'no feature vn-segment-vlan-based',
|
43
42
|
'no feature vni',
|
44
43
|
'no feature vtp'].each { |f| config_no_warn(f) }
|
44
|
+
|
45
|
+
# Special case for 'no feature-set fex'
|
46
|
+
# Some image versions prompt y/n to remove the feature-set.
|
47
|
+
config_no_warn('terminal dont-ask')
|
48
|
+
config_no_warn('no feature-set fex')
|
45
49
|
end
|
46
50
|
|
47
51
|
###########
|
@@ -226,6 +230,7 @@ class TestFeature < CiscoTestCase
|
|
226
230
|
|
227
231
|
# clean
|
228
232
|
if Feature.fex_installed?
|
233
|
+
config_no_warn('terminal dont-ask')
|
229
234
|
config_no_warn("no #{fs}")
|
230
235
|
config_no_warn("no install #{fs}")
|
231
236
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Interface Evpn Multisite Unit Tests
|
2
|
+
#
|
3
|
+
# Rahul Shenoy, October, 2017
|
4
|
+
#
|
5
|
+
# Copyright (c) 2017 Cisco and/or its affiliates.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative 'ciscotest'
|
20
|
+
require_relative '../lib/cisco_node_utils/interface_evpn_multisite'
|
21
|
+
require_relative '../lib/cisco_node_utils/evpn_multisite'
|
22
|
+
|
23
|
+
# TestInterfaceEvpnMultisite - Minitest for InterfaceEvpnMultisite class
|
24
|
+
class TestInterfaceEvpnMultisite < CiscoTestCase
|
25
|
+
@skip_unless_supported = 'interface_evpn_multisite'
|
26
|
+
|
27
|
+
def setup
|
28
|
+
# ensure we are starting with a clean slate for each test.
|
29
|
+
super
|
30
|
+
skip("#{node.product_id} doesn't support this feature") unless
|
31
|
+
node.product_id[/N9K.*EX/]
|
32
|
+
interface_ethernet_default(interfaces[0])
|
33
|
+
end
|
34
|
+
|
35
|
+
def interface_ethernet_default(intf)
|
36
|
+
config("default interface #{intf}")
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_enable_disable
|
40
|
+
interface = interfaces[0]
|
41
|
+
intf_ms = InterfaceEvpnMultisite.new(interface)
|
42
|
+
ms = EvpnMultisite.new(100)
|
43
|
+
intf_ms.enable('dci-tracking')
|
44
|
+
assert_equal('dci-tracking', intf_ms.tracking)
|
45
|
+
intf_ms.disable('dci-tracking')
|
46
|
+
assert_nil(intf_ms.tracking)
|
47
|
+
ms.destroy
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_enable_with_no_multisite_bordergateway
|
51
|
+
interface = interfaces[0]
|
52
|
+
intf_ms = InterfaceEvpnMultisite.new(interface)
|
53
|
+
ms = EvpnMultisite.new(100)
|
54
|
+
ms.destroy
|
55
|
+
assert_raises(CliError, 'Invalid command') do
|
56
|
+
intf_ms.enable('dci-tracking')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# IP Multicast Unit Tests
|
2
|
+
#
|
3
|
+
# Rahul Shenoy, January, 2018
|
4
|
+
#
|
5
|
+
# Copyright (c) 2018 Cisco and/or its affiliates.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative 'ciscotest'
|
20
|
+
require_relative '../lib/cisco_node_utils/ip_multicast'
|
21
|
+
require_relative '../lib/cisco_node_utils/feature'
|
22
|
+
|
23
|
+
# TestIpMulticast - Minitest for IpMulticast class
|
24
|
+
class TestIpMulticast < CiscoTestCase
|
25
|
+
@skip_unless_supported = 'ip_multicast'
|
26
|
+
|
27
|
+
def setup
|
28
|
+
# Disable feature ngmvpn before each test to
|
29
|
+
# ensure we are starting with a clean slate for each test.
|
30
|
+
super
|
31
|
+
skip_incompat_version?('feature', 'ngmvpn')
|
32
|
+
config_no_warn('no feature ngmvpn')
|
33
|
+
end
|
34
|
+
|
35
|
+
def teardown
|
36
|
+
# Disable feature ngmvpn after each test
|
37
|
+
config_no_warn('no feature ngmvpn')
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_ip_multicast
|
42
|
+
ipm = IpMulticast.new
|
43
|
+
opts = %w(overlay_distributed_dr overlay_spt_only)
|
44
|
+
|
45
|
+
# test defaults
|
46
|
+
opts.each do |opt|
|
47
|
+
have = ipm.send("#{opt}")
|
48
|
+
should = ipm.send("default_#{opt}")
|
49
|
+
assert_equal(have, should, "#{opt} doesn't match the default")
|
50
|
+
end
|
51
|
+
|
52
|
+
# test property set
|
53
|
+
opts.each do |opt|
|
54
|
+
ipm.send("#{opt}=", true)
|
55
|
+
should = 'ip multicast ' + opt.tr('_', '-')
|
56
|
+
assert_equal(ipm.send("#{opt}"), should, "#{opt} was not set")
|
57
|
+
end
|
58
|
+
|
59
|
+
# unset property
|
60
|
+
opts.each do |opt|
|
61
|
+
ipm.send("#{opt}=", false)
|
62
|
+
should = false
|
63
|
+
assert_equal(ipm.send("#{opt}"), should, "#{opt} was not unset")
|
64
|
+
assert_equal(ipm.send("#{opt}"), ipm.send("default_#{opt}"), "#{opt} doesn't match default")
|
65
|
+
end
|
66
|
+
|
67
|
+
ipm.destroy
|
68
|
+
end
|
69
|
+
end
|