X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_l2bd_arp_term.py;h=bdf0a80caa7ca181860858067e433e4b13c28a0f;hb=bc764c8bc;hp=20cc537e43b2c218468f9f48124fa3fb5d5ce07d;hpb=c125eccc10db9c0b9c5d161d3ad20b4fc8c69b26;p=vpp.git diff --git a/test/test_l2bd_arp_term.py b/test/test_l2bd_arp_term.py index 20cc537e43b..bdf0a80caa7 100644 --- a/test/test_l2bd_arp_term.py +++ b/test/test_l2bd_arp_term.py @@ -19,7 +19,7 @@ from scapy.layers.inet6 import IPv6, UDP, ICMPv6ND_NS, ICMPv6ND_RS, \ ICMPv6ND_NA, ICMPv6NDOptDstLLAddr, ICMPv6DestUnreach, icmp6types from framework import VppTestCase, VppTestRunner -from util import Host, ppp, mactobinary +from util import Host, ppp class TestL2bdArpTerm(VppTestCase): @@ -51,6 +51,10 @@ class TestL2bdArpTerm(VppTestCase): super(TestL2bdArpTerm, cls).tearDownClass() raise + @classmethod + def tearDownClass(cls): + super(TestL2bdArpTerm, cls).tearDownClass() + def setUp(self): """ Clear trace and packet infos before running each test. @@ -63,18 +67,22 @@ class TestL2bdArpTerm(VppTestCase): Show various debug prints after each test. """ super(TestL2bdArpTerm, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show l2fib verbose")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show l2fib verbose")) + # many tests delete bridge-domain 1 as the last task. don't output + # the details of a non-existent bridge-domain. + if self.vapi.l2_fib_table_dump(bd_id=1): self.logger.info(self.vapi.ppcli("show bridge-domain 1 detail")) def add_del_arp_term_hosts(self, entries, bd_id=1, is_add=1, is_ipv6=0): for e in entries: - ip = e.ip4n if is_ipv6 == 0 else e.ip6n - self.vapi.bd_ip_mac_add_del(bd_id=bd_id, - mac=e.bin_mac, - ip=ip, - is_ipv6=is_ipv6, - is_add=is_add) + ip = e.ip4 if is_ipv6 == 0 else e.ip6 + self.vapi.bd_ip_mac_add_del(is_add=is_add, + entry={ + 'bd_id': bd_id, + 'ip': ip, + 'mac': e.mac}) @classmethod def mac_list(cls, b6_range): @@ -111,8 +119,8 @@ class TestL2bdArpTerm(VppTestCase): self.vapi.bridge_domain_add_del(bd_id=bd_id, is_add=is_add) for swif in self.bd_swifs(bd_id): swif_idx = swif.sw_if_index - self.vapi.sw_interface_set_l2_bridge( - swif_idx, bd_id=bd_id, enable=is_add) + self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=swif_idx, + bd_id=bd_id, enable=is_add) if not is_add: self.vapi.bridge_domain_add_del(bd_id=bd_id, is_add=is_add) @@ -154,23 +162,22 @@ class TestL2bdArpTerm(VppTestCase): def arp_resp_hosts(self, src_host, pkts): return {self.arp_resp_host(src_host, p) for p in pkts} - def inttoip4(self, ip): + @staticmethod + def inttoip4(ip): o1 = int(ip / 16777216) % 256 o2 = int(ip / 65536) % 256 o3 = int(ip / 256) % 256 o4 = int(ip) % 256 - return '%(o1)s.%(o2)s.%(o3)s.%(o4)s' % locals() + return '%s.%s.%s.%s' % (o1, o2, o3, o4) def arp_event_host(self, e): - return Host(mac=':'.join(['%02x' % ord(char) for char in e.new_mac]), - ip4=self.inttoip4(e.address)) + return Host(str(e.mac), ip4=str(e.ip)) def arp_event_hosts(self, evs): return {self.arp_event_host(e) for e in evs} def nd_event_host(self, e): - return Host(mac=':'.join(['%02x' % ord(char) for char in e.new_mac]), - ip6=inet_ntop(AF_INET6, e.address)) + return Host(str(e.mac), ip6=str(e.ip)) def nd_event_hosts(self, evs): return {self.nd_event_host(e) for e in evs} @@ -230,7 +237,8 @@ class TestL2bdArpTerm(VppTestCase): else: raise ValueError("Unknown feature used: %s" % flag) is_set = 1 if args[flag] else 0 - self.vapi.bridge_flags(bd_id, is_set, feature_bitmap) + self.vapi.bridge_flags(bd_id=bd_id, is_set=is_set, + flags=feature_bitmap) self.logger.info("Bridge domain ID %d updated" % bd_id) def verify_arp(self, src_host, req_hosts, resp_hosts, bd_id=1): @@ -271,6 +279,7 @@ class TestL2bdArpTerm(VppTestCase): macs = self.mac_list(range(1, 5)) hosts = self.ip4_hosts(4, 1, macs) self.add_del_arp_term_hosts(hosts, is_add=1) + self.verify_arp(src_host, hosts, hosts) type(self).hosts = hosts @@ -437,7 +446,7 @@ class TestL2bdArpTerm(VppTestCase): def test_l2bd_arp_term_12(self): """ L2BD ND term - send NS packets verify reports """ - self.vapi.want_ip6_nd_events(address=inet_pton(AF_INET6, "::0")) + self.vapi.want_ip6_nd_events(ip="::") dst_host = self.ip6_host(50, 50, "00:00:11:22:33:44") self.bd_add_del(1, is_add=1) self.set_bd_flags(1, arp_term=True, flood=False, @@ -473,8 +482,7 @@ class TestL2bdArpTerm(VppTestCase): def test_l2bd_arp_term_14(self): """ L2BD ND term - disable ip4 arp events,send ns, verify no events """ - self.vapi.want_ip6_nd_events(enable_disable=0, - address=inet_pton(AF_INET6, "::0")) + self.vapi.want_ip6_nd_events(enable_disable=0, ip="::") dst_host = self.ip6_host(50, 50, "00:00:11:22:33:44") macs = self.mac_list(range(10, 15)) hosts = self.ip6_hosts(5, 1, macs)