X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftemplate_bd.py;h=291f4684db9b332697f712ca93e8105aa49f5f79;hb=ffba3c3;hp=6c384922bbd31f5c2315c6a3c29cbbbba293fe26;hpb=c4aaee11468aa5ed7af01d0747d912493cff002d;p=vpp.git diff --git a/test/template_bd.py b/test/template_bd.py index 6c384922bbd..291f4684db9 100644 --- a/test/template_bd.py +++ b/test/template_bd.py @@ -5,6 +5,8 @@ from abc import abstractmethod, ABCMeta from scapy.layers.l2 import Ether, Raw from scapy.layers.inet import IP, UDP +from util import ip4_range + class BridgeDomain(object): """ Bridge domain abstraction """ @@ -26,6 +28,11 @@ class BridgeDomain(object): UDP(sport=20000, dport=10000) / Raw('\xa5' * 100)) + @abstractmethod + def ip_range(self, start, end): + """ range of remote ip's """ + pass + @abstractmethod def encap_mcast(self, pkt, src_ip, src_mac, vni): """ Encapsulate mcast packet """ @@ -73,8 +80,8 @@ class BridgeDomain(object): self.pg_start() - # Pick first received frame and check if it's the - # non-encapsulated frame + # Pick first received frame and check if it's the non-encapsulated + # frame out = self.pg1.get_capture(1) pkt = out[0] self.assert_eq_pkts(pkt, self.frame_request) @@ -110,7 +117,7 @@ class BridgeDomain(object): self.pg_start() # Get packet from each tunnel and assert it's corectly encapsulated. - out = self.pg0.get_capture(10) + out = self.pg0.get_capture(self.n_ucast_tunnels) for pkt in out: self.check_encapsulation(pkt, self.ucast_flood_bd, True) payload = self.decapsulate(pkt) @@ -130,15 +137,12 @@ class BridgeDomain(object): # Pick first received frame and check if it's corectly encapsulated. out = self.pg0.get_capture(1) pkt = out[0] - self.check_encapsulation(pkt, self.mcast_flood_bd, True) + self.check_encapsulation(pkt, self.mcast_flood_bd, + local_only=False, mcast_pkt=True) payload = self.decapsulate(pkt) self.assert_eq_pkts(payload, self.frame_reply) - @staticmethod - def ipn_to_ip(ipn): - return '.'.join(str(i) for i in bytearray(ipn)) - def test_mcast_rcv(self): """ Multicast receive test Send 20 encapsulated frames from pg0 only 10 match unicast tunnels @@ -148,10 +152,8 @@ class BridgeDomain(object): ip_range_start = 10 ip_range_end = 30 mcast_stream = [ - self.encap_mcast(self.frame_request, self.ipn_to_ip(ip), mac, - self.mcast_flood_bd) - for ip in self.ip4_range(self.pg0.remote_ip4n, - ip_range_start, ip_range_end)] + self.encap_mcast(self.frame_request, ip, mac, self.mcast_flood_bd) + for ip in self.ip_range(ip_range_start, ip_range_end)] self.pg0.add_stream(mcast_stream) self.pg2.enable_capture() self.pg_start()