Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | """L2 FIB Test Case HLD: |
| 3 | |
| 4 | **config 1** |
| 5 | - add 4 pg-l2 interfaces |
| 6 | - configure them into l2bd |
| 7 | - configure 100 MAC entries in L2 fib - 25 MACs per interface |
| 8 | - L2 MAC learning and unknown unicast flooding disabled in l2bd |
| 9 | - configure 100 MAC entries in L2 fib - 25 MACs per interface |
| 10 | |
| 11 | **test 1** |
| 12 | - send L2 MAC frames between all 4 pg-l2 interfaces for all of 100 MAC \ |
| 13 | entries in the FIB |
| 14 | |
| 15 | **verify 1** |
| 16 | - all packets received correctly |
| 17 | |
| 18 | **config 2** |
| 19 | - delete 12 MAC entries - 3 MACs per interface |
| 20 | |
| 21 | **test 2a** |
| 22 | - send L2 MAC frames between all 4 pg-l2 interfaces for non-deleted MAC \ |
| 23 | entries |
| 24 | |
| 25 | **verify 2a** |
| 26 | - all packets received correctly |
| 27 | |
| 28 | **test 2b** |
| 29 | - send L2 MAC frames between all 4 pg-l2 interfaces for all of 12 deleted \ |
| 30 | MAC entries |
| 31 | |
| 32 | **verify 2b** |
| 33 | - no packet received on all 4 pg-l2 interfaces |
| 34 | |
| 35 | **config 3** |
| 36 | - configure new 100 MAC entries in L2 fib - 25 MACs per interface |
| 37 | |
| 38 | **test 3** |
| 39 | - send L2 MAC frames between all 4 pg-l2 interfaces for all of 188 MAC \ |
| 40 | entries in the FIB |
| 41 | |
| 42 | **verify 3** |
| 43 | - all packets received correctly |
| 44 | |
| 45 | **config 4** |
| 46 | - delete 160 MAC entries, 40 MACs per interface |
| 47 | |
| 48 | **test 4a** |
| 49 | - send L2 MAC frames between all 4 pg-l2 interfaces for all of 28 \ |
| 50 | non-deleted MAC entries |
| 51 | |
| 52 | **verify 4a** |
| 53 | - all packets received correctly |
| 54 | |
| 55 | **test 4b** |
| 56 | - try send L2 MAC frames between all 4 pg-l2 interfaces for all of 172 \ |
| 57 | deleted MAC entries |
| 58 | |
| 59 | **verify 4b** |
| 60 | - no packet received on all 4 pg-l2 interfaces |
| 61 | """ |
| 62 | |
| 63 | import unittest |
| 64 | import random |
| 65 | |
| 66 | from scapy.packet import Raw |
| 67 | from scapy.layers.l2 import Ether |
| 68 | from scapy.layers.inet import IP, UDP |
| 69 | |
| 70 | from framework import VppTestCase, VppTestRunner |
Klement Sekera | 9225dee | 2016-12-12 08:36:58 +0100 | [diff] [blame] | 71 | from util import Host, ppp |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 72 | |
| 73 | |
| 74 | class TestL2fib(VppTestCase): |
| 75 | """ L2 FIB Test Case """ |
| 76 | |
| 77 | @classmethod |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 78 | def bd_ifs(cls, bd_id): |
| 79 | return range((bd_id - 1) * cls.n_ifs_per_bd, bd_id * cls.n_ifs_per_bd) |
| 80 | |
| 81 | @classmethod |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 82 | def setUpClass(cls): |
| 83 | """ |
| 84 | Perform standard class setup (defined by class method setUpClass in |
| 85 | class VppTestCase) before running the test case, set test case related |
| 86 | variables and configure VPP. |
| 87 | |
| 88 | :var int bd_id: Bridge domain ID. |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 89 | """ |
| 90 | super(TestL2fib, cls).setUpClass() |
| 91 | |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 92 | try: |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 93 | n_brs = cls.n_brs = range(1, 3) |
| 94 | cls.n_ifs_per_bd = 4 |
| 95 | n_ifs = range(cls.n_ifs_per_bd * len(cls.n_brs)) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 96 | # Create 4 pg interfaces |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 97 | cls.create_pg_interfaces(n_ifs) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 98 | |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 99 | cls.flows = dict() |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 100 | for bd_id in n_brs: |
| 101 | # Packet flows mapping pg0 -> pg1, pg2, pg3 etc. |
| 102 | ifs = cls.bd_ifs(bd_id) |
| 103 | for j in ifs: |
| 104 | cls.flows[cls.pg_interfaces[j]] = [ |
| 105 | cls.pg_interfaces[x] for x in ifs if x != j] |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 106 | |
| 107 | # Packet sizes |
| 108 | cls.pg_if_packet_sizes = [64, 512, 1518, 9018] |
| 109 | |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 110 | for bd_id in n_brs: |
| 111 | # Create BD with MAC learning and unknown unicast flooding |
| 112 | # disabled and put interfaces to this BD |
| 113 | cls.vapi.bridge_domain_add_del( |
| 114 | bd_id=bd_id, uu_flood=0, learn=0) |
| 115 | ifs = [cls.pg_interfaces[i] for i in cls.bd_ifs(bd_id)] |
| 116 | for pg_if in ifs: |
| 117 | cls.vapi.sw_interface_set_l2_bridge(pg_if.sw_if_index, |
| 118 | bd_id=bd_id) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 119 | |
| 120 | # Set up all interfaces |
| 121 | for i in cls.pg_interfaces: |
| 122 | i.admin_up() |
| 123 | |
| 124 | # Mapping between packet-generator index and lists of test hosts |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 125 | cls.hosts = dict() |
| 126 | cls.fib_hosts = dict() |
| 127 | cls.deleted_hosts = dict() |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 128 | for pg_if in cls.pg_interfaces: |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 129 | cls.hosts[pg_if.sw_if_index] = [] |
| 130 | cls.fib_hosts[pg_if.sw_if_index] = [] |
| 131 | cls.deleted_hosts[pg_if.sw_if_index] = [] |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 132 | |
| 133 | except Exception: |
| 134 | super(TestL2fib, cls).tearDownClass() |
| 135 | raise |
| 136 | |
| 137 | def setUp(self): |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 138 | super(TestL2fib, self).setUp() |
Klement Sekera | dab231a | 2016-12-21 08:50:14 +0100 | [diff] [blame] | 139 | self.reset_packet_infos() |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 140 | |
| 141 | def tearDown(self): |
| 142 | """ |
| 143 | Show various debug prints after each test. |
| 144 | """ |
| 145 | super(TestL2fib, self).tearDown() |
| 146 | if not self.vpp_dead: |
| 147 | self.logger.info(self.vapi.ppcli("show l2fib verbose")) |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 148 | for bd_id in self.n_brs: |
| 149 | self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" |
| 150 | % bd_id)) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 151 | |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 152 | def create_hosts(self, n_hosts_per_if, subnet): |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 153 | """ |
| 154 | Create required number of host MAC addresses and distribute them among |
| 155 | interfaces. Create host IPv4 address for every host MAC address. |
| 156 | |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 157 | :param int n_hosts_per_if: Number of per interface hosts to |
| 158 | create MAC/IPv4 addresses for. |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 159 | """ |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 160 | |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 161 | for pg_if in self.pg_interfaces: |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 162 | swif = pg_if.sw_if_index |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 163 | |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 164 | def mac(j): return "00:00:%02x:ff:%02x:%02x" % (subnet, swif, j) |
| 165 | |
| 166 | def ip(j): return "172.%02u.1%02x.%u" % (subnet, swif, j) |
| 167 | |
| 168 | def h(j): return Host(mac(j), ip(j)) |
| 169 | self.hosts[swif] = [h(j) for j in range(n_hosts_per_if)] |
| 170 | |
| 171 | def config_l2_fib_entries(self, bd_id, n_hosts_per_if): |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 172 | """ |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 173 | Config required number of L2 FIB entries. |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 174 | |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 175 | :param int bd_id: BD's id |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 176 | :param int count: Number of L2 FIB entries to be created. |
| 177 | :param int start: Starting index of the host list. (Default value = 0) |
| 178 | """ |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 179 | ifs = [self.pg_interfaces[i] for i in self.bd_ifs(bd_id)] |
| 180 | for pg_if in ifs: |
| 181 | swif = pg_if.sw_if_index |
| 182 | hosts = self.hosts[swif] |
| 183 | fhosts = self.fib_hosts[swif] |
| 184 | for j in range(n_hosts_per_if): |
| 185 | host = hosts.pop() |
Klement Sekera | da505f6 | 2017-01-04 12:58:53 +0100 | [diff] [blame] | 186 | self.vapi.l2fib_add_del( |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 187 | host.mac, bd_id, swif, static_mac=1) |
| 188 | fhosts.append(host) |
| 189 | # del hosts[0] |
| 190 | self.logger.info("Configure %d L2 FIB entries .." % |
| 191 | len(self.pg_interfaces) * n_hosts_per_if) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 192 | self.logger.info(self.vapi.ppcli("show l2fib")) |
| 193 | |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 194 | def delete_l2_fib_entry(self, bd_id, n_hosts_per_if): |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 195 | """ |
| 196 | Delete required number of L2 FIB entries. |
| 197 | |
| 198 | :param int count: Number of L2 FIB entries to be created. |
| 199 | """ |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 200 | ifs = [self.pg_interfaces[i] for i in self.bd_ifs(bd_id)] |
| 201 | for pg_if in ifs: |
| 202 | swif = pg_if.sw_if_index |
| 203 | hosts = self.fib_hosts[swif] |
| 204 | dhosts = self.deleted_hosts[swif] |
| 205 | for j in range(n_hosts_per_if): |
| 206 | host = hosts.pop() |
Klement Sekera | da505f6 | 2017-01-04 12:58:53 +0100 | [diff] [blame] | 207 | self.vapi.l2fib_add_del( |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 208 | host.mac, bd_id, swif, is_add=0) |
| 209 | dhosts.append(host) |
| 210 | self.logger.info(self.vapi.ppcli("show l2fib")) |
| 211 | |
| 212 | def flush_int(self, swif): |
| 213 | """ |
| 214 | Flush swif L2 FIB entries. |
| 215 | |
| 216 | :param int swif: sw if index. |
| 217 | """ |
| 218 | self.vapi.l2fib_flush_int(swif) |
| 219 | self.deleted_hosts[swif] = self.fib_hosts[swif] + \ |
| 220 | self.deleted_hosts[swif] |
| 221 | self.fib_hosts[swif] = [] |
| 222 | self.logger.info(self.vapi.ppcli("show l2fib")) |
| 223 | |
| 224 | def flush_bd(self, bd_id): |
| 225 | """ |
| 226 | Flush bd_id L2 FIB entries. |
| 227 | |
| 228 | :param int bd_id: Bridge Domain id. |
| 229 | """ |
| 230 | self.vapi.l2fib_flush_bd(bd_id) |
| 231 | ifs = [self.pg_interfaces[i] for i in self.bd_ifs(bd_id)] |
| 232 | for pg_if in ifs: |
| 233 | swif = pg_if.sw_if_index |
| 234 | self.deleted_hosts[swif] = self.fib_hosts[swif] + \ |
| 235 | self.deleted_hosts[swif] |
| 236 | self.fib_hosts[swif] = [] |
| 237 | self.logger.info(self.vapi.ppcli("show l2fib")) |
| 238 | |
| 239 | def flush_all(self): |
| 240 | """ |
| 241 | Flush All L2 FIB entries. |
| 242 | """ |
| 243 | self.vapi.l2fib_flush_all() |
| 244 | for pg_if in self.pg_interfaces: |
| 245 | swif = pg_if.sw_if_index |
| 246 | self.deleted_hosts[swif] = self.fib_hosts[swif] + \ |
| 247 | self.deleted_hosts[swif] |
| 248 | self.fib_hosts[swif] = [] |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 249 | self.logger.info(self.vapi.ppcli("show l2fib")) |
| 250 | |
| 251 | def create_stream(self, src_if, packet_sizes, deleted=False): |
| 252 | """ |
| 253 | Create input packet stream for defined interface using hosts or |
| 254 | deleted_hosts list. |
| 255 | |
| 256 | :param object src_if: Interface to create packet stream for. |
| 257 | :param list packet_sizes: List of required packet sizes. |
| 258 | :param boolean deleted: Set to True if deleted_hosts list required. |
| 259 | :return: Stream of packets. |
| 260 | """ |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 261 | src_hosts = self.fib_hosts[src_if.sw_if_index] |
| 262 | if not src_hosts: |
| 263 | return [] |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 264 | pkts = [] |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 265 | for dst_if in self.flows[src_if]: |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 266 | dst_hosts = self.deleted_hosts[dst_if.sw_if_index]\ |
| 267 | if deleted else self.fib_hosts[dst_if.sw_if_index] |
| 268 | for i in range(0, len(dst_hosts)): |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 269 | dst_host = dst_hosts[i] |
| 270 | src_host = random.choice(src_hosts) |
Klement Sekera | dab231a | 2016-12-21 08:50:14 +0100 | [diff] [blame] | 271 | pkt_info = self.create_packet_info(src_if, dst_if) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 272 | payload = self.info_to_payload(pkt_info) |
| 273 | p = (Ether(dst=dst_host.mac, src=src_host.mac) / |
| 274 | IP(src=src_host.ip4, dst=dst_host.ip4) / |
| 275 | UDP(sport=1234, dport=1234) / |
| 276 | Raw(payload)) |
| 277 | pkt_info.data = p.copy() |
| 278 | size = random.choice(packet_sizes) |
| 279 | self.extend_packet(p, size) |
| 280 | pkts.append(p) |
| 281 | return pkts |
| 282 | |
| 283 | def verify_capture(self, pg_if, capture): |
| 284 | """ |
| 285 | Verify captured input packet stream for defined interface. |
| 286 | |
| 287 | :param object pg_if: Interface to verify captured packet stream for. |
| 288 | :param list capture: Captured packet stream. |
| 289 | """ |
| 290 | last_info = dict() |
| 291 | for i in self.pg_interfaces: |
| 292 | last_info[i.sw_if_index] = None |
| 293 | dst_sw_if_index = pg_if.sw_if_index |
| 294 | for packet in capture: |
| 295 | payload_info = self.payload_to_info(str(packet[Raw])) |
| 296 | try: |
| 297 | ip = packet[IP] |
| 298 | udp = packet[UDP] |
| 299 | packet_index = payload_info.index |
| 300 | self.assertEqual(payload_info.dst, dst_sw_if_index) |
| 301 | self.logger.debug("Got packet on port %s: src=%u (id=%u)" % |
| 302 | (pg_if.name, payload_info.src, packet_index)) |
| 303 | next_info = self.get_next_packet_info_for_interface2( |
| 304 | payload_info.src, dst_sw_if_index, |
| 305 | last_info[payload_info.src]) |
| 306 | last_info[payload_info.src] = next_info |
| 307 | self.assertTrue(next_info is not None) |
| 308 | self.assertEqual(packet_index, next_info.index) |
| 309 | saved_packet = next_info.data |
| 310 | # Check standard fields |
| 311 | self.assertEqual(ip.src, saved_packet[IP].src) |
| 312 | self.assertEqual(ip.dst, saved_packet[IP].dst) |
| 313 | self.assertEqual(udp.sport, saved_packet[UDP].sport) |
| 314 | self.assertEqual(udp.dport, saved_packet[UDP].dport) |
| 315 | except: |
Klement Sekera | 9225dee | 2016-12-12 08:36:58 +0100 | [diff] [blame] | 316 | self.logger.error(ppp("Unexpected or invalid packet:", packet)) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 317 | raise |
| 318 | for i in self.pg_interfaces: |
| 319 | remaining_packet = self.get_next_packet_info_for_interface2( |
| 320 | i, dst_sw_if_index, last_info[i.sw_if_index]) |
| 321 | self.assertTrue( |
| 322 | remaining_packet is None, |
| 323 | "Port %u: Packet expected from source %u didn't arrive" % |
| 324 | (dst_sw_if_index, i.sw_if_index)) |
| 325 | |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 326 | def run_verify_test(self, bd_id): |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 327 | # Test |
| 328 | # Create incoming packet streams for packet-generator interfaces |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 329 | self.reset_packet_infos() |
| 330 | ifs = [self.pg_interfaces[i] for i in self.bd_ifs(bd_id)] |
| 331 | for i in ifs: |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 332 | pkts = self.create_stream(i, self.pg_if_packet_sizes) |
| 333 | i.add_stream(pkts) |
| 334 | |
| 335 | # Enable packet capture and start packet sending |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 336 | self.pg_enable_capture(ifs) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 337 | self.pg_start() |
| 338 | |
| 339 | # Verify |
| 340 | # Verify outgoing packet streams per packet-generator interface |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 341 | for i in ifs: |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 342 | capture = i.get_capture() |
| 343 | self.logger.info("Verifying capture on interface %s" % i.name) |
| 344 | self.verify_capture(i, capture) |
| 345 | |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 346 | def run_verify_negat_test(self, bd_id): |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 347 | # Test |
| 348 | # Create incoming packet streams for packet-generator interfaces for |
| 349 | # deleted MAC addresses |
Klement Sekera | dab231a | 2016-12-21 08:50:14 +0100 | [diff] [blame] | 350 | self.reset_packet_infos() |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 351 | ifs = [self.pg_interfaces[i] for i in self.bd_ifs(bd_id)] |
| 352 | for i in ifs: |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 353 | pkts = self.create_stream(i, self.pg_if_packet_sizes, deleted=True) |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 354 | if pkts: |
| 355 | i.add_stream(pkts) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 356 | |
| 357 | # Enable packet capture and start packet sending |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 358 | self.pg_enable_capture(ifs) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 359 | self.pg_start() |
| 360 | |
| 361 | # Verify |
| 362 | # Verify outgoing packet streams per packet-generator interface |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 363 | for i in ifs: |
Klement Sekera | 9225dee | 2016-12-12 08:36:58 +0100 | [diff] [blame] | 364 | i.assert_nothing_captured(remark="outgoing interface") |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 365 | |
| 366 | def test_l2_fib_01(self): |
| 367 | """ L2 FIB test 1 - program 100 MAC addresses |
| 368 | """ |
| 369 | # Config 1 |
| 370 | # Create test host entries |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 371 | self.create_hosts(100, subnet=17) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 372 | |
| 373 | # Add first 100 MAC entries to L2 FIB |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 374 | self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=100) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 375 | |
| 376 | # Test 1 |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 377 | self.run_verify_test(bd_id=1) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 378 | |
| 379 | def test_l2_fib_02(self): |
| 380 | """ L2 FIB test 2 - delete 12 MAC entries |
| 381 | """ |
| 382 | # Config 2 |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 383 | # Delete 12 MAC entries per interface from L2 FIB |
| 384 | self.delete_l2_fib_entry(bd_id=1, n_hosts_per_if=12) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 385 | |
| 386 | # Test 2a |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 387 | self.run_verify_test(bd_id=1) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 388 | |
| 389 | # Verify 2a |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 390 | self.run_verify_negat_test(bd_id=1) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 391 | |
| 392 | def test_l2_fib_03(self): |
| 393 | """ L2 FIB test 3 - program new 100 MAC addresses |
| 394 | """ |
| 395 | # Config 3 |
| 396 | # Create new test host entries |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 397 | self.create_hosts(100, subnet=22) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 398 | |
| 399 | # Add new 100 MAC entries to L2 FIB |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 400 | self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=100) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 401 | |
| 402 | # Test 3 |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 403 | self.run_verify_test(bd_id=1) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 404 | |
| 405 | def test_l2_fib_04(self): |
| 406 | """ L2 FIB test 4 - delete 160 MAC entries |
| 407 | """ |
| 408 | # Config 4 |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 409 | # Delete 160 MAC entries per interface from L2 FIB |
| 410 | self.delete_l2_fib_entry(bd_id=1, n_hosts_per_if=160) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 411 | |
| 412 | # Test 4a |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 413 | self.run_verify_negat_test(bd_id=1) |
| 414 | |
| 415 | def test_l2_fib_05(self): |
| 416 | """ L2 FIB test 5 - flush first interface |
| 417 | """ |
| 418 | self.flush_int(self.pg_interfaces[0].sw_if_index) |
| 419 | self.sleep(3) |
| 420 | self.create_hosts(1, subnet=31) |
| 421 | self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=1) |
| 422 | self.run_verify_test(bd_id=1) |
| 423 | self.run_verify_negat_test(bd_id=1) |
| 424 | |
| 425 | def test_l2_fib_06(self): |
| 426 | """ L2 FIB test 6 - Program 20 new MAC entries |
| 427 | """ |
| 428 | self.create_hosts(20, subnet=33) |
| 429 | |
| 430 | self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=20) |
| 431 | self.config_l2_fib_entries(bd_id=2, n_hosts_per_if=20) |
| 432 | self.run_verify_test(bd_id=1) |
| 433 | self.run_verify_test(bd_id=2) |
| 434 | |
| 435 | def test_l2_fib_07(self): |
| 436 | """ L2 FIB test 7 - flush bd_id |
| 437 | """ |
| 438 | self.flush_bd(bd_id=1) |
| 439 | self.run_verify_negat_test(bd_id=1) |
| 440 | self.run_verify_test(bd_id=2) |
| 441 | |
| 442 | def test_l2_fib_08(self): |
| 443 | """ L2 FIB test 8 - Program 20 new MAC entries |
| 444 | """ |
| 445 | self.create_hosts(20, subnet=34) |
| 446 | |
| 447 | self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=20) |
| 448 | self.config_l2_fib_entries(bd_id=2, n_hosts_per_if=20) |
| 449 | self.run_verify_test(bd_id=1) |
| 450 | self.run_verify_test(bd_id=2) |
| 451 | |
| 452 | def test_l2_fib_09(self): |
| 453 | """ L2 FIB test 9 - flush all |
| 454 | """ |
| 455 | self.flush_all() |
| 456 | self.sleep(3) |
| 457 | self.run_verify_negat_test(bd_id=1) |
| 458 | self.run_verify_negat_test(bd_id=2) |
| 459 | |
| 460 | def test_l2_fib_10(self): |
| 461 | """ L2 FIB test 10 - Program 20 new MAC entries |
| 462 | """ |
| 463 | self.create_hosts(20, subnet=35) |
| 464 | |
| 465 | self.config_l2_fib_entries(bd_id=1, n_hosts_per_if=20) |
| 466 | self.config_l2_fib_entries(bd_id=2, n_hosts_per_if=20) |
| 467 | self.run_verify_test(bd_id=1) |
| 468 | self.run_verify_test(bd_id=2) |
| 469 | self.run_verify_negat_test(bd_id=1) |
| 470 | self.run_verify_negat_test(bd_id=2) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 471 | |
| 472 | |
| 473 | if __name__ == '__main__': |
| 474 | unittest.main(testRunner=VppTestRunner) |