aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJerome Tollet <jtollet@cisco.com>2021-01-07 12:44:17 +0100
committerJohn Lo <loj@cisco.com>2021-01-08 21:46:37 +0000
commit0f8d100354ec71ba4e9e6c0e5b018eb379aca216 (patch)
treed343b8ba4832cbdf495d3c9e043a074454cf6bf6 /test
parent23f41d789c54bd8d9b87db8cf43d0235c5699da4 (diff)
l2: Separating scan-delay and learn-limit into a separate API from want_l2_macs_events
Type: feature Signed-off-by: Jerome Tollet <jtollet@cisco.com> Change-Id: I6de6dae7da4ec1001e2811975a9b67acfc1a148c
Diffstat (limited to 'test')
-rw-r--r--test/test_l2_fib.py52
-rw-r--r--test/vpp_papi_provider.py1
2 files changed, 53 insertions, 0 deletions
diff --git a/test/test_l2_fib.py b/test/test_l2_fib.py
index 51c17470966..9ce289f1652 100644
--- a/test/test_l2_fib.py
+++ b/test/test_l2_fib.py
@@ -498,6 +498,29 @@ class TestL2fib(VppTestCase):
self.vapi.want_l2_macs_events(enable_disable=0)
self.assertEqual(len(learned_macs ^ macs), 0)
+ def test_l2_fib_mac_learn_evs2(self):
+ """ L2 FIB - mac learning events using want_l2_macs_events2
+ """
+ bd1 = 1
+ hosts = self.create_hosts(10, subnet=39)
+
+ self.vapi.l2fib_set_scan_delay(scan_delay=10)
+ self.vapi.want_l2_macs_events2()
+ self.sleep(1)
+ self.learn_hosts(bd1, hosts)
+
+ self.sleep(1)
+ self.logger.info(self.vapi.ppcli("show l2fib"))
+ evs = self.vapi.collect_events()
+ action = VppEnum.vl_api_mac_event_action_t.MAC_EVENT_ACTION_API_ADD
+ learned_macs = {
+ e.mac[i].mac_addr.packed for e in evs for i in range(e.n_macs)
+ if e.mac[i].action == action}
+ macs = {h.bin_mac for swif in self.bd_ifs(bd1)
+ for h in hosts[self.pg_interfaces[swif].sw_if_index]}
+ self.vapi.want_l2_macs_events2(enable_disable=0)
+ self.assertEqual(len(learned_macs ^ macs), 0)
+
def test_l2_fib_macs_learn_max(self):
""" L2 FIB - mac learning max macs in event
"""
@@ -525,6 +548,35 @@ class TestL2fib(VppTestCase):
self.assertLess(len(e), ev_macs * 10)
self.assertEqual(len(learned_macs ^ macs), 0)
+ def test_l2_fib_macs_learn_max2(self):
+ """ L2 FIB - mac learning max macs in event using want_l2_macs_events2
+ """
+ bd1 = 1
+ hosts = self.create_hosts(10, subnet=40)
+
+ ev_macs = 1
+ self.vapi.l2fib_set_scan_delay(scan_delay=10)
+ self.vapi.want_l2_macs_events2(max_macs_in_event=ev_macs)
+ self.sleep(1)
+ self.learn_hosts(bd1, hosts)
+
+ self.sleep(1)
+ self.logger.info(self.vapi.ppcli("show l2fib"))
+ evs = self.vapi.collect_events()
+ self.vapi.want_l2_macs_events2(enable_disable=0)
+
+ self.assertGreater(len(evs), 0)
+ action = VppEnum.vl_api_mac_event_action_t.MAC_EVENT_ACTION_API_ADD
+ learned_macs = {
+ e.mac[i].mac_addr.packed for e in evs for i in range(e.n_macs)
+ if e.mac[i].action == action}
+ macs = {h.bin_mac for swif in self.bd_ifs(bd1)
+ for h in hosts[self.pg_interfaces[swif].sw_if_index]}
+
+ for e in evs:
+ self.assertLess(len(e), ev_macs * 10)
+ self.assertEqual(len(learned_macs ^ macs), 0)
+
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index d1a4eaf7fc6..c5e8ff0e068 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -104,6 +104,7 @@ defaultmapping = {
'want_igmp_events': {'enable': 1, },
'want_interface_events': {'enable_disable': 1, },
'want_l2_macs_events': {'enable_disable': 1, 'pid': os.getpid(), },
+ 'want_l2_macs_events2': {'enable_disable': 1, 'pid': os.getpid(), },
}