aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2021-03-15 16:58:10 +0100
committerAndrew Yourtchenko <ayourtch@gmail.com>2021-03-20 01:14:20 +0000
commit8d8150262b00435c365a43c8f859584901736aff (patch)
treec7eace6feab4895d6f40b16a54ef65cc63bebe67
parent290526e3c72888ac05928ed0a6dddee02f7df650 (diff)
tests: add support for worker awareness
VppTestCase now has vpp_worker_count property set to number of workers. This can be overriden by child classes. Also overriden by VPP_WORKER_CONFIG variable for legacy reasons. Type: improvement Change-Id: Ic328bacb9003ddf9e92815767653bd362aa7f086 Signed-off-by: Klement Sekera <ksekera@cisco.com>
-rw-r--r--src/plugins/nat/test/test_nat44_ed.py2
-rw-r--r--src/plugins/nat/test/test_nat44_ei.py2
-rw-r--r--src/plugins/quic/test/test_quic.py2
-rwxr-xr-xsrc/plugins/wireguard/test/test_wireguard.py2
-rw-r--r--src/vnet/policer/test/test_policer_input.py2
-rw-r--r--test/framework.py58
-rw-r--r--test/template_ipsec.py4
-rw-r--r--test/test_ip4.py2
-rw-r--r--test/test_ip6.py2
-rw-r--r--test/test_ipsec_esp.py4
-rw-r--r--test/test_reassembly.py39
-rw-r--r--test/test_vlib.py2
-rw-r--r--test/test_vppinfra.py2
13 files changed, 64 insertions, 59 deletions
diff --git a/src/plugins/nat/test/test_nat44_ed.py b/src/plugins/nat/test/test_nat44_ed.py
index 5eb56a1301e..ba068b476c6 100644
--- a/src/plugins/nat/test/test_nat44_ed.py
+++ b/src/plugins/nat/test/test_nat44_ed.py
@@ -1957,7 +1957,7 @@ class TestNAT44ED(NAT44EDTestCase):
class TestNAT44EDMW(TestNAT44ED):
""" NAT44ED MW Test Case """
- worker_config = "workers 1"
+ vpp_worker_count = 1
def get_stats_counter(self, path, worker=1):
return super(TestNAT44EDMW, self).get_stats_counter(path, worker)
diff --git a/src/plugins/nat/test/test_nat44_ei.py b/src/plugins/nat/test/test_nat44_ei.py
index dcd7f46f073..f5c5abefa9e 100644
--- a/src/plugins/nat/test/test_nat44_ei.py
+++ b/src/plugins/nat/test/test_nat44_ei.py
@@ -3896,7 +3896,7 @@ class TestNAT44Out2InDPO(MethodHolder):
class TestNAT44EIMW(MethodHolder):
""" NAT44EI Test Cases (multiple workers) """
- worker_config = "workers %d" % 2
+ vpp_worker_count = 2
max_translations = 10240
max_users = 10240
diff --git a/src/plugins/quic/test/test_quic.py b/src/plugins/quic/test/test_quic.py
index d984b99610c..0e4cb2dacca 100644
--- a/src/plugins/quic/test/test_quic.py
+++ b/src/plugins/quic/test/test_quic.py
@@ -177,7 +177,7 @@ class QUICEchoExtTestCase(QUICTestCase):
post_test_sleep = 1
app = "vpp_echo"
evt_q_len = 16384
- worker_config = "workers 1"
+ vpp_worker_count = 1
server_fifo_size = "1M"
client_fifo_size = "4M"
extra_vpp_punt_config = ["session", "{",
diff --git a/src/plugins/wireguard/test/test_wireguard.py b/src/plugins/wireguard/test/test_wireguard.py
index 82ba2625498..edc305b1336 100755
--- a/src/plugins/wireguard/test/test_wireguard.py
+++ b/src/plugins/wireguard/test/test_wireguard.py
@@ -663,7 +663,7 @@ class TestWg(VppTestCase):
class WireguardHandoffTests(TestWg):
""" Wireguard Tests in multi worker setup """
- worker_config = "workers 2"
+ vpp_worker_count = 2
def test_wg_peer_init(self):
""" Handoff """
diff --git a/src/vnet/policer/test/test_policer_input.py b/src/vnet/policer/test/test_policer_input.py
index 29ae58ad5de..c95f6643ff2 100644
--- a/src/vnet/policer/test/test_policer_input.py
+++ b/src/vnet/policer/test/test_policer_input.py
@@ -15,7 +15,7 @@ NUM_PKTS = 67
class TestPolicerInput(VppTestCase):
""" Policer on an input interface """
- worker_config = "workers 2"
+ vpp_worker_count = 2
def setUp(self):
super(TestPolicerInput, self).setUp()
diff --git a/test/framework.py b/test/framework.py
index 4e0949bcf45..22a9509f030 100644
--- a/test/framework.py
+++ b/test/framework.py
@@ -406,11 +406,18 @@ class VppTestCase(unittest.TestCase):
coredump_size = "coredump-size unlimited"
cpu_core_number = cls.get_least_used_cpu()
- if not hasattr(cls, "worker_config"):
- cls.worker_config = os.getenv("VPP_WORKER_CONFIG", "")
- if cls.worker_config != "":
- if cls.has_tag(TestCaseTag.FIXME_VPP_WORKERS):
- cls.worker_config = ""
+ if not hasattr(cls, "vpp_worker_count"):
+ cls.vpp_worker_count = 0
+ worker_config = os.getenv("VPP_WORKER_CONFIG", "")
+ if worker_config:
+ elems = worker_config.split(" ")
+ if elems[0] != "workers" or len(elems) != 2:
+ raise ValueError("Wrong VPP_WORKER_CONFIG == '%s' value." %
+ worker_config)
+ cls.vpp_worker_count = int(elems[1])
+ if cls.vpp_worker_count > 0 and\
+ cls.has_tag(TestCaseTag.FIXME_VPP_WORKERS):
+ cls.vpp_worker_count = 0
default_variant = os.getenv("VARIANT")
if default_variant is not None:
@@ -422,25 +429,27 @@ class VppTestCase(unittest.TestCase):
if api_fuzzing is None:
api_fuzzing = 'off'
- cls.vpp_cmdline = [cls.vpp_bin, "unix",
- "{", "nodaemon", debug_cli, "full-coredump",
- coredump_size, "runtime-dir", cls.tempdir, "}",
- "api-trace", "{", "on", "}", "api-segment", "{",
- "prefix", cls.shm_prefix, "}", "cpu", "{",
- "main-core", str(cpu_core_number),
- cls.worker_config, "}",
- "physmem", "{", "max-size", "32m", "}",
- "statseg", "{", "socket-name", cls.stats_sock, "}",
- "socksvr", "{", "socket-name", cls.api_sock, "}",
- "node { ", default_variant, "}",
- "api-fuzz {", api_fuzzing, "}",
- "plugins",
- "{", "plugin", "dpdk_plugin.so", "{", "disable",
- "}", "plugin", "rdma_plugin.so", "{", "disable",
- "}", "plugin", "lisp_unittest_plugin.so", "{",
- "enable",
- "}", "plugin", "unittest_plugin.so", "{", "enable",
- "}"] + cls.extra_vpp_plugin_config + ["}", ]
+ cls.vpp_cmdline = [
+ cls.vpp_bin,
+ "unix", "{", "nodaemon", debug_cli, "full-coredump",
+ coredump_size, "runtime-dir", cls.tempdir, "}",
+ "api-trace", "{", "on", "}",
+ "api-segment", "{", "prefix", cls.shm_prefix, "}",
+ "cpu", "{", "main-core", str(cpu_core_number), ]
+ if cls.vpp_worker_count:
+ cls.vpp_cmdline.extend(["workers", str(cls.vpp_worker_count)])
+ cls.vpp_cmdline.extend([
+ "}",
+ "physmem", "{", "max-size", "32m", "}",
+ "statseg", "{", "socket-name", cls.stats_sock, "}",
+ "socksvr", "{", "socket-name", cls.api_sock, "}",
+ "node { ", default_variant, "}",
+ "api-fuzz {", api_fuzzing, "}",
+ "plugins", "{", "plugin", "dpdk_plugin.so", "{", "disable", "}",
+ "plugin", "rdma_plugin.so", "{", "disable", "}",
+ "plugin", "lisp_unittest_plugin.so", "{", "enable", "}",
+ "plugin", "unittest_plugin.so", "{", "enable", "}"
+ ] + cls.extra_vpp_plugin_config + ["}", ])
if cls.extra_vpp_punt_config is not None:
cls.vpp_cmdline.extend(cls.extra_vpp_punt_config)
@@ -774,7 +783,6 @@ class VppTestCase(unittest.TestCase):
super(VppTestCase, self).setUp()
self.reporter.send_keep_alive(self)
if self.vpp_dead:
-
raise VppDiedError(rv=None, testcase=self.__class__.__name__,
method_name=self._testMethodName)
self.sleep(.1, "during setUp")
diff --git a/test/template_ipsec.py b/test/template_ipsec.py
index f7becf0f82a..62271d33579 100644
--- a/test/template_ipsec.py
+++ b/test/template_ipsec.py
@@ -1217,7 +1217,7 @@ class IpsecTun6Tests(IpsecTun6):
class IpsecTun6HandoffTests(IpsecTun6):
""" UT test methods for Tunnel v6 with multiple workers """
- worker_config = "workers 2"
+ vpp_worker_count = 2
def test_tun_handoff_66(self):
""" ipsec 6o6 tunnel worker hand-off test """
@@ -1251,7 +1251,7 @@ class IpsecTun6HandoffTests(IpsecTun6):
class IpsecTun4HandoffTests(IpsecTun4):
""" UT test methods for Tunnel v4 with multiple workers """
- worker_config = "workers 2"
+ vpp_worker_count = 2
def test_tun_handooff_44(self):
""" ipsec 4o4 tunnel worker hand-off test """
diff --git a/test/test_ip4.py b/test/test_ip4.py
index f9fa33c1c7c..3f2894d01c1 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -1605,7 +1605,7 @@ class TestIPPunt(IPPuntSetup, VppTestCase):
class TestIPPuntHandoff(IPPuntSetup, VppTestCase):
""" IPv4 Punt Policer thread handoff """
- worker_config = "workers 2"
+ vpp_worker_count = 2
def setUp(self):
super(TestIPPuntHandoff, self).setUp()
diff --git a/test/test_ip6.py b/test/test_ip6.py
index db90b84ed0f..8abd8d6807f 100644
--- a/test/test_ip6.py
+++ b/test/test_ip6.py
@@ -2320,7 +2320,7 @@ class TestIP6Punt(IP6PuntSetup, VppTestCase):
class TestIP6PuntHandoff(IP6PuntSetup, VppTestCase):
""" IPv6 Punt Police/Redirect """
- worker_config = "workers 2"
+ vpp_worker_count = 2
def setUp(self):
super(TestIP6PuntHandoff, self).setUp()
diff --git a/test/test_ipsec_esp.py b/test/test_ipsec_esp.py
index dcbbb826775..acff595996b 100644
--- a/test/test_ipsec_esp.py
+++ b/test/test_ipsec_esp.py
@@ -470,7 +470,7 @@ class TestIpsecEsp2(TemplateIpsecEsp, IpsecTcpTests):
class TestIpsecEspAsync(TemplateIpsecEsp):
""" Ipsec ESP - Aysnc tests """
- worker_config = "workers 2"
+ vpp_worker_count = 2
def setUp(self):
super(TestIpsecEspAsync, self).setUp()
@@ -852,7 +852,7 @@ class RunTestIpsecEspAll(ConfigIpsecESP,
test_args = str.split(cls.__doc__, " ")
engine = test_args[0]
if engine == "async":
- cls.worker_config = "workers 2"
+ cls.vpp_worker_count = 2
super(RunTestIpsecEspAll, cls).setUpConstants()
def setUp(self):
diff --git a/test/test_reassembly.py b/test/test_reassembly.py
index a8dc60a2df6..124fec0a820 100644
--- a/test/test_reassembly.py
+++ b/test/test_reassembly.py
@@ -21,9 +21,6 @@ from vpp_papi import VppEnum
# 35 is enough to have >257 400-byte fragments
test_packet_count = 35
-# number of workers used for multi-worker test cases
-worker_count = 3
-
class TestIPv4Reassembly(VppTestCase):
""" IPv4 Reassembly """
@@ -789,13 +786,13 @@ class TestIPv4SVReassembly(VppTestCase):
class TestIPv4MWReassembly(VppTestCase):
""" IPv4 Reassembly (multiple workers) """
- worker_config = "workers %d" % worker_count
+ vpp_worker_count = 3
@classmethod
def setUpClass(cls):
super(TestIPv4MWReassembly, cls).setUpClass()
- cls.create_pg_interfaces(range(worker_count+1))
+ cls.create_pg_interfaces(range(cls.vpp_worker_count+1))
cls.src_if = cls.pg0
cls.send_ifs = cls.pg_interfaces[:-1]
cls.dst_if = cls.pg_interfaces[-1]
@@ -908,7 +905,7 @@ class TestIPv4MWReassembly(VppTestCase):
"Packet with packet_index %d not received" % index)
def send_packets(self, packets):
- for counter in range(worker_count):
+ for counter in range(self.vpp_worker_count):
if 0 == len(packets[counter]):
continue
send_if = self.send_ifs[counter]
@@ -924,19 +921,19 @@ class TestIPv4MWReassembly(VppTestCase):
# in first wave we send fragments which don't start at offset 0
# then we send fragments with offset 0 on a different thread
# then the rest of packets on a random thread
- first_packets = [[] for n in range(worker_count)]
- second_packets = [[] for n in range(worker_count)]
- rest_of_packets = [[] for n in range(worker_count)]
+ first_packets = [[] for n in range(self.vpp_worker_count)]
+ second_packets = [[] for n in range(self.vpp_worker_count)]
+ rest_of_packets = [[] for n in range(self.vpp_worker_count)]
for (_, p) in self.pkt_infos:
- wi = randrange(worker_count)
+ wi = randrange(self.vpp_worker_count)
second_packets[wi].append(p[0])
if len(p) <= 1:
continue
wi2 = wi
while wi2 == wi:
- wi2 = randrange(worker_count)
+ wi2 = randrange(self.vpp_worker_count)
first_packets[wi2].append(p[1])
- wi3 = randrange(worker_count)
+ wi3 = randrange(self.vpp_worker_count)
rest_of_packets[wi3].extend(p[2:])
self.pg_enable_capture()
@@ -1437,13 +1434,13 @@ class TestIPv6Reassembly(VppTestCase):
class TestIPv6MWReassembly(VppTestCase):
""" IPv6 Reassembly (multiple workers) """
- worker_config = "workers %d" % worker_count
+ vpp_worker_count = 3
@classmethod
def setUpClass(cls):
super(TestIPv6MWReassembly, cls).setUpClass()
- cls.create_pg_interfaces(range(worker_count+1))
+ cls.create_pg_interfaces(range(cls.vpp_worker_count+1))
cls.src_if = cls.pg0
cls.send_ifs = cls.pg_interfaces[:-1]
cls.dst_if = cls.pg_interfaces[-1]
@@ -1556,7 +1553,7 @@ class TestIPv6MWReassembly(VppTestCase):
"Packet with packet_index %d not received" % index)
def send_packets(self, packets):
- for counter in range(worker_count):
+ for counter in range(self.vpp_worker_count):
if 0 == len(packets[counter]):
continue
send_if = self.send_ifs[counter]
@@ -1572,19 +1569,19 @@ class TestIPv6MWReassembly(VppTestCase):
# in first wave we send fragments which don't start at offset 0
# then we send fragments with offset 0 on a different thread
# then the rest of packets on a random thread
- first_packets = [[] for n in range(worker_count)]
- second_packets = [[] for n in range(worker_count)]
- rest_of_packets = [[] for n in range(worker_count)]
+ first_packets = [[] for n in range(self.vpp_worker_count)]
+ second_packets = [[] for n in range(self.vpp_worker_count)]
+ rest_of_packets = [[] for n in range(self.vpp_worker_count)]
for (_, p) in self.pkt_infos:
- wi = randrange(worker_count)
+ wi = randrange(self.vpp_worker_count)
second_packets[wi].append(p[0])
if len(p) <= 1:
continue
wi2 = wi
while wi2 == wi:
- wi2 = randrange(worker_count)
+ wi2 = randrange(self.vpp_worker_count)
first_packets[wi2].append(p[1])
- wi3 = randrange(worker_count)
+ wi3 = randrange(self.vpp_worker_count)
rest_of_packets[wi3].extend(p[2:])
self.pg_enable_capture()
diff --git a/test/test_vlib.py b/test/test_vlib.py
index 89ccb396ecd..64218eabbb3 100644
--- a/test/test_vlib.py
+++ b/test/test_vlib.py
@@ -11,7 +11,7 @@ from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
class TestVlib(VppTestCase):
""" Vlib Unit Test Cases """
- worker_config = "workers 1"
+ vpp_worker_count = 1
@classmethod
def setUpClass(cls):
diff --git a/test/test_vppinfra.py b/test/test_vppinfra.py
index 9cb782d3593..8b6ec965fea 100644
--- a/test/test_vppinfra.py
+++ b/test/test_vppinfra.py
@@ -8,7 +8,7 @@ from framework import running_gcov_tests
class TestVppinfra(VppTestCase):
""" Vppinfra Unit Test Cases """
- worker_config = "workers 1"
+ vpp_worker_count = 1
@classmethod
def setUpClass(cls):