Ejemplo n.º 1
0
def test_standby_tor_downstream_t1_link_recovered(
        rand_selected_dut, require_mocked_dualtor,
        verify_crm_nexthop_counter_not_increased, tbinfo, get_testbed_params):
    """
    Verify traffic is distributed evenly after t1 link is recovered;
    Verify CRM that no new nexthop created
    """
    PAUSE_TIME = 30

    down_link = shutdown_random_one_t1_link(rand_selected_dut)
    time.sleep(PAUSE_TIME)
    params = get_testbed_params()
    try:
        check_tunnel_balance(**params)
    except Exception as e:
        no_shutdown_t1_link(rand_selected_dut, down_link)
        raise e

    no_shutdown_t1_link(rand_selected_dut, down_link)
    time.sleep(PAUSE_TIME)
    params = get_testbed_params()
    # For mocked dualtor, we should update static route manually after link recovered
    if 't0' in tbinfo['topo']['name']:
        remove_static_routes(rand_selected_dut, params['active_tor_ip'])
        add_nexthop_routes(rand_selected_dut, params['active_tor_ip'])
    check_tunnel_balance(**params)
Ejemplo n.º 2
0
def test_downstream_ecmp_nexthops(ptfadapter, rand_selected_dut, tbinfo,
                                  require_mocked_dualtor,
                                  toggle_all_simulator_ports, tor_mux_intfs):
    dst_server_ipv4 = "1.1.1.2"
    nexthops_count = 4
    set_mux_state(rand_selected_dut, tbinfo, 'active', tor_mux_intfs,
                  toggle_all_simulator_ports)

    iface_server_map = get_interface_server_map(rand_selected_dut,
                                                nexthops_count)
    interface_to_server = dict()
    for interface, servers in iface_server_map.items():
        interface_to_server[interface] = servers['server_ipv4'].split("/")[0]

    nexthop_servers = list(interface_to_server.values())
    nexthop_interfaces = list(interface_to_server.keys())

    logging.info("Add route with four nexthops, where four muxes are active")
    add_nexthop_routes(rand_selected_dut,
                       dst_server_ipv4,
                       nexthops=nexthop_servers[0:nexthops_count])

    logging.info(
        "Verify traffic to this route destination is distributed to four server ports"
    )
    check_nexthops_balance(rand_selected_dut, ptfadapter, dst_server_ipv4,
                           tbinfo, nexthop_interfaces, nexthops_count)

    ### Sequentially set four mux states to standby
    for index, interface in enumerate(nexthop_interfaces):
        uplink_ports_active = index + 1
        logging.info("Simulate {} mux state change to Standby".format(
            nexthop_servers[index]))
        set_mux_state(rand_selected_dut, tbinfo, 'standby', [interface],
                      toggle_all_simulator_ports)
        logging.info("Verify traffic to this route destination is distributed to"\
            " {} server ports and {} tunnel nexthop".format(
                nexthops_count-uplink_ports_active, uplink_ports_active))
        check_nexthops_balance(
            rand_selected_dut, ptfadapter, dst_server_ipv4, tbinfo,
            nexthop_interfaces[uplink_ports_active:nexthops_count],
            nexthops_count)

    ### Revert two mux states to active
    for index, interface in reversed(list(enumerate(nexthop_interfaces))):
        logging.info("Simulate {} mux state change back to Active".format(
            nexthop_servers[index]))
        set_mux_state(rand_selected_dut, tbinfo, 'active', [interface],
                      toggle_all_simulator_ports)
        logging.info("Verify traffic to this route destination is distributed to"\
            " {} server ports and {} tunnel nexthop".format(nexthops_count-index, index))
        check_nexthops_balance(rand_selected_dut, ptfadapter, dst_server_ipv4,
                               tbinfo,
                               nexthop_interfaces[index:nexthops_count],
                               nexthops_count)
    ### Remove the nexthop route
    remove_static_routes(rand_selected_dut, dst_server_ipv4)
def test_standby_tor_downstream_loopback_route_readded(ptfhost, rand_selected_dut, rand_unselected_dut, tbinfo):
    """
    Verify traffic is equally distributed via loopback route
    """
    pt_require('dualtor' in tbinfo['topo']['name'], "Only run on dualtor testbed")
    params = dualtor_info(ptfhost, rand_selected_dut, rand_unselected_dut, tbinfo)
    active_tor_loopback0 = params['active_tor_ip']

    # Remove loopback routes and verify traffic is equally distributed
    remove_static_routes(rand_selected_dut, active_tor_loopback0)
    check_tunnel_balance(**params)

    # Readd loopback routes and verify traffic is equally distributed
    add_nexthop_routes(rand_selected_dut, active_tor_loopback0)
    check_tunnel_balance(**params)
