Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
API refactoring : vhost_user
[vpp.git]
/
test
/
test_gre.py
diff --git
a/test/test_gre.py
b/test/test_gre.py
index
f54b6e0
..
f00e446
100644
(file)
--- a/
test/test_gre.py
+++ b/
test/test_gre.py
@@
-1,22
+1,22
@@
#!/usr/bin/env python
import unittest
#!/usr/bin/env python
import unittest
-import socket
from logging import *
from framework import VppTestCase, VppTestRunner
from logging import *
from framework import VppTestCase, VppTestRunner
-from vpp_sub_interface import Vpp
SubInterface, VppDot1QSubint, VppDot1AD
Subint
+from vpp_sub_interface import Vpp
Dot1Q
Subint
from vpp_gre_interface import VppGreInterface
from vpp_gre_interface import VppGreInterface
-from vpp_ip_route import IpRoute,
Ip
Path
+from vpp_ip_route import IpRoute,
Route
Path
from vpp_papi_provider import L2_VTR_OP
from scapy.packet import Raw
from vpp_papi_provider import L2_VTR_OP
from scapy.packet import Raw
-from scapy.layers.l2 import Ether, Dot1Q,
ARP,
GRE
+from scapy.layers.l2 import Ether, Dot1Q, GRE
from scapy.layers.inet import IP, UDP
from scapy.layers.inet import IP, UDP
-from scapy.layers.inet6 import ICMPv6ND_NS, ICMPv6ND_RA, IPv6, UDP
-from scapy.contrib.mpls import MPLS
+from scapy.layers.inet6 import IPv6
from scapy.volatile import RandMAC, RandIP
from scapy.volatile import RandMAC, RandIP
+from util import ppp, ppc
+
class TestGRE(VppTestCase):
""" GRE Test Case """
class TestGRE(VppTestCase):
""" GRE Test Case """
@@
-129,18
+129,9
@@
class TestGRE(VppTestCase):
pkts.append(p)
return pkts
pkts.append(p)
return pkts
- def verify_filter(self, capture, sent):
- if not len(capture) == len(sent):
- # filter out any IPv6 RAs from the captur
- for p in capture:
- if (p.haslayer(ICMPv6ND_RA)):
- capture.remove(p)
- return capture
-
def verify_tunneled_4o4(self, src_if, capture, sent,
tunnel_src, tunnel_dst):
def verify_tunneled_4o4(self, src_if, capture, sent,
tunnel_src, tunnel_dst):
- capture = self.verify_filter(capture, sent)
self.assertEqual(len(capture), len(sent))
for i in range(len(capture)):
self.assertEqual(len(capture), len(sent))
for i in range(len(capture)):
@@
-163,13
+154,12
@@
class TestGRE(VppTestCase):
self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl)
except:
self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl)
except:
-
rx.show(
)
-
tx.show(
)
+
self.logger.error(ppp("Rx:", rx)
)
+
self.logger.error(ppp("Tx:", tx)
)
raise
def verify_tunneled_l2o4(self, src_if, capture, sent,
tunnel_src, tunnel_dst):
raise
def verify_tunneled_l2o4(self, src_if, capture, sent,
tunnel_src, tunnel_dst):
- capture = self.verify_filter(capture, sent)
self.assertEqual(len(capture), len(sent))
for i in range(len(capture)):
self.assertEqual(len(capture), len(sent))
for i in range(len(capture)):
@@
-196,17
+186,16
@@
class TestGRE(VppTestCase):
self.assertEqual(rx_ip.ttl, tx_ip.ttl)
except:
self.assertEqual(rx_ip.ttl, tx_ip.ttl)
except:
-
rx.show(
)
-
tx.show(
)
+
self.logger.error(ppp("Rx:", rx)
)
+
self.logger.error(ppp("Tx:", tx)
)
raise
def verify_tunneled_vlano4(self, src_if, capture, sent,
tunnel_src, tunnel_dst, vlan):
try:
raise
def verify_tunneled_vlano4(self, src_if, capture, sent,
tunnel_src, tunnel_dst, vlan):
try:
- capture = self.verify_filter(capture, sent)
self.assertEqual(len(capture), len(sent))
except:
self.assertEqual(len(capture), len(sent))
except:
-
capture.show(
)
+
ppc("Unexpected packets captured:", capture
)
raise
for i in range(len(capture)):
raise
for i in range(len(capture)):
@@
-237,12
+226,11
@@
class TestGRE(VppTestCase):
self.assertEqual(rx_ip.ttl, tx_ip.ttl)
except:
self.assertEqual(rx_ip.ttl, tx_ip.ttl)
except:
-
rx.show(
)
-
tx.show(
)
+
self.logger.error(ppp("Rx:", rx)
)
+
self.logger.error(ppp("Tx:", tx)
)
raise
def verify_decapped_4o4(self, src_if, capture, sent):
raise
def verify_decapped_4o4(self, src_if, capture, sent):
- capture = self.verify_filter(capture, sent)
self.assertEqual(len(capture), len(sent))
for i in range(len(capture)):
self.assertEqual(len(capture), len(sent))
for i in range(len(capture)):
@@
-261,12
+249,11
@@
class TestGRE(VppTestCase):
self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl)
except:
self.assertEqual(rx_ip.ttl + 1, tx_ip.ttl)
except:
-
rx.show(
)
-
tx.show(
)
+
self.logger.error(ppp("Rx:", rx)
)
+
self.logger.error(ppp("Tx:", tx)
)
raise
def verify_decapped_6o4(self, src_if, capture, sent):
raise
def verify_decapped_6o4(self, src_if, capture, sent):
- capture = self.verify_filter(capture, sent)
self.assertEqual(len(capture), len(sent))
for i in range(len(capture)):
self.assertEqual(len(capture), len(sent))
for i in range(len(capture)):
@@
-284,8
+271,8
@@
class TestGRE(VppTestCase):
self.assertEqual(rx_ip.hlim + 1, tx_ip.hlim)
except:
self.assertEqual(rx_ip.hlim + 1, tx_ip.hlim)
except:
-
rx.show(
)
-
tx.show(
)
+
self.logger.error(ppp("Rx:", rx)
)
+
self.logger.error(ppp("Tx:", tx)
)
raise
def test_gre(self):
raise
def test_gre(self):
@@
-317,7
+304,7
@@
class TestGRE(VppTestCase):
gre_if.config_ip4()
route_via_tun = IpRoute(self, "4.4.4.4", 32,
gre_if.config_ip4()
route_via_tun = IpRoute(self, "4.4.4.4", 32,
- [
Ip
Path("0.0.0.0", gre_if.sw_if_index)])
+ [
Route
Path("0.0.0.0", gre_if.sw_if_index)])
route_via_tun.add_vpp_config()
route_via_tun.add_vpp_config()
@@
-333,20
+320,15
@@
class TestGRE(VppTestCase):
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx = self.pg0.get_capture()
-
- try:
- self.assertEqual(0, len(rx))
- except:
- error("GRE packets forwarded without DIP resolved")
- error(rx.show())
- raise
+ self.pg0.assert_nothing_captured(
+ remark="GRE packets forwarded without DIP resolved")
#
# Add a route that resolves the tunnel's destination
#
route_tun_dst = IpRoute(self, "1.1.1.2", 32,
#
# Add a route that resolves the tunnel's destination
#
route_tun_dst = IpRoute(self, "1.1.1.2", 32,
- [IpPath(self.pg0.remote_ip4, self.pg0.sw_if_index)])
+ [RoutePath(self.pg0.remote_ip4,
+ self.pg0.sw_if_index)])
route_tun_dst.add_vpp_config()
#
route_tun_dst.add_vpp_config()
#
@@
-396,13
+378,8
@@
class TestGRE(VppTestCase):
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx = self.pg0.get_capture()
- try:
- self.assertEqual(0, len(rx))
- except:
- error("GRE packets forwarded despite no SRC address match")
- error(rx.show())
- raise
+ self.pg0.assert_nothing_captured(
+ remark="GRE packets forwarded despite no SRC address match")
#
# Configure IPv6 on the PG interface so we can route IPv6
#
# Configure IPv6 on the PG interface so we can route IPv6
@@
-426,13
+403,8
@@
class TestGRE(VppTestCase):
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
self.pg_enable_capture(self.pg_interfaces)
self.pg_start()
- rx = self.pg0.get_capture()
- try:
- self.assertEqual(0, len(rx))
- except:
- error("IPv6 GRE packets forwarded despite IPv6 not enabled on tunnel")
- error(rx.show())
- raise
+ self.pg0.assert_nothing_captured(remark="IPv6 GRE packets forwarded "
+ "despite IPv6 not enabled on tunnel")
#
# Enable IPv6 on the tunnel
#
# Enable IPv6 on the tunnel
@@
-487,7
+459,7
@@
class TestGRE(VppTestCase):
# Add a route via the tunnel - in the overlay
#
route_via_tun = IpRoute(self, "9.9.9.9", 32,
# Add a route via the tunnel - in the overlay
#
route_via_tun = IpRoute(self, "9.9.9.9", 32,
- [
Ip
Path("0.0.0.0", gre_if.sw_if_index)])
+ [
Route
Path("0.0.0.0", gre_if.sw_if_index)])
route_via_tun.add_vpp_config()
#
route_via_tun.add_vpp_config()
#
@@
-495,8
+467,8
@@
class TestGRE(VppTestCase):
# underlay table
#
route_tun_dst = IpRoute(self, "2.2.2.2", 32, table_id=1,
# underlay table
#
route_tun_dst = IpRoute(self, "2.2.2.2", 32, table_id=1,
- paths=[
Ip
Path(self.pg1.remote_ip4,
- self.pg1.sw_if_index)])
+ paths=[
Route
Path(self.pg1.remote_ip4,
+
self.pg1.sw_if_index)])
route_tun_dst.add_vpp_config()
#
route_tun_dst.add_vpp_config()
#
@@
-548,11
+520,11
@@
class TestGRE(VppTestCase):
# Add routes to resolve the tunnel destinations
#
route_tun1_dst = IpRoute(self, "2.2.2.2", 32,
# Add routes to resolve the tunnel destinations
#
route_tun1_dst = IpRoute(self, "2.2.2.2", 32,
- [
Ip
Path(self.pg0.remote_ip4,
- self.pg0.sw_if_index)])
+ [
Route
Path(self.pg0.remote_ip4,
+
self.pg0.sw_if_index)])
route_tun2_dst = IpRoute(self, "2.2.2.3", 32,
route_tun2_dst = IpRoute(self, "2.2.2.3", 32,
- [
Ip
Path(self.pg0.remote_ip4,
- self.pg0.sw_if_index)])
+ [
Route
Path(self.pg0.remote_ip4,
+
self.pg0.sw_if_index)])
route_tun1_dst.add_vpp_config()
route_tun2_dst.add_vpp_config()
route_tun1_dst.add_vpp_config()
route_tun2_dst.add_vpp_config()