def configure_dut(minigraph_facts, duthosts, rand_one_dut_hostname,
                  vnet_config, vnet_test_params):
    """
    Setup/teardown fixture for VNET route leak test

    During the setup portion, generates VNET VxLAN configurations and applies them to the DUT
    During the teardown portion, removes all previously pushed VNET VxLAN information from the DUT

    Args:
        minigraph_facts: Minigraph information
        duthost: DUT host object
        vnet_config: Dictionary containing VNET configuration information
        vnet_test_params: Dictionary containing VNET test parameters
    """
    duthost = duthosts[rand_one_dut_hostname]

    logger.info("Backing up config_db.json")
    duthost.shell(BACKUP_CONFIG_DB_CMD)

    duthost.shell("sonic-clear fdb all")
    generate_dut_config_files(duthost, minigraph_facts, vnet_test_params,
                              vnet_config)
    apply_dut_config_files(duthost, vnet_test_params)

    # In this case yield is used only to separate this fixture into setup and teardown portions
    yield

    if vnet_test_params[CLEANUP_KEY]:
        logger.info("Restoring config_db.json")
        duthost.shell(RESTORE_CONFIG_DB_CMD)
        duthost.shell(DELETE_BACKUP_CONFIG_DB_CMD)

        cleanup_vnet_routes(duthost, vnet_test_params)
        cleanup_dut_vnets(duthost, minigraph_facts, vnet_config)
        cleanup_vxlan_tunnels(duthost, vnet_test_params)

        logger.info("Restarting BGP and waiting for BGP sessions")
        duthost.shell(RESTART_BGP_CMD)

        if not wait_until(BGP_WAIT_TIMEOUT, BGP_POLL_RATE, bgp_connected,
                          duthost):
            logger.warning(
                "BGP sessions not up {} seconds after BGP restart, restoring with `config_reload`"
                .format(BGP_WAIT_TIMEOUT))
            duthost.shell(CONFIG_RELOAD_CMD)
    else:
        logger.info("Skipping cleanup")
Beispiel #2
0
def setup(duthosts, rand_one_dut_hostname, ptfhost, minigraph_facts, vnet_config, vnet_test_params):
    """
    Prepares DUT and PTF hosts for testing

    Args:
        duthost: DUT host object
        ptfhost: PTF host object
        minigraph_facts: Minigraph facts
        vnet_config: Configuration file generated from templates/vnet_config.j2
        vnet_test_params: Dictionary holding vnet test parameters
    """
    duthost = duthosts[rand_one_dut_hostname]

    dut_facts = duthost.facts

    prepare_ptf(ptfhost, minigraph_facts, dut_facts, vnet_config)

    generate_dut_config_files(duthost, minigraph_facts, vnet_test_params, vnet_config)

    return minigraph_facts
Beispiel #3
0
def setup(duthost, ptfhost, minigraph_facts, vnet_config, vnet_test_params):
    """
    Prepares DUT and PTF hosts for testing

    Args:
        duthost: DUT host object
        ptfhost: PTF host object
        minigraph_facts: Minigraph facts
        vnet_config: Configuration file generated from templates/vnet_config.j2
        vnet_test_params: Dictionary holding vnet test parameters
    """

    dut_facts = duthost.setup(gather_subset="!all,!any,network",
                              filter="ansible_Ethernet*")["ansible_facts"]

    prepare_ptf(ptfhost, minigraph_facts, dut_facts, vnet_config)

    generate_dut_config_files(duthost, minigraph_facts, vnet_test_params,
                              vnet_config)

    return minigraph_facts