aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_mpls.py
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2019-05-09 15:53:10 -0400
committerNeale Ranns <nranns@cisco.com>2019-05-14 13:54:24 +0000
commit80b5e4f69e5d095e8a4fb37311c0399daec32876 (patch)
treebf4a150b2e30953a4eceeb28a25755da798bdfa1 /test/test_mpls.py
parentf6c7aec95f82feb0c64b3ddd8558f41c33923bac (diff)
tests: fix TestMPLSPIC tests in test_mpls.py.
* Corrected stray ARP/ND packets in captures interfering with test results. * Added tests to match counts of recv'd pkts against sent. * Changes the number of packets to 67 for exercising single, dual, and quad-loops. Change-Id: I9147b8578988607ea4444741d10854e4d8683191 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'test/test_mpls.py')
-rw-r--r--test/test_mpls.py110
1 files changed, 82 insertions, 28 deletions
diff --git a/test/test_mpls.py b/test/test_mpls.py
index 4a1c663c444..2e0b71f3328 100644
--- a/test/test_mpls.py
+++ b/test/test_mpls.py
@@ -18,6 +18,8 @@ from scapy.layers.inet import IP, UDP, ICMP
from scapy.layers.inet6 import IPv6, ICMPv6TimeExceeded
from scapy.contrib.mpls import MPLS
+NUM_PKTS = 67
+
def verify_filter(capture, sent):
if not len(capture) == len(sent):
@@ -1476,7 +1478,7 @@ class TestMPLSDisabled(VppTestCase):
class TestMPLSPIC(VppTestCase):
- """ MPLS PIC edge convergence """
+ """ MPLS Prefix-Independent Convergence (PIC) edge convergence """
@classmethod
def setUpClass(cls):
@@ -1504,6 +1506,7 @@ class TestMPLSPIC(VppTestCase):
self.pg0.config_ip4()
self.pg0.resolve_arp()
self.pg0.enable_mpls()
+
self.pg1.admin_up()
self.pg1.config_ip4()
self.pg1.resolve_arp()
@@ -1517,6 +1520,7 @@ class TestMPLSPIC(VppTestCase):
self.pg2.set_table_ip6(1)
self.pg2.config_ip6()
self.pg2.resolve_ndp()
+
self.pg3.admin_up()
self.pg3.set_table_ip4(1)
self.pg3.config_ip4()
@@ -1537,7 +1541,7 @@ class TestMPLSPIC(VppTestCase):
super(TestMPLSPIC, self).tearDown()
def test_mpls_ibgp_pic(self):
- """ MPLS iBGP PIC edge convergence
+ """ MPLS iBGP Prefix-Independent Convergence (PIC) edge convergence
1) setup many iBGP VPN routes via a pair of iBGP peers.
2) Check EMCP forwarding to these peers
@@ -1566,7 +1570,7 @@ class TestMPLSPIC(VppTestCase):
#
vpn_routes = []
pkts = []
- for ii in range(64):
+ for ii in range(NUM_PKTS):
dst = "192.168.1.%d" % ii
vpn_routes.append(VppIpRoute(self, dst, 32,
[VppRoutePath("10.0.0.45",
@@ -1594,13 +1598,16 @@ class TestMPLSPIC(VppTestCase):
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx0 = self.pg0._get_capture(1)
- rx1 = self.pg1._get_capture(1)
+ rx0 = self.pg0._get_capture(NUM_PKTS)
+ rx1 = self.pg1._get_capture(NUM_PKTS)
# not testing the LB hashing algorithm so we're not concerned
# with the split ratio, just as long as neither is 0
self.assertNotEqual(0, len(rx0))
self.assertNotEqual(0, len(rx1))
+ self.assertEqual(len(pkts), len(rx0) + len(rx1),
+ "Expected all (%s) packets across both ECMP paths. "
+ "rx0: %s rx1: %s." % (len(pkts), len(rx0), len(rx1)))
#
# use a test CLI command to stop the FIB walk process, this
@@ -1622,7 +1629,10 @@ class TestMPLSPIC(VppTestCase):
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx0 = self.pg0.get_capture(len(pkts))
+ rx0 = self.pg0.get_capture(NUM_PKTS)
+ self.assertEqual(len(pkts), len(rx0),
+ "Expected all (%s) packets across single path. "
+ "rx0: %s." % (len(pkts), len(rx0)))
#
# enable the FIB walk process to converge the FIB
@@ -1636,7 +1646,10 @@ class TestMPLSPIC(VppTestCase):
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx0 = self.pg0.get_capture(64)
+ rx0 = self.pg0.get_capture(NUM_PKTS)
+ self.assertEqual(len(pkts), len(rx0),
+ "Expected all (%s) packets across single path. "
+ "rx0: %s." % (len(pkts), len(rx0)))
#
# Add the IGP route back and we return to load-balancing
@@ -1647,15 +1660,18 @@ class TestMPLSPIC(VppTestCase):
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx0 = self.pg0._get_capture(1)
- rx1 = self.pg1._get_capture(1)
+ rx0 = self.pg0._get_capture(NUM_PKTS)
+ rx1 = self.pg1._get_capture(NUM_PKTS)
self.assertNotEqual(0, len(rx0))
self.assertNotEqual(0, len(rx1))
+ self.assertEqual(len(pkts), len(rx0) + len(rx1),
+ "Expected all (%s) packets across both ECMP paths. "
+ "rx0: %s rx1: %s." % (len(pkts), len(rx0), len(rx1)))
def test_mpls_ebgp_pic(self):
- """ MPLS eBGP PIC edge convergence
+ """ MPLS eBGP Prefix-Independent Convergence (PIC) edge convergence
- 1) setup many eBGP VPN routes via a pair of eBGP peers
+ 1) setup many eBGP VPN routes via a pair of eBGP peers.
2) Check EMCP forwarding to these peers
3) withdraw one eBGP path - expect LB across remaining eBGP
"""
@@ -1667,7 +1683,7 @@ class TestMPLSPIC(VppTestCase):
vpn_routes = []
vpn_bindings = []
pkts = []
- for ii in range(64):
+ for ii in range(NUM_PKTS):
dst = "192.168.1.%d" % ii
local_label = 1600 + ii
vpn_routes.append(VppIpRoute(self, dst, 32,
@@ -1693,14 +1709,24 @@ class TestMPLSPIC(VppTestCase):
UDP(sport=1234, dport=1234) /
Raw('\xa5' * 100))
+ #
+ # Send the packet stream (one pkt to each VPN route)
+ # - expect a 50-50 split of the traffic
+ #
self.pg0.add_stream(pkts)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx0 = self.pg2._get_capture(1)
- rx1 = self.pg3._get_capture(1)
+ rx0 = self.pg2._get_capture(NUM_PKTS)
+ rx1 = self.pg3._get_capture(NUM_PKTS)
+
+ # not testing the LB hashing algorithm so we're not concerned
+ # with the split ratio, just as long as neither is 0
self.assertNotEqual(0, len(rx0))
self.assertNotEqual(0, len(rx1))
+ self.assertEqual(len(pkts), len(rx0) + len(rx1),
+ "Expected all (%s) packets across both ECMP paths. "
+ "rx0: %s rx1: %s." % (len(pkts), len(rx0), len(rx1)))
#
# use a test CLI command to stop the FIB walk process, this
@@ -1721,34 +1747,48 @@ class TestMPLSPIC(VppTestCase):
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx0 = self.pg3.get_capture(len(pkts))
+ rx0 = self.pg3.get_capture(NUM_PKTS)
+ self.assertEqual(len(pkts), len(rx0),
+ "Expected all (%s) packets across single path. "
+ "rx0: %s." % (len(pkts), len(rx0)))
#
# enable the FIB walk process to converge the FIB
#
self.vapi.ppcli("test fib-walk-process enable")
+
+ #
+ # packets should still be forwarded through the remaining peer
+ #
self.pg0.add_stream(pkts)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx0 = self.pg3.get_capture(len(pkts))
+ rx0 = self.pg3.get_capture(NUM_PKTS)
+ self.assertEqual(len(pkts), len(rx0),
+ "Expected all (%s) packets across single path. "
+ "rx0: %s." % (len(pkts), len(rx0)))
#
- # put the connecteds back
+ # put the connected routes back
#
self.pg2.config_ip4()
+ self.pg2.resolve_arp()
self.pg0.add_stream(pkts)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx0 = self.pg2._get_capture(1)
- rx1 = self.pg3._get_capture(1)
+ rx0 = self.pg2._get_capture(NUM_PKTS)
+ rx1 = self.pg3._get_capture(NUM_PKTS)
self.assertNotEqual(0, len(rx0))
self.assertNotEqual(0, len(rx1))
+ self.assertEqual(len(pkts), len(rx0) + len(rx1),
+ "Expected all (%s) packets across both ECMP paths. "
+ "rx0: %s rx1: %s." % (len(pkts), len(rx0), len(rx1)))
def test_mpls_v6_ebgp_pic(self):
- """ MPLSv6 eBGP PIC edge convergence
+ """ MPLSv6 eBGP Prefix-Independent Convergence (PIC) edge convergence
1) setup many eBGP VPNv6 routes via a pair of eBGP peers
2) Check EMCP forwarding to these peers
@@ -1762,7 +1802,7 @@ class TestMPLSPIC(VppTestCase):
vpn_routes = []
vpn_bindings = []
pkts = []
- for ii in range(64):
+ for ii in range(NUM_PKTS):
dst = "3000::%d" % ii
local_label = 1600 + ii
vpn_routes.append(VppIpRoute(
@@ -1797,10 +1837,13 @@ class TestMPLSPIC(VppTestCase):
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx0 = self.pg2._get_capture(1)
- rx1 = self.pg3._get_capture(1)
+ rx0 = self.pg2._get_capture(NUM_PKTS)
+ rx1 = self.pg3._get_capture(NUM_PKTS)
self.assertNotEqual(0, len(rx0))
self.assertNotEqual(0, len(rx1))
+ self.assertEqual(len(pkts), len(rx0) + len(rx1),
+ "Expected all (%s) packets across both ECMP paths. "
+ "rx0: %s rx1: %s." % (len(pkts), len(rx0), len(rx1)))
#
# use a test CLI command to stop the FIB walk process, this
@@ -1823,7 +1866,10 @@ class TestMPLSPIC(VppTestCase):
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx0 = self.pg3.get_capture(len(pkts))
+ rx0 = self.pg3.get_capture(NUM_PKTS)
+ self.assertEqual(len(pkts), len(rx0),
+ "Expected all (%s) packets across single path. "
+ "rx0: %s." % (len(pkts), len(rx0)))
#
# enable the FIB walk process to converge the FIB
@@ -1833,22 +1879,29 @@ class TestMPLSPIC(VppTestCase):
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx0 = self.pg3.get_capture(len(pkts))
+ rx0 = self.pg3.get_capture(NUM_PKTS)
+ self.assertEqual(len(pkts), len(rx0),
+ "Expected all (%s) packets across single path. "
+ "rx0: %s." % (len(pkts), len(rx0)))
#
- # put the connecteds back
+ # put the connected routes back
#
self.pg2.admin_up()
self.pg2.config_ip6()
+ self.pg2.resolve_ndp()
self.pg0.add_stream(pkts)
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx0 = self.pg2._get_capture(1)
- rx1 = self.pg3._get_capture(1)
+ rx0 = self.pg2._get_capture(NUM_PKTS)
+ rx1 = self.pg3._get_capture(NUM_PKTS)
self.assertNotEqual(0, len(rx0))
self.assertNotEqual(0, len(rx1))
+ self.assertEqual(len(pkts), len(rx0) + len(rx1),
+ "Expected all (%s) packets across both ECMP paths. "
+ "rx0: %s rx1: %s." % (len(pkts), len(rx0), len(rx1)))
class TestMPLSL2(VppTestCase):
@@ -2064,5 +2117,6 @@ class TestMPLSL2(VppTestCase):
self.vapi.sw_interface_set_l2_bridge(
rx_sw_if_index=self.pg1.sw_if_index, bd_id=1, enable=0)
+
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)