コード例 #1
0
def setup_env(duthosts, rand_one_dut_hostname):
    """
    Setup/teardown fixture for acl config
    Args:
        duthosts: list of DUTs.
        rand_selected_dut: The fixture returns a randomly selected DuT.
    """
    duthost = duthosts[rand_one_dut_hostname]
    original_iptable_rules = get_iptable_rules(duthost)
    create_checkpoint(duthost)

    yield

    try:
        logger.info("Rolled back to original checkpoint")
        rollback_or_reload(duthost)

        current_iptable_rules = get_iptable_rules(duthost)
        pytest_assert(
            set(original_iptable_rules) == set(current_iptable_rules),
            "iptable rules are not suppose to change after test")

        current_cacl_tables = get_cacl_tables(duthost)
        pytest_assert(
            set(T0_CACL_TABLE) == set(current_cacl_tables),
            "iptable rules are not suppose to change after test")
    finally:
        delete_checkpoint(duthost)
コード例 #2
0
def test_monitor_config_tc1_suite(duthost, get_valid_acl_ports):
    """ Test enable/disable EverflowAlwaysOn config
    """
    # Step 1: Create checkpoint at initial state where no monitor config exist
    bgp_monitor_config_cleanup(duthost)
    create_checkpoint(duthost, MONITOR_CONFIG_INITIAL_CP)

    # Step 2: Add EverflowAlwaysOn config to duthost
    monitor_config_add_config(duthost, get_valid_acl_ports)

    # Step 3: Create checkpoint that containing desired EverflowAlwaysOn config
    create_checkpoint(duthost, MONITOR_CONFIG_TEST_CP)

    try:
        # Step 4: Rollback to initial state disabling monitor config
        output = rollback(duthost, MONITOR_CONFIG_INITIAL_CP)
        pytest_assert(
            not output['rc']
            and "Config rolled back successfull" in output['stdout'],
            "config rollback to {} failed.".format(MONITOR_CONFIG_INITIAL_CP))
        verify_no_monitor_config(duthost)

        # Step 5: Rollback to EverflowAlwaysOn config and verify
        output = rollback(duthost, MONITOR_CONFIG_TEST_CP)
        pytest_assert(
            not output['rc']
            and "Config rolled back successfull" in output['stdout'],
            "config rollback to {} failed.".format(MONITOR_CONFIG_TEST_CP))
        verify_monitor_config(duthost)

    finally:
        delete_checkpoint(duthost, MONITOR_CONFIG_INITIAL_CP)
        delete_checkpoint(duthost, MONITOR_CONFIG_TEST_CP)
コード例 #3
0
def ensure_dut_readiness(duthost):
    """
    Setup/teardown fixture for pfcwd interval config update tst

    Args:
        duthost: DUT host object
    """
    create_checkpoint(duthost)

    yield

    try:
        logger.info("Rolled back to original  checkpoint")
        rollback_or_reload(duthost)
    finally:
        delete_checkpoint(duthost)
コード例 #4
0
def setup_env(duthosts, rand_one_dut_hostname):
    """
    Setup/teardown fixture for bgp prefix config
    Args:
        duthosts: list of DUTs.
        rand_selected_dut: The fixture returns a randomly selected DuT.
    """
    duthost = duthosts[rand_one_dut_hostname]
    create_checkpoint(duthost)

    yield

    try:
        logger.info("Rolled back to original checkpoint")
        rollback_or_reload(duthost)
    finally:
        delete_checkpoint(duthost)
コード例 #5
0
def ensure_dut_readiness(duthost):
    """
    Setup/teardown fixture for each ipv6 test
    rollback to check if it goes back to starting config

    Args:
        duthost: DUT host object under test
    """

    create_checkpoint(duthost)

    yield

    try:
        logger.info("Rolled back to original checkpoint")
        rollback_or_reload(duthost)
    finally:
        delete_checkpoint(duthost)
コード例 #6
0
def ensure_dut_readiness(duthost):
    """
    Setup/teardown fixture for incremental qos config update tst

    Args:
        duthost: DUT host object
    """
    verify_orchagent_running_or_assert(duthost)
    create_checkpoint(duthost)

    yield

    try:
        verify_orchagent_running_or_assert(duthost)
        logger.info("Rolled back to original checkpoint")
        rollback_or_reload(duthost)
    finally:
        delete_checkpoint(duthost)
コード例 #7
0
ファイル: test_syslog.py プロジェクト: xumia/sonic-mgmt
def setup_env(duthosts, rand_one_dut_hostname, cfg_facts, init_syslog_config,
              original_syslog_servers):
    """
    Setup/teardown fixture for syslog config
    Args:
        duthosts: list of DUTs.
        rand_selected_dut: The fixture returns a randomly selected DuT.
        cfg_facts: config facts for selected DUT
        init_syslog_config: set up the initial syslog config for test
        original_syslog_servers: original syslog servers stored in config
    """
    duthost = duthosts[rand_one_dut_hostname]
    create_checkpoint(duthost)

    if init_syslog_config == CONFIG_CLEANUP:
        syslog_config_cleanup(duthost, cfg_facts)
    elif init_syslog_config == CONFIG_ADD_DEFAULT:
        syslog_config_cleanup(duthost, cfg_facts)
        syslog_config_add_default(duthost)
    else:
        pytest.fail("Not supported initial syslog config: {}".format(
            init_syslog_config))

    create_checkpoint(duthost, SETUP_ENV_CP)

    yield

    # Rollback twice. First rollback to checkpoint just before 'yield'
    # Second rollback is to back to original setup
    try:
        output = rollback(duthost, SETUP_ENV_CP)
        check_syslog_after_rollback(duthost, output, init_syslog_config)

        logger.info("Rolled back to original checkpoint")
        rollback_or_reload(duthost)

        current_syslog_servers = get_current_syslog_servers(duthost)
        pytest_assert(
            set(current_syslog_servers) == set(original_syslog_servers),
            "Syslog servers are not rollback_or_reload to initial config setup"
        )
    finally:
        delete_checkpoint(duthost, SETUP_ENV_CP)
        delete_checkpoint(duthost)
