aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/test_ip4.py47
-rw-r--r--test/test_ip6.py44
-rw-r--r--test/vpp_policer.py4
3 files changed, 93 insertions, 2 deletions
diff --git a/test/test_ip4.py b/test/test_ip4.py
index f0b43947736..c89d546023d 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -1642,8 +1642,7 @@ class TestIPPuntHandoff(IPPuntSetup, VppTestCase):
for worker in [0, 1]:
self.send_and_expect(self.pg0, pkts, self.pg1, worker=worker)
- if worker == 0:
- self.logger.debug(self.vapi.cli("show trace max 100"))
+ self.logger.debug(self.vapi.cli("show trace max 100"))
# Combined stats, all threads
stats = policer.get_stats()
@@ -1663,6 +1662,50 @@ class TestIPPuntHandoff(IPPuntSetup, VppTestCase):
self.assertEqual(stats1['exceed_packets'], 0)
self.assertEqual(stats1['violate_packets'], 0)
+ # Bind the policer to worker 1 and repeat
+ policer.bind_vpp_config(1, True)
+ for worker in [0, 1]:
+ self.send_and_expect(self.pg0, pkts, self.pg1, worker=worker)
+ self.logger.debug(self.vapi.cli("show trace max 100"))
+
+ # The 2 workers should now have policed the same amount
+ stats = policer.get_stats()
+ stats0 = policer.get_stats(worker=0)
+ stats1 = policer.get_stats(worker=1)
+
+ self.assertGreater(stats0['conform_packets'], 0)
+ self.assertEqual(stats0['exceed_packets'], 0)
+ self.assertGreater(stats0['violate_packets'], 0)
+
+ self.assertGreater(stats1['conform_packets'], 0)
+ self.assertEqual(stats1['exceed_packets'], 0)
+ self.assertGreater(stats1['violate_packets'], 0)
+
+ self.assertEqual(stats0['conform_packets'] + stats1['conform_packets'],
+ stats['conform_packets'])
+
+ self.assertEqual(stats0['violate_packets'] + stats1['violate_packets'],
+ stats['violate_packets'])
+
+ # Unbind the policer and repeat
+ policer.bind_vpp_config(1, False)
+ for worker in [0, 1]:
+ self.send_and_expect(self.pg0, pkts, self.pg1, worker=worker)
+ self.logger.debug(self.vapi.cli("show trace max 100"))
+
+ # The policer should auto-bind to worker 0 when packets arrive
+ stats = policer.get_stats()
+ stats0new = policer.get_stats(worker=0)
+ stats1new = policer.get_stats(worker=1)
+
+ self.assertGreater(stats0new['conform_packets'],
+ stats0['conform_packets'])
+ self.assertEqual(stats0new['exceed_packets'], 0)
+ self.assertGreater(stats0new['violate_packets'],
+ stats0['violate_packets'])
+
+ self.assertEqual(stats1, stats1new)
+
#
# Clean up
#
diff --git a/test/test_ip6.py b/test/test_ip6.py
index a3da6650d8b..8a2b332d167 100644
--- a/test/test_ip6.py
+++ b/test/test_ip6.py
@@ -2377,6 +2377,50 @@ class TestIP6PuntHandoff(IP6PuntSetup, VppTestCase):
self.assertEqual(stats1['exceed_packets'], 0)
self.assertEqual(stats1['violate_packets'], 0)
+ # Bind the policer to worker 1 and repeat
+ policer.bind_vpp_config(1, True)
+ for worker in [0, 1]:
+ self.send_and_expect(self.pg0, pkts, self.pg1, worker=worker)
+ self.logger.debug(self.vapi.cli("show trace max 100"))
+
+ # The 2 workers should now have policed the same amount
+ stats = policer.get_stats()
+ stats0 = policer.get_stats(worker=0)
+ stats1 = policer.get_stats(worker=1)
+
+ self.assertGreater(stats0['conform_packets'], 0)
+ self.assertEqual(stats0['exceed_packets'], 0)
+ self.assertGreater(stats0['violate_packets'], 0)
+
+ self.assertGreater(stats1['conform_packets'], 0)
+ self.assertEqual(stats1['exceed_packets'], 0)
+ self.assertGreater(stats1['violate_packets'], 0)
+
+ self.assertEqual(stats0['conform_packets'] + stats1['conform_packets'],
+ stats['conform_packets'])
+
+ self.assertEqual(stats0['violate_packets'] + stats1['violate_packets'],
+ stats['violate_packets'])
+
+ # Unbind the policer and repeat
+ policer.bind_vpp_config(1, False)
+ for worker in [0, 1]:
+ self.send_and_expect(self.pg0, pkts, self.pg1, worker=worker)
+ self.logger.debug(self.vapi.cli("show trace max 100"))
+
+ # The policer should auto-bind to worker 0 when packets arrive
+ stats = policer.get_stats()
+ stats0new = policer.get_stats(worker=0)
+ stats1new = policer.get_stats(worker=1)
+
+ self.assertGreater(stats0new['conform_packets'],
+ stats0['conform_packets'])
+ self.assertEqual(stats0new['exceed_packets'], 0)
+ self.assertGreater(stats0new['violate_packets'],
+ stats0['violate_packets'])
+
+ self.assertEqual(stats1, stats1new)
+
#
# Clean up
#
diff --git a/test/vpp_policer.py b/test/vpp_policer.py
index 7f6d8191138..387ab270214 100644
--- a/test/vpp_policer.py
+++ b/test/vpp_policer.py
@@ -57,6 +57,10 @@ class VppPolicer(VppObject):
self._test.vapi.policer_add_del(is_add=False, name=self.name)
self._policer_index = INVALID_INDEX
+ def bind_vpp_config(self, worker, bind):
+ self._test.vapi.policer_bind(name=self.name, worker_index=worker,
+ bind_enable=bind)
+
def query_vpp_config(self):
dump = self._test.vapi.policer_dump(
match_name_valid=True, match_name=self.name)