コード例 #1
0
def test_standby_tor_remove_neighbor_downstream_standby(
    conn_graph_facts, ptfadapter, ptfhost,
    rand_selected_dut, rand_unselected_dut, tbinfo,
    require_mocked_dualtor, set_crm_polling_interval,
    tunnel_traffic_monitor, vmhost
):
    """
    @summary: Verify that after removing neighbor entry for a server over standby
    ToR, the packets sent to the server will be dropped(neither passed to the server
    or redirected to the active ToR).
    """

    @contextlib.contextmanager
    def stop_garp(ptfhost):
        """Temporarily stop garp service."""
        ptfhost.shell("supervisorctl stop garp_service")
        yield
        ptfhost.shell("supervisorctl start garp_service")

    tor = rand_selected_dut
    test_params = dualtor_info(ptfhost, rand_selected_dut, rand_unselected_dut, tbinfo)
    server_ipv4 = test_params["target_server_ip"]

    pkt, exp_pkt = build_packet_to_server(tor, ptfadapter, server_ipv4)
    ptf_t1_intf = random.choice(get_t1_ptf_ports(tor, tbinfo))
    logging.info("send traffic to server %s from ptf t1 interface %s", server_ipv4, ptf_t1_intf)
    tunnel_monitor = tunnel_traffic_monitor(tor, existing=True)
    with tunnel_monitor:
        testutils.send(ptfadapter, int(ptf_t1_intf.strip("eth")), pkt, count=10)

    logging.info("send traffic to server %s after removing neighbor entry", server_ipv4)
    tunnel_monitor.existing = False
    server_traffic_monitor = ServerTrafficMonitor(
        tor, ptfhost, vmhost, tbinfo, test_params["selected_port"],
        conn_graph_facts, exp_pkt, existing=False, is_mocked=is_mocked_dualtor(tbinfo)
    )
    # for real dualtor testbed, leave the neighbor restoration to garp service
    flush_neighbor_ct = flush_neighbor(tor, server_ipv4, restore=is_t0_mocked_dualtor)
    with crm_neighbor_checker(tor), stop_garp(ptfhost), flush_neighbor_ct, tunnel_monitor, server_traffic_monitor:
        testutils.send(ptfadapter, int(ptf_t1_intf.strip("eth")), pkt, count=10)

    logging.info("send traffic to server %s after neighbor entry is restored", server_ipv4)
    tunnel_monitor.existing = True
    with crm_neighbor_checker(tor), tunnel_monitor:
        testutils.send(ptfadapter, int(ptf_t1_intf.strip("eth")), pkt, count=10)