def test_downstream_standby_mux_toggle_active(
    conn_graph_facts, ptfadapter, ptfhost,
    rand_selected_dut, rand_unselected_dut, tbinfo,
    require_mocked_dualtor, tunnel_traffic_monitor,
    vmhost, toggle_all_simulator_ports, tor_mux_intfs
    ):
    # set rand_selected_dut as standby and rand_unselected_dut to active tor
    test_params = dualtor_info(ptfhost, rand_selected_dut, rand_unselected_dut, tbinfo)
    server_ipv4 = test_params["target_server_ip"]
    random_dst_ip = "1.1.1.2"
    pkt, exp_pkt = build_packet_to_server(rand_selected_dut, ptfadapter, random_dst_ip)
    ptf_t1_intf = random.choice(get_t1_ptf_ports(rand_selected_dut, tbinfo))

    def monitor_tunnel_and_server_traffic(torhost, expect_tunnel_traffic=True, expect_server_traffic=True):
        tunnel_monitor = tunnel_traffic_monitor(rand_selected_dut, existing=True)
        server_traffic_monitor = ServerTrafficMonitor(
            torhost, ptfhost, vmhost, tbinfo, test_params["selected_port"],
            conn_graph_facts, exp_pkt, existing=False, is_mocked=is_mocked_dualtor(tbinfo)
        )
        tunnel_monitor.existing = expect_tunnel_traffic
        server_traffic_monitor.existing = expect_server_traffic
        with tunnel_monitor, server_traffic_monitor:
            testutils.send(ptfadapter, int(ptf_t1_intf.strip("eth")), pkt, count=10)

    logger.info("Stage 1: Verify Standby Forwarding")
    logger.info("Step 1.1: Add route to a nexthop which is a standby Neighbor")
    set_mux_state(rand_selected_dut, tbinfo, 'standby', tor_mux_intfs, toggle_all_simulator_ports)
    add_nexthop_routes(rand_selected_dut, random_dst_ip, nexthops=[server_ipv4])
    logger.info("Step 1.2: Verify traffic to this route dst is forwarded to Active ToR and equally distributed")
    check_tunnel_balance(**test_params)
    monitor_tunnel_and_server_traffic(rand_selected_dut, expect_server_traffic=False, expect_tunnel_traffic=True)

    logger.info("Stage 2: Verify Active Forwarding")
    logger.info("Step 2.1: Simulate Mux state change to active")
    set_mux_state(rand_selected_dut, tbinfo, 'active', tor_mux_intfs, toggle_all_simulator_ports)
    logger.info("Step 2.2: Verify traffic to this route dst is forwarded directly to server")
    monitor_tunnel_and_server_traffic(rand_selected_dut, expect_server_traffic=True, expect_tunnel_traffic=False)

    logger.info("Stage 3: Verify Standby Forwarding Again")
    logger.info("Step 3.1: Simulate Mux state change to standby")
    set_mux_state(rand_selected_dut, tbinfo, 'standby', tor_mux_intfs, toggle_all_simulator_ports)
    logger.info("Step 3.2: Verify traffic to this route dst is now redirected back to Active ToR and equally distributed")
    monitor_tunnel_and_server_traffic(rand_selected_dut, expect_server_traffic=False, expect_tunnel_traffic=True)
    check_tunnel_balance(**test_params)

    remove_static_routes(rand_selected_dut, random_dst_ip)
def test_downstream_ecmp_nexthops(ptfadapter, rand_selected_dut, tbinfo,
                                  require_mocked_dualtor,
                                  toggle_all_simulator_ports, tor_mux_intfs,
                                  ip_version):
    nexthops_count = 4
    set_mux_state(rand_selected_dut, tbinfo, 'active', tor_mux_intfs,
                  toggle_all_simulator_ports)
    iface_server_map = get_interface_server_map(rand_selected_dut,
                                                nexthops_count)

    if ip_version == "ipv4":
        dst_server_addr = "1.1.1.2"
        interface_to_server = {
            intf: servers["server_ipv4"].split("/")[0]
            for intf, servers in iface_server_map.items()
        }
    elif ip_version == "ipv6":
        dst_server_addr = "fc10:2020::f"
        interface_to_server = {
            intf: servers["server_ipv6"].split("/")[0]
            for intf, servers in iface_server_map.items()
        }
    else:
        raise ValueError("Unknown IP version '%s'" % ip_version)

    nexthop_servers = list(interface_to_server.values())
    nexthop_interfaces = list(interface_to_server.keys())

    logging.info("Add route with four nexthops, where four muxes are active")
    add_nexthop_routes(rand_selected_dut,
                       dst_server_addr,
                       nexthops=nexthop_servers)

    try:
        logging.info(
            "Verify traffic to this route destination is distributed to four server ports"
        )
        check_nexthops_balance(rand_selected_dut, ptfadapter, dst_server_addr,
                               tbinfo, nexthop_interfaces, nexthops_count)

        ### Sequentially set four mux states to standby
        for index, interface in enumerate(nexthop_interfaces):
            uplink_ports_active = index + 1
            logging.info("Simulate {} mux state change to Standby".format(
                nexthop_servers[index]))
            set_mux_state(rand_selected_dut, tbinfo, 'standby', [interface],
                          toggle_all_simulator_ports)
            logging.info("Verify traffic to this route destination is distributed to"\
                " {} server ports and {} tunnel nexthop".format(
                    nexthops_count-uplink_ports_active, uplink_ports_active))
            check_nexthops_balance(
                rand_selected_dut, ptfadapter, dst_server_addr, tbinfo,
                nexthop_interfaces[uplink_ports_active:nexthops_count],
                nexthops_count)

        ### Revert two mux states to active
        for index, interface in reversed(list(enumerate(nexthop_interfaces))):
            logging.info("Simulate {} mux state change back to Active".format(
                nexthop_servers[index]))
            set_mux_state(rand_selected_dut, tbinfo, 'active', [interface],
                          toggle_all_simulator_ports)
            logging.info("Verify traffic to this route destination is distributed to"\
                " {} server ports and {} tunnel nexthop".format(nexthops_count-index, index))
            check_nexthops_balance(rand_selected_dut, ptfadapter,
                                   dst_server_addr, tbinfo,
                                   nexthop_interfaces[index:nexthops_count],
                                   nexthops_count)
    finally:
        ### Remove the nexthop route
        remove_static_routes(rand_selected_dut, dst_server_addr)