Esempio n. 1
0
def vxlan_status(setup, request, duthosts, rand_one_dut_hostname, ptfhost,
                 vnet_test_params, vnet_config, creds, tbinfo):
    """
    Paramterized fixture that tests the Disabled, Enabled, and Cleanup configs for VxLAN

    Args:
        setup: Pytest fixture that provides access to minigraph facts
        request: Contains the parameter (Disabled, Enabled, WR_ARP, or Cleanup) for the current test iteration
        duthost: DUT host object

    Returns:
        A tuple containing the VxLAN status (True or False), and the test scenario (one of the pytest parameters)
    """
    duthost = duthosts[rand_one_dut_hostname]
    mg_facts = setup
    attached_vlan = mg_facts["minigraph_vlan_interfaces"][0]['attachto']
    vlan_member = mg_facts["minigraph_vlans"][attached_vlan]['members'][0]
    global vlan_tagging_mode

    vxlan_enabled = False
    if request.param == "Disabled":
        vxlan_enabled = False
    elif request.param == "Enabled":
        duthost.shell("sonic-clear fdb all")
        result = duthost.shell(
            "redis-cli -n 4 HGET \"VLAN_MEMBER|{}|{}\" tagging_mode ".format(
                attached_vlan, vlan_member))
        if result["stdout_lines"] is not None:
            vlan_tagging_mode = result["stdout_lines"][0]
            duthost.shell("redis-cli -n 4 del \"VLAN_MEMBER|{}|{}\"".format(
                attached_vlan, vlan_member))

        apply_dut_config_files(duthost, vnet_test_params)
        # Check arp table status in a loop with delay.
        pytest_assert(
            wait_until(120, 20, 10, is_neigh_reachable, duthost, vnet_config),
            "Neighbor is unreachable")
        vxlan_enabled = True
    elif request.param == "Cleanup" and vnet_test_params[CLEANUP_KEY]:
        if vlan_tagging_mode != "":
            duthost.shell(
                "redis-cli -n 4 hset \"VLAN_MEMBER|{}|{}\" tagging_mode {} ".
                format(attached_vlan, vlan_member, vlan_tagging_mode))

        vxlan_enabled = True
        cleanup_vnet_routes(duthost, vnet_config)
        cleanup_dut_vnets(duthost, setup, vnet_config)
        cleanup_vxlan_tunnels(duthost, vnet_test_params)
    elif request.param == "WR_ARP":
        testWrArp = test_wr_arp.TestWrArp()
        testWrArp.Setup(duthost, ptfhost, tbinfo)
        try:
            test_wr_arp.TestWrArp.testWrArp(testWrArp, request, duthost,
                                            ptfhost, creds)
        finally:
            testWrArp.Teardown(duthost)

    return vxlan_enabled, request.param
Esempio n. 2
0
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")
Esempio n. 3
0
def vxlan_status(setup, request, duthosts, rand_one_dut_hostname,
                 vnet_test_params, vnet_config):
    """
    Paramterized fixture that tests the Disabled, Enabled, and Cleanup configs for VxLAN

    Args:
        setup: Pytest fixture that provides access to minigraph facts
        request: Contains the parameter (Disabled, Enabled, or Cleanup) for the current test iteration
        duthost: DUT host object

    Returns:
        A tuple containing the VxLAN status (True or False), and the test scenario (one of the pytest parameters)
    """
    duthost = duthosts[rand_one_dut_hostname]
    mg_facts = setup
    attached_vlan = mg_facts["minigraph_vlan_interfaces"][0]['attachto']
    vlan_member = mg_facts["minigraph_vlans"][attached_vlan]['members'][0]
    global vlan_tagging_mode

    vxlan_enabled = False
    if request.param == "Disabled":
        vxlan_enabled = False
    elif request.param == "Enabled":
        duthost.shell("sonic-clear fdb all")
        result = duthost.shell(
            "redis-cli -n 4 HGET \"VLAN_MEMBER|{}|{}\" tagging_mode ".format(
                attached_vlan, vlan_member))
        if result["stdout_lines"] is not None:
            vlan_tagging_mode = result["stdout_lines"][0]
            duthost.shell("redis-cli -n 4 del \"VLAN_MEMBER|{}|{}\"".format(
                attached_vlan, vlan_member))

        apply_dut_config_files(duthost, vnet_test_params)

        vxlan_enabled = True
    elif request.param == "Cleanup" and vnet_test_params[CLEANUP_KEY]:
        if vlan_tagging_mode != "":
            duthost.shell(
                "redis-cli -n 4 hset \"VLAN_MEMBER|{}|{}\" tagging_mode {} ".
                format(attached_vlan, vlan_member, vlan_tagging_mode))

        vxlan_enabled = True
        cleanup_vnet_routes(duthost, vnet_config)
        cleanup_dut_vnets(duthost, setup, vnet_config)
        cleanup_vxlan_tunnels(duthost, vnet_test_params)
    return vxlan_enabled, request.param
Esempio n. 4
0
def vxlan_status(setup, request, duthost, vnet_test_params, vnet_config):
    """
    Paramterized fixture that tests the Disabled, Enabled, and Cleanup configs for VxLAN

    Args:
        setup: Pytest fixture that provides access to minigraph facts
        request: Contains the parameter (Disabled, Enabled, or Cleanup) for the current test iteration
        duthost: DUT host object

    Returns:
        A tuple containing the VxLAN status (True or False), and the test scenario (one of the pytest parameters)
    """

    vxlan_enabled = False
    if request.param == "Disabled":
        vxlan_enabled = False
    elif request.param == "Enabled":
        mg_facts = setup

        duthost.shell("sonic-clear fdb all")

        attached_vlan = mg_facts["minigraph_vlan_interfaces"][0]['attachto']
        member_to_remove = mg_facts["minigraph_vlans"][attached_vlan][
            'members'][0]
        duthost.shell("redis-cli -n 4 del \"VLAN_MEMBER|{}|{}\"".format(
            attached_vlan, member_to_remove))

        apply_dut_config_files(duthost, vnet_test_params)

        vxlan_enabled = True
    elif request.param == "Cleanup" and vnet_test_params[CLEANUP_KEY]:
        vxlan_enabled = True
        cleanup_vnet_routes(duthost, vnet_config)
        cleanup_dut_vnets(duthost, setup, vnet_config)
        cleanup_vxlan_tunnels(duthost, vnet_test_params)
    return vxlan_enabled, request.param