コード例 #8
0
ファイル: test_dhcp_relay.py プロジェクト: xumia/sonic-mgmt
def setup_vlan(duthosts, rand_one_dut_hostname, vlan_intfs_dict,
               first_avai_vlan_port, cfg_facts, init_dhcp_server_config,
               vlan_intfs_list):
    duthost = duthosts[rand_one_dut_hostname]
    create_checkpoint(duthost)

    # --------------------- Setup -----------------------
    create_test_vlans(duthost, cfg_facts, vlan_intfs_dict,
                      first_avai_vlan_port)
    ensure_dhcp_relay_running(duthost)
    if init_dhcp_server_config == CONFIG_CLEANUP:
        clean_setup()
    elif init_dhcp_server_config == CONFIG_ADD_DEFAULT:
        default_setup(duthost, vlan_intfs_list)
    else:
        pytest.fail("Not supported initial dhcp_relay config: {}".format(
            init_dhcp_server_config))

    dhcp_relay_info_before_test = get_dhcp_relay_info_from_all_vlans(duthost)
    create_checkpoint(duthost, SETUP_ENV_CP)
    # --------------------- Testing -----------------------
    yield

    # --------------------- Teardown -----------------------
    # Rollback twice. First rollback to checkpoint just before 'yield'
    # Second rollback is to back to original setup
    try:
        output = rollback(duthost, SETUP_ENV_CP)
        pytest_assert(
            not output['rc']
            and "Config rolled back successfull" in output['stdout'],
            "Rollback to previous setup env failed.")

        dhcp_relay_info_after_test = get_dhcp_relay_info_from_all_vlans(
            duthost)
        pytest_assert(
            dhcp_relay_info_before_test == dhcp_relay_info_after_test,
            "dhcp relay info should be the same after rollback")

        logger.info("Rolled back to original checkpoint")
        rollback_or_reload(duthost)
    finally:
        delete_checkpoint(duthost, SETUP_ENV_CP)
        delete_checkpoint(duthost)
コード例 #9
0
def setup_env(duthosts, rand_one_dut_hostname):
    """
    Setup/teardown fixture for each loopback interface test.
    rollback to check if it goes back to starting config without vrf set

    Args:
        duthosts: list of DUTs.
        rand_selected_dut: The fixture returns a randomly selected DuT.
    """
    duthost = duthosts[rand_one_dut_hostname]
    create_checkpoint(duthost)

    yield

    try:
        logger.info("Rolled back to original checkpoint")
        rollback_or_reload(duthost)
        check_show_ip_intf(duthost, "Loopback0", ["10.1.0.32/32"], ["Vrf"], is_ipv4=True)
        check_show_ip_intf(duthost, "Loopback0", ["fc00:1::32/128"], ["Vrf"], is_ipv4=False)
    finally:
        delete_checkpoint(duthost)
コード例 #10
0
ファイル: test_bgpl.py プロジェクト: vmorokhx/sonic-mgmt
def setup_env(duthosts, rand_one_dut_hostname):
    """
    Setup/teardown fixture for bgpmon config
    Args:
        duthosts: list of DUTs.
        rand_selected_dut: The fixture returns a randomly selected DuT.
    """
    duthost = duthosts[rand_one_dut_hostname]
    original_bgp_listener_config = get_bgp_monitor_runningconfig(duthost)
    create_checkpoint(duthost)

    yield

    try:
        logger.info("Rolled back to original checkpoint")
        rollback_or_reload(duthost)
        current_bgp_listener_config = get_bgp_monitor_runningconfig(duthost)
        pytest_assert(set(original_bgp_listener_config) == set(current_bgp_listener_config),
            "bgp listener config are not suppose to change after test"
        )
    finally:
        delete_checkpoint(duthost)
コード例 #11
0
def cleanup_test_env(duthosts, rand_one_dut_hostname):
    """
    Setup/teardown fixture for VLAN interface config
    Args:
        duthosts: list of DUTs.
        rand_selected_dut: The fixture returns a randomly selected DuT.
    """
    duthost = duthosts[rand_one_dut_hostname]
    create_checkpoint(duthost)

    yield

    try:
        logger.info("Rolled back to original checkpoint")
        rollback_or_reload(duthost)
        check_show_ip_intf(duthost,
                           "Vlan1000", ["192.168.0.1/21"], [],
                           is_ipv4=True)
        check_show_ip_intf(duthost,
                           "Vlan1000", ["fc02:1000::1/64"], [],
                           is_ipv4=False)
    finally:
        delete_checkpoint(duthost)