コード例 #2
0
def test_mac_move(require_mocked_dualtor, announce_new_neighbor,
                  apply_active_state_to_orchagent, conn_graph_facts,
                  ptfadapter, ptfhost, rand_selected_dut,
                  set_crm_polling_interval, tbinfo, tunnel_traffic_monitor,
                  vmhost):
    tor = rand_selected_dut
    ptf_t1_intf = random.choice(get_t1_ptf_ports(tor, tbinfo))
    ptf_t1_intf_index = int(ptf_t1_intf.strip("eth"))

    # new neighbor learnt on an active port
    test_port = next(announce_new_neighbor)
    announce_new_neighbor.send(None)
    logging.info("let new neighbor learnt on active port %s", test_port)
    pkt, exp_pkt = build_packet_to_server(tor, ptfadapter,
                                          NEW_NEIGHBOR_IPV4_ADDR)
    tunnel_monitor = tunnel_traffic_monitor(tor, existing=False)
    server_traffic_monitor = ServerTrafficMonitor(
        tor,
        ptfhost,
        vmhost,
        tbinfo,
        test_port,
        conn_graph_facts,
        exp_pkt,
        existing=True,
        is_mocked=is_mocked_dualtor(tbinfo))
    with crm_neighbor_checker(tor), tunnel_monitor, server_traffic_monitor:
        testutils.send(ptfadapter, ptf_t1_intf_index, pkt, count=10)

    # mac move to a standby port
    test_port = next(announce_new_neighbor)
    announce_new_neighbor.send(
        lambda iface: set_dual_tor_state_to_orchagent(tor, "standby", [iface]))
    logging.info("mac move to a standby port %s", test_port)
    pkt, exp_pkt = build_packet_to_server(tor, ptfadapter,
                                          NEW_NEIGHBOR_IPV4_ADDR)
    tunnel_monitor = tunnel_traffic_monitor(tor, existing=True)
    server_traffic_monitor = ServerTrafficMonitor(
        tor,
        ptfhost,
        vmhost,
        tbinfo,
        test_port,
        conn_graph_facts,
        exp_pkt,
        existing=False,
        is_mocked=is_mocked_dualtor(tbinfo))
    with crm_neighbor_checker(tor), tunnel_monitor, server_traffic_monitor:
        testutils.send(ptfadapter, ptf_t1_intf_index, pkt, count=10)

    # standby forwarding check after fdb ageout/flush
    tor.shell("fdbclear")
    server_traffic_monitor = ServerTrafficMonitor(
        tor,
        ptfhost,
        vmhost,
        tbinfo,
        test_port,
        conn_graph_facts,
        exp_pkt,
        existing=False,
        is_mocked=is_mocked_dualtor(tbinfo))
    with crm_neighbor_checker(tor), tunnel_monitor, server_traffic_monitor:
        testutils.send(ptfadapter, ptf_t1_intf_index, pkt, count=10)

    # mac move to another active port
    test_port = next(announce_new_neighbor)
    announce_new_neighbor.send(None)
    logging.info("mac move to another active port %s", test_port)
    pkt, exp_pkt = build_packet_to_server(tor, ptfadapter,
                                          NEW_NEIGHBOR_IPV4_ADDR)
    tunnel_monitor = tunnel_traffic_monitor(tor, existing=False)
    server_traffic_monitor = ServerTrafficMonitor(
        tor,
        ptfhost,
        vmhost,
        tbinfo,
        test_port,
        conn_graph_facts,
        exp_pkt,
        existing=True,
        is_mocked=is_mocked_dualtor(tbinfo))
    with crm_neighbor_checker(tor), tunnel_monitor, server_traffic_monitor:
        testutils.send(ptfadapter, ptf_t1_intf_index, pkt, count=10)

    # active forwarding check after fdb ageout/flush
    tor.shell("fdbclear")
    server_traffic_monitor = ServerTrafficMonitor(
        tor,
        ptfhost,
        vmhost,
        tbinfo,
        test_port,
        conn_graph_facts,
        exp_pkt,
        existing=False,
        is_mocked=is_mocked_dualtor(tbinfo))
    with crm_neighbor_checker(tor), tunnel_monitor, server_traffic_monitor:
        testutils.send(ptfadapter, ptf_t1_intf_index, pkt, count=10)
コード例 #3
0
def test_active_tor_remove_neighbor_downstream_active(
        conn_graph_facts, ptfadapter, ptfhost, rand_selected_dut,
        rand_unselected_dut, tbinfo, set_crm_polling_interval,
        tunnel_traffic_monitor, vmhost):
    """
    @Verify those two scenarios:
    If the neighbor entry of a server is present on active ToR,
    all traffic to server should be directly forwarded.
    If the neighbor entry of a server is removed, all traffic to server
    should be dropped and no tunnel traffic.
    """
    @contextlib.contextmanager
    def stop_garp(ptfhost):
        """Temporarily stop garp service."""
        ptfhost.shell("supervisorctl stop garp_service")
        yield
        ptfhost.shell("supervisorctl start garp_service")

    tor = rand_selected_dut
    test_params = dualtor_info(ptfhost, rand_selected_dut, rand_unselected_dut,
                               tbinfo)
    server_ipv4 = test_params["target_server_ip"]

    pkt, exp_pkt = build_packet_to_server(tor, ptfadapter, server_ipv4)
    ptf_t1_intf = random.choice(get_t1_ptf_ports(tor, tbinfo))
    logging.info("send traffic to server %s from ptf t1 interface %s",
                 server_ipv4, ptf_t1_intf)
    server_traffic_monitor = ServerTrafficMonitor(
        tor,
        ptfhost,
        vmhost,
        tbinfo,
        test_params["selected_port"],
        conn_graph_facts,
        exp_pkt,
        existing=True,
        is_mocked=is_mocked_dualtor(tbinfo))
    tunnel_monitor = tunnel_traffic_monitor(tor, existing=False)
    with crm_neighbor_checker(tor), tunnel_monitor, server_traffic_monitor:
        testutils.send(ptfadapter,
                       int(ptf_t1_intf.strip("eth")),
                       pkt,
                       count=10)

    logging.info("send traffic to server %s after removing neighbor entry",
                 server_ipv4)
    server_traffic_monitor = ServerTrafficMonitor(
        tor,
        ptfhost,
        vmhost,
        tbinfo,
        test_params["selected_port"],
        conn_graph_facts,
        exp_pkt,
        existing=False,
        is_mocked=is_mocked_dualtor(tbinfo)
    )  # for real dualtor testbed, leave the neighbor restoration to garp service
    flush_neighbor_ct = flush_neighbor(tor,
                                       server_ipv4,
                                       restore=is_t0_mocked_dualtor)
    with crm_neighbor_checker(tor), stop_garp(
            ptfhost
    ), flush_neighbor_ct, tunnel_monitor, server_traffic_monitor:
        testutils.send(ptfadapter,
                       int(ptf_t1_intf.strip("eth")),
                       pkt,
                       count=10)

    logging.info("send traffic to server %s after neighbor entry is restored",
                 server_ipv4)
    server_traffic_monitor = ServerTrafficMonitor(
        tor,
        ptfhost,
        vmhost,
        tbinfo,
        test_params["selected_port"],
        conn_graph_facts,
        exp_pkt,
        existing=True,
        is_mocked=is_mocked_dualtor(tbinfo))
    with crm_neighbor_checker(tor), tunnel_monitor, server_traffic_monitor:
        testutils.send(ptfadapter,
                       int(ptf_t1_intf.strip("eth")),
                       pkt,
                       count=10)
