summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/subdir.am8
-rw-r--r--[-rwxr-xr-x]tests/topotests/all-protocol-startup/test_all_protocol_startup.py214
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py0
-rw-r--r--tests/topotests/bgp-evpn-mh/test_evpn_mh.py4
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp-prefix-list-topo1/test_prefix_lists.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp-route-map/test_route_map_topo1.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp-route-map/test_route_map_topo2.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py2
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py0
-rw-r--r--tests/topotests/eigrp-topo1/test_eigrp_topo1.py2
-rw-r--r--[-rwxr-xr-x]tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py0
-rw-r--r--[-rwxr-xr-x]tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py4
-rw-r--r--tests/topotests/isis-topo1-vrf/test_isis_topo1_vrf.py4
-rw-r--r--[-rwxr-xr-x]tests/topotests/ldp-topo1/test_ldp_topo1.py0
-rw-r--r--tests/topotests/lib/bgp.py13
-rw-r--r--tests/topotests/lib/common_config.py34
-rw-r--r--tests/topotests/lib/ltemplate.py8
-rw-r--r--[-rwxr-xr-x]tests/topotests/lib/lutil.py38
-rw-r--r--tests/topotests/lib/ospf.py12
-rw-r--r--tests/topotests/lib/topogen.py21
-rw-r--r--tests/topotests/lib/topojson.py2
-rw-r--r--tests/topotests/lib/topolog.py2
-rw-r--r--tests/topotests/lib/topotest.py15
-rw-r--r--tests/topotests/ospf-topo2/test_ospf_topo2.py22
-rw-r--r--tests/topotests/pbr-topo1/test_pbr_topo1.py20
-rw-r--r--[-rwxr-xr-x]tests/topotests/rip-topo1/test_rip_topo1.py8
-rw-r--r--[-rwxr-xr-x]tests/topotests/ripng-topo1/test_ripng_topo1.py0
39 files changed, 243 insertions, 190 deletions
diff --git a/tests/subdir.am b/tests/subdir.am
index 2cdb214f0b..d7318efc72 100644
--- a/tests/subdir.am
+++ b/tests/subdir.am
@@ -12,8 +12,10 @@ TESTS_BGPD = \
tests/bgpd/test_mp_attr \
tests/bgpd/test_mpath \
tests/bgpd/test_bgp_table
+IGNORE_BGPD =
else
TESTS_BGPD =
+IGNORE_BGPD = --ignore=bgpd/
endif
if ISISD
@@ -23,16 +25,20 @@ TESTS_ISISD = \
tests/isisd/test_isis_spf \
tests/isisd/test_isis_vertex_queue \
# end
+IGNORE_ISISD =
else
TESTS_ISISD =
+IGNORE_ISISD = --ignore=isisd/
endif
if OSPF6D
TESTS_OSPF6D = \
tests/ospf6d/test_lsdb \
# end
+IGNORE_OSPF6D =
else
TESTS_OSPF6D =
+IGNORE_OSPF6D = --ignore=ospf6d/
endif
clippy_scan += \
@@ -368,7 +374,7 @@ EXTRA_DIST += \
.PHONY: tests/tests.xml
tests/tests.xml: $(check_PROGRAMS)
- ( cd tests; $(PYTHON) ../$(srcdir)/tests/runtests.py --junitxml=tests.xml -v ../$(srcdir)/tests; )
+ ( cd tests; $(PYTHON) ../$(srcdir)/tests/runtests.py --junitxml=tests.xml -v ../$(srcdir)/tests $(IGNORE_BGPD) $(IGNORE_ISISD) $(IGNORE_OSPF6D); )
check: tests/tests.xml
clean-local: clean-tests
diff --git a/tests/topotests/all-protocol-startup/test_all_protocol_startup.py b/tests/topotests/all-protocol-startup/test_all_protocol_startup.py
index 2a00398e28..32b219283b 100755..100644
--- a/tests/topotests/all-protocol-startup/test_all_protocol_startup.py
+++ b/tests/topotests/all-protocol-startup/test_all_protocol_startup.py
@@ -113,8 +113,8 @@ def setup_module(module):
net['r%s' % i].loadConf('ospfd', '%s/r%s/ospfd.conf' % (thisDir, i))
if net['r1'].checkRouterVersion('<', '4.0'):
net['r%s' % i].loadConf('ospf6d', '%s/r%s/ospf6d.conf-pre-v4' % (thisDir, i))
- else:
- net['r%s' % i].loadConf('ospf6d', '%s/r%s/ospf6d.conf' % (thisDir, i))
+ else:
+ net['r%s' % i].loadConf('ospf6d', '%s/r%s/ospf6d.conf' % (thisDir, i))
net['r%s' % i].loadConf('isisd', '%s/r%s/isisd.conf' % (thisDir, i))
net['r%s' % i].loadConf('bgpd', '%s/r%s/bgpd.conf' % (thisDir, i))
if net['r%s' % i].daemon_available('ldpd'):
@@ -374,26 +374,36 @@ def route_get_nhg_id(route_str):
nhg_id = int(match.group(1))
return nhg_id
-def verify_nexthop_group(nhg_id, recursive=False):
+def verify_nexthop_group(nhg_id, recursive=False, ecmp=0):
# Verify NHG is valid/installed
output = net["r1"].cmd('vtysh -c "show nexthop-group rib %d"' % nhg_id)
match = re.search(r"Valid", output)
assert match is not None, "Nexthop Group ID=%d not marked Valid" % nhg_id
- # If recursive, we need to look at its resolved group
- if recursive:
- match = re.search(r"Depends: \((\d+)\)", output)
- resolved_id = int(match.group(1))
- verify_nexthop_group(resolved_id, False)
+ if ecmp or recursive:
+ match = re.search(r"Depends:.*\n", output)
+ assert match is not None, "Nexthop Group ID=%d has no depends" % nhg_id
+
+ # list of IDs in group
+ depends = re.findall(r"\((\d+)\)", match.group(0))
+
+ if ecmp:
+ assert (len(depends) == ecmp), "Nexthop Group ID=%d doesn't match ecmp size" % nhg_id
+ else:
+ # If recursive, we need to look at its resolved group
+ assert (len(depends) == 1), "Nexthop Group ID=%d should only have one recursive depend" % nhg_id
+ resolved_id = int(depends[0])
+ verify_nexthop_group(resolved_id, False)
+
else:
match = re.search(r"Installed", output)
assert match is not None, "Nexthop Group ID=%d not marked Installed" % nhg_id
-def verify_route_nexthop_group(route_str, recursive=False):
+def verify_route_nexthop_group(route_str, recursive=False, ecmp=0):
# Verify route and that zebra created NHGs for and they are valid/installed
nhg_id = route_get_nhg_id(route_str)
- verify_nexthop_group(nhg_id, recursive)
+ verify_nexthop_group(nhg_id, recursive, ecmp)
def test_nexthop_groups():
global fatal_error
@@ -611,7 +621,7 @@ def test_ospfv2_interfaces():
actual = net['r%s' % i].cmd('vtysh -c "show ip ospf interface" 2> /dev/null').rstrip()
# Mask out Bandwidth portion. They may change..
actual = re.sub(r"BW [0-9]+ Mbit", "BW XX Mbit", actual)
- actual = re.sub(r"ifindex [0-9]", "ifindex X", actual)
+ actual = re.sub(r"ifindex [0-9]", "ifindex X", actual)
# Drop time in next due
actual = re.sub(r"Hello due in [0-9\.]+s", "Hello due in XX.XXXs", actual)
@@ -882,45 +892,45 @@ def test_bgp_ipv4():
print("******************************************\n")
diffresult = {}
for i in range(1, 2):
- success = 0
- for refTableFile in (glob.glob(
- '%s/r%s/show_bgp_ipv4*.ref' % (thisDir, i))):
- if os.path.isfile(refTableFile):
- # Read expected result from file
- expected = open(refTableFile).read().rstrip()
- # Fix newlines (make them all the same)
- expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
-
- # Actual output from router
- actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv4" 2> /dev/null').rstrip()
- # Remove summary line (changed recently)
- actual = re.sub(r'Total number.*', '', actual)
- actual = re.sub(r'Displayed.*', '', actual)
- actual = actual.rstrip()
- # Fix newlines (make them all the same)
- actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
-
- # Generate Diff
- diff = topotest.get_textdiff(actual, expected,
- title1="actual SHOW BGP IPv4",
- title2="expected SHOW BGP IPv4")
-
- # Empty string if it matches, otherwise diff contains unified diff
- if diff:
- diffresult[refTableFile] = diff
- else:
- success = 1
- print("template %s matched: r%s ok" % (refTableFile, i))
- break
-
- if not success:
- resultstr = 'No template matched.\n'
- for f in diffresult.iterkeys():
- resultstr += (
- 'template %s: r%s failed SHOW BGP IPv4 check:\n%s\n'
- % (f, i, diffresult[f]))
- raise AssertionError(
- "SHOW BGP IPv4 failed for router r%s:\n%s" % (i, resultstr))
+ success = 0
+ for refTableFile in (glob.glob(
+ '%s/r%s/show_bgp_ipv4*.ref' % (thisDir, i))):
+ if os.path.isfile(refTableFile):
+ # Read expected result from file
+ expected = open(refTableFile).read().rstrip()
+ # Fix newlines (make them all the same)
+ expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
+
+ # Actual output from router
+ actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv4" 2> /dev/null').rstrip()
+ # Remove summary line (changed recently)
+ actual = re.sub(r'Total number.*', '', actual)
+ actual = re.sub(r'Displayed.*', '', actual)
+ actual = actual.rstrip()
+ # Fix newlines (make them all the same)
+ actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
+
+ # Generate Diff
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual SHOW BGP IPv4",
+ title2="expected SHOW BGP IPv4")
+
+ # Empty string if it matches, otherwise diff contains unified diff
+ if diff:
+ diffresult[refTableFile] = diff
+ else:
+ success = 1
+ print("template %s matched: r%s ok" % (refTableFile, i))
+ break
+
+ if not success:
+ resultstr = 'No template matched.\n'
+ for f in diffresult.iterkeys():
+ resultstr += (
+ 'template %s: r%s failed SHOW BGP IPv4 check:\n%s\n'
+ % (f, i, diffresult[f]))
+ raise AssertionError(
+ "SHOW BGP IPv4 failed for router r%s:\n%s" % (i, resultstr))
# Make sure that all daemons are running
for i in range(1, 2):
@@ -945,44 +955,44 @@ def test_bgp_ipv6():
print("******************************************\n")
diffresult = {}
for i in range(1, 2):
- success = 0
- for refTableFile in (glob.glob(
- '%s/r%s/show_bgp_ipv6*.ref' % (thisDir, i))):
- if os.path.isfile(refTableFile):
- # Read expected result from file
- expected = open(refTableFile).read().rstrip()
- # Fix newlines (make them all the same)
- expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
-
- # Actual output from router
- actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv6" 2> /dev/null').rstrip()
- # Remove summary line (changed recently)
- actual = re.sub(r'Total number.*', '', actual)
- actual = re.sub(r'Displayed.*', '', actual)
- actual = actual.rstrip()
- # Fix newlines (make them all the same)
- actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
-
- # Generate Diff
- diff = topotest.get_textdiff(actual, expected,
- title1="actual SHOW BGP IPv6",
- title2="expected SHOW BGP IPv6")
-
- # Empty string if it matches, otherwise diff contains unified diff
- if diff:
- diffresult[refTableFile] = diff
- else:
- success = 1
- print("template %s matched: r%s ok" % (refTableFile, i))
-
- if not success:
- resultstr = 'No template matched.\n'
- for f in diffresult.iterkeys():
- resultstr += (
- 'template %s: r%s failed SHOW BGP IPv6 check:\n%s\n'
- % (f, i, diffresult[f]))
- raise AssertionError(
- "SHOW BGP IPv6 failed for router r%s:\n%s" % (i, resultstr))
+ success = 0
+ for refTableFile in (glob.glob(
+ '%s/r%s/show_bgp_ipv6*.ref' % (thisDir, i))):
+ if os.path.isfile(refTableFile):
+ # Read expected result from file
+ expected = open(refTableFile).read().rstrip()
+ # Fix newlines (make them all the same)
+ expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1)
+
+ # Actual output from router
+ actual = net['r%s' % i].cmd('vtysh -c "show bgp ipv6" 2> /dev/null').rstrip()
+ # Remove summary line (changed recently)
+ actual = re.sub(r'Total number.*', '', actual)
+ actual = re.sub(r'Displayed.*', '', actual)
+ actual = actual.rstrip()
+ # Fix newlines (make them all the same)
+ actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
+
+ # Generate Diff
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual SHOW BGP IPv6",
+ title2="expected SHOW BGP IPv6")
+
+ # Empty string if it matches, otherwise diff contains unified diff
+ if diff:
+ diffresult[refTableFile] = diff
+ else:
+ success = 1
+ print("template %s matched: r%s ok" % (refTableFile, i))
+
+ if not success:
+ resultstr = 'No template matched.\n'
+ for f in diffresult.iterkeys():
+ resultstr += (
+ 'template %s: r%s failed SHOW BGP IPv6 check:\n%s\n'
+ % (f, i, diffresult[f]))
+ raise AssertionError(
+ "SHOW BGP IPv6 failed for router r%s:\n%s" % (i, resultstr))
# Make sure that all daemons are running
for i in range(1, 2):
@@ -1101,6 +1111,34 @@ def test_nexthop_groups_with_route_maps():
net["r1"].cmd('vtysh -c "c t" -c "no route-map NOPE"')
net["r1"].cmd('vtysh -c "c t" -c "no ip prefix-list NOPE seq 5 permit %s/32"' % permit_route_str)
+def test_nexthop_group_replace():
+ global fatal_error
+ global net
+
+ # Skip if previous fatal error condition is raised
+ if (fatal_error != ""):
+ pytest.skip(fatal_error)
+
+ print("\n\n** Verifying Nexthop Groups")
+ print("******************************************\n")
+
+ ### Nexthop Group Tests
+
+ ## 2-Way ECMP Directly Connected
+
+ net["r1"].cmd('vtysh -c "c t" -c "nexthop-group replace" -c "nexthop 1.1.1.1 r1-eth1 onlink" -c "nexthop 1.1.1.2 r1-eth2 onlink"')
+
+ # Create with sharpd using nexthop-group
+ net["r1"].cmd('vtysh -c "sharp install routes 3.3.3.1 nexthop-group replace 1"')
+
+ verify_route_nexthop_group("3.3.3.1/32")
+
+ # Change the nexthop group
+ net["r1"].cmd('vtysh -c "c t" -c "nexthop-group replace" -c "no nexthop 1.1.1.1 r1-eth1 onlink" -c "nexthop 1.1.1.3 r1-eth1 onlink" -c "nexthop 1.1.1.4 r1-eth4 onlink"')
+
+ # Verify it updated. We can just check install and ecmp count here.
+ verify_route_nexthop_group("3.3.3.1/32", False, 3)
+
def test_mpls_interfaces():
global fatal_error
global net
diff --git a/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py b/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py
index 41fa7c0a09..41fa7c0a09 100755..100644
--- a/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py
+++ b/tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py
diff --git a/tests/topotests/bgp-evpn-mh/test_evpn_mh.py b/tests/topotests/bgp-evpn-mh/test_evpn_mh.py
index ee50a422a7..9af22c06bd 100644
--- a/tests/topotests/bgp-evpn-mh/test_evpn_mh.py
+++ b/tests/topotests/bgp-evpn-mh/test_evpn_mh.py
@@ -477,9 +477,9 @@ def check_es(dut):
vtep_ips.append(vtep["vtep_ip"])
if "local" in types:
- result = check_local_es(esi, vtep_ips, dut.name, [])
+ result = check_local_es(esi, vtep_ips, dut.name, [])
else:
- result = check_remote_es(esi, vtep_ips, dut.name, [])
+ result = check_remote_es(esi, vtep_ips, dut.name, [])
if result:
return result
diff --git a/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py b/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py
index 607b036c6a..607b036c6a 100755..100644
--- a/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py
+++ b/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py
diff --git a/tests/topotests/bgp-prefix-list-topo1/test_prefix_lists.py b/tests/topotests/bgp-prefix-list-topo1/test_prefix_lists.py
index 22952f645c..22952f645c 100755..100644
--- a/tests/topotests/bgp-prefix-list-topo1/test_prefix_lists.py
+++ b/tests/topotests/bgp-prefix-list-topo1/test_prefix_lists.py
diff --git a/tests/topotests/bgp-route-map/test_route_map_topo1.py b/tests/topotests/bgp-route-map/test_route_map_topo1.py
index 1aa951edaa..1aa951edaa 100755..100644
--- a/tests/topotests/bgp-route-map/test_route_map_topo1.py
+++ b/tests/topotests/bgp-route-map/test_route_map_topo1.py
diff --git a/tests/topotests/bgp-route-map/test_route_map_topo2.py b/tests/topotests/bgp-route-map/test_route_map_topo2.py
index 3056aa29f3..3056aa29f3 100755..100644
--- a/tests/topotests/bgp-route-map/test_route_map_topo2.py
+++ b/tests/topotests/bgp-route-map/test_route_map_topo2.py
diff --git a/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py b/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py
index f9d22a3a36..f9d22a3a36 100755..100644
--- a/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py
+++ b/tests/topotests/bgp_as_allow_in/test_bgp_as_allow_in.py
diff --git a/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py b/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py
index 3ad989c601..0d99f23ad9 100755..100644
--- a/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py
+++ b/tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py
@@ -143,7 +143,7 @@ def setup_module(mod):
logger.info('result: '+output);
router = tgen.gears['r1']
- for rname, router in router_list.iteritems():
+ for rname, router in router_list.items():
if rname == 'r1':
router.load_config(
TopoRouter.RD_ZEBRA,
diff --git a/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py b/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py
index fdbd317093..fdbd317093 100755..100644
--- a/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py
+++ b/tests/topotests/bgp_gr_functionality_topo1/test_bgp_gr_functionality_topo1.py
diff --git a/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py b/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py
index e1ec0ea81b..e1ec0ea81b 100755..100644
--- a/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py
+++ b/tests/topotests/bgp_gr_functionality_topo2/test_bgp_gr_functionality_topo2.py
diff --git a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py
index dc06b7131a..dc06b7131a 100755..100644
--- a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py
+++ b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_1.py
diff --git a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py
index bb88e47415..bb88e47415 100755..100644
--- a/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py
+++ b/tests/topotests/bgp_large_community/test_bgp_large_community_topo_2.py
diff --git a/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py b/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py
index c15b88d371..c15b88d371 100755..100644
--- a/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py
+++ b/tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py
diff --git a/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py b/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py
index bb13d54019..bb13d54019 100755..100644
--- a/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py
+++ b/tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py
diff --git a/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py b/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py
index 6344f7bb40..6344f7bb40 100755..100644
--- a/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py
+++ b/tests/topotests/bgp_multiview_topo1/test_bgp_multiview_topo1.py
diff --git a/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py b/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py
index fef6eb71dc..fef6eb71dc 100755..100644
--- a/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py
+++ b/tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py
diff --git a/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py b/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py
index 0fabd90341..0fabd90341 100755..100644
--- a/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py
+++ b/tests/topotests/bgp_route_aggregation/test_bgp_aggregation.py
diff --git a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py
index 1947548b3e..1947548b3e 100755..100644
--- a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py
+++ b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py
diff --git a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py
index 6c106060b8..6c106060b8 100755..100644
--- a/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py
+++ b/tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo2.py
diff --git a/tests/topotests/eigrp-topo1/test_eigrp_topo1.py b/tests/topotests/eigrp-topo1/test_eigrp_topo1.py
index 70666a3d61..3ce1472ac0 100644
--- a/tests/topotests/eigrp-topo1/test_eigrp_topo1.py
+++ b/tests/topotests/eigrp-topo1/test_eigrp_topo1.py
@@ -252,7 +252,7 @@ def ip_eigrp_topo(node):
if code not in ["P", "A", "U", "Q", "R", "r", "s"]:
continue
- if not result.has_key(code):
+ if code not in result:
result[code] = {}
# Split network from the rest
diff --git a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py
index e913105e43..e913105e43 100755..100644
--- a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py
+++ b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_chaos_topo1.py
diff --git a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py
index 9e385823fc..c1eb7d68bb 100755..100644
--- a/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py
+++ b/tests/topotests/evpn_type5_test_topo1/test_evpn_type5_topo1.py
@@ -26,9 +26,9 @@ Following tests are covered to test EVPN-Type5 functionality:
1. RD verification (manual/auto).
2. RT verification(manual)
3. In an active/standby EVPN implementation, if active DCG goes down,
- secondary takes over.
+ secondary takes over.
4. EVPN routes are advertised/withdrawn, based on VNFs
- advertising/withdrawing IP prefixes.
+ advertising/withdrawing IP prefixes.
5. Route-map operations for EVPN address family.
6. BGP attributes for EVPN address-family.
"""
diff --git a/tests/topotests/isis-topo1-vrf/test_isis_topo1_vrf.py b/tests/topotests/isis-topo1-vrf/test_isis_topo1_vrf.py
index 65515f22cc..7943b94189 100644
--- a/tests/topotests/isis-topo1-vrf/test_isis_topo1_vrf.py
+++ b/tests/topotests/isis-topo1-vrf/test_isis_topo1_vrf.py
@@ -210,7 +210,7 @@ def test_isis_linux_route_installation():
dist = platform.dist()
if (dist[1] == "16.04"):
- pytest.skip("Kernel not supported for vrf")
+ pytest.skip("Kernel not supported for vrf")
"Check whether all expected routes are present and installed in the OS"
tgen = get_topogen()
@@ -267,7 +267,7 @@ def test_isis_linux_route6_installation():
dist = platform.dist()
if (dist[1] == "16.04"):
- pytest.skip("Kernel not supported for vrf")
+ pytest.skip("Kernel not supported for vrf")
"Check whether all expected routes are present and installed in the OS"
tgen = get_topogen()
diff --git a/tests/topotests/ldp-topo1/test_ldp_topo1.py b/tests/topotests/ldp-topo1/test_ldp_topo1.py
index 31adeafbf6..31adeafbf6 100755..100644
--- a/tests/topotests/ldp-topo1/test_ldp_topo1.py
+++ b/tests/topotests/ldp-topo1/test_ldp_topo1.py
diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py
index a3d846edbb..72b99eeba8 100644
--- a/tests/topotests/lib/bgp.py
+++ b/tests/topotests/lib/bgp.py
@@ -28,6 +28,7 @@ from lib import topotest
from lib.topolog import logger
from lib.topogen import TopoRouter, get_topogen
+from lib.topotest import frr_unicode
# Import common_config to use commomnly used APIs
from lib.common_config import (
@@ -393,7 +394,7 @@ def __create_bgp_unicast_neighbor(
# Generating IPs for verification
network_list = generate_ips(network, no_of_network)
for ip in network_list:
- ip = str(ipaddress.ip_network(unicode(ip)))
+ ip = str(ipaddress.ip_network(frr_unicode(ip)))
cmd = "network {}".format(ip)
if del_action:
@@ -1037,7 +1038,7 @@ def verify_router_id(tgen, topo, input_dict):
logger.info("Checking router %s router-id", router)
show_bgp_json = run_frr_cmd(rnode, "show bgp summary json", isjson=True)
router_id_out = show_bgp_json["ipv4Unicast"]["routerId"]
- router_id_out = ipaddress.IPv4Address(unicode(router_id_out))
+ router_id_out = ipaddress.IPv4Address(frr_unicode(router_id_out))
# Once router-id is deleted, highest interface ip should become
# router-id
@@ -1045,7 +1046,7 @@ def verify_router_id(tgen, topo, input_dict):
router_id = find_interface_with_greater_ip(topo, router)
else:
router_id = input_dict[router]["bgp"]["router_id"]
- router_id = ipaddress.IPv4Address(unicode(router_id))
+ router_id = ipaddress.IPv4Address(frr_unicode(router_id))
if router_id == router_id_out:
logger.info("Found expected router-id %s for router %s", router_id, router)
@@ -2286,7 +2287,7 @@ def verify_best_path_as_per_bgp_attribute(
routes = generate_ips(_network, no_of_ip)
for route in routes:
- route = str(ipaddress.ip_network(unicode(route)))
+ route = str(ipaddress.ip_network(frr_unicode(route)))
if route in sh_ip_bgp_json["routes"]:
route_attributes = sh_ip_bgp_json["routes"][route]
@@ -2604,7 +2605,7 @@ def verify_bgp_rib(tgen, addr_type, dut, input_dict, next_hop=None, aspath=None)
ip_list = generate_ips(network, no_of_ip)
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
@@ -2742,7 +2743,7 @@ def verify_bgp_rib(tgen, addr_type, dut, input_dict, next_hop=None, aspath=None)
ip_list = generate_ips(network, no_of_network)
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py
index 6dd8d646f3..1fa6d35101 100644
--- a/tests/topotests/lib/common_config.py
+++ b/tests/topotests/lib/common_config.py
@@ -31,16 +31,14 @@ from re import search as re_search
from tempfile import mkdtemp
import os
+import io
import sys
-import ConfigParser
import traceback
import socket
import ipaddress
import platform
-
if sys.version_info[0] > 2:
- import io
import configparser
else:
import StringIO
@@ -48,7 +46,7 @@ else:
from lib.topolog import logger, logger_config
from lib.topogen import TopoRouter, get_topogen
-from lib.topotest import interface_set_status, version_cmp
+from lib.topotest import interface_set_status, version_cmp, frr_unicode
FRRCFG_FILE = "frr_json.conf"
FRRCFG_BKUP_FILE = "frr_json_initial.conf"
@@ -638,7 +636,7 @@ def get_frr_ipv6_linklocal(tgen, router, intf=None, vrf=None):
ll_per_if_count = 0
# Interface ip
- m1 = re_search("inet6 (fe80[:a-fA-F0-9]+[\/0-9]+)", line)
+ m1 = re_search("inet6 (fe80[:a-fA-F0-9]+[/0-9]+)", line)
if m1:
local = m1.group(1)
ll_per_if_count += 1
@@ -700,18 +698,20 @@ def start_topology(tgen, daemon=None):
router_list = tgen.routers()
ROUTER_LIST = sorted(
- router_list.keys(), key=lambda x: int(re_search("\d+", x).group(0))
+ router_list.keys(), key=lambda x: int(re_search("[0-9]+", x).group(0))
)
TMPDIR = os.path.join(LOGDIR, tgen.modname)
+ linux_ver = ''
router_list = tgen.routers()
for rname in ROUTER_LIST:
router = router_list[rname]
# It will help in debugging the failures, will give more details on which
# specific kernel version tests are failing
- linux_ver = router.run("uname -a")
- logger.info("Logging platform related details: \n %s \n", linux_ver)
+ if linux_ver == '':
+ linux_ver = router.run("uname -a")
+ logger.info("Logging platform related details: \n %s \n", linux_ver)
try:
os.chdir(TMPDIR)
@@ -827,7 +827,7 @@ def topo_daemons(tgen, topo):
router_list = tgen.routers()
ROUTER_LIST = sorted(
- router_list.keys(), key=lambda x: int(re_search("\d+", x).group(0))
+ router_list.keys(), key=lambda x: int(re_search("[0-9]+", x).group(0))
)
for rtr in ROUTER_LIST:
@@ -1152,10 +1152,10 @@ def generate_ips(network, no_of_ips):
addr_type = validate_ip_address(start_ip)
if addr_type == "ipv4":
- start_ip = ipaddress.IPv4Address(unicode(start_ip))
+ start_ip = ipaddress.IPv4Address(frr_unicode(start_ip))
step = 2 ** (32 - mask)
if addr_type == "ipv6":
- start_ip = ipaddress.IPv6Address(unicode(start_ip))
+ start_ip = ipaddress.IPv6Address(frr_unicode(start_ip))
step = 2 ** (128 - mask)
next_ip = start_ip
@@ -2667,7 +2667,7 @@ def verify_rib(
nh_found = False
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
@@ -2863,7 +2863,7 @@ def verify_rib(
nh_found = False
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
@@ -3012,7 +3012,7 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None):
nh_found = False
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
#st_rt = str(ipaddr.IPNetwork(unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
@@ -3119,7 +3119,7 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None):
for st_rt in ip_list:
#st_rt = str(ipaddr.IPNetwork(unicode(st_rt)))
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
@@ -3268,7 +3268,7 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None):
nh_found = False
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
@@ -3373,7 +3373,7 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None):
nh_found = False
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
diff --git a/tests/topotests/lib/ltemplate.py b/tests/topotests/lib/ltemplate.py
index 192c121008..3c93e1ac5c 100644
--- a/tests/topotests/lib/ltemplate.py
+++ b/tests/topotests/lib/ltemplate.py
@@ -157,8 +157,8 @@ def ltemplateTest(script, SkipIfFailed=True, CallOnFail=None, CheckFuncStr=None,
if SkipIfFailed and tgen.routers_have_failure():
pytest.skip(tgen.errors)
if numEntry > 0:
- if not KeepGoing:
- pytest.skip("Have %d errors" % numEntry)
+ if not KeepGoing:
+ pytest.skip("Have %d errors" % numEntry)
if CheckFuncStr != None:
check = eval(CheckFuncStr)
@@ -172,8 +172,8 @@ def ltemplateTest(script, SkipIfFailed=True, CallOnFail=None, CheckFuncStr=None,
if numFail > 0:
luShowFail()
fatal_error = "%d tests failed" % numFail
- if not KeepGoing:
- assert "scripts/cleanup_all.py failed" == "See summary output above", fatal_error
+ if not KeepGoing:
+ assert "scripts/cleanup_all.py failed" == "See summary output above", fatal_error
# Memory leak test template
def test_memory_leak():
diff --git a/tests/topotests/lib/lutil.py b/tests/topotests/lib/lutil.py
index 4ea97a3692..05ed9c007d 100755..100644
--- a/tests/topotests/lib/lutil.py
+++ b/tests/topotests/lib/lutil.py
@@ -204,17 +204,17 @@ Total %-4d %-4d %d\n\
self.log('WARNING: JSON load failed -- confirm command output is in JSON format.')
self.log('COMMAND OUTPUT:%s:' % report)
- # Experiment: can we achieve the same match behavior via DOTALL
- # without converting newlines to spaces?
- out_nl = out
- search_nl = re.search(regexp, out_nl, re.DOTALL);
- self.l_last_nl = search_nl
- # Set up for comparison
- if search_nl != None:
- group_nl = search_nl.group()
- group_nl_converted = " ".join(group_nl.splitlines())
+ # Experiment: can we achieve the same match behavior via DOTALL
+ # without converting newlines to spaces?
+ out_nl = out
+ search_nl = re.search(regexp, out_nl, re.DOTALL);
+ self.l_last_nl = search_nl
+ # Set up for comparison
+ if search_nl != None:
+ group_nl = search_nl.group()
+ group_nl_converted = " ".join(group_nl.splitlines())
else:
- group_nl_converted = None
+ group_nl_converted = None
out = " ".join(out.splitlines())
search = re.search(regexp, out)
@@ -234,9 +234,9 @@ Total %-4d %-4d %d\n\
success = False
level = 5
self.log('found:%s:' % ret, level)
- # Experiment: compare matched strings obtained each way
- if self.l_dotall_experiment and (group_nl_converted != ret):
- self.log('DOTALL experiment: strings differ dotall=[%s] orig=[%s]' % (group_nl_converted, ret), 9)
+ # Experiment: compare matched strings obtained each way
+ if self.l_dotall_experiment and (group_nl_converted != ret):
+ self.log('DOTALL experiment: strings differ dotall=[%s] orig=[%s]' % (group_nl_converted, ret), 9)
if op == 'pass' or op == 'fail':
self.result(target, success, result)
if js != None:
@@ -297,13 +297,13 @@ def luCommand(target, command, regexp='.', op='none', result='', time=10, return
def luLast(usenl=False):
if usenl:
- if LUtil.l_last_nl != None:
- LUtil.log('luLast:%s:' % LUtil.l_last_nl.group(), 7)
- return LUtil.l_last_nl
+ if LUtil.l_last_nl != None:
+ LUtil.log('luLast:%s:' % LUtil.l_last_nl.group(), 7)
+ return LUtil.l_last_nl
else:
- if LUtil.l_last != None:
- LUtil.log('luLast:%s:' % LUtil.l_last.group(), 7)
- return LUtil.l_last
+ if LUtil.l_last != None:
+ LUtil.log('luLast:%s:' % LUtil.l_last.group(), 7)
+ return LUtil.l_last
def luInclude(filename, CallOnFail=None):
tstFile = LUtil.base_script_dir + '/' + filename
diff --git a/tests/topotests/lib/ospf.py b/tests/topotests/lib/ospf.py
index a2351bf747..9d6b8fa691 100644
--- a/tests/topotests/lib/ospf.py
+++ b/tests/topotests/lib/ospf.py
@@ -23,7 +23,7 @@ import traceback
from time import sleep
from lib.topolog import logger
import ipaddr
-
+from lib.topotest import frr_unicode
# Import common_config to use commomnly used APIs
from lib.common_config import (create_common_configuration,
@@ -516,7 +516,7 @@ def verify_ospf_neighbor(tgen, topo, dut=None, input_dict=None, lan=False):
logger.debug("Entering lib API: verify_ospf_neighbor()")
result = False
if input_dict:
- for router, rnode in tgen.routers().iteritems():
+ for router, rnode in tgen.routers().items():
if 'ospf' not in topo['routers'][router]:
continue
@@ -584,7 +584,7 @@ def verify_ospf_neighbor(tgen, topo, dut=None, input_dict=None, lan=False):
return errormsg
continue
else:
- for router, rnode in tgen.routers().iteritems():
+ for router, rnode in tgen.routers().items():
if 'ospf' not in topo['routers'][router]:
continue
@@ -694,7 +694,7 @@ def verify_ospf_rib(tgen, dut, input_dict, next_hop=None,
additional_nexthops_in_required_nhs = []
found_hops = []
for routerInput in input_dict.keys():
- for router, rnode in router_list.iteritems():
+ for router, rnode in router_list.items():
if router != dut:
continue
@@ -739,7 +739,7 @@ def verify_ospf_rib(tgen, dut, input_dict, next_hop=None,
nh_found = False
for st_rt in ip_list:
- st_rt = str(ipaddr.IPNetwork(unicode(st_rt)))
+ st_rt = str(ipaddr.IPNetwork(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != 'ipv4':
@@ -927,7 +927,7 @@ def verify_ospf_interface(tgen, topo, dut=None,lan=False, input_dict=None):
logger.debug("Entering lib API: verify_ospf_interface()")
result = False
- for router, rnode in tgen.routers().iteritems():
+ for router, rnode in tgen.routers().items():
if 'ospf' not in topo['routers'][router]:
continue
diff --git a/tests/topotests/lib/topogen.py b/tests/topotests/lib/topogen.py
index 171a894b35..ffdcb683e7 100644
--- a/tests/topotests/lib/topogen.py
+++ b/tests/topotests/lib/topogen.py
@@ -40,6 +40,7 @@ Basic usage instructions:
import os
import sys
+import io
import logging
import json
@@ -97,7 +98,7 @@ tgen_defaults = {
"verbosity": "info",
"frrdir": "/usr/lib/frr",
"routertype": "frr",
- "memleak_path": None,
+ "memleak_path": "",
}
@@ -182,7 +183,7 @@ class Topogen(object):
params["frrdir"] = self.config.get(self.CONFIG_SECTION, "frrdir")
params["memleak_path"] = self.config.get(self.CONFIG_SECTION, "memleak_path")
- if not params.has_key("routertype"):
+ if "routertype" not in params:
params["routertype"] = self.config.get(self.CONFIG_SECTION, "routertype")
self.gears[name] = TopoRouter(self, cls, name, **params)
@@ -360,7 +361,7 @@ class Topogen(object):
memleak_file = os.environ.get("TOPOTESTS_CHECK_MEMLEAK") or self.config.get(
self.CONFIG_SECTION, "memleak_path"
)
- if memleak_file is None:
+ if memleak_file == "" or memleak_file == None:
return False
return True
@@ -586,7 +587,7 @@ class TopoRouter(TopoGear):
self.cls = cls
self.options = {}
self.routertype = params.get("routertype", "frr")
- if not params.has_key("privateDirs"):
+ if "privateDirs" not in params:
params["privateDirs"] = self.PRIVATE_DIRS
self.options["memleak_path"] = params.get("memleak_path", None)
@@ -822,7 +823,7 @@ class TopoRouter(TopoGear):
memleak_file = (
os.environ.get("TOPOTESTS_CHECK_MEMLEAK") or self.options["memleak_path"]
)
- if memleak_file is None:
+ if memleak_file == "" or memleak_file == None:
return
self.stop()
@@ -1011,7 +1012,7 @@ def diagnose_env_linux():
logger.info("Running environment diagnostics")
# Load configuration
- config = configparser.ConfigParser(tgen_defaults)
+ config = configparser.ConfigParser(defaults=tgen_defaults)
pytestini_path = os.path.join(CWD, "../pytest.ini")
config.read(pytestini_path)
@@ -1106,10 +1107,10 @@ def diagnose_env_linux():
# TODO remove me when we start supporting exabgp >= 4
try:
- output = subprocess.check_output(["exabgp", "-v"])
- line = output.split("\n")[0]
- version = line.split(" ")[2]
- if topotest.version_cmp(version, "4") >= 0:
+ p = os.popen("exabgp -v")
+ line = p.readlines()
+ version = line[0].split()
+ if topotest.version_cmp(version[2], "4") >= 0:
logger.warning(
"BGP topologies are still using exabgp version 3, expect failures"
)
diff --git a/tests/topotests/lib/topojson.py b/tests/topotests/lib/topojson.py
index b3af09aa99..6535918e36 100644
--- a/tests/topotests/lib/topojson.py
+++ b/tests/topotests/lib/topojson.py
@@ -216,7 +216,7 @@ def build_topo_from_json(tgen, topo):
# Physical Interfaces
if "links" in topo['switches'][curSwitch]:
for destRouterLink, data in sorted(
- topo['switches'][curSwitch]['links'].iteritems()):
+ topo['switches'][curSwitch]['links'].items()):
# Loopback interfaces
if "dst_node" in data:
diff --git a/tests/topotests/lib/topolog.py b/tests/topotests/lib/topolog.py
index 0dfa870930..9fde01cca0 100644
--- a/tests/topotests/lib/topolog.py
+++ b/tests/topotests/lib/topolog.py
@@ -93,7 +93,7 @@ class Logger(object):
"""
if log_level is None:
log_level = self.log_level
- if self.loggers.has_key(name):
+ if name in self.loggers:
return self.loggers[name]
nlogger = logging.Logger(name, level=log_level)
diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py
index 00bfac4103..a187971e41 100644
--- a/tests/topotests/lib/topotest.py
+++ b/tests/topotests/lib/topotest.py
@@ -992,11 +992,11 @@ class Router(Node):
# Backward compatibility:
# Load configuration defaults like topogen.
self.config_defaults = configparser.ConfigParser(
- {
+ defaults = {
"verbosity": "info",
"frrdir": "/usr/lib/frr",
"routertype": "frr",
- "memleak_path": None,
+ "memleak_path": "",
}
)
self.config_defaults.read(
@@ -1525,7 +1525,7 @@ class Router(Node):
for daemon in self.daemons:
if (self.daemons[daemon] == 1) and not (daemon in daemonsRunning):
sys.stderr.write("%s: Daemon %s not running\n" % (self.name, daemon))
- if daemon is "staticd":
+ if daemon == "staticd":
sys.stderr.write(
"You may have a copy of staticd installed but are attempting to test against\n"
)
@@ -1591,7 +1591,7 @@ class Router(Node):
logger.info("{}: running version: {}".format(self.name, self.version))
rversion = self.version
- if rversion is None:
+ if rversion == None:
return False
result = version_cmp(rversion, version)
@@ -1737,3 +1737,10 @@ class LegacySwitch(OVSSwitch):
def __init__(self, name, **params):
OVSSwitch.__init__(self, name, failMode="standalone", **params)
self.switchIP = None
+
+def frr_unicode(s):
+ '''Convert string to unicode, depending on python version'''
+ if sys.version_info[0] > 2:
+ return s
+ else:
+ return unicode(s)
diff --git a/tests/topotests/ospf-topo2/test_ospf_topo2.py b/tests/topotests/ospf-topo2/test_ospf_topo2.py
index 0b6f568462..79e8e6bf58 100644
--- a/tests/topotests/ospf-topo2/test_ospf_topo2.py
+++ b/tests/topotests/ospf-topo2/test_ospf_topo2.py
@@ -86,19 +86,19 @@ def setup_module(mod):
os.path.join(CWD, '{}/ospfd.conf'.format(rname))
)
- # What is this? OSPF Unnumbered depends on the rp_filter
- # being set appropriately( HA! )
- # Effectively we are putting different /32's on the interface
- # the multicast packet delivery is somewhat controlled by
- # the rp_filter. Setting it to '0' allows the OS to pass
- # up the mcast packet not destined for the local routers
- # network.
- topotest.set_sysctl(tgen.net['r1'],
- 'net.ipv4.conf.r1-eth1.rp_filter', 0)
+ # What is this? OSPF Unnumbered depends on the rp_filter
+ # being set appropriately( HA! )
+ # Effectively we are putting different /32's on the interface
+ # the multicast packet delivery is somewhat controlled by
+ # the rp_filter. Setting it to '0' allows the OS to pass
+ # up the mcast packet not destined for the local routers
+ # network.
+ topotest.set_sysctl(tgen.net['r1'],
+ 'net.ipv4.conf.r1-eth1.rp_filter', 0)
topotest.set_sysctl(tgen.net['r1'],
'net.ipv4.conf.all.rp_filter', 0)
- topotest.set_sysctl(tgen.net['r2'],
- 'net.ipv4.conf.r2-eth1.rp_filter', 0)
+ topotest.set_sysctl(tgen.net['r2'],
+ 'net.ipv4.conf.r2-eth1.rp_filter', 0)
topotest.set_sysctl(tgen.net['r2'],
'net.ipv4.conf.all.rp_filter', 0)
diff --git a/tests/topotests/pbr-topo1/test_pbr_topo1.py b/tests/topotests/pbr-topo1/test_pbr_topo1.py
index 9ae4cce360..91979a8f04 100644
--- a/tests/topotests/pbr-topo1/test_pbr_topo1.py
+++ b/tests/topotests/pbr-topo1/test_pbr_topo1.py
@@ -88,8 +88,8 @@ def setup_module(module):
krel = platform.release()
if topotest.version_cmp(krel, "4.10") < 0:
- tgen.errors = "Newer kernel than 4.9 needed for pbr tests"
- pytest.skip(tgen.errors)
+ tgen.errors = "Newer kernel than 4.9 needed for pbr tests"
+ pytest.skip(tgen.errors)
router_list = tgen.routers()
for rname, router in router_list.items():
@@ -150,8 +150,8 @@ def test_pbr_data():
test_func = partial(topotest.router_json_cmp, router, "show pbr interface json", expected)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assertmsg = '"show pbr interface" mismatches on {}'.format(router.name)
- if result is not None:
- gather_pbr_data_on_error(router)
+ if result is not None:
+ gather_pbr_data_on_error(router)
assert result is None, assertmsg
map_file = "{}/{}/pbr-map.json".format(CWD, router.name)
@@ -164,8 +164,8 @@ def test_pbr_data():
test_func = partial(topotest.router_json_cmp, router, "show pbr map json", expected)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assertmsg = '"show pbr map" mismatches on {}'.format(router.name)
- if result is not None:
- gather_pbr_data_on_error(router)
+ if result is not None:
+ gather_pbr_data_on_error(router)
assert result is None, assertmsg
nexthop_file = "{}/{}/pbr-nexthop-groups.json".format(CWD, router.name)
@@ -178,8 +178,8 @@ def test_pbr_data():
test_func = partial(topotest.router_json_cmp, router, "show pbr nexthop-groups json", expected)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assertmsg = '"show pbr nexthop-groups" mismatches on {}'.format(router.name)
- if result is not None:
- gather_pbr_data_on_error(router)
+ if result is not None:
+ gather_pbr_data_on_error(router)
assert result is None, assertmsg
def test_pbr_flap():
@@ -215,8 +215,8 @@ def test_pbr_flap():
test_func = partial(topotest.router_json_cmp, router, "show pbr interface json", expected)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assertmsg = '"show pbr interface" mismatches on {}'.format(router.name)
- if result is not None:
- gather_pbr_data_on_error(router)
+ if result is not None:
+ gather_pbr_data_on_error(router)
assert result is None, assertmsg
diff --git a/tests/topotests/rip-topo1/test_rip_topo1.py b/tests/topotests/rip-topo1/test_rip_topo1.py
index 7ff18ba524..de11b78824 100755..100644
--- a/tests/topotests/rip-topo1/test_rip_topo1.py
+++ b/tests/topotests/rip-topo1/test_rip_topo1.py
@@ -91,11 +91,11 @@ class NetworkTopo(Topo):
switch[4] = self.addSwitch("sw4", cls=topotest.LegacySwitch)
self.addLink(switch[4], router[3], intfName2="r3-eth0")
- switch[5] = self.addSwitch("sw5", cls=topotest.LegacySwitch)
- self.addLink(switch[5], router[1], intfName2="r1-eth2")
+ switch[5] = self.addSwitch("sw5", cls=topotest.LegacySwitch)
+ self.addLink(switch[5], router[1], intfName2="r1-eth2")
- switch[6] = self.addSwitch("sw6", cls=topotest.LegacySwitch)
- self.addLink(switch[6], router[1], intfName2="r1-eth3")
+ switch[6] = self.addSwitch("sw6", cls=topotest.LegacySwitch)
+ self.addLink(switch[6], router[1], intfName2="r1-eth3")
#####################################################
diff --git a/tests/topotests/ripng-topo1/test_ripng_topo1.py b/tests/topotests/ripng-topo1/test_ripng_topo1.py
index 2976cdefe4..2976cdefe4 100755..100644
--- a/tests/topotests/ripng-topo1/test_ripng_topo1.py
+++ b/tests/topotests/ripng-topo1/test_ripng_topo1.py