Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
ESP_AH_test_automation_scripts rev1
[vpp.git]
/
test
/
test_lb.py
diff --git
a/test/test_lb.py
b/test/test_lb.py
index
fa4900d
..
ab9a209
100644
(file)
--- a/
test/test_lb.py
+++ b/
test/test_lb.py
@@
-1,5
+1,4
@@
import socket
import socket
-from logging import *
from scapy.layers.inet import IP, UDP
from scapy.layers.inet6 import IPv6
from scapy.layers.inet import IP, UDP
from scapy.layers.inet6 import IPv6
@@
-7,6
+6,7
@@
from scapy.layers.l2 import Ether, GRE
from scapy.packet import Raw
from framework import VppTestCase
from scapy.packet import Raw
from framework import VppTestCase
+from util import ppp
""" TestLB is a subclass of VPPTestCase classes.
""" TestLB is a subclass of VPPTestCase classes.
@@
-57,7
+57,7
@@
class TestLB(VppTestCase):
def tearDown(self):
super(TestLB, self).tearDown()
if not self.vpp_dead:
def tearDown(self):
super(TestLB, self).tearDown()
if not self.vpp_dead:
- info(self.vapi.cli("show lb vip verbose"))
+
self.logger.
info(self.vapi.cli("show lb vip verbose"))
def getIPv4Flow(self, id):
return (IP(dst="90.0.%u.%u" % (id / 255, id % 255),
def getIPv4Flow(self, id):
return (IP(dst="90.0.%u.%u" % (id / 255, id % 255),
@@
-69,10
+69,10
@@
class TestLB(VppTestCase):
UDP(sport=10000 + id, dport=20000 + id))
def generatePackets(self, src_if, isv4):
UDP(sport=10000 + id, dport=20000 + id))
def generatePackets(self, src_if, isv4):
- self.
packet_infos = {}
+ self.
reset_packet_infos()
pkts = []
for pktid in self.packets:
pkts = []
for pktid in self.packets:
- info = self.create_packet_info(src_if
.sw_if_index, pktid
)
+ info = self.create_packet_info(src_if
, self.pg1
)
payload = self.info_to_payload(info)
ip = self.getIPv4Flow(pktid) if isv4 else self.getIPv6Flow(pktid)
packet = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
payload = self.info_to_payload(info)
ip = self.getIPv4Flow(pktid) if isv4 else self.getIPv6Flow(pktid)
packet = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
@@
-90,17
+90,13
@@
class TestLB(VppTestCase):
self.assertEqual(gre.version, 0)
inner = IPver(str(gre.payload))
payload_info = self.payload_to_info(str(inner[Raw]))
self.assertEqual(gre.version, 0)
inner = IPver(str(gre.payload))
payload_info = self.payload_to_info(str(inner[Raw]))
- self.info = self.
get_next_packet_info_for_interface2(
-
self.pg0.sw_if_index, payload_info.dst, self.info
)
+ self.info = self.
packet_infos[payload_info.index]
+
self.assertEqual(payload_info.src, self.pg0.sw_if_index
)
self.assertEqual(str(inner), str(self.info.data[IPver]))
def checkCapture(self, gre4, isv4):
self.assertEqual(str(inner), str(self.info.data[IPver]))
def checkCapture(self, gre4, isv4):
- out = self.pg0.get_capture()
- # This check is edited because RA appears in output, maybe disable RA?
- # self.assertEqual(len(out), 0)
- self.assertLess(len(out), 20)
- out = self.pg1.get_capture()
- self.assertEqual(len(out), len(self.packets))
+ self.pg0.assert_nothing_captured()
+ out = self.pg1.get_capture(len(self.packets))
load = [0] * len(self.ass)
self.info = None
load = [0] * len(self.ass)
self.info = None
@@
-139,8
+135,7
@@
class TestLB(VppTestCase):
self.checkInner(gre, isv4)
load[asid] += 1
except:
self.checkInner(gre, isv4)
load[asid] += 1
except:
- error("Unexpected or invalid packet:")
- p.show()
+ self.logger.error(ppp("Unexpected or invalid packet:", p))
raise
# This is just to roughly check that the balancing algorithm
raise
# This is just to roughly check that the balancing algorithm
@@
-167,6
+162,7
@@
class TestLB(VppTestCase):
for asid in self.ass:
self.vapi.cli("lb as 90.0.0.0/8 10.0.0.%u del" % (asid))
self.vapi.cli("lb vip 90.0.0.0/8 encap gre4 del")
for asid in self.ass:
self.vapi.cli("lb as 90.0.0.0/8 10.0.0.%u del" % (asid))
self.vapi.cli("lb vip 90.0.0.0/8 encap gre4 del")
+ self.vapi.cli("test lb flowtable flush")
def test_lb_ip6_gre4(self):
""" Load Balancer IP6 GRE4 """
def test_lb_ip6_gre4(self):
""" Load Balancer IP6 GRE4 """
@@
-185,6
+181,7
@@
class TestLB(VppTestCase):
for asid in self.ass:
self.vapi.cli("lb as 2001::/16 10.0.0.%u del" % (asid))
self.vapi.cli("lb vip 2001::/16 encap gre4 del")
for asid in self.ass:
self.vapi.cli("lb as 2001::/16 10.0.0.%u del" % (asid))
self.vapi.cli("lb vip 2001::/16 encap gre4 del")
+ self.vapi.cli("test lb flowtable flush")
def test_lb_ip4_gre6(self):
""" Load Balancer IP4 GRE6 """
def test_lb_ip4_gre6(self):
""" Load Balancer IP4 GRE6 """
@@
-200,8
+197,9
@@
class TestLB(VppTestCase):
self.checkCapture(gre4=False, isv4=True)
finally:
for asid in self.ass:
self.checkCapture(gre4=False, isv4=True)
finally:
for asid in self.ass:
- self.vapi.cli("lb as 90.0.0.0/8 2002::%u" % (asid))
+ self.vapi.cli("lb as 90.0.0.0/8 2002::%u
del
" % (asid))
self.vapi.cli("lb vip 90.0.0.0/8 encap gre6 del")
self.vapi.cli("lb vip 90.0.0.0/8 encap gre6 del")
+ self.vapi.cli("test lb flowtable flush")
def test_lb_ip6_gre6(self):
""" Load Balancer IP6 GRE6 """
def test_lb_ip6_gre6(self):
""" Load Balancer IP6 GRE6 """
@@
-219,3
+217,4
@@
class TestLB(VppTestCase):
for asid in self.ass:
self.vapi.cli("lb as 2001::/16 2002::%u del" % (asid))
self.vapi.cli("lb vip 2001::/16 encap gre6 del")
for asid in self.ass:
self.vapi.cli("lb as 2001::/16 2002::%u del" % (asid))
self.vapi.cli("lb vip 2001::/16 encap gre6 del")
+ self.vapi.cli("test lb flowtable flush")