Exemplo n.º 1
0
    def test_front_panel_admindown_port(self, duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_asic_index,
                                        all_cfg_facts, setup, nbrhosts, nbr_macs, established_arp):
        """
        Verify tables, databases, and kernel routes are correctly deleted when the DUT port is admin down/up.

        Test Steps

        * Admin down interface on DUT.
        * On local linecard:
            * Verify ARP/NDP entries are removed from CLI for neighbors on down port.
            * Verify table entries in ASIC, AppDb are removed for addresses on down port.
        * On Supervisor card:
            * Verify Chassis App DB entry are removed for only the cleared address.  Entries for addresses on other
            line cards should still be present.
        * On remote linecards:
            * Verify table entries in ASICDB, APPDB, and host ARP table are removed for cleared addresses.
            * Verify kernel routes for cleared address are deleted.
        * Admin interface up, verify recreation after restarting traffic.

        Args:
            duthosts: duthosts fixture.
            enum_rand_one_per_hwsku_frontend_hostname: frontend iteration fixture.
            enum_asic_index: asic iteration fixture.
            all_cfg_facts: all_cfg_facts fixture from voq/conftest.py
            setup: setup fixture for this module.
            nbrhosts: nbrhosts fixture.
            established_arp: Fixture to establish ARP to all neighbors.

        """

        per_host = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
        asic = per_host.asics[enum_asic_index if enum_asic_index is not None else 0]
        cfg_facts = all_cfg_facts[per_host.hostname][asic.asic_index]['ansible_facts']

        neighs = cfg_facts['BGP_NEIGHBOR']

        intfs, intfs_to_test = pick_ports(cfg_facts)

        logger.info("Will test interfaces: %s", intfs_to_test)

        for intf in intfs_to_test:
            local_ips = [i.split("/")[0] for i in intfs[intf].keys()]  # [u'2064:100::2/64', u'100.0.0.2/24']
            neighbors = [n for n in neighs if neighs[n]['local_addr'] in local_ips]

            logger.info("Testing neighbors: %s on intf: %s", neighbors, intf)

            self.localport_admindown(per_host, intf)
            try:
                check_neighbors_are_gone(duthosts, all_cfg_facts, per_host, asic, neighbors)
            finally:
                self.localport_adminup(per_host, intf)

            for neighbor in neighbors:
                sonic_ping(asic, neighbor)

            for neighbor in neighbors:
                pytest_assert(wait_until(60, 2, check_arptable_state, per_host, neighbor, "REACHABLE"),
                              "STATE for neighbor {} did not change to reachable".format(neighbor))

            dump_and_verify_neighbors_on_asic(duthosts, per_host, asic, neighbors, nbrhosts, all_cfg_facts, nbr_macs)
Exemplo n.º 2
0
def test_neighbor_clear_all(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_asic_index,
                            setup, teardown, nbrhosts, all_cfg_facts, nbr_macs, established_arp):
    """
    Verify tables, databases, and kernel routes are correctly deleted when the entire neighbor table is cleared.

    Test Steps
    * On local linecard:
        * Issue `sonic-clear arp` command. and verify all addresses are removed and kernel routes are deleted on
          all hosts and ASICs.
        * Verify ARP/NDP entries are removed from CLI.
        * Verify table entries in ASIC, AppDb are removed for all cleared addresses.
    * On Supervisor card:
        * Verify Chassis App DB entry are removed for only the cleared address.  Entries for addresses on other line
        cards should still be present.
    * On remote linecards:
        * Verify table entries in ASICDB, APPDB, and host ARP table are removed for cleared addresses.
        * Verify kernel routes for cleared address are deleted.
    * Send full mesh traffic and verify relearn and DB.

    Args:
        duthosts: duthosts fixture.
        setup: setup fixture for this module.
        nbrhosts: nbrhosts fixture.
        all_cfg_facts: all_cfg_facts fixture from voq/conftest.py
        established_arp: Fixture to establish ARP to all neighbors.

    """

    per_host = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
    asic = per_host.asics[enum_asic_index if enum_asic_index is not None else 0]
    cfg_facts = all_cfg_facts[per_host.hostname][asic.asic_index]['ansible_facts']
    if 'BGP_NEIGHBOR' in cfg_facts:
        neighs = cfg_facts['BGP_NEIGHBOR']
    else:
        logger.info("No local neighbors for host: %s/%s, skipping", per_host.hostname, asic.asic_index)
        return

    asic_cmd(asic, "sonic-clear arp")
    asic_cmd(asic, "sonic-clear ndp")

    logger.info("Wait for clear.")
    poll_neighbor_table_delete(duthosts, neighs)

    logger.info("Verify neighbors are gone.")
    check_neighbors_are_gone(duthosts, all_cfg_facts, per_host, asic, neighs.keys())

    # relearn and check
    logger.info("Relearn neighbors on all nodes")
    ping_all_dut_local_nbrs(duthosts)
    check_all_neighbors_present(duthosts, nbrhosts, all_cfg_facts, nbr_macs)
