def test_bgp_vrf_tcp_mss(request): tgen = get_topogen() tc_name = request.node.name if tgen.routers_have_failure(): pytest.skip(tgen.errors) step("Verify the router failures") if tgen.routers_have_failure(): check_router_status(tgen) step("Configuring 5 static Routes in Router R3 with NULL0 as Next hop") for addr_type in ADDR_TYPES: static_routes_input = { "r3": { "static_routes": [ { "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, { "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, { "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, { "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, { "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, ] } } result = create_static_routes(tgen, static_routes_input) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Verify the static Routes in R3 on default VRF") for addr_type in ADDR_TYPES: static_routes_input = { "r3": { "static_routes": [ { "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, { "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, { "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, { "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, { "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, ] } } dut = "r3" result = verify_bgp_rib(tgen, addr_type, dut, static_routes_input) assert result is True, "Testcase {} :Failed \n Error {}".format( tc_name, result) step("Verify the static Routes in R2 on default VRF") for addr_type in ADDR_TYPES: static_routes_input = { "r3": { "static_routes": [ { "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, { "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, { "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, { "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, { "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], }, ] } } dut = "r2" result = verify_bgp_rib(tgen, addr_type, dut, static_routes_input) assert result is True, "Testcase {} :Failed \n Error {}".format( tc_name, result) step("importing default vrf on R2 under VRF RED Address Family") for addr_type in ADDR_TYPES: input_import_vrf = { "r2": { "bgp": [{ "local_as": 200, "vrf": "RED", "address_family": { addr_type: { "unicast": { "import": { "vrf": "default" } } } }, }] } } result = create_router_bgp(tgen, topo, input_import_vrf) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Verify the static Routes in R2 on RED VRF") for addr_type in ADDR_TYPES: static_routes_input = { "r3": { "static_routes": [ { "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], "vrf": "RED", }, { "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], "vrf": "RED", }, { "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], "vrf": "RED", }, { "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], "vrf": "RED", }, { "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], "vrf": "RED", }, ] } } dut = "r2" result = verify_bgp_rib(tgen, addr_type, dut, static_routes_input) assert result is True, "Testcase {} :Failed \n Error {}".format( tc_name, result) step("Verify the static Routes in R1 on RED VRF") for addr_type in ADDR_TYPES: static_routes_input = { "r3": { "static_routes": [ { "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], "vrf": "RED", }, { "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], "vrf": "RED", }, { "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], "vrf": "RED", }, { "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], "vrf": "RED", }, { "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]], "next_hop": NEXT_HOP_IP[addr_type], "vrf": "RED", }, ] } } dut = "r1" result = verify_bgp_rib(tgen, addr_type, dut, static_routes_input) assert result is True, "Testcase {} :Failed \n Error {}".format( tc_name, result) step("Enabling tcp-mss 150 on Router R1 in VRF RED") TCP_MSS = 150 raw_config = { "r1": { "raw_config": [ "router bgp {} vrf {}".format( topo["routers"]["r1"]["bgp"][0]["local_as"], topo["routers"]["r1"]["bgp"][0]["vrf"], ), "neighbor {} tcp-mss {}".format( topo["routers"]["r2"]["links"]["r1-link1"]["ipv4"].split( "/")[0], TCP_MSS, ), "neighbor {} tcp-mss {}".format( topo["routers"]["r2"]["links"]["r1-link1"]["ipv6"].split( "/")[0], TCP_MSS, ), ] }, } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Clearing BGP on R1 and R2 ") for addr_type in ADDR_TYPES: clear_bgp(tgen, addr_type, "r1", vrf=topo["routers"]["r1"]["bgp"][0]["vrf"]) clear_bgp(tgen, addr_type, "r2", vrf=topo["routers"]["r2"]["bgp"][1]["vrf"]) step("Verify the BGP Convergence at R1 & R2 after Clear BGP") r1_convergence = verify_bgp_convergence(tgen, topo, dut="r1") assert (r1_convergence is True ), "BGP convergence after Clear BGP :Failed \n Error: {}".format( r1_convergence) r2_convergence = verify_bgp_convergence(tgen, topo, dut="r2") assert (r2_convergence is True ), "BGP convergence after Clear BGP :Failed \n Error: {}".format( r2_convergence) step("Verify the TCP-MSS value on both Router R1 and R2") for addr_type in ADDR_TYPES: dut = "r1" tcp_mss_result = verify_tcp_mss( tgen, dut, topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/") [0], TCP_MSS, "RED", ) assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format( tcp_mss_result) step("Enabling tcp-mss 500 between R2 and R3 of VRF Default") TCP_MSS = 500 raw_config = { "r2": { "raw_config": [ "router bgp {} ".format( topo["routers"]["r2"]["bgp"][0]["local_as"]), "neighbor {} tcp-mss {}".format( topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split( "/")[0], TCP_MSS, ), "neighbor {} tcp-mss {}".format( topo["routers"]["r3"]["links"]["r2-link1"]["ipv6"].split( "/")[0], TCP_MSS, ), ] }, "r3": { "raw_config": [ "router bgp {} ".format( topo["routers"]["r3"]["bgp"][0]["local_as"]), "neighbor {} tcp-mss {}".format( topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split( "/")[0], TCP_MSS, ), "neighbor {} tcp-mss {}".format( topo["routers"]["r2"]["links"]["r3-link1"]["ipv6"].split( "/")[0], TCP_MSS, ), ] }, } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Clear BGP at router R2 and R3") for addr_type in ADDR_TYPES: clear_bgp(tgen, topo, "r2", addr_type) clear_bgp(tgen, topo, "r3", addr_type) step("Verify the BGP Convergence at R2 & R3 after Clear BGP") r1_convergence = verify_bgp_convergence(tgen, topo, dut="r2") assert (r1_convergence is True ), "BGP convergence after Clear BGP :Failed \n Error: {}".format( r2_convergence) r2_convergence = verify_bgp_convergence(tgen, topo, dut="r3") assert (r2_convergence is True ), "BGP convergence after Clear BGP :Failed \n Error: {}".format( r2_convergence) step("Verify the TCP-MSS value on both Router R2 and R3") for addr_type in ADDR_TYPES: dut = "r2" tcp_mss_result = verify_tcp_mss( tgen, dut, topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0], TCP_MSS, ) assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format( tcp_mss_result) dut = "r3" tcp_mss_result = verify_tcp_mss( tgen, dut, topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0], TCP_MSS, ) assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format( tcp_mss_result) step("Removing tcp-mss 150 between R1 and R2 of VRF RED ") TCP_MSS = 150 raw_config = { "r1": { "raw_config": [ "router bgp {} vrf {}".format( topo["routers"]["r1"]["bgp"][0]["local_as"], topo["routers"]["r1"]["bgp"][0]["vrf"], ), "no neighbor {} tcp-mss {}".format( topo["routers"]["r2"]["links"]["r1-link1"]["ipv4"].split( "/")[0], TCP_MSS, ), "no neighbor {} tcp-mss {}".format( topo["routers"]["r2"]["links"]["r1-link1"]["ipv6"].split( "/")[0], TCP_MSS, ), ] } } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) raw_config = { "r2": { "raw_config": [ "router bgp {} vrf {}".format( topo["routers"]["r2"]["bgp"][0]["local_as"], topo["routers"]["r2"]["bgp"][1]["vrf"], ), "no neighbor {} tcp-mss {}".format( topo["routers"]["r1"]["links"]["r2-link1"]["ipv4"].split( "/")[0], TCP_MSS, ), "no neighbor {} tcp-mss {}".format( topo["routers"]["r1"]["links"]["r2-link1"]["ipv6"].split( "/")[0], TCP_MSS, ), ] } } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Verify the TCP-MSS value cleared on both Router R1 and R2") for addr_type in ADDR_TYPES: dut = "r1" tcp_mss_result = verify_tcp_mss( tgen, dut, topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/") [0], TCP_MSS, "RED", ) assert (tcp_mss_result is not True), " TCP-MSS mismatch :Failed \n Error: {}".format( tcp_mss_result) dut = "r2" tcp_mss_result = verify_tcp_mss( tgen, dut, topo["routers"]["r1"]["links"]["r2-link1"]["ipv4"].split("/")[0], TCP_MSS, "RED", ) assert (tcp_mss_result is not True), " TCP-MSS mismatch :Failed \n Error: {}".format( tcp_mss_result) step("Removing tcp-mss 500 between R2 and R3 of VRF Default ") TCP_MSS = 500 raw_config = { "r2": { "raw_config": [ "router bgp {} ".format( topo["routers"]["r2"]["bgp"][0]["local_as"]), "no neighbor {} tcp-mss {}".format( topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split( "/")[0], TCP_MSS, ), "no neighbor {} tcp-mss {}".format( topo["routers"]["r3"]["links"]["r2-link1"]["ipv6"].split( "/")[0], TCP_MSS, ), ] } } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) raw_config = { "r3": { "raw_config": [ "router bgp {} ".format( topo["routers"]["r3"]["bgp"][0]["local_as"]), "no neighbor {} tcp-mss {}".format( topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split( "/")[0], TCP_MSS, ), "no neighbor {} tcp-mss {}".format( topo["routers"]["r2"]["links"]["r3-link1"]["ipv6"].split( "/")[0], TCP_MSS, ), ] } } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Verify the TCP-MSS value got cleared on both Router R2 and R3") for addr_type in ADDR_TYPES: dut = "r2" tcp_mss_result = verify_tcp_mss( tgen, dut, topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0], TCP_MSS, ) assert (tcp_mss_result is not True), " TCP-MSS mismatch :Failed \n Error: {}".format( tcp_mss_result) dut = "r3" tcp_mss_result = verify_tcp_mss( tgen, dut, topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0], TCP_MSS, ) assert (tcp_mss_result is not True), " TCP-MSS mismatch :Failed \n Error: {}".format( tcp_mss_result) step("Configuring different TCP-MSS R2 and R3 ") TCP_MSS = 500 raw_config = { "r2": { "raw_config": [ "router bgp {}".format( topo["routers"]["r2"]["bgp"][0]["local_as"]), "neighbor {} tcp-mss {}".format( topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split( "/")[0], TCP_MSS, ), "neighbor {} tcp-mss {}".format( topo["routers"]["r3"]["links"]["r2-link1"]["ipv6"].split( "/")[0], TCP_MSS, ), ] } } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) TCP_MSS = 300 raw_config = { "r3": { "raw_config": [ "router bgp {} ".format( topo["routers"]["r3"]["bgp"][0]["local_as"]), "neighbor {} tcp-mss {}".format( topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split( "/")[0], TCP_MSS, ), "neighbor {} tcp-mss {}".format( topo["routers"]["r2"]["links"]["r3-link1"]["ipv6"].split( "/")[0], TCP_MSS, ), ] } } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Verify the TCP-MSS value on both Router R2 and R3") for addr_type in ADDR_TYPES: TCP_MSS = 500 dut = "r2" tcp_mss_result = verify_tcp_mss( tgen, dut, topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0], TCP_MSS, ) assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format( tcp_mss_result) TCP_MSS = 300 dut = "r3" tcp_mss_result = verify_tcp_mss( tgen, dut, topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0], TCP_MSS, ) assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format( tcp_mss_result) step("Configure TCP_MSS > MTU on R2 and R3 and it should be 1460 ") TCP_MSS = 4096 REF_TCP_MSS = 1460 raw_config = { "r2": { "raw_config": [ "router bgp {} ".format( topo["routers"]["r2"]["bgp"][0]["local_as"]), "neighbor {} tcp-mss {}".format( topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split( "/")[0], TCP_MSS, ), "neighbor {} tcp-mss {}".format( topo["routers"]["r3"]["links"]["r2-link1"]["ipv6"].split( "/")[0], TCP_MSS, ), ] } } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) raw_config = { "r3": { "raw_config": [ "router bgp {} ".format( topo["routers"]["r3"]["bgp"][0]["local_as"]), "neighbor {} tcp-mss {}".format( topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split( "/")[0], TCP_MSS, ), "neighbor {} tcp-mss {}".format( topo["routers"]["r2"]["links"]["r3-link1"]["ipv6"].split( "/")[0], TCP_MSS, ), ] } } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Restarting BGP Daemon on R3") kill_router_daemons(tgen, "r3", ["bgpd"]) start_router_daemons(tgen, "r3", ["bgpd"]) step( "Verify the configured TCP-MSS 4096 value on restarting both Daemon both Router R2 and R3 " ) for addr_type in ADDR_TYPES: TCP_MSS = 4096 dut = "r2" tcp_mss_result = verify_tcp_mss( tgen, dut, topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0], TCP_MSS, ) assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format( tcp_mss_result) dut = "r3" tcp_mss_result = verify_tcp_mss( tgen, dut, topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0], TCP_MSS, ) assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format( tcp_mss_result) write_test_footer(tc_name)
def pre_config_for_receiver_dr_tests(tgen, topo, tc_name, highest_priority, lowest_priority): """ API to do common pre-configuration for receiver test cases parameters: ----------- * `tgen`: topogen object * `topo`: input json data * `tc_name`: caller test case name * `highest_priority`: router which will be having highest DR priority * `lowest_priority`: router which will be having lowest DR priority """ global intf_r1_s1, intf_r1_s1_addr, intf_r2_s1, intf_r2_s1_addr, intf_r3_s1, intf_r3_s1_addr, intf_i1_s1, intf_i1_s1_addr step("Configure IGMP and PIM on switch connected receiver nodes") step("Configure PIM on all upstream interfaces") step("Configure link between R1, R2 ,R3 and receiver on" " same vlan") step("Make sure {0} is DR initially configuring highest IP on {0} and R2 " "second highest, {1} is lower".format(highest_priority, lowest_priority)) intf_r1_s1 = topo["routers"]["r1"]["links"]["s1"]["interface"] intf_r1_s1_addr = topo["routers"]["r1"]["links"]["s1"]["ipv4"] intf_r2_s1 = topo["routers"]["r2"]["links"]["s1"]["interface"] intf_r2_s1_addr = topo["routers"]["r2"]["links"]["s1"]["ipv4"] intf_r3_s1 = topo["routers"]["r3"]["links"]["s1"]["interface"] intf_r3_s1_addr = topo["routers"]["r3"]["links"]["s1"]["ipv4"] intf_i1_s1 = topo["routers"]["i1"]["links"]["s1"]["interface"] intf_i1_s1_addr = topo["routers"]["i1"]["links"]["s1"]["ipv4"] if lowest_priority == "r1": lowest_pr_intf = intf_r1_s1 else: lowest_pr_intf = intf_r3_s1 if highest_priority == "r1": highest_pr_intf = intf_r1_s1 else: highest_pr_intf = intf_r3_s1 vlan_input = { lowest_priority: { "vlan": { VLAN_1: [{ lowest_pr_intf: { "ip": SAME_VLAN_IP_1["ip"], "subnet": SAME_VLAN_IP_1["subnet"], } }] } }, "r2": { "vlan": { VLAN_1: [{ intf_r2_s1: { "ip": SAME_VLAN_IP_2["ip"], "subnet": SAME_VLAN_IP_2["subnet"], } }] } }, highest_priority: { "vlan": { VLAN_1: [{ highest_pr_intf: { "ip": SAME_VLAN_IP_3["ip"], "subnet": SAME_VLAN_IP_3["subnet"], } }] } }, "i1": { "vlan": { VLAN_1: [{ intf_i1_s1: { "ip": SAME_VLAN_IP_4["ip"], "subnet": SAME_VLAN_IP_4["subnet"], } }] } }, } add_interfaces_to_vlan(tgen, vlan_input) raw_config = { "r1": { "raw_config": [ "interface {}".format(intf_r1_s1), "no ip address {}".format(intf_r1_s1_addr), "no ip pim", ] }, "r2": { "raw_config": [ "interface {}".format(intf_r2_s1), "no ip address {}".format(intf_r2_s1_addr), "no ip pim", ] }, "r3": { "raw_config": [ "interface {}".format(intf_r3_s1), "no ip address {}".format(intf_r3_s1_addr), "no ip pim", ] }, "i1": { "raw_config": [ "interface {}".format(intf_i1_s1), "no ip address {}".format(intf_i1_s1_addr), ] }, } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) raw_config = { lowest_priority: { "raw_config": [ "interface {}.{}".format(lowest_pr_intf, VLAN_1), "ip address {}/{}".format(SAME_VLAN_IP_1["ip"], SAME_VLAN_IP_1["cidr"]), "ip pim", "ip igmp", "ip igmp version 2", ] }, "r2": { "raw_config": [ "interface {}.{}".format(intf_r2_s1, VLAN_1), "ip address {}/{}".format(SAME_VLAN_IP_2["ip"], SAME_VLAN_IP_2["cidr"]), "ip pim", "ip igmp", "ip igmp version 2", ] }, highest_priority: { "raw_config": [ "interface {}.{}".format(highest_pr_intf, VLAN_1), "ip address {}/{}".format(SAME_VLAN_IP_3["ip"], SAME_VLAN_IP_3["cidr"]), "ip pim", "ip igmp", "ip igmp version 2", ] }, "i1": { "raw_config": [ "interface {}.{}".format(intf_i1_s1, VLAN_1), "ip address {}/{}".format(SAME_VLAN_IP_4["ip"], SAME_VLAN_IP_4["cidr"]), ] }, } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) for dut, intf in zip(["r1", "r2", "r3"], [intf_r1_s1, intf_r2_s1, intf_r3_s1]): raw_config = { dut: { "raw_config": [ "interface {}.{}".format(intf, VLAN_1), "ip pim hello {} {}".format(HELLO_TIMER, HOLD_TIMER), ] } } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Configure R4 as RP on all the nodes for group range 224.0.0.0/24") input_dict = { "r4": { "pim": { "rp": [{ "rp_addr": topo["routers"]["r4"]["links"]["lo"]["ipv4"].split("/")[0], "group_addr_range": GROUP_RANGE_1, }] } } } result = create_pim_config(tgen, topo, input_dict) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Send IGMP join for groups 226.1.1.1 to 226.1.1.5") vlan_intf_i1_s1 = "{}.{}".format(intf_i1_s1, VLAN_1) result = app_helper.run_join("i1", IGMP_JOIN_RANGE_1, join_intf=vlan_intf_i1_s1) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) step("Using static routes instead OSPF: Enable OSPF between all the nodes") step("Start traffic from R4 connected source") result = app_helper.run_traffic("i2", IGMP_JOIN_RANGE_1, "r5") assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) return True
def test_mroute_with_RP_default_route_all_nodes_p2(request): """ TC_50 Verify mroute when LHR,FHR,RP and transit routers reachable using default routes """ tgen = get_topogen() tc_name = request.node.name write_test_header(tc_name) # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) # Don"t run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) step("Remove c1-c2 connected link to simulate topo " "c1(LHR)---l1(RP)----r2---f1-----c2(FHR)") intf_c1_c2 = topo["routers"]["c1"]["links"]["c2"]["interface"] intf_c2_c1 = topo["routers"]["c2"]["links"]["c1"]["interface"] shutdown_bringup_interface(tgen, "c1", intf_c1_c2, False) shutdown_bringup_interface(tgen, "c2", intf_c2_c1, False) step("Enable the PIM on all the interfaces of FRR1, FRR2, FRR3") step("Enable IGMP of FRR1 interface and send IGMP joins " " from FRR1 node for group range (225.1.1.1-5)") intf_c1_i4 = topo["routers"]["c1"]["links"]["i4"]["interface"] input_dict = { "c1": { "igmp": { "interfaces": { intf_c1_i4: { "igmp": { "version": "2" } } } } } } result = create_igmp_config(tgen, topo, input_dict) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) input_join = {"i4": topo["routers"]["i4"]["links"]["c1"]["interface"]} for recvr, recvr_intf in input_join.items(): result = config_to_send_igmp_join_and_traffic(tgen, topo, tc_name, recvr, recvr_intf, GROUP_RANGE_1, join=True) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) result = iperfSendIGMPJoin(tgen, recvr, IGMP_JOIN_RANGE_1, join_interval=1) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) step("Configure static RP for (225.1.1.1-5) as R2") input_dict = { "l1": { "pim": { "rp": [{ "rp_addr": topo["routers"]["l1"]["links"]["lo"]["ipv4"].split("/")[0], "group_addr_range": GROUP_RANGE, }] } } } result = create_pim_config(tgen, topo, input_dict) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Send traffic from C2 to all the groups ( 225.1.1.1 to 225.1.1.5)") input_src = {"i5": topo["routers"]["i5"]["links"]["c2"]["interface"]} for src, src_intf in input_src.items(): result = config_to_send_igmp_join_and_traffic(tgen, topo, tc_name, src, src_intf, GROUP_RANGE_1, traffic=True) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) result = iperfSendTraffic(tgen, src, IGMP_JOIN_RANGE_1, 32, 2500) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) source_i5 = topo["routers"]["i5"]["links"]["c2"]["ipv4"].split("/")[0] input_dict_starg = [{ "dut": "c1", "src_address": "*", "iif": topo["routers"]["c1"]["links"]["l1"]["interface"], "oil": topo["routers"]["c1"]["links"]["i4"]["interface"], }] input_dict_sg = [{ "dut": "c1", "src_address": source_i5, "iif": topo["routers"]["c1"]["links"]["l1"]["interface"], "oil": topo["routers"]["c1"]["links"]["i4"]["interface"], }] step("Verify mroutes and iff upstream") for data in input_dict_sg: result = verify_ip_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1, data["iif"], data["oil"], ) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) result = verify_upstream_iif(tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) for data in input_dict_starg: result = verify_ip_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1, data["iif"], data["oil"], ) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) result = verify_upstream_iif(tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Delete static routes RP on all the nodes") input_dict = { "c2": { "static_routes": [{ "network": ["1.0.4.11/32"], "next_hop": "10.0.3.2", "delete": True }] }, "c1": { "static_routes": [{ "network": ["1.0.4.11/32"], "next_hop": "10.0.2.2", "delete": True }] }, "r2": { "static_routes": [{ "network": ["1.0.4.11/32"], "next_hop": "10.0.12.1", "delete": True }] }, "f1": { "static_routes": [{ "network": ["1.0.4.11/32"], "next_hop": "10.0.7.2", "delete": True }] }, } result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format( tc_name, result) step("Verify RP info unknown after removing static route from c2 ") dut = "c2" rp_address = topo["routers"]["l1"]["links"]["lo"]["ipv4"].split("/")[0] SOURCE = "Static" result = verify_pim_rp_info(tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) for data in input_dict_starg: result = verify_ip_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1, data["iif"], data["oil"], expected=False, ) assert ( result is not True ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format( tc_name, result) result = verify_upstream_iif( tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1, expected=False, ) assert ( result is not True ), "Testcase {} : Failed \n " "upstream is still present \n Error: {}".format( tc_name, result) step("Configure default routes on all the nodes") intf_f1_c2 = topo["routers"]["f1"]["links"]["c2"]["ipv4"].split("/")[0] intf_l1_c1 = topo["routers"]["l1"]["links"]["c1"]["ipv4"].split("/")[0] intf_l1_r2 = topo["routers"]["l1"]["links"]["r2"]["ipv4"].split("/")[0] intf_r2_f1 = topo["routers"]["r2"]["links"]["f1"]["ipv4"].split("/")[0] input_dict = { "c1": { "static_routes": [{ "network": "0.0.0.0/0", "next_hop": intf_l1_c1 }] }, "c2": { "static_routes": [{ "network": "0.0.0.0/0", "next_hop": intf_f1_c2 }] }, "r2": { "static_routes": [{ "network": "0.0.0.0/0", "next_hop": intf_l1_r2 }] }, "f1": { "static_routes": [{ "network": "0.0.0.0/0", "next_hop": intf_r2_f1 }] }, } result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format( tc_name, result) step("applying ip nht config on c2") raw_config = { "c1": { "raw_config": ["ip nht resolve-via-default"] }, "c2": { "raw_config": ["ip nht resolve-via-default"] }, "r2": { "raw_config": ["ip nht resolve-via-default"] }, "f1": { "raw_config": ["ip nht resolve-via-default"] }, "l1": { "raw_config": ["ip nht resolve-via-default"] }, } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Verify RP info Not unknown after removing static route from c2 ") dut = "c2" step("Verify RP info is NOT unknown after removing static route from c2 ") result = verify_pim_rp_info(tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE, expected=False) assert result is not True, ( "Testcase {} : Failed \n " "RP info is unknown after removing static route from c2 \n Error: {}". format(tc_name, result)) step("Verify (s,g) populated after adding default route ") for data in input_dict_sg: result = verify_ip_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1, data["iif"], data["oil"], ) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) result = verify_upstream_iif(tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Verify (*,g) populated after adding default route ") for data in input_dict_starg: result = verify_ip_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1, data["iif"], data["oil"], ) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) result = verify_upstream_iif(tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) write_test_footer(tc_name)
def test_PIM_hello_tx_rx_p1(request): """ TC_54 Verify received and transmit hello stats are getting cleared after PIM nbr reset """ tgen = get_topogen() tc_name = request.node.name write_test_header(tc_name) # Creating configuration from JSON kill_iperf(tgen) clear_ip_mroute(tgen) reset_config_on_routers(tgen) clear_ip_pim_interface_traffic(tgen, topo) # Don"t run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) step("Remove c1-c2 connected link to simulate topo " "c1(LHR)---l1(RP)----r2---f1-----c2(FHR)") intf_c1_c2 = topo["routers"]["c1"]["links"]["c2"]["interface"] intf_c2_c1 = topo["routers"]["c2"]["links"]["c1"]["interface"] shutdown_bringup_interface(tgen, "c1", intf_c1_c2, False) shutdown_bringup_interface(tgen, "c2", intf_c2_c1, False) step("Enable the PIM on all the interfaces of FRR1, FRR2, FRR3") step("Enable IGMP of FRR1 interface and send IGMP joins " " from FRR1 node for group range (225.1.1.1-5)") intf_c1_i4 = topo["routers"]["c1"]["links"]["i4"]["interface"] input_dict = { "c1": { "igmp": { "interfaces": { intf_c1_i4: { "igmp": { "version": "2" } } } } } } result = create_igmp_config(tgen, topo, input_dict) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) input_join = {"i4": topo["routers"]["i4"]["links"]["c1"]["interface"]} for recvr, recvr_intf in input_join.items(): result = config_to_send_igmp_join_and_traffic(tgen, topo, tc_name, recvr, recvr_intf, GROUP_RANGE_1, join=True) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) result = iperfSendIGMPJoin(tgen, recvr, IGMP_JOIN_RANGE_1, join_interval=1) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) step("Configure static RP for (225.1.1.1-5) as R2") input_dict = { "l1": { "pim": { "rp": [{ "rp_addr": topo["routers"]["l1"]["links"]["lo"]["ipv4"].split("/")[0], "group_addr_range": GROUP_RANGE, }] } } } result = create_pim_config(tgen, topo, input_dict) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step( "Send Mcast traffic from C2 to all the groups ( 225.1.1.1 to 225.1.1.5)" ) input_src = {"i5": topo["routers"]["i5"]["links"]["c2"]["interface"]} for src, src_intf in input_src.items(): result = config_to_send_igmp_join_and_traffic(tgen, topo, tc_name, src, src_intf, GROUP_RANGE_1, traffic=True) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) result = iperfSendTraffic(tgen, src, IGMP_JOIN_RANGE_1, 32, 2500) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) source_i5 = topo["routers"]["i5"]["links"]["c2"]["ipv4"].split("/")[0] input_dict_starg = [{ "dut": "c1", "src_address": "*", "iif": topo["routers"]["c1"]["links"]["l1"]["interface"], "oil": topo["routers"]["c1"]["links"]["i4"]["interface"], }] input_dict_sg = [{ "dut": "c1", "src_address": source_i5, "iif": topo["routers"]["c1"]["links"]["l1"]["interface"], "oil": topo["routers"]["c1"]["links"]["i4"]["interface"], }] step( "(*,G) and (S,G) created on f1 and node verify using 'show ip mroute'") for data in input_dict_sg: result = verify_ip_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1, data["iif"], data["oil"], ) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) for data in input_dict_starg: result = verify_ip_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1, data["iif"], data["oil"], ) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) intf_l1_c1 = topo["routers"]["l1"]["links"]["c1"]["interface"] intf_c1_l1 = topo["routers"]["c1"]["links"]["l1"]["interface"] step("verify before stats on C1") state_dict = { "c1": { intf_c1_l1: ["helloTx", "helloRx"], } } c1_state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( c1_state_before, dict), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(tc_name, result) step( "Flap PIM nbr while doing interface c1-l1 interface shut from f1 side") shutdown_bringup_interface(tgen, "c1", intf_c1_l1, False) step( "After shut of local interface from c1 , verify rx/tx hello counters are cleared on c1 side" "verify using 'show ip pim interface traffic'") shutdown_bringup_interface(tgen, "c1", intf_c1_l1, True) step("verify stats after on c1") c1_state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( c1_state_after, dict), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(tc_name, result) step("verify stats not increamented on c1") result = verify_state_incremented(c1_state_before, c1_state_after) assert (result is not True ), "Testcase{} : Failed Error: {}" "stats incremented".format( tc_name, result) step("verify before stats on l1") l1_state_dict = { "l1": { intf_l1_c1: ["helloTx", "helloRx"], } } l1_state_before = verify_pim_interface_traffic(tgen, l1_state_dict) assert isinstance( l1_state_before, dict), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(tc_name, result) step("Flap PIM nbr while doing interface r2-c1 shut from r2 side") shutdown_bringup_interface(tgen, "l1", intf_l1_c1, False) step( "After shut the interface from r2 side , verify r2 side rx and tx of hello" "counters are resetted show ip pim interface traffic") shutdown_bringup_interface(tgen, "l1", intf_l1_c1, True) step("verify stats after on l1") l1_state_after = verify_pim_interface_traffic(tgen, l1_state_dict) assert isinstance( l1_state_after, dict), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(tc_name, result) step("verify stats not increamented on l1") result = verify_state_incremented(l1_state_before, l1_state_after) assert (result is not True ), "Testcase{} : Failed Error: {}" "stats incremented".format( tc_name, result) step("Reinit the dict") c1_state_before = {} l1_state_before = {} c1_state_after = {} l1_state_after = {} step("verify before stats on C1") state_dict = { "c1": { intf_c1_l1: ["helloTx", "helloRx"], } } c1_state_before = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( c1_state_before, dict), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(tc_name, result) step("Flap c1-r2 pim nbr while changing ip address from c1 side") c1_l1_ip_subnet = topo["routers"]["c1"]["links"]["l1"]["ipv4"] raw_config = { "c1": { "raw_config": [ "interface {}".format(intf_c1_l1), "no ip address {}".format(c1_l1_ip_subnet), "ip address {}".format(NEW_ADDRESS_2_SUBNET), ] } } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("verify stats after on c1") c1_state_after = verify_pim_interface_traffic(tgen, state_dict) assert isinstance( c1_state_after, dict), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(tc_name, result) step("verify stats not increamented on c1") result = verify_state_incremented(c1_state_before, c1_state_after) assert (result is not True ), "Testcase{} : Failed Error: {}" "stats incremented".format( tc_name, result) write_test_footer(tc_name)
def test_dynamic_import_ecmp_imported_routed_diffrent_vrfs_p0(request): """ Verify ECMP for imported routes from different VRFs. """ tgen = get_topogen() tc_name = request.node.name write_test_header(tc_name) if tgen.routers_have_failure(): check_router_status(tgen) reset_config_on_routers(tgen) step("Configure same static routes in tenant vrfs RED and GREEN on router " "R3 and redistribute in respective BGP process") for vrf_name in ["RED", "GREEN"]: for addr_type in ADDR_TYPES: if vrf_name == "GREEN": next_hop_vrf = topo["routers"]["r1"]["links"]["r3-link3"][ addr_type].split("/")[0] else: next_hop_vrf = topo["routers"]["r2"]["links"]["r3-link1"][ addr_type].split("/")[0] static_routes = { "r3": { "static_routes": [{ "network": [NETWORK1_1[addr_type]], "next_hop": next_hop_vrf, "vrf": vrf_name }] } } result = create_static_routes(tgen, static_routes) assert result is True, "Testcase {} :Failed \n Error: {}". \ format(tc_name, result) step("Redistribute static route on BGP VRF : {}".format(vrf_name)) temp = {} for addr_type in ADDR_TYPES: temp.update({ addr_type: { "unicast": { "redistribute": [{ "redist_type": "static" }] } } }) redist_dict = { "r3": { "bgp": [{ "vrf": vrf_name, "local_as": 3, "address_family": temp }] } } result = create_router_bgp(tgen, topo, redist_dict) assert result is True, "Testcase {} :Failed \n Error: {}". \ format(tc_name, result) step("Verify that configured static routes are installed in respective " "BGP table for vrf RED & GREEN") for vrf_name in ["RED", "GREEN"]: for addr_type in ADDR_TYPES: if vrf_name == "GREEN": next_hop_vrf = topo["routers"]["r1"]["links"]["r3-link3"][ addr_type].split("/")[0] else: next_hop_vrf = topo["routers"]["r2"]["links"]["r3-link1"][ addr_type].split("/")[0] static_routes = { "r3": { "static_routes": [{ "network": [NETWORK1_1[addr_type]], "vrf": vrf_name }] } } result = verify_bgp_rib(tgen, addr_type, "r3", static_routes, next_hop=next_hop_vrf) assert result is True, "Testcase {} : Failed \n Error {}". \ format(tc_name, result) result = verify_rib(tgen, addr_type, "r3", static_routes, next_hop=next_hop_vrf) assert result is True, "Testcase {} : Failed \n Error {}". \ format(tc_name, result) step("Import vrf RED and GREEN into default vrf and Configure ECMP") bgp_val = [] for vrf_name in ["RED", "GREEN"]: temp = {} for addr_type in ADDR_TYPES: temp.update({ addr_type: { "unicast": { "import": { "vrf": vrf_name }, "maximum_paths": { "ebgp": 2 } } } }) bgp_val.append({"local_as": 3, "address_family": temp}) import_dict = {"r3": {"bgp": bgp_val}} result = create_router_bgp(tgen, topo, import_dict) assert result is True, "Testcase {} :Failed \n Error: {}". \ format(tc_name, result) step("Configure bgp bestpath on router r3") r3_raw_config = { "r3": { "raw_config": ["router bgp 3", "bgp bestpath as-path multipath-relax"] } } result = apply_raw_config(tgen, r3_raw_config) assert result is True, "Testcase {} :Failed \n Error: {}". \ format(tc_name, result) step("Verify that routes are imported with two different next-hop vrfs " "and IPs. Additionally R3 must do ECMP for both the routes.") for addr_type in ADDR_TYPES: next_hop_vrf = [ topo["routers"]["r2"]["links"]["r3-link1"][addr_type]. \ split("/")[0], topo["routers"]["r1"]["links"]["r3-link3"][addr_type]. \ split("/")[0] ] static_routes = { "r3": { "static_routes": [{ "network": [NETWORK1_1[addr_type]], }] } } result = verify_bgp_rib(tgen, addr_type, "r3", static_routes, next_hop=next_hop_vrf) assert result is True, "Testcase {} : Failed \n Error {}". \ format(tc_name, result) result = verify_rib(tgen, addr_type, "r3", static_routes, next_hop=next_hop_vrf) assert result is True, "Testcase {} : Failed \n Error {}". \ format(tc_name, result) step("Now change the next-hop of static routes in vrf RED and GREEN to " "same IP address") for addr_type in ADDR_TYPES: next_hop_vrf = topo["routers"]["r1"]["links"]["r3-link3"][ addr_type].split("/")[0] static_routes = { "r3": { "static_routes": [{ "network": [NETWORK1_1[addr_type]], "next_hop": next_hop_vrf, "vrf": "RED" }, { "network": [NETWORK1_1[addr_type]], "next_hop": topo["routers"]["r2"]["links"]["r3-link1"] [addr_type].split("/")[0], "vrf": "RED", "delete": True }] } } result = create_static_routes(tgen, static_routes) assert result is True, "Testcase {} :Failed \n Error: {}". \ format(tc_name, result) step("Verify that now routes are imported with two different next-hop " "vrfs but same IPs. Additionally R3 must do ECMP for both the routes") for addr_type in ADDR_TYPES: next_hop_vrf = [ topo["routers"]["r1"]["links"]["r3-link3"][addr_type].\ split("/")[0], topo["routers"]["r1"]["links"]["r3-link3"][addr_type]. \ split("/")[0] ] static_routes = { "r3": { "static_routes": [{ "network": [NETWORK1_1[addr_type]], }] } } result = verify_bgp_rib(tgen, addr_type, "r3", static_routes, next_hop=next_hop_vrf) assert result is True, "Testcase {} : Failed \n Error {}". \ format(tc_name, result) result = verify_rib(tgen, addr_type, "r3", static_routes, next_hop=next_hop_vrf) assert result is True, "Testcase {} : Failed \n Error {}". \ format(tc_name, result) write_test_footer(tc_name)
def test_ecmp_fast_convergence(request, test_type, tgen, topo): """This test is to verify bgp fast-convergence cli functionality""" tc_name = request.node.name write_test_header(tc_name) # Verifying RIB routes dut = "r3" protocol = "bgp" reset_config_on_routers(tgen) static_or_nw(tgen, topo, tc_name, test_type, "r2") for addr_type in ADDR_TYPES: input_dict = { "r3": { "static_routes": [{ "network": NETWORK[addr_type] }] } } logger.info("Verifying %s routes on r3", addr_type) result = verify_rib( tgen, addr_type, dut, input_dict, protocol=protocol, ) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) intf1 = topo["routers"]["r2"]["links"]["r3-link1"]["interface"] intf2 = topo["routers"]["r2"]["links"]["r3-link2"]["interface"] logger.info("Shutdown one of the link b/w r2 and r3") shutdown_bringup_interface(tgen, "r2", intf1, False) logger.info("Verify bgp neighbors are still up") result = verify_bgp_convergence(tgen, topo) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) logger.info("Shutdown another link b/w r2 and r3") shutdown_bringup_interface(tgen, "r2", intf2, False) logger.info("Wait for 10 sec and make sure bgp neighbors are still up") sleep(10) result = verify_bgp_convergence(tgen, topo) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) logger.info("No shut links b/w r2 and r3") shutdown_bringup_interface(tgen, "r2", intf1, True) shutdown_bringup_interface(tgen, "r2", intf2, True) logger.info("Ensure that the links are still up") result = verify_bgp_convergence(tgen, topo) logger.info("Enable bgp fast-convergence cli") raw_config = { "r2": { "raw_config": [ "router bgp {}".format( topo["routers"]["r2"]["bgp"]["local_as"]), "bgp fast-convergence", ] } } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) logger.info("Ensure BGP has processed the cli") r2 = tgen.gears["r2"] output = r2.vtysh_cmd("show run") verify = re.search(r"fast-convergence", output) assert verify is not None, ( "r2 does not have the fast convergence command yet") logger.info("Shutdown one link b/w r2 and r3") shutdown_bringup_interface(tgen, "r2", intf1, False) logger.info("Verify bgp neighbors goes down immediately") result = verify_bgp_convergence(tgen, topo, dut="r2", expected=False) assert result is not True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) logger.info("Shutdown second link b/w r2 and r3") shutdown_bringup_interface(tgen, "r2", intf2, False) logger.info("Verify bgp neighbors goes down immediately") result = verify_bgp_convergence(tgen, topo, dut="r2", expected=False) assert result is not True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name)
def test_configuring_igmp_local_join_on_reciever_dr_non_dr_nodes_p1(request): """ Configure IGMP local join on DR and non DR """ tgen = get_topogen() tc_name = request.node.name write_test_header(tc_name) # Creating configuration from JSON app_helper.stop_all_hosts() clear_mroute(tgen) check_router_status(tgen) reset_config_on_routers(tgen) clear_pim_interface_traffic(tgen, topo) # Don"t run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) step("Configure IGMP and PIM on switch connected receiver nodes") step("Configure PIM on all upstream interfaces") step("Configure link between R1, R2 ,R3 and receiver on" " same vlan") step("Make sure R1 is DR initially configuring highest IP on R1 and R2 " "second highest, R1 is lower") intf_r1_s1 = topo["routers"]["r1"]["links"]["s1"]["interface"] intf_r1_s1_addr = topo["routers"]["r1"]["links"]["s1"]["ipv4"] intf_r2_s1 = topo["routers"]["r2"]["links"]["s1"]["interface"] intf_r2_s1_addr = topo["routers"]["r2"]["links"]["s1"]["ipv4"] intf_i1_s1 = topo["routers"]["i1"]["links"]["s1"]["interface"] intf_i1_s1_addr = topo["routers"]["i1"]["links"]["s1"]["ipv4"] vlan_input = { "r1": { "vlan": { VLAN_1: [{ intf_r1_s1: { "ip": SAME_VLAN_IP_1["ip"], "subnet": SAME_VLAN_IP_1["subnet"], } }] } }, "r2": { "vlan": { VLAN_1: [{ intf_r2_s1: { "ip": SAME_VLAN_IP_2["ip"], "subnet": SAME_VLAN_IP_2["subnet"], } }] } }, "i1": { "vlan": { VLAN_1: [{ intf_i1_s1: { "ip": SAME_VLAN_IP_4["ip"], "subnet": SAME_VLAN_IP_4["subnet"], } }] } }, } add_interfaces_to_vlan(tgen, vlan_input) raw_config = { "r1": { "raw_config": [ "interface {}".format(intf_r1_s1), "no ip address {}".format(intf_r1_s1_addr), "no ip pim", ] }, "r2": { "raw_config": [ "interface {}".format(intf_r2_s1), "no ip address {}".format(intf_r2_s1_addr), "no ip pim", ] }, "i1": { "raw_config": [ "interface {}".format(intf_i1_s1), "no ip address {}".format(intf_i1_s1_addr), ] }, } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) raw_config = { "r1": { "raw_config": [ "interface {}.{}".format(intf_r1_s1, VLAN_1), "ip address {}/{}".format(SAME_VLAN_IP_1["ip"], SAME_VLAN_IP_1["cidr"]), "ip pim", "ip igmp", "ip igmp version 2", ] }, "r2": { "raw_config": [ "interface {}.{}".format(intf_r2_s1, VLAN_1), "ip address {}/{}".format(SAME_VLAN_IP_2["ip"], SAME_VLAN_IP_2["cidr"]), "ip pim", "ip igmp", "ip igmp version 2", ] }, "i1": { "raw_config": [ "interface {}.{}".format(intf_i1_s1, VLAN_1), "ip address {}/{}".format(SAME_VLAN_IP_4["ip"], SAME_VLAN_IP_4["cidr"]), ] }, } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) for dut, intf in zip(["r1", "r2"], [intf_r1_s1, intf_r2_s1]): raw_config = { dut: { "raw_config": [ "interface {}.{}".format(intf, VLAN_1), "ip pim hello {} {}".format(HELLO_TIMER, HOLD_TIMER), ] } } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Configure R4 as RP on all the nodes for group range 224.0.0.0/24") input_dict = { "r4": { "pim": { "rp": [{ "rp_addr": topo["routers"]["r4"]["links"]["lo"]["ipv4"].split("/")[0], "group_addr_range": GROUP_RANGE_1 + GROUP_RANGE_3, }] } } } result = create_pim_config(tgen, topo, input_dict) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Send IGMP local join for groups 226.1.1.1 to 226.1.1.5") vlan_intf_r1_s1 = "{}.{}".format(intf_r1_s1, VLAN_1) input_dict = { "r1": { "igmp": { "interfaces": { vlan_intf_r1_s1: { "igmp": { "version": "2", "join": IGMP_JOIN_RANGE_1 } } } } } } result = create_igmp_config(tgen, topo, input_dict) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) step("Enable OSPF between all the nodes") step("Configure local join on R1 for group range (227.1.1.1)") vlan_intf_r1_s1 = "{}.{}".format(intf_r1_s1, VLAN_1) input_dict = { "r1": { "igmp": { "interfaces": { vlan_intf_r1_s1: { "igmp": { "version": "2", "join": IGMP_JOIN_RANGE_3 } } } } } } result = create_igmp_config(tgen, topo, input_dict) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) step("Start traffic from R4 connected source") input_src = {"i2": topo["routers"]["i2"]["links"]["r5"]["interface"]} result = app_helper.run_traffic("i2", IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3, "r5") assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("R1, R2 and R2 has IGMP groups for 226.x.x.x and 227.1.1.1 groups") intf_r1_s1 = "{}.{}".format( topo["routers"]["r1"]["links"]["s1"]["interface"], VLAN_1) intf_r2_s1 = "{}.{}".format( topo["routers"]["r2"]["links"]["s1"]["interface"], VLAN_1) for dut, intf in zip(["r1", "r2"], [intf_r1_s1, intf_r2_s1]): result = verify_igmp_groups(tgen, dut, intf, IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("R1 is DR, R2 has 226.x.x.x and 227.1.1.1 (*,G) mroute with SC flag") step("(S,G) mroute for 226.1.1.1 group present on R2") source_i2 = topo["routers"]["i2"]["links"]["r5"]["ipv4"].split("/")[0] input_dict_r2 = [{ "dut": "r2", "src_address": "*", "iif": topo["routers"]["r2"]["links"]["r4"]["interface"], "oil": "{}.{}".format(topo["routers"]["r2"]["links"]["s1"]["interface"], VLAN_1), }] for data in input_dict_r2: result = verify_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3, data["iif"], data["oil"], ) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) for dut, flag in zip(["r2"], ["SC"]): step("{} has (*,G) flag as {}".format(dut, flag)) result = verify_multicast_flag_state(tgen, dut, "*", IGMP_JOIN_RANGE_1, flag) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Delete local join from DR node") for _join in IGMP_JOIN_RANGE_3: input_dict = { "r1": { "igmp": { "interfaces": { vlan_intf_r1_s1: { "igmp": { "join": [_join], "delete_attr": True, } } } } } } result = create_igmp_config(tgen, topo, input_dict) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) step( "After removing local join 227.1.1.1 group removed from IGMP join " "of R1, R2 node , using 'show ip igmp groups json'") for dut, intf in zip(["r1", "r2"], [intf_r1_s1, intf_r2_s1]): result = verify_igmp_groups(tgen, dut, intf, IGMP_JOIN_RANGE_3, expected=False) assert result is not True, ( "Testcase {} : Failed \n " "IGMP groups are still present \n Error: {}".format( tc_name, result)) step("(*,G) mroute for 227.1.1.1 group removed from R1 node") step( "After remove of local join from R1 and R2 node verify (*,G) and (S,G) " "mroutes should not present on R1, R2 and R3 nodes") for data in input_dict_r2: result = verify_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1, data["iif"], data["oil"], ) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) result = verify_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_3, data["iif"], data["oil"], expected=False, ) assert ( result is not True ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format( tc_name, result) step("Configure local join on R2 for group range (227.1.1.1)") input_dict = { "r2": { "igmp": { "interfaces": { intf_r2_s1: { "igmp": { "version": "2", "join": IGMP_JOIN_RANGE_3 } } } } } } result = create_igmp_config(tgen, topo, input_dict) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) step( "After configuring local join on R2 non DR node, IGMP groups for 26.x.x.x and " "227.1.1.1 present on all the nodes") for dut, intf in zip(["r1", "r2"], [intf_r1_s1, intf_r2_s1]): result = verify_igmp_groups(tgen, dut, intf, IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("R2 has 227.1.1.1 (*,G) mroute with SC flag") for dut, flag in zip(["r2"], ["SC"]): step("{} has (*,G) flag as {}".format(dut, flag)) result = verify_multicast_flag_state(tgen, dut, "*", IGMP_JOIN_RANGE_3, flag) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("Configure local join on R1 for group range (227.1.1.1)") input_dict = { "r1": { "igmp": { "interfaces": { vlan_intf_r1_s1: { "igmp": { "version": "2", "join": IGMP_JOIN_RANGE_3 } } } } } } result = create_igmp_config(tgen, topo, input_dict) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) step( "After configuring 227.1.1.1 on R1 node, verify no change on IGMP groups on all the nodes" ) for dut, intf in zip(["r1", "r2"], [intf_r1_s1, intf_r2_s1]): result = verify_igmp_groups(tgen, dut, intf, IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3) assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("R2 has 227.1.1.1 (*,G) mroute with SC flag") step("r2 has (*,G) flag as SC") result = verify_multicast_flag_state(tgen, "r2", "*", IGMP_JOIN_RANGE_3, "SC") assert result is True, "Testcase {} : Failed Error: {}".format( tc_name, result) step("R1 should not have (*,G) join and (S,G) join present") input_dict_r1 = [ { "dut": "r1", "src_address": "*", "iif": topo["routers"]["r1"]["links"]["r4"]["interface"], "oil": "{}.{}".format(topo["routers"]["r1"]["links"]["s1"]["interface"], VLAN_1), }, { "dut": "r1", "src_address": source_i2, "iif": topo["routers"]["r1"]["links"]["r4"]["interface"], "oil": "{}.{}".format(topo["routers"]["r1"]["links"]["s1"]["interface"], VLAN_1), }, ] for data in input_dict_r1: result = verify_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3, data["iif"], data["oil"], expected=False, ) assert ( result is not True ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format( tc_name, result) step("Remove local join from DR and Non DR node") input_dict = { "r1": { "igmp": { "interfaces": { vlan_intf_r1_s1: { "igmp": { "version": "2", "join": IGMP_JOIN_RANGE_3, "delete_attr": True, } } } } }, "r2": { "igmp": { "interfaces": { intf_r2_s1: { "igmp": { "version": "2", "join": IGMP_JOIN_RANGE_3, "delete_attr": True, } } } } }, } result = create_igmp_config(tgen, topo, input_dict) assert result is True, "Testcase {}: Failed Error: {}".format( tc_name, result) step( "After remove of local join from R1 and R2 node verify (*,G) and (S,G) mroutes " "should not present on R1, R2 nodes") for data in input_dict_r1: result = verify_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3, data["iif"], data["oil"], expected=False, ) assert ( result is not True ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format( tc_name, result) for data in input_dict_r2: result = verify_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3, data["iif"], data["oil"], expected=False, ) assert ( result is not True ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format( tc_name, result) write_test_footer(tc_name)
def test_mroute_when_transit_router_present_between_rp_and_source_dr_p1(request): """ Verify mroutes when transit router present between RP and Source DR """ tgen = get_topogen() tc_name = request.node.name write_test_header(tc_name) # Creating configuration from JSON app_helper.stop_all_hosts() clear_mroute(tgen) check_router_status(tgen) reset_config_on_routers(tgen) clear_pim_interface_traffic(tgen, topo) # Don"t run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) result = pre_config_for_source_dr_tests(tgen, topo, tc_name, "r1", "r2") assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) step("Taken care in base config: Add router R6 between RP and R1 , R2") step("R1 is the DR, mroute and upstream created on R1") vlan_intf_r1_s1 = "{}.{}".format(intf_r1_s1, VLAN_1) input_dict_dr = { "r1": { "pim": { "interfaces": {vlan_intf_r1_s1: {"drAddress": SAME_VLAN_IP_2["ip"]}} } } } result = verify_pim_config(tgen, input_dict_dr) assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) step("On R1 Mroute OIL towards R6, upstream in join Rej Prune state") source_i1 = SAME_VLAN_IP_4["ip"] input_dict_r1 = [ { "dut": "r1", "src_address": source_i1, "oil": topo["routers"]["r1"]["links"]["r6"]["interface"], "iif": "{}.{}".format( topo["routers"]["r1"]["links"]["s1"]["interface"], VLAN_1 ), } ] for data in input_dict_r1: result = verify_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1, data["iif"], data["oil"], ) assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) result = verify_upstream_iif( tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1 ) assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) step( "R5 have mroute created and traffic is received, verify using " "'show ip mroute json' 'show ip multicast json'" ) input_dict_r5 = [ { "dut": "r5", "src_address": "*", "iif": topo["routers"]["r5"]["links"]["r4"]["interface"], "oil": topo["routers"]["r5"]["links"]["i2"]["interface"], }, { "dut": "r5", "src_address": source_i1, "iif": topo["routers"]["r5"]["links"]["r4"]["interface"], "oil": topo["routers"]["r5"]["links"]["i2"]["interface"], }, ] for data in input_dict_r5: result = verify_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1, data["iif"], data["oil"], ) assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) input_dict_traffic_r5 = { "r5": { "traffic_received": [topo["routers"]["r5"]["links"]["r4"]["interface"]], "traffic_sent": [topo["routers"]["r5"]["links"]["i2"]["interface"]], } } result = verify_multicast_traffic(tgen, input_dict_traffic_r5) assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) step("Make R2 as DR configuring higher priority value") raw_config = { "r1": { "raw_config": [ "interface {}.{}".format(intf_r1_s1, VLAN_1), "no ip address {}/{}".format( SAME_VLAN_IP_2["ip"], SAME_VLAN_IP_1["cidr"] ), "ip address {}/{}".format(SAME_VLAN_IP_1["ip"], SAME_VLAN_IP_1["cidr"]), ] }, "r2": { "raw_config": [ "interface {}.{}".format(intf_r2_s1, VLAN_1), "no ip address {}/{}".format( SAME_VLAN_IP_1["ip"], SAME_VLAN_IP_1["cidr"] ), "ip address {}/{}".format(SAME_VLAN_IP_2["ip"], SAME_VLAN_IP_2["cidr"]), ] }, } result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) step("R2 is the DR, mroute and upstream created on R2") vlan_intf_r2_s1 = "{}.{}".format(intf_r2_s1, VLAN_1) input_dict_dr = { "r2": { "pim": { "interfaces": {vlan_intf_r2_s1: {"drAddress": SAME_VLAN_IP_2["ip"]}} } } } result = verify_pim_config(tgen, input_dict_dr) assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) step( "R5 have mroute created and traffic is received, verify using " "'show ip mroute json' 'show ip multicast json'" ) for data in input_dict_r5: result = verify_mroutes( tgen, data["dut"], data["src_address"], IGMP_JOIN_RANGE_1, data["iif"], data["oil"], ) assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) result = verify_multicast_traffic(tgen, input_dict_traffic_r5) assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) write_test_footer(tc_name)
def test_bgp_with_loopback_with_same_subnet_p1(request): """ Verify routes not installed in zebra when /32 routes received with loopback BGP session subnet """ tgen = get_topogen() if BGP_CONVERGENCE is not True: pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = request.node.name write_test_header(tc_name) # Creating configuration from JSON reset_config_on_routers(tgen) step("Delete BGP seesion created initially") input_dict_r1 = { "r1": {"bgp": {"delete": True}}, "r2": {"bgp": {"delete": True}}, "r3": {"bgp": {"delete": True}}, "r4": {"bgp": {"delete": True}}, } result = create_router_bgp(tgen, topo, input_dict_r1) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) step("Create BGP session over loop address") topo_modify = deepcopy(topo) for routerN in sorted(topo["routers"].keys()): for addr_type in ADDR_TYPES: for bgp_neighbor in topo_modify["routers"][routerN]["bgp"][ "address_family" ][addr_type]["unicast"]["neighbor"].keys(): # Adding ['source_link'] = 'lo' key:value pair topo_modify["routers"][routerN]["bgp"]["address_family"][addr_type][ "unicast" ]["neighbor"][bgp_neighbor]["dest_link"] = { "lo": {"source_link": "lo", "ebgp_multihop": 2} } result = create_router_bgp(tgen, topo_modify["routers"]) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) step("Disable IPv6 BGP nbr from ipv4 address family") raw_config = { "r1": { "raw_config": [ "router bgp {}".format(topo["routers"]["r1"]["bgp"]["local_as"]), "address-family ipv4 unicast", "no neighbor {} activate".format( topo["routers"]["r2"]["links"]["lo"]["ipv6"].split("/")[0] ), "no neighbor {} activate".format( topo["routers"]["r3"]["links"]["lo"]["ipv6"].split("/")[0] ), ] }, "r2": { "raw_config": [ "router bgp {}".format(topo["routers"]["r2"]["bgp"]["local_as"]), "address-family ipv4 unicast", "no neighbor {} activate".format( topo["routers"]["r1"]["links"]["lo"]["ipv6"].split("/")[0] ), "no neighbor {} activate".format( topo["routers"]["r3"]["links"]["lo"]["ipv6"].split("/")[0] ), ] }, "r3": { "raw_config": [ "router bgp {}".format(topo["routers"]["r3"]["bgp"]["local_as"]), "address-family ipv4 unicast", "no neighbor {} activate".format( topo["routers"]["r1"]["links"]["lo"]["ipv6"].split("/")[0] ), "no neighbor {} activate".format( topo["routers"]["r2"]["links"]["lo"]["ipv6"].split("/")[0] ), "no neighbor {} activate".format( topo["routers"]["r4"]["links"]["lo"]["ipv6"].split("/")[0] ), ] }, "r4": { "raw_config": [ "router bgp {}".format(topo["routers"]["r4"]["bgp"]["local_as"]), "address-family ipv4 unicast", "no neighbor {} activate".format( topo["routers"]["r3"]["links"]["lo"]["ipv6"].split("/")[0] ), ] }, } step("Configure kernel routes") result = apply_raw_config(tgen, raw_config) assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) r1_ipv4_lo = topo["routers"]["r1"]["links"]["lo"]["ipv4"] r1_ipv6_lo = topo["routers"]["r1"]["links"]["lo"]["ipv6"] r2_ipv4_lo = topo["routers"]["r2"]["links"]["lo"]["ipv4"] r2_ipv6_lo = topo["routers"]["r2"]["links"]["lo"]["ipv6"] r3_ipv4_lo = topo["routers"]["r3"]["links"]["lo"]["ipv4"] r3_ipv6_lo = topo["routers"]["r3"]["links"]["lo"]["ipv6"] r4_ipv4_lo = topo["routers"]["r4"]["links"]["lo"]["ipv4"] r4_ipv6_lo = topo["routers"]["r4"]["links"]["lo"]["ipv6"] r1_r2 = topo["routers"]["r1"]["links"]["r2"]["ipv6"].split("/")[0] r2_r1 = topo["routers"]["r2"]["links"]["r1"]["ipv6"].split("/")[0] r1_r3 = topo["routers"]["r1"]["links"]["r3"]["ipv6"].split("/")[0] r3_r1 = topo["routers"]["r3"]["links"]["r1"]["ipv6"].split("/")[0] r2_r3 = topo["routers"]["r2"]["links"]["r3"]["ipv6"].split("/")[0] r3_r2 = topo["routers"]["r3"]["links"]["r2"]["ipv6"].split("/")[0] r3_r4 = topo["routers"]["r3"]["links"]["r4"]["ipv6"].split("/")[0] r4_r3 = topo["routers"]["r4"]["links"]["r3"]["ipv6"].split("/")[0] r1_r2_ipv4 = topo["routers"]["r1"]["links"]["r2"]["ipv4"].split("/")[0] r2_r1_ipv4 = topo["routers"]["r2"]["links"]["r1"]["ipv4"].split("/")[0] r1_r3_ipv4 = topo["routers"]["r1"]["links"]["r3"]["ipv4"].split("/")[0] r3_r1_ipv4 = topo["routers"]["r3"]["links"]["r1"]["ipv4"].split("/")[0] r2_r3_ipv4 = topo["routers"]["r2"]["links"]["r3"]["ipv4"].split("/")[0] r3_r2_ipv4 = topo["routers"]["r3"]["links"]["r2"]["ipv4"].split("/")[0] r3_r4_ipv4 = topo["routers"]["r3"]["links"]["r4"]["ipv4"].split("/")[0] r4_r3_ipv4 = topo["routers"]["r4"]["links"]["r3"]["ipv4"].split("/")[0] r1_r2_intf = topo["routers"]["r1"]["links"]["r2"]["interface"] r2_r1_intf = topo["routers"]["r2"]["links"]["r1"]["interface"] r1_r3_intf = topo["routers"]["r1"]["links"]["r3"]["interface"] r3_r1_intf = topo["routers"]["r3"]["links"]["r1"]["interface"] r2_r3_intf = topo["routers"]["r2"]["links"]["r3"]["interface"] r3_r2_intf = topo["routers"]["r3"]["links"]["r2"]["interface"] r3_r4_intf = topo["routers"]["r3"]["links"]["r4"]["interface"] r4_r3_intf = topo["routers"]["r4"]["links"]["r3"]["interface"] ipv4_list = [ ("r1", r1_r2_intf, r2_ipv4_loopback), ("r1", r1_r3_intf, r3_ipv4_loopback), ("r2", r2_r1_intf, r1_ipv4_loopback), ("r2", r2_r3_intf, r3_ipv4_loopback), ("r3", r3_r1_intf, r1_ipv4_loopback), ("r3", r3_r2_intf, r2_ipv4_loopback), ("r3", r3_r4_intf, r4_ipv4_loopback), ("r4", r4_r3_intf, r3_ipv4_loopback), ] ipv6_list = [ ("r1", r1_r2_intf, r2_ipv6_loopback, r2_r1), ("r1", r1_r3_intf, r3_ipv6_loopback, r3_r1), ("r2", r2_r1_intf, r1_ipv6_loopback, r1_r2), ("r2", r2_r3_intf, r3_ipv6_loopback, r3_r2), ("r3", r3_r1_intf, r1_ipv6_loopback, r1_r3), ("r3", r3_r2_intf, r2_ipv6_loopback, r2_r3), ("r3", r3_r4_intf, r4_ipv6_loopback, r4_r3), ("r4", r4_r3_intf, r3_ipv6_loopback, r3_r4), ] for dut, intf, loop_addr in ipv4_list: result = addKernelRoute(tgen, dut, intf, loop_addr) assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) for dut, intf, loop_addr, next_hop in ipv6_list: result = addKernelRoute(tgen, dut, intf, loop_addr, next_hop) assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) step("Configure static routes") input_dict = { "r1": { "static_routes": [ {"network": r2_ipv4_loopback, "next_hop": r2_r1_ipv4}, {"network": r3_ipv4_loopback, "next_hop": r3_r1_ipv4}, {"network": r2_ipv6_loopback, "next_hop": r2_r1}, {"network": r3_ipv6_loopback, "next_hop": r3_r1}, ] }, "r2": { "static_routes": [ {"network": r1_ipv4_loopback, "next_hop": r1_r2_ipv4}, {"network": r3_ipv4_loopback, "next_hop": r3_r2_ipv4}, {"network": r1_ipv6_loopback, "next_hop": r1_r2}, {"network": r3_ipv6_loopback, "next_hop": r3_r2}, ] }, "r3": { "static_routes": [ {"network": r1_ipv4_loopback, "next_hop": r1_r3_ipv4}, {"network": r2_ipv4_loopback, "next_hop": r2_r3_ipv4}, {"network": r4_ipv4_loopback, "next_hop": r4_r3_ipv4}, {"network": r1_ipv6_loopback, "next_hop": r1_r3}, {"network": r2_ipv6_loopback, "next_hop": r2_r3}, {"network": r4_ipv6_loopback, "next_hop": r4_r3}, ] }, "r4": { "static_routes": [ {"network": r3_ipv4_loopback, "next_hop": r3_r4_ipv4}, {"network": r3_ipv6_loopback, "next_hop": r3_r4}, ] }, } result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("Verify BGP session convergence") result = verify_bgp_convergence(tgen, topo_modify) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("Configure redistribute connected on R2 and R4") input_dict_1 = { "r2": { "bgp": { "address_family": { "ipv4": { "unicast": {"redistribute": [{"redist_type": "connected"}]} }, "ipv6": { "unicast": {"redistribute": [{"redist_type": "connected"}]} }, } } }, "r4": { "bgp": { "address_family": { "ipv4": { "unicast": {"redistribute": [{"redist_type": "connected"}]} }, "ipv6": { "unicast": {"redistribute": [{"redist_type": "connected"}]} }, } } }, } result = create_router_bgp(tgen, topo, input_dict_1) assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) step("Verify Ipv4 and Ipv6 network installed in R1 RIB but not in FIB") input_dict_r1 = { "r1": { "static_routes": [ {"network": "1.0.2.17/32"}, {"network": "2001:db8:f::2:17/128"}, ] } } dut = "r1" protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict_r1, protocol=protocol) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result ) result = verify_fib_routes(tgen, addr_type, dut, input_dict_r1, expected=False) assert result is not True, "Testcase {} : Failed \n" "Expected behavior: routes should not present in fib \n" "Error: {}".format(tc_name, result) step("Verify Ipv4 and Ipv6 network installed in r3 RIB but not in FIB") input_dict_r3 = { "r3": { "static_routes": [ {"network": "1.0.4.17/32"}, {"network": "2001:db8:f::4:17/128"}, ] } } dut = "r3" protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib( tgen, addr_type, dut, input_dict_r3, protocol=protocol, fib=None ) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result ) result = verify_fib_routes(tgen, addr_type, dut, input_dict_r1, expected=False) assert result is not True, "Testcase {} : Failed \n" "Expected behavior: routes should not present in fib \n" "Error: {}".format(tc_name, result) write_test_footer(tc_name)