summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_lb.py273
1 files changed, 218 insertions, 55 deletions
diff --git a/test/test_lb.py b/test/test_lb.py
index d2e7185cf3f..45dab79fd42 100644
--- a/test/test_lb.py
+++ b/test/test_lb.py
@@ -12,13 +12,14 @@ from util import ppp
""" TestLB is a subclass of VPPTestCase classes.
TestLB class defines Load Balancer test cases for:
- - IP4 to GRE4 encap
- - IP4 to GRE6 encap
- - IP6 to GRE4 encap
- - IP6 to GRE6 encap
- - IP4 to L3DSR encap
- - IP4 to NAT4 encap
- - IP6 to NAT6 encap
+ - IP4 to GRE4 encap on per-port vip case
+ - IP4 to GRE6 encap on per-port vip case
+ - IP6 to GRE4 encap on per-port vip case
+ - IP6 to GRE6 encap on per-port vip case
+ - IP4 to L3DSR encap on vip case
+ - IP4 to L3DSR encap on per-port vip case
+ - IP4 to NAT4 encap on per-port vip case
+ - IP6 to NAT6 encap on per-port vip case
As stated in comments below, GRE has issues with IPv6.
All test cases involving IPv6 are executed, but
@@ -35,7 +36,7 @@ class TestLB(VppTestCase):
super(TestLB, cls).setUpClass()
cls.ass = range(5)
- cls.packets = range(100)
+ cls.packets = range(1)
try:
cls.create_pg_interfaces(range(2))
@@ -66,11 +67,11 @@ class TestLB(VppTestCase):
def getIPv4Flow(self, id):
return (IP(dst="90.0.%u.%u" % (id / 255, id % 255),
src="40.0.%u.%u" % (id / 255, id % 255)) /
- UDP(sport=10000 + id, dport=20000 + id))
+ UDP(sport=10000 + id, dport=20000))
def getIPv6Flow(self, id):
return (IPv6(dst="2001::%u" % (id), src="fd00:f00d:ffff::%u" % (id)) /
- UDP(sport=10000 + id, dport=20000 + id))
+ UDP(sport=10000 + id, dport=20000))
def generatePackets(self, src_if, isv4):
self.reset_packet_infos()
@@ -117,7 +118,6 @@ class TestLB(VppTestCase):
self.assertEqual(ip.dst, "10.0.0.%u" % asid)
self.assertEqual(ip.proto, 47)
self.assertEqual(len(ip.options), 0)
- self.assertGreaterEqual(ip.ttl, 64)
gre = p[GRE]
self.checkInner(gre, isv4)
elif (encap == 'gre6'):
@@ -134,7 +134,6 @@ class TestLB(VppTestCase):
socket.inet_pton(socket.AF_INET6, "2002::%u" % asid)
)
self.assertEqual(ip.nh, 47)
- self.assertGreaterEqual(ip.hlim, 64)
# self.assertEqual(len(ip.options), 0)
gre = GRE(str(p[IPv6].payload))
self.checkInner(gre, isv4)
@@ -159,7 +158,6 @@ class TestLB(VppTestCase):
self.assertEqual(ip.dst, "10.0.0.%u" % asid)
self.assertEqual(ip.proto, 17)
self.assertEqual(len(ip.options), 0)
- self.assertGreaterEqual(ip.ttl, 63)
udp = p[UDP]
self.assertEqual(udp.dport, 3307)
elif (encap == 'nat6'):
@@ -183,7 +181,7 @@ class TestLB(VppTestCase):
self.logger.error(ppp("Unexpected or invalid packet:", p))
raise
- # This is just to roughly check that the balancing algorithm
+ # This is just to 1roughly check that the balancing algorithm
# is not completly biased.
for asid in self.ass:
if load[asid] < len(self.packets) / (len(self.ass) * 2):
@@ -192,11 +190,14 @@ class TestLB(VppTestCase):
raise Exception("Load Balancer algorithm is biased")
def test_lb_ip4_gre4(self):
- """ Load Balancer IP4 GRE4 """
+ """ Load Balancer IP4 GRE4 on vip case """
try:
- self.vapi.cli("lb vip 90.0.0.0/8 encap gre4")
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 encap gre4")
for asid in self.ass:
- self.vapi.cli("lb as 90.0.0.0/8 10.0.0.%u" % (asid))
+ self.vapi.cli(
+ "lb as 90.0.0.0/8 10.0.0.%u"
+ % (asid))
self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True))
self.pg_enable_capture(self.pg_interfaces)
@@ -205,17 +206,23 @@ class TestLB(VppTestCase):
finally:
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(
+ "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 """
+ """ Load Balancer IP6 GRE4 on vip case """
try:
- self.vapi.cli("lb vip 2001::/16 encap gre4")
+ self.vapi.cli(
+ "lb vip 2001::/16 encap gre4")
for asid in self.ass:
- self.vapi.cli("lb as 2001::/16 10.0.0.%u" % (asid))
+ self.vapi.cli(
+ "lb as 2001::/16 10.0.0.%u"
+ % (asid))
self.pg0.add_stream(self.generatePackets(self.pg0, isv4=False))
self.pg_enable_capture(self.pg_interfaces)
@@ -224,16 +231,22 @@ class TestLB(VppTestCase):
self.checkCapture(encap='gre4', isv4=False)
finally:
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(
+ "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 """
+ """ Load Balancer IP4 GRE6 on vip case """
try:
- self.vapi.cli("lb vip 90.0.0.0/8 encap gre6")
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 encap gre6")
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"
+ % (asid))
self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True))
self.pg_enable_capture(self.pg_interfaces)
@@ -242,16 +255,22 @@ class TestLB(VppTestCase):
self.checkCapture(encap='gre6', isv4=True)
finally:
for asid in self.ass:
- 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 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("test lb flowtable flush")
def test_lb_ip6_gre6(self):
- """ Load Balancer IP6 GRE6 """
+ """ Load Balancer IP6 GRE6 on vip case """
try:
- self.vapi.cli("lb vip 2001::/16 encap gre6")
+ self.vapi.cli(
+ "lb vip 2001::/16 encap gre6")
for asid in self.ass:
- self.vapi.cli("lb as 2001::/16 2002::%u" % (asid))
+ self.vapi.cli(
+ "lb as 2001::/16 2002::%u"
+ % (asid))
self.pg0.add_stream(self.generatePackets(self.pg0, isv4=False))
self.pg_enable_capture(self.pg_interfaces)
@@ -260,16 +279,144 @@ class TestLB(VppTestCase):
self.checkCapture(encap='gre6', isv4=False)
finally:
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(
+ "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")
+
+ def test_lb_ip4_gre4_port(self):
+ """ Load Balancer IP4 GRE4 on per-port-vip case """
+ try:
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 protocol udp port 20000 encap gre4")
+ for asid in self.ass:
+ self.vapi.cli(
+ "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u"
+ % (asid))
+
+ self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True))
+ self.pg_enable_capture(self.pg_interfaces)
+ self.pg_start()
+ self.checkCapture(encap='gre4', isv4=True)
+
+ finally:
+ for asid in self.ass:
+ self.vapi.cli(
+ "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u del"
+ % (asid))
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 protocol udp port 20000 encap gre4 del")
+ self.vapi.cli("test lb flowtable flush")
+
+ def test_lb_ip6_gre4_port(self):
+ """ Load Balancer IP6 GRE4 on per-port-vip case """
+
+ try:
+ self.vapi.cli(
+ "lb vip 2001::/16 protocol udp port 20000 encap gre4")
+ for asid in self.ass:
+ self.vapi.cli(
+ "lb as 2001::/16 protocol udp port 20000 10.0.0.%u"
+ % (asid))
+
+ self.pg0.add_stream(self.generatePackets(self.pg0, isv4=False))
+ self.pg_enable_capture(self.pg_interfaces)
+ self.pg_start()
+
+ self.checkCapture(encap='gre4', isv4=False)
+ finally:
+ for asid in self.ass:
+ self.vapi.cli(
+ "lb as 2001::/16 protocol udp port 20000 10.0.0.%u del"
+ % (asid))
+ self.vapi.cli(
+ "lb vip 2001::/16 protocol udp port 20000 encap gre4 del")
+ self.vapi.cli("test lb flowtable flush")
+
+ def test_lb_ip4_gre6_port(self):
+ """ Load Balancer IP4 GRE6 on per-port-vip case """
+ try:
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 protocol udp port 20000 encap gre6")
+ for asid in self.ass:
+ self.vapi.cli(
+ "lb as 90.0.0.0/8 protocol udp port 20000 2002::%u"
+ % (asid))
+
+ self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True))
+ self.pg_enable_capture(self.pg_interfaces)
+ self.pg_start()
+
+ self.checkCapture(encap='gre6', isv4=True)
+ finally:
+ for asid in self.ass:
+ self.vapi.cli(
+ "lb as 90.0.0.0/8 protocol udp port 20000 2002::%u del"
+ % (asid))
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 protocol udp port 20000 encap gre6 del")
+ self.vapi.cli("test lb flowtable flush")
+
+ def test_lb_ip6_gre6_port(self):
+ """ Load Balancer IP6 GRE6 on per-port-vip case """
+ try:
+ self.vapi.cli(
+ "lb vip 2001::/16 protocol udp port 20000 encap gre6")
+ for asid in self.ass:
+ self.vapi.cli(
+ "lb as 2001::/16 protocol udp port 20000 2002::%u"
+ % (asid))
+
+ self.pg0.add_stream(self.generatePackets(self.pg0, isv4=False))
+ self.pg_enable_capture(self.pg_interfaces)
+ self.pg_start()
+
+ self.checkCapture(encap='gre6', isv4=False)
+ finally:
+ for asid in self.ass:
+ self.vapi.cli(
+ "lb as 2001::/16 protocol udp port 20000 2002::%u del"
+ % (asid))
+ self.vapi.cli(
+ "lb vip 2001::/16 protocol udp port 20000 encap gre6 del")
self.vapi.cli("test lb flowtable flush")
def test_lb_ip4_l3dsr(self):
- """ Load Balancer IP4 L3DSR """
+ """ Load Balancer IP4 L3DSR on vip case """
+ try:
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 encap l3dsr dscp 7")
+ for asid in self.ass:
+ self.vapi.cli(
+ "lb as 90.0.0.0/8 10.0.0.%u"
+ % (asid))
+
+ self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True))
+ self.pg_enable_capture(self.pg_interfaces)
+ self.pg_start()
+ self.checkCapture(encap='l3dsr', isv4=True)
+
+ finally:
+ 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 l3dsr"
+ " dscp 7 del")
+ self.vapi.cli("test lb flowtable flush")
+
+ def test_lb_ip4_l3dsr_port(self):
+ """ Load Balancer IP4 L3DSR on per-port-vip case """
try:
- self.vapi.cli("lb vip 90.0.0.0/8 encap l3dsr dscp 7")
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 protocol udp port 20000 encap l3dsr dscp 7")
for asid in self.ass:
- self.vapi.cli("lb as 90.0.0.0/8 10.0.0.%u" % (asid))
+ self.vapi.cli(
+ "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u"
+ % (asid))
self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True))
self.pg_enable_capture(self.pg_interfaces)
@@ -278,17 +425,24 @@ class TestLB(VppTestCase):
finally:
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 l3dsr dscp 7 del")
+ self.vapi.cli(
+ "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u del"
+ % (asid))
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 protocol udp port 20000 encap l3dsr"
+ " dscp 7 del")
self.vapi.cli("test lb flowtable flush")
- def test_lb_ip4_nat4(self):
- """ Load Balancer IP4 NAT4 """
+ def test_lb_ip4_nat4_port(self):
+ """ Load Balancer IP4 NAT4 on per-port-vip case """
try:
- self.vapi.cli("lb vip 90.0.0.0/8 encap nat4"
- " type clusterip port 3306 target_port 3307")
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 protocol udp port 20000 encap nat4"
+ " type clusterip target_port 3307")
for asid in self.ass:
- self.vapi.cli("lb as 90.0.0.0/8 10.0.0.%u" % (asid))
+ self.vapi.cli(
+ "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u"
+ % (asid))
self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True))
self.pg_enable_capture(self.pg_interfaces)
@@ -297,18 +451,24 @@ class TestLB(VppTestCase):
finally:
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 nat4"
- " type clusterip port 3306 target_port 3307 del")
+ self.vapi.cli(
+ "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u del"
+ % (asid))
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 protocol udp port 20000 encap nat4"
+ " type clusterip target_port 3307 del")
self.vapi.cli("test lb flowtable flush")
- def test_lb_ip6_nat6(self):
- """ Load Balancer IP6 NAT6 """
+ def test_lb_ip6_nat6_port(self):
+ """ Load Balancer IP6 NAT6 on per-port-vip case """
try:
- self.vapi.cli("lb vip 2001::/16 encap nat6"
- " type clusterip port 3306 target_port 3307")
+ self.vapi.cli(
+ "lb vip 2001::/16 protocol udp port 20000 encap nat6"
+ " type clusterip target_port 3307")
for asid in self.ass:
- self.vapi.cli("lb as 2001::/16 2002::%u" % (asid))
+ self.vapi.cli(
+ "lb as 2001::/16 protocol udp port 20000 2002::%u"
+ % (asid))
self.pg0.add_stream(self.generatePackets(self.pg0, isv4=False))
self.pg_enable_capture(self.pg_interfaces)
@@ -317,7 +477,10 @@ class TestLB(VppTestCase):
finally:
for asid in self.ass:
- self.vapi.cli("lb as 2001::/16 2002::%u del" % (asid))
- self.vapi.cli("lb vip 2001::/16 encap nat6"
- " type clusterip port 3306 target_port 3307 del")
+ self.vapi.cli(
+ "lb as 2001::/16 protocol udp port 20000 2002::%u del"
+ % (asid))
+ self.vapi.cli(
+ "lb vip 2001::/16 protocol udp port 20000 encap nat6"
+ " type clusterip target_port 3307 del")
self.vapi.cli("test lb flowtable flush")