コード例 #4
0
def test_active_tor_remove_neighbor_downstream_active(
        conn_graph_facts, ptfadapter, ptfhost, testbed_setup,
        rand_selected_dut, tbinfo, require_mocked_dualtor,
        set_crm_polling_interval, tunnel_traffic_monitor, vmhost):
    """
    @Verify those two scenarios:
    If the neighbor entry of a server is present on active ToR,
    all traffic to server should be directly forwarded.
    If the neighbor entry of a server is removed, all traffic to server
    should be dropped and no tunnel traffic.
    """
    @contextlib.contextmanager
    def remove_neighbor(ptfhost, duthost, server_ip, ip_version):
        # restore ipv4 neighbor since it is statically configured
        if ip_version == "ipv4":
            restore = True
            neighbor_advertise_process = "garp_service"
        elif ip_version == "ipv6":
            restore = False
            neighbor_advertise_process = "arp_responder"
        else:
            raise ValueError("Unknown IP version '%s'" % ip_version)
        flush_neighbor_ct = flush_neighbor(duthost, server_ip, restore=restore)
        try:
            ptfhost.shell("supervisorctl stop %s" % neighbor_advertise_process)
            with flush_neighbor_ct:
                yield
        finally:
            ptfhost.shell("supervisorctl start %s" %
                          neighbor_advertise_process)

    tor = rand_selected_dut
    test_port, server_ip, ip_version = testbed_setup

    pkt, exp_pkt = build_packet_to_server(tor, ptfadapter, server_ip)
    ptf_t1_intf = random.choice(get_t1_ptf_ports(tor, tbinfo))
    logging.info("send traffic to server %s from ptf t1 interface %s",
                 server_ip, ptf_t1_intf)
    server_traffic_monitor = ServerTrafficMonitor(
        tor,
        ptfhost,
        vmhost,
        tbinfo,
        test_port,
        conn_graph_facts,
        exp_pkt,
        existing=True,
        is_mocked=is_mocked_dualtor(tbinfo))
    tunnel_monitor = tunnel_traffic_monitor(tor, existing=False)
    with crm_neighbor_checker(tor), tunnel_monitor, server_traffic_monitor:
        testutils.send(ptfadapter,
                       int(ptf_t1_intf.strip("eth")),
                       pkt,
                       count=10)

    logging.info("send traffic to server %s after removing neighbor entry",
                 server_ip)
    server_traffic_monitor = ServerTrafficMonitor(
        tor,
        ptfhost,
        vmhost,
        tbinfo,
        test_port,
        conn_graph_facts,
        exp_pkt,
        existing=False,
        is_mocked=is_mocked_dualtor(tbinfo))
    remove_neighbor_ct = remove_neighbor(ptfhost, tor, server_ip, ip_version)
    with crm_neighbor_checker(
            tor), remove_neighbor_ct, tunnel_monitor, server_traffic_monitor:
        testutils.send(ptfadapter,
                       int(ptf_t1_intf.strip("eth")),
                       pkt,
                       count=10)

    logging.info("send traffic to server %s after neighbor entry is restored",
                 server_ip)
    server_traffic_monitor = ServerTrafficMonitor(
        tor,
        ptfhost,
        vmhost,
        tbinfo,
        test_port,
        conn_graph_facts,
        exp_pkt,
        existing=True,
        is_mocked=is_mocked_dualtor(tbinfo))
    with crm_neighbor_checker(tor), tunnel_monitor, server_traffic_monitor:
        testutils.send(ptfadapter,
                       int(ptf_t1_intf.strip("eth")),
                       pkt,
                       count=10)