- def test_l2_fib_01(self):
- """ L2 FIB test 1 - program 100 MAC addresses
- """
- # Config 1
- # Create test host entries
- self.create_hosts(100, subnet=17)
-
- # Add first 100 MAC entries to L2 FIB
- self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=100)
-
- # Test 1
- self.run_verify_test(bd_id=1)
-
- def test_l2_fib_02(self):
- """ L2 FIB test 2 - delete 12 MAC entries
- """
- # Config 2
- # Delete 12 MAC entries per interface from L2 FIB
- self.delete_l2_fib_entry(bd_id=1, n_hosts_per_if=12)
-
- # Test 2a
- self.run_verify_test(bd_id=1)
-
- # Verify 2a
- self.run_verify_negat_test(bd_id=1)
-
- def test_l2_fib_03(self):
- """ L2 FIB test 3 - program new 100 MAC addresses
- """
- # Config 3
- # Create new test host entries
- self.create_hosts(100, subnet=22)
-
- # Add new 100 MAC entries to L2 FIB
- self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=100)
-
- # Test 3
- self.run_verify_test(bd_id=1)
-
- def test_l2_fib_04(self):
- """ L2 FIB test 4 - delete 160 MAC entries
- """
- # Config 4
- # Delete 160 MAC entries per interface from L2 FIB
- self.delete_l2_fib_entry(bd_id=1, n_hosts_per_if=160)
-
- # Test 4a
- self.run_verify_negat_test(bd_id=1)
-
- def test_l2_fib_05(self):
- """ L2 FIB test 5 - Program 10 new MAC entries, learn 10
- """
- self.create_hosts(20, subnet=35)
-
- self.learn_hosts(bd_id=1, n_hosts_per_if=10)
- self.learn_hosts(bd_id=2, n_hosts_per_if=10)
- self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=10)
- self.config_l2_fib_entries(bd_id=2, n_hosts_per_if=10)
- self.run_verify_test(bd_id=1, dst_hosts=self.learned_hosts)
- self.run_verify_test(bd_id=2, dst_hosts=self.learned_hosts)
-
- def test_l2_fib_06(self):
- """ L2 FIB test 6 - flush first interface
- """
- self.create_hosts(20, subnet=36)
-
- self.learn_hosts(bd_id=1, n_hosts_per_if=10)
- self.learn_hosts(bd_id=2, n_hosts_per_if=10)
- self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=10)
- self.config_l2_fib_entries(bd_id=2, n_hosts_per_if=10)
- flushed = self.flush_int(self.pg_interfaces[0].sw_if_index)
- self.run_verify_test(bd_id=1, dst_hosts=self.learned_hosts)
- self.run_verify_negat_test(bd_id=1, dst_hosts=flushed)
-
- def test_l2_fib_07(self):
- """ L2 FIB test 7 - flush bd_id
- """
- self.create_hosts(20, subnet=37)
-
- self.learn_hosts(bd_id=1, n_hosts_per_if=10)
- self.learn_hosts(bd_id=2, n_hosts_per_if=10)
- self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=10)
- self.config_l2_fib_entries(bd_id=2, n_hosts_per_if=10)
- flushed = self.flush_bd(bd_id=1)
- self.run_verify_negat_test(bd_id=1, dst_hosts=flushed)
- self.run_verify_test(bd_id=2, dst_hosts=self.learned_hosts)
-
- def test_l2_fib_08(self):
- """ L2 FIB test 8 - flush all
- """
- self.create_hosts(20, subnet=38)
-
- self.learn_hosts(bd_id=1, n_hosts_per_if=10)
- self.learn_hosts(bd_id=2, n_hosts_per_if=10)
- self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=10)
- self.config_l2_fib_entries(bd_id=2, n_hosts_per_if=10)
- flushed = self.flush_all()
- self.run_verify_negat_test(bd_id=1, dst_hosts=flushed)
- self.run_verify_negat_test(bd_id=2, dst_hosts=flushed)
-
-
-if __name__ == '__main__':
+ def test_l2_fib_program100(self):
+ """L2 FIB - program 100 MACs"""
+ bd_id = 1
+ hosts = self.create_hosts(100, subnet=17)
+ self.config_l2_fib_entries(bd_id, hosts)
+ self.run_verify_test(bd_id, hosts, hosts)
+
+ def test_l2_fib_program100_delete12(self):
+ """L2 FIB - program 100, delete 12 MACs"""
+ bd_id = 1
+ hosts = self.create_hosts(100, subnet=17)
+ self.config_l2_fib_entries(bd_id, hosts)
+ del_hosts = self.split_hosts(hosts, 12)
+ self.delete_l2_fib_entry(bd_id, del_hosts)
+
+ self.run_verify_test(bd_id, hosts, hosts)
+ self.run_verify_negat_test(bd_id, hosts, del_hosts)
+
+ def test_l2_fib_program100_add100(self):
+ """L2 FIB - program 100, add 100 MACs"""
+ bd_id = 1
+ hosts = self.create_hosts(100, subnet=17)
+ self.config_l2_fib_entries(bd_id, hosts)
+ hosts2 = self.create_hosts(100, subnet=22)
+ self.config_l2_fib_entries(bd_id, hosts2)
+ self.run_verify_test(bd_id, hosts, hosts2)
+
+ def test_l2_fib_program10_learn10(self):
+ """L2 FIB - program 10 MACs, learn 10"""
+ hosts = self.create_hosts(20, subnet=35)
+ lhosts = self.split_hosts(hosts, 10)
+
+ bd1 = 1
+ bd2 = 2
+ self.learn_hosts(bd1, lhosts)
+ self.learn_hosts(bd2, lhosts)
+ self.config_l2_fib_entries(bd1, hosts)
+ self.config_l2_fib_entries(bd2, hosts)
+ self.run_verify_test(bd1, lhosts, hosts)
+ self.run_verify_test(bd2, lhosts, hosts)
+
+ def test_l2_fib_flush_int(self):
+ """L2 FIB - flush interface"""
+ hosts = self.create_hosts(20, subnet=36)
+ lhosts = self.split_hosts(hosts, 10)
+
+ bd1 = 1
+ self.learn_hosts(bd1, lhosts)
+ self.config_l2_fib_entries(bd1, hosts)
+ self.run_verify_test(bd1, lhosts, hosts)
+ flushed = self.flush_int(self.pg_interfaces[0].sw_if_index, lhosts)
+ self.run_verify_test(bd1, hosts, lhosts)
+ self.run_verify_negat_test(bd1, hosts, flushed)
+
+ def test_l2_fib_flush_bd(self):
+ """L2 FIB - flush BD"""
+ hosts = self.create_hosts(20, subnet=37)
+ lhosts = self.split_hosts(hosts, 10)
+
+ bd1 = 1
+ self.learn_hosts(bd1, lhosts)
+ self.config_l2_fib_entries(bd1, hosts)
+ self.run_verify_test(bd1, lhosts, hosts)
+ flushed = self.flush_bd(bd1, lhosts)
+ self.run_verify_negat_test(bd1, hosts, flushed)
+
+ def test_l2_fib_flush_all(self):
+ """L2 FIB - flush all"""
+ hosts = self.create_hosts(20, subnet=38)
+ lhosts = self.split_hosts(hosts, 10)
+
+ bd1 = 1
+ bd2 = 2
+ self.learn_hosts(bd1, lhosts)
+ self.learn_hosts(bd2, lhosts)
+ self.config_l2_fib_entries(bd1, hosts)
+ self.config_l2_fib_entries(bd2, hosts)
+ self.run_verify_test(bd1, hosts, lhosts)
+ self.run_verify_test(bd2, hosts, lhosts)
+
+ self.flush_all()
+
+ self.run_verify_negat_test(bd1, hosts, lhosts)
+ self.run_verify_negat_test(bd2, hosts, lhosts)
+
+ def test_l2_fib_mac_learn_evs(self):
+ """L2 FIB - mac learning events"""
+ bd1 = 1
+ hosts = self.create_hosts(10, subnet=39)
+
+ self.vapi.want_l2_macs_events()
+ self.learn_hosts(bd1, hosts)
+
+ self.virtual_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_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.virtual_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"""
+ bd1 = 1
+ hosts = self.create_hosts(10, subnet=40)
+
+ ev_macs = 1
+ self.vapi.want_l2_macs_events(max_macs_in_event=ev_macs)
+ 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_events(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)
+
+ 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.virtual_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__":