Exemplo n.º 3
0
def test_neighbor_clear_one(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_asic_index,
                            setup, teardown, nbrhosts, all_cfg_facts, nbr_macs, established_arp):
    """
    Verify tables, databases, and kernel routes are correctly deleted when a single neighbor adjacency is cleared.

    Test Steps
    * On local linecard:
        * Clear single address with command:  `ip neigh flush to "addr"`.
        * Verify ARP/NDP entry removed from CLI.
        * Verify table entries in ASIC, AppDb are removed for only the cleared address.
    * On Supervisor card:
        * Verify Chassis App DB entry are removed for only the cleared address.
    * On remote linecards:
        * Verify table entries in ASICDB, APPDB, and host ARP table are removed.
        * Verify kernel route for cleared address is deleted.
    * Restart traffic, verify relearn.

    Args:
        duthosts: duthosts fixture.
        setup: setup fixture for this module.
        nbrhosts: nbrhosts fixture.
        all_cfg_facts: all_cfg_facts fixture from voq/conftest.py
        established_arp: Fixture to establish ARP to all neighbors.

    """
    per_host = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
    asic = per_host.asics[enum_asic_index if enum_asic_index is not None else 0]
    cfg_facts = all_cfg_facts[per_host.hostname][asic.asic_index]['ansible_facts']
    if 'BGP_NEIGHBOR' in cfg_facts:
        neighs = cfg_facts['BGP_NEIGHBOR']
    else:
        logger.info("No local neighbors for host: %s/%s, skipping", per_host.hostname, asic.asic_index)
        return

    eth_cfg = cfg_facts['INTERFACE'] if 'INTERFACE' in cfg_facts else {}
    pos_cfg = cfg_facts['PORTCHANNEL_INTERFACE'] if 'PORTCHANNEL_INTERFACE' in cfg_facts else {}
    nbr_to_test = []
    if eth_cfg != {}:
        nbr_to_test.extend(select_neighbors(eth_cfg, cfg_facts))

    if pos_cfg != {}:
        nbr_to_test.extend(select_neighbors(pos_cfg, cfg_facts))

    untouched_nbrs = [nbr for nbr in neighs if nbr not in nbr_to_test]

    logger.info("We will test these neighbors: %s", nbr_to_test)
    logger.info("These neighbors should not be affected: %s", untouched_nbrs)

    for neighbor in nbr_to_test:
        logger.info(
            "Flushing neighbor: {} on host {}/{}".format(neighbor, per_host.hostname, asic.asic_index))
        asic_cmd(asic, "ip neigh flush to %s" % neighbor)

    logger.info("Wait for flush.")
    poll_neighbor_table_delete(duthosts, nbr_to_test)
    logger.info("Verify neighbors are gone.")
    check_neighbors_are_gone(duthosts, all_cfg_facts, per_host, asic, nbr_to_test)

    logger.info("Verify other neighbors are not affected.")
    dump_and_verify_neighbors_on_asic(duthosts, per_host, asic, untouched_nbrs, nbrhosts, all_cfg_facts, nbr_macs)

    # relearn and check
    logger.info("Relearn neighbors on all nodes")
    ping_all_dut_local_nbrs(duthosts)
    logger.info("Check neighbor relearn on all nodes.")
    check_all_neighbors_present(duthosts, nbrhosts, all_cfg_facts, nbr_macs)