def bgp_module_hooks(request):
    global bgp_cli_type
    st.ensure_min_topology('D1D2:1', 'D1T1:1', 'D2T1:1')
    bgp_cli_type = st.get_ui_type()
    if bgp_cli_type == 'click':
        bgp_cli_type = 'vtysh'
    bgplib.init_resource_data(st.get_testbed_vars())
    bgp_pre_config()
    yield
    bgp_pre_config_cleanup()
Exemple #2
0
def bgp_pre_config():
    global topo
    st.banner("BGP MODULE CONFIG - START")
    st.log("Ensure minimum linear 4-node topology")
    st.ensure_min_topology('D1D2:1', 'D2D3:1', 'D3D4:1')
    bgp4nodelib.l3_ipv4v6_address_config_unconfig(config='yes',
                                                  config_type='all')
    # Ping Verification
    if not bgp4nodelib.l3tc_vrfipv4v6_address_ping_test(config_type='all',
                                                        ping_count=3):
        st.error("Ping failed in between DUTs")
        st.report_fail('test_case_failed')
    topo = bgp4nodelib.get_confed_topology_info()
    st.log(topo)
    st.banner("BGP MODULE CONFIG - END")
Exemple #3
0
def test_ft_vlan_delete_with_member():
    """
    Author: Surendra Kumar Vella ([email protected])

    Verify that user is not able to delete a valn till its members are deleted

    """
    vars = st.ensure_min_topology("D1T1:1")
    st.log(
        "Adding TGen connected interfaces to newly created vlan in tagging mode."
    )
    if not vlan.add_vlan_member(vars.D1,
                                sc_data.vlan, [vars.D1D2P1],
                                tagging_mode=True,
                                cli_type=sc_data.cli_type):
        st.report_fail("vlan_tagged_member_fail", vars.D1D2P1, sc_data.vlan)
    st.log("checking whether vlan with member is deleted or not ")
    if not st.is_community_build(vars.D1):
        if vlan.delete_vlan(vars.D1, sc_data.vlan, cli_type="click"):
            st.report_fail("vlan_deletion_successfull_albiet_having_member",
                           sc_data.vlan)
        if not vlan.delete_vlan_member(
                vars.D1, sc_data.vlan, vars.D1D2P1, cli_type=sc_data.cli_type):
            st.report_fail("vlan_tagged_member_fail", vars.D1D2P1,
                           sc_data.vlan)
    else:
        if not vlan.delete_vlan(vars.D1, sc_data.vlan, cli_type="click"):
            st.report_fail("vlan_delete_fail", sc_data.vlan)
    st.log("deleting the vlan after its member deletion")
    st.report_pass("test_case_passed")
Exemple #4
0
def test_ft_vlan_syslog_verify():
    """
    Author:Anil Kumar Kacharla <*****@*****.**>
    Referrence Topology :   Test bed ID:4 D1--Mgmt network
    verify VLAN syslog functionality.
    """
    vars = st.ensure_min_topology("D1")
    sc_data.vlan_test = str(random_vlan_list(1, [int(sc_data.vlan)])[0])
    result = 1
    st.log("checking vlan count before vlan addition or deletion")
    count_before_add = slog.get_logging_count(vars.D1, severity="NOTICE", filter_list=["addVlan"])
    count_before_delete = slog.get_logging_count(vars.D1, severity="NOTICE", filter_list=["removeVlan"])
    st.log("vlan count before  adding vlan:{}".format(count_before_add))
    st.log("vlan count before  deleting vlan:{}".format(count_before_delete))
    vlan.create_vlan(vars.D1, sc_data.vlan_test)
    vlan.delete_vlan(vars.D1, sc_data.vlan_test)
    st.log("checking vlan count after adding vlan")
    count_after_add = slog.get_logging_count(vars.D1, severity="NOTICE", filter_list=["addVlan"])
    st.log("vlan count after  adding vlan:{}".format(count_after_add))
    count_after_delete = slog.get_logging_count(vars.D1, severity="NOTICE", filter_list=["removeVlan"])
    st.log("vlan count after  deleting vlan:{}".format(count_after_delete))
    if not count_after_add > count_before_add:
        st.error("vlan log count increamented after adding vlan:{}".format(count_after_add))
        result = 0
    if not count_after_delete > count_before_delete:
        st.error("vlan log count increamented after deleting vlan:{}".format(count_after_delete))
        result = 0
    if not result:
        st.report_fail("test_case_fail")
    st.log(" vlan count after adding or deleting vlan is incremented")
    st.report_pass("test_case_passed")
Exemple #5
0
def global_vars_and_constants_init():
    global vars
    global tf_data
    vars = st.ensure_min_topology('D1T1:4')
    tf_data = SpyTestDict()
    hw_constants = st.get_datastore(vars.D1, "constants")
    scapi.get_running_config(vars.D1)
    # Global Vars
    tf_data.tg_port_list = [vars.T1D1P1, vars.T1D1P2, vars.T1D1P3, vars.T1D1P4]
    tf_data.port_list = [vars.D1T1P1, vars.D1T1P2, vars.D1T1P3, vars.D1T1P4]
    tf_data.platform = bcapi.get_hwsku(vars.D1).lower()
    tf_data.unicast = 'unicast'
    tf_data.multicast = 'multicast'
    tf_data.tg_current_mode = tf_data.unicast
    tf_data.queues_to_check = [
        'COUNTERS_PG_NAME_MAP', 'COUNTERS_QUEUE_NAME_MAP'
    ]
    tf_data.max_time_to_check_sys_maps = [150, 2]  # Seconds
    tf_data.traffic_duration = 3  # Seconds
    tf_data.test_max_retries_count = 3
    tf_data.need_debug_prints = True
    # Common Constants
    tf_data.pg_headroom_un_supported_platforms = hw_constants[
        'THRESHOLD_FEATURE_PG_HEADROOM_UN_SUPPORTED_PLATFORMS']
    tf_data.th3_platforms = hw_constants['TH3_PLATFORMS']
    return tf_data
Exemple #6
0
def global_vars_and_constants_init():
    global tf_rest_data
    global vars
    vars = st.ensure_min_topology('D1')
    tf_rest_data = SpyTestDict()
    hw_constants = st.get_datastore(vars.D1, "constants")
    tf_rest_data.all_ports = intapi.get_all_interfaces(vars.D1,
                                                       int_type='physical')
    # Global Vars
    tf_rest_data.platform = bcapi.get_hwsku(vars.D1)
    tf_rest_data.show_version = bcapi.show_version(vars.D1)
    tf_rest_data.feature = "bst"
    tf_rest_data.configure_bst_thresholds = "configure-bst-thresholds"
    tf_rest_data.configure_bst_multi_thresholds = "configure-bst-multi-thresholds"
    tf_rest_data.get_bst_thresholds = "get-bst-thresholds"
    tf_rest_data.clear_bst_thresholds = "clear-bst-thresholds"
    tf_rest_data.queues_to_check = [
        'COUNTERS_PG_NAME_MAP', 'COUNTERS_QUEUE_NAME_MAP'
    ]
    tf_rest_data.max_time_to_check_sys_maps = [150, 2]  # Seconds
    tf_rest_data.default_threshold_value = 0  # Percentage
    # Common Constants
    tf_rest_data.pg_headroom_un_supported_platforms = \
        hw_constants['THRESHOLD_FEATURE_PG_HEADROOM_UN_SUPPORTED_PLATFORMS']
    tf_rest_data.build_product_info = hw_constants[
        'BUILD_BROADCOM_CLOUD_ADVANCED'] + hw_constants[
            'BUILD_BROADCOM_ENTERPRISE_ADVANCED']
Exemple #7
0
def ndp_module_hooks(request):
    vars = st.ensure_min_topology("D1T1:2")

    # Initialize TG and TG port handlers
    tg_handler = tgapi.get_handles_byname("T1D1P1", "T1D1P2")
    tg = tg_handler["tg"]

    # Test setup details
    data.my_dut_list = st.get_dut_names()
    dut1 = data.my_dut_list[0]

    # NDP module configuration
    st.log("NDP module configuration.")
    ip_obj.config_ip_addr_interface(dut1,
                                    vars.D1T1P1,
                                    data.local_ip6_addr[0],
                                    64,
                                    family=data.af_ipv6)
    vlan_obj.create_vlan(dut1, data.vlan_1)
    vlan_obj.add_vlan_member(dut1, data.vlan_1, vars.D1T1P2, True)
    ip_obj.config_ip_addr_interface(dut1,
                                    data.vlan_int_1,
                                    data.local_ip6_addr[1],
                                    64,
                                    family=data.af_ipv6)

    # TG ports reset
    st.log("Resetting the TG ports")
    tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"])

    # TG protocol interface creation
    st.log("TG protocol interface creation")
    h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"],
                                mode='config',
                                ipv6_intf_addr=data.neigh_ip6_addr_gw[0],
                                ipv6_prefix_length='64',
                                ipv6_gateway=data.local_ip6_addr[0],
                                src_mac_addr=data.tg_mac1,
                                arp_send_req='1',
                                count=data.count)
    st.log("INTFCONF: " + str(h1))
    h2 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"],
                                mode='config',
                                ipv6_intf_addr=data.neigh_ip6_addr_gw[1],
                                ipv6_prefix_length='64',
                                ipv6_gateway=data.local_ip6_addr[1],
                                src_mac_addr=data.tg_mac2,
                                arp_send_req='1',
                                vlan_id=data.vlan_1,
                                vlan=1,
                                count=data.count)
    st.log("INTFCONF: " + str(h2))

    yield
    # NDP module cleanup
    st.log("NDP module cleanup.")
    ip_obj.clear_ip_configuration(dut1,
                                  family="ipv6",
                                  thread=data.clear_parallel)
    vlan_obj.clear_vlan_configuration(dut1, thread=data.clear_parallel)
Exemple #8
0
def rbac_module_hooks():
    global vars
    vars = st.ensure_min_topology("D1 D2")
    rbac_variables_init()
    rbac_module_prolog()
    yield
    rbac_module_epilog()
def initialize_topology():
    st.log(
        "Script Starts Here!. Initialize.........................................................................................."
    )
    vars = st.ensure_min_topology("D1D2:4", "D2D3:4", "D1T1:2", "D3T1:2")
    data.dut_list = st.get_dut_names()
    data.dut1 = data.dut_list[0]
    data.dut2 = data.dut_list[1]
    data.dut3 = data.dut_list[2]
    utils.exec_all(True,
                   [[bgp_obj.enable_docker_routing_config_mode, data.dut1],
                    [bgp_obj.enable_docker_routing_config_mode, data.dut2],
                    [bgp_obj.enable_docker_routing_config_mode, data.dut3]])
    data.d1_d2_ports = [vars.D1D2P1, vars.D1D2P2, vars.D1D2P3, vars.D1D2P4]
    data.d2_d1_ports = [vars.D2D1P1, vars.D2D1P2, vars.D2D1P3, vars.D2D1P4]
    data.d2_d3_ports = [vars.D2D3P1, vars.D2D3P2, vars.D2D3P3, vars.D2D3P4]
    data.d3_d2_ports = [vars.D3D2P1, vars.D3D2P2, vars.D3D2P3, vars.D3D2P4]
    data.dut1_tg_ports = [vars.D1T1P1, vars.D1T1P2]
    data.dut3_tg_ports = [vars.D3T1P1, vars.D3T1P2]
    data.tg_dut1_ports = [vars.T1D1P1, vars.T1D1P2]
    data.tg_dut3_ports = [vars.T1D3P1, vars.T1D3P2]
    data.tg = tgen_obj_dict[vars['tgen_list'][0]]
    data.tg_dut1_p1 = data.tg.get_port_handle(vars.T1D1P1)
    data.tg_dut3_p1 = data.tg.get_port_handle(vars.T1D3P1)
    data.tg_dut1_p2 = data.tg.get_port_handle(vars.T1D1P2)
    data.tg_dut3_p2 = data.tg.get_port_handle(vars.T1D3P2)
    data.d1_stream_list = {}
    data.d1_stream_list_vrf = {}
    data.d3_stream_list = {}
    if 'ixia' in vars['tgen_list'][0]:
        data.tgen_type = 'ixia'
        data.delay_factor = 2
    else:
        data.tgen_type = 'stc'
        data.delay_factor = 1
Exemple #10
0
def nat_pre_config():
    global vars
    vars = st.ensure_min_topology("D1D2:1", "D2D3:1")
    platform = basic_obj.get_hwsku(vars.D2)
    common_constants = st.get_datastore(vars.D2, "constants", "default")
    if platform.lower() in common_constants['TH3_PLATFORMS']:
        st.error("NAT is not supported for this platform {}".format(platform))
        st.report_unsupported('NAT_unsupported_platform',platform)
    ip_obj.config_ip_addr_interface(vars.D1, vars.D1D2P1, data.d1d2_ip_addr, data.ip_addr_mask, family=data.af_ipv4)
    ip_obj.config_ip_addr_interface(vars.D2, vars.D2D1P1, data.d2d1_ip_addr, data.ip_addr_mask, family=data.af_ipv4)
    ip_obj.config_ip_addr_interface(vars.D2, vars.D2D3P1, data.d2d3_ip_addr, data.ip_addr_mask, family=data.af_ipv4)
    ip_obj.config_ip_addr_interface(vars.D3, vars.D3D2P1, data.d3d2_ip_addr, data.ip_addr_mask, family=data.af_ipv4)
    ip_obj.create_static_route(vars.D1, data.d2d1_ip_addr,"{}/{}".format(data.d1_static_nw, data.ip_addr_mask),
                               shell=data.shell_vtysh, family=data.af_ipv4)
    ip_obj.create_static_route(vars.D3, data.d2d3_ip_addr, "{}/{}".format(data.d3_static_nw, data.ip_addr_mask),
                               shell=data.shell_vtysh, family=data.af_ipv4)
    st.log("NAT Configuration")
    nat_obj.config_nat_feature(vars.D2, 'enable')
    util_nat_zone_config(vars.D2, [vars.D2D1P1, vars.D2D3P1], [data.zone_1, data.zone_2], config=data.config_add)
    st.log("Creating NAT Pool")
    nat_obj.config_nat_pool(vars.D2, pool_name=data.pool_name[0], global_ip_range=data.d2d1_ip_addr,
                            global_port_range=data.global_port_range, config=data.config_add)
    st.log("Creating NAT Pool binding")
    nat_obj.config_nat_pool_binding(vars.D2, binding_name=data.bind_name[0], pool_name=data.pool_name[0],
                                    config=data.config_add)
    utils.exec_all(True, [[ip_obj.show_ip_route, vars.D1], [ip_obj.show_ip_route, vars.D2]])
    ip_obj.show_ip_route(vars.D3)
Exemple #11
0
def snapshot_feature_module_hooks(request):
    global vars
    vars = st.ensure_min_topology('D1T1:4')
    global_vars_and_constants_init()
    sf_module_prolog()
    yield
    sf_module_epilog()
def initialize_topology_vars():
    vars = st.ensure_min_topology("D1D3:4", "D2D3:4", "D1D4:4", "D2D4:4",
                                  "D3T1:1", "D4T1:1", "D1D2:1")
    data.dut_list = st.get_dut_names()
    data.dut1 = data.dut_list[0]
    data.dut2 = data.dut_list[1]
    data.dut3 = data.dut_list[2]
    data.dut4 = data.dut_list[3]
    for dut in vars.dut_list:
        bgp_api.enable_docker_routing_config_mode(dut)
    data.d1d2_ports = [vars.D1D2P1]
    data.d2d1_ports = [vars.D2D1P1]
    data.d1d3_ports = [vars.D1D3P1, vars.D1D3P2, vars.D1D3P3, vars.D1D3P4]
    data.d1d4_ports = [vars.D1D4P1, vars.D1D4P2, vars.D1D4P3, vars.D1D4P4]
    data.d2d3_ports = [vars.D2D3P1, vars.D2D3P2, vars.D2D3P3, vars.D2D3P4]
    data.d2d4_ports = [vars.D2D4P1, vars.D2D4P2, vars.D2D4P3, vars.D2D4P4]
    data.d3d1_ports = [vars.D3D1P1, vars.D3D1P2, vars.D3D1P3, vars.D3D1P4]
    data.d3d2_ports = [vars.D3D2P1, vars.D3D2P2, vars.D3D2P3, vars.D3D2P4]
    data.d4d1_ports = [vars.D4D1P1, vars.D4D1P2, vars.D4D1P3, vars.D4D1P4]
    data.d4d2_ports = [vars.D4D2P1, vars.D4D2P2, vars.D4D2P3, vars.D4D2P4]
    data.d4tg_ports = vars.D4T1P1
    data.d3tg_ports = vars.D3T1P1
    data.tg1 = tgen_obj_dict[vars['tgen_list'][0]]
    data.tg2 = tgen_obj_dict[vars['tgen_list'][0]]
    data.tgd3_ports = vars.T1D3P1
    data.tgd4_ports = vars.T1D4P1
    data.tg_dut3_p1 = data.tg1.get_port_handle(vars.T1D3P1)
    data.tg_dut4_p1 = data.tg2.get_port_handle(vars.T1D4P1)
    data.tg_handles = [data.tg_dut3_p1, data.tg_dut4_p1]
    data.D4_tg_mac = basic_api.get_ifconfig(data.dut4,
                                            data.d4tg_ports)[0]['mac']
    if 'ixia' in vars['tgen_list'][0]:
        data.delay_factor = 2
    else:
        data.delay_factor = 1
Exemple #13
0
def copp_module_hooks(request):
    global vars, tg, tg_ph_1, d1_p1, hw_constants, deviation_percentage, d1_p1_mac, copp_data, vlan_igmp, copp_data_pir
    vars = st.ensure_min_topology("D1T1:1")
    hw_constants = st.get_datastore(vars.D1, "constants", "default")
    st.debug("hw_constants: {}".format(hw_constants))
    tg, tg_ph_1 = tgapi.get_handle_byname("T1D1P1")
    d1_p1 = vars.D1T1P1
    vlan_igmp = 3188
    vlan_obj.create_vlan(vars.D1, vlan_igmp)
    deviation_percentage = 0.05
    ret_val = copp_obj.get_copp_config(dut=vars.D1, table_name='all')
    if ret_val:
        copp_data = ret_val
    else:
        st.report_fail('module_config_failed',
                       'show copp config command failed')
    copp_data_pir = copp_obj.set_copp_pir_config(vars.D1, config='get')
    # Get the DUT mac address
    d1_p1_mac = basic_obj.get_ifconfig(vars.D1, d1_p1)[0]['mac']
    # Config the routing interface
    ip_obj.config_ip_addr_interface(dut=vars.D1,
                                    interface_name=d1_p1,
                                    ip_address='1.1.1.2',
                                    subnet='24')
    yield
    # Un-configure the routing interface
    ip_obj.delete_ip_interface(dut=vars.D1,
                               interface_name=d1_p1,
                               ip_address='1.1.1.2',
                               subnet='24')
    vlan_obj.delete_vlan(vars.D1, vlan_igmp)
Exemple #14
0
def create_glob_vars():
    global vars
    vars = st.ensure_min_topology("D1D2:2", "D2D3:2", "D1T1:1", "D3T1:1")
    tg_dict["tg"], tg_dict["d1_tg_ph1"] = tgapi.get_handle_byname("T1D1P1")
    tg_dict["tg"], tg_dict["d3_tg_ph1"] = tgapi.get_handle_byname("T1D3P1")
    tg_dict["d1_tg_port1"], tg_dict["d3_tg_port1"] = vars.T1D1P1, vars.T1D3P1
    tg_dict["tgen_rate_pps"] = '1000'
    tg_dict["l3_len"] = '512'
    tg_dict["duration"] = 5
    acl_dict["dut_list"] = [vars.D1, vars.D2, vars.D3]
    acl_dict["dut1"]["intf_list_tg"] = [vars.D1T1P1]
    acl_dict["dut1"]["intf_list_dut2"] = [vars.D1D2P1, vars.D1D2P2]
    acl_dict["dut2"]["intf_list_tg"] = [vars.D2T1P1]
    acl_dict["dut2"]["intf_list_dut1"] = [vars.D2D1P1, vars.D2D1P2]
    acl_dict["dut2"]["intf_list_dut3"] = [vars.D2D3P1, vars.D2D3P2]
    acl_dict["dut3"]["intf_list_tg"] = [vars.D3T1P1]
    acl_dict["dut3"]["intf_list_dut2"] = [vars.D3D2P1, vars.D3D2P2]
    acl_dict["dut1_gw_mac"] = basic.get_ifconfig(vars.D1,
                                                 vars.D1T1P1)[0]['mac']
    acl_dict["dut3_gw_mac"] = basic.get_ifconfig(vars.D3,
                                                 vars.D3T1P1)[0]['mac']
    d1_out = st.get_credentials(vars.D1)
    d3_out = st.get_credentials(vars.D3)
    acl_dict["d1_uname"] = d1_out[0]
    acl_dict["d3_uname"] = d3_out[0]
    acl_dict["d1_pwd"] = d1_out[3]
    acl_dict["d3_pwd"] = d3_out[3]
    tg_dict["live_stream"] = ""
def security_module_hooks(request):
    global vars
    vars = st.ensure_min_topology("D1")
    security_variables()
    security_module_prolog()
    yield
    security_module_epilog()
def test_ft_logging_verify_logs_after_system_reboot():
    """
    Author: Anil Kumar Kacharla <*****@*****.**>
    Referrence Topology :   Test bed ID:4 D1--Mgmt network
    Verify that  logs get generated upon system reboot.
    """
    st.log("Ensuring minimum topology")
    vars = st.ensure_min_topology("D1")
    data.count = '0'
    st.log("configuring syslog server in config_db file")
    slog_obj.config_syslog_server(vars.D1, [data.syslog_server])
    st.log("checking logging count")
    slog_obj.get_logging_count(vars.D1)
    count = slog_obj.get_logging_count(vars.D1)
    st.log("logging count:{}".format(count))
    st.log("performing system reboot")
    st.reboot(vars.D1, 'fast')
    st.log("checking logs after  system reboot ")
    count = slog_obj.get_logging_count(vars.D1)
    if slog_obj.get_logging_count(vars.D1) == data.count:
        st.report_fail("logs_are_not_getting_generated_after_reboot")
    else:
        st.log("Logs are generated after reboot")
        st.log("logs count after reboot:{}".format(count))
    output = bsapi.generate_tech_support(vars.D1)
    if "Tar append operation failed" in output:
        st.report_fail("Tech_support_operation_failed")
    st.report_pass("test_case_passed")
def bgp_rst_prologue():
    global vars
    vars = st.ensure_min_topology("D1D2:4")
    st.banner("Routing interface configuration in both DUTs")
    [_, exceptions] = exec_all(
        True, [[dut1_routing_int_cfg, "add"], [dut2_routing_int_cfg, "add"]])
    ensure_no_exception(exceptions)
Exemple #18
0
def qos_fast_reboot_module_hooks(request):
    # add things at the start of this module
    global vars
    vars = st.ensure_min_topology("D1T1:1")

    st.log("Configuring supported QoS features")
    wred_data = wred_config.init_vars(vars)
    st.log('Creating WRED and ECN table')
    putils.exec_all(True, [
        putils.ExecAllFunc(apply_wred_ecn_config, vars.D1,
                           wred_data['wred_ecn_json_config'])
    ])
    st.log("Checking for wred config before save and fast-reboot")
    wred_verify()
    st.log("checking for ecn config before save and fast-reboot")
    ecn_verify()
    st.log("Configuring IPV4 ACL with rule")
    ipv4_acl_config()
    st.log("Configuring IPV6 ACL with rule")
    ipv6_acl_config()
    st.log("Checking for IPV4 ACL config before save and fast-reboot")
    ipv4_acl_verify()
    st.log("Checking for IPV6 ACL config before save and fast-reboot")
    ipv6_acl_verify()
    st.log("Configuring COS")
    cos_config()
    st.log("Checking for COS config before save and fast-reboot")
    cos_config_verify()

    yield
    # add things at the end of this module"
    #Below step will clear COS, WRED and ECN config from the device.
    qos_obj.clear_qos_config(vars.D1)
    #Below step will clear all ACL config from the device.
    acl_obj.clear_acl_config(vars.D1)
def initialize_topology():
    st.log(
        "Script Starts Here!. Initialize.........................................................................................."
    )

    #DUT topology variables
    vars = st.ensure_min_topology("D1D2:4", "D1T1:2", "D2T1:2")
    data.dut_list = st.get_dut_names()
    data.dut1 = data.dut_list[0]
    data.dut2 = data.dut_list[1]
    data.d1_d2_ports = [vars.D1D2P1, vars.D1D2P2, vars.D1D2P3, vars.D1D2P4]
    data.d2_d1_ports = [vars.D2D1P1, vars.D2D1P2, vars.D2D1P3, vars.D2D1P4]

    #DUT-TG topology variables
    data.dut1_tg_ports = [vars.D1T1P1, vars.D1T1P2]
    data.dut2_tg_ports = [vars.D2T1P1, vars.D2T1P2]
    data.tg_dut1_ports = [vars.T1D1P1, vars.T1D1P2]
    data.tg_dut2_ports = [vars.T1D2P1, vars.T1D2P2]
    data.tg = tgen_obj_dict[vars['tgen_list'][0]]
    data.tg_dut1_p1 = data.tg.get_port_handle(vars.T1D1P1)
    data.tg_dut2_p1 = data.tg.get_port_handle(vars.T1D2P1)
    data.tg_dut1_p2 = data.tg.get_port_handle(vars.T1D1P2)
    data.tg_dut2_p2 = data.tg.get_port_handle(vars.T1D2P2)
    data.d1_stream_list = {}
    data.d2_stream_list = {}
    data.d1_gateway_mac = mac_obj.get_sbin_intf_mac(data.dut1,
                                                    data.dut1_tg_ports[0])
    #TGEN delay
    if 'ixia' in vars['tgen_list'][0]:
        data.tgen_type = 'ixia'
        data.delay_factor = 2
    else:
        data.tgen_type = 'stc'
        data.delay_factor = 1
Exemple #20
0
def lldp_snmp_module_hooks(request):
    global vars
    vars = st.ensure_min_topology("D1D2:2")
    global_vars()
    lldp_snmp_pre_config()
    yield
    lldp_snmp_post_config()
def bgp_fast_reboot_module_hooks(request):
    global vars
    vars = st.ensure_min_topology("D1D2:1", "D1T1:2")
    if not st.is_feature_supported("bgp-neighbotship-performance", vars.D1):
        data.neighborship_wait = 30

    st.log("Enabling IPv6 mode globally")
    ip_obj.config_ipv6(vars.D1, action='enable')
    ip_obj.config_ipv6(vars.D2, action='enable')

    st.log("Configuring ipv4 addresses on routing interfaces")
    ipv4_ip_address_config()

    st.log("Verifying ipv4 addresses on routing interfaces")
    verify_ipv4_address_config()

    if data.ipv6_support:
        st.log("Configuring ipv6 addresses on routing interfaces")
        ipv6_address_config()
        st.log("Verifying ipv6 addresses on routing interfaces")
        verify_ipv6_address_config()
        st.log(
            "Configuring IPV6 eBGP config between DUT1 and DUT2,iBGP config between DUT1 and TG2"
        )
        ipv6_bgp_config()

    st.log(
        "Configuring IPV4 eBGP config between DUT1 and DUT2,iBGP config between DUT1 and TG1"
    )
    ipv4_bgp_config()

    if data.ipv6_support:
        st.log("Configuring TG2 V6 iBGP config")
        tg_bgpv6_config(vars, data.local_asn4, data.remote_asn4)

    st.log("Configuring TG1 V4 iBGP config")
    tg_bgp_config(vars, data.local_asn4, data.remote_asn4)

    st.log(
        "Verify IPV4 eBGP neighborship between D1 and D2 and iBGP neighborship between D1 and TG1"
    )
    verify_v4_bgp_neigborship()

    if data.ipv6_support:
        st.log(
            "Verify IPV6 eBGP neighborship between D1 and D2 and iBGP neighborship between D1 and TG2"
        )
        verify_v6_bgp_neigborship()

    yield

    bgp_obj.cleanup_router_bgp(st.get_dut_names())
    ip_obj.clear_ip_configuration(st.get_dut_names())

    if data.ipv6_support:
        ip_obj.clear_ip_configuration(st.get_dut_names(), 'ipv6')

    vlan_obj.clear_vlan_configuration(st.get_dut_names())
    portchannel_obj.clear_portchannel_configuration(st.get_dut_names())
def test_ft_ztp_install_docker_package(ztp_func_hooks):
    # ################ Author Details ################
    # Name: Chaitanya Vella
    # Email: [email protected]
    # ################################################
    # ############## Test bed details ################
    #  D1 ---- DHCP Server
    # ft_ztp_install_docker_package : Verify that ZTP can install a docker package using pre-defined firmware plugin.
    vars = st.ensure_min_topology("D1")
    #hostname = basic_obj.get_hostname(vars.D1)
    config_params.config_file = "ztp_docker.json"
    config_params.static_ip = ztp_params.dhcp.static_ip
    config_params.config_path = ztp_params.config_path
    config_params.dhcp_config_file = ztp_params.dhcp.config_file
    config_params.type = "http"
    config_params.dhcp_service_name = data.dhcp_service_name
    config_params.action = 'restart'
    config_params.device = 'server'
    config_params.device_action = "run"
    config_params.reboot_type = "normal"
    config_params.ztp_log_path = data.ztp_log_path
    config_params.file_names = ["02-configdb-json", "03-firmware"]
    config_params.log_msg = "Checking configuration section {} result: SUCCESS"
    config_params.ztp_log_string = "ZTP successfully completed"
    config_params.option_type = "67"
    config_params.result = ""
    config_params.config_db_path = data.config_db_path
    config_params.config_db_temp = data.config_db_temp
    config_params.json_config_path = "http://{}{}/".format(
        ztp_params.dhcp.static_ip, ztp_params.config_path)
    config_params.docker_path = "http://{}{}/{}".format(
        ztp_params.dhcp.static_ip, ztp_params.docker_path,
        ztp_params.docker_image)
    config_params.json_content = {
        "ztp": {
            "02-configdb-json": {
                "url": {
                    "source": "file://{}".format(config_params.config_db_temp),
                    "timeout": 300
                }
            },
            "03-firmware": {
                "upgrade-docker": {
                    "url": config_params.docker_path,
                    "container-name": ztp_params.docker_component_name
                }
            }
        }
    }
    ztp_obj.config_and_verify_dhcp_option(ssh_conn_obj, vars.D1, ztp_params,
                                          config_params)
    ztp_status = ztp_obj.show_ztp_status(vars.D1)
    if "dhcp-opt67" not in ztp_status["source"]:
        st.log(
            "ZTP source verification failed with {} against dhcp-opt67".format(
                ztp_status["source"]))
        st.report_fail("ztp_source_verification_failed", "dhcp-opt67",
                       ztp_status["source"])
    st.report_pass("test_case_passed")
Exemple #23
0
def test_ft_ntp_disable_enable_with_message_log():
    """
    Author: Anil Kumar Kacharla <*****@*****.**>
    Referrence Topology : 	Test bed ID:4 D1--Mgmt network
    Verify that Ntp synchronization is successful after doing NTP server on and off  and the message log display the correct time based upon the system up time.
    """
    st.log("Ensuring minimum topology")
    vars = st.ensure_min_topology("D1")
    data.string_generate = 'Iam Testing NTP'
    data.lines = 1
    data.time_date = time.strftime('%a %B %d %H:%M:%S %Z %Y')
    ntp_obj.config_date(vars.D1, data.time_date)
    st.log("checking time in message log without ntp ")
    log_message_1 = syslog_obj.show_logging(vars.D1,
                                            severity=None,
                                            filter_list=[],
                                            lines=data.lines)
    if not log_message_1:
        st.log("log message_1 not created")
        st.report_fail("operation_failed")
    clock = common_obj.log_parser(log_message_1[0])
    config_ntp_server_on_config_db_file(vars.D1, data.servers)
    st.log("Generating log messages")
    syslog_obj.clear_logging(vars.D1)
    syslog_obj.write_logging(vars.D1, data.string_generate)
    log_message = syslog_obj.show_logging(vars.D1,
                                          severity=None,
                                          filter_list=[data.string_generate])
    if not log_message:
        st.log("log message not created")
        st.report_fail("operation_failed")
    st.log("printing system clock")
    ntp_obj.show_clock(vars.D1)
    out = common_obj.log_parser(log_message[0])
    if not (clock[0]['month'] == out[0]['month'] and clock[0]['hours']
            == out[0]['hours'] and clock[0]['date'] == out[0]['date']
            and clock[0]['minutes'] <= out[0]['minutes']
            or clock[0]['seconds'] >= out[0]['seconds']):
        st.log("time not updated")
        st.report_fail("operation_failed")
    st.log("message log displaying correct timed based on system up time")
    st.log("disabling ntp")
    basic_obj.service_operations(vars.D1, data.ntp_service, action="stop")
    if not ntp_obj.verify_ntp_service_status(vars.D1, 'inactive (dead)'):
        st.log("ntp disabled failed")
        st.report_fail("operation_failed")
    st.log("Enabling NTP")
    basic_obj.service_operations(vars.D1, data.ntp_service, action="restart")
    if not ntp_obj.verify_ntp_service_status(
            vars.D1, 'active (running)', iteration=65, delay=2):
        st.log("ntp is exited after enable and disable ntp")
        st.report_fail("operation_failed")
    if not ntp_obj.verify_ntp_status(
            vars.D1, iteration=65, delay=2, server=data.servers):
        st.log("ntp syncronization failed after enable and disable ntp")
        st.report_fail("operation_failed")
    st.report_pass("test_case_passed")
Exemple #24
0
def config_mgmt_func_hooks(request):
    # add things at the start every test case
    # use 'st.get_func_name(request)' to compare
    # if any thing specific a particular test case
    global vars
    vars = st.get_testbed_vars()
    st.log("Ensuring minimum topology")
    vars = st.ensure_min_topology("D1")
    data.gmin = "100"
    data.gmax = "1000"
    data.rmin = "100"
    data.rmax = "1000"
    data.ymin = "100"
    data.ymax = "1000"
    data.ECN_profile_name = "ECN"
    data.cos_name = "COS"
    data.acl_ipv4_table_name = 'acl_table_v4'
    data.acl_ipv6_table_name = 'acl_table_v6'
    data.src_ip = '192.168.11.1'
    data.src_ipv6 = '2001::10'
    data.mask = '24'
    data.mask_ipv6 = '128'
    data.description = 'INGRESS_drop'
    data.acl_rule = 'ipv4_acl_rule'
    data.acl_rule_v6 = 'ipv6_acl_rule'
    data.priority = '55'
    data.type = 'L3'
    data.type_ipv6 = 'L3V6'
    data.packet_action = 'drop'
    data.stage = 'INGRESS'
    data.mode_high = 'high'
    data.mode_low = 'low'
    data.polling_interval = '1'
    data.threshold_percentage_type = 'percentage'
    data.threshold_used_type = 'used'
    data.threshold_free_type = 'free'
    data.ipv4_route_family = "ipv4_route"
    data.ipv6_route_family = "ipv6_route"
    data.fdb_family = "fdb"
    data.ipv4_neighbor_family = "ipv4_neighbor"
    data.ipv6_neighbor_family = "ipv6_neighbor"
    data.acl_group_entry_family = 'acl_group_entry'
    data.acl_group_counter_family = 'acl_group_counter'
    data.ipv6_nexthop_family = 'ipv6_nexthop'
    data.ipv4_nexthop_family = 'ipv4_nexthop'
    data.acl_table_family = "acl_table"
    data.mode_high_percentage = 50
    data.mode_low_percentage = 20
    data.mode_high_used = 1000
    data.mode_low_used = 10
    data.mode_high_free = 1000
    data.mode_low_free = 10
    data.mtu = "9216"
    data.eth = "Ethernet4"
    data.property = "mtu"
    data.mtu_default = "9100"
    yield
Exemple #25
0
def mclag_stp_interaction_module_hooks(request):
    global vars
    vars = st.ensure_min_topology("D1D2:4", "D1D3:3", "D1D4:1", "D1D5:1",
                                  "D2D4:3", "D2D3:1", "D3D4:3", "D3D5:1",
                                  "D4D5:1", "D1T1:1", "D2T1:1", "D3T1:1",
                                  "D4T1:1", "D5T1:1")
    lib_stp.module_config(vars, stp_protocol, topology_2_tier)
    yield
    lib_stp.module_unconfig(stp_protocol)
Exemple #26
0
def arp_module_hooks(request):
    global vars, tg_handler, tg, dut1, d1_mac_addr, h1, h2

    # Min topology verification
    vars = st.ensure_min_topology("D1T1:2")

    # Initialize TG and TG port handlers
    tg_handler = tgapi.get_handles_byname("T1D1P1", "T1D1P2")
    tg = tg_handler["tg"]

    # Test setup details
    data.my_dut_list = st.get_dut_names()
    dut1 = data.my_dut_list[0]

    # Test variables
    d1_mac_addr = mac.get_sbin_intf_mac(dut1, "eth0")

    # ARP module configuration
    st.log("ARP module configuration.")
    ip_obj.config_ip_addr_interface(dut1, vars.D1T1P1, data.d1t1_ip_addr,
                                    data.mask)
    vlan_obj.create_vlan(dut1, data.vlan_1)
    vlan_obj.add_vlan_member(dut1, data.vlan_1, vars.D1T1P2, True)
    ip_obj.config_ip_addr_interface(dut1, data.vlan_int_1, data.d1t2_ip_addr,
                                    data.mask)

    # TG ports reset
    st.log("Resetting the TG ports")
    tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"])

    # TG protocol interface creation
    st.log("TG protocol interface creation")
    h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"],
                                mode='config',
                                intf_ip_addr=data.t1d1_ip_addr,
                                gateway=data.d1t1_ip_addr,
                                src_mac_addr=data.t1d1_mac_addr,
                                arp_send_req='1')
    st.log("INTFCONF: " + str(h1))
    h2 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"],
                                mode='config',
                                intf_ip_addr=data.t2d1_ip_addr,
                                gateway=data.d1t2_ip_addr,
                                src_mac_addr=data.t2d1_mac_addr,
                                arp_send_req='1',
                                vlan_id=data.vlan_1,
                                vlan=1)
    st.log("INTFCONF: " + str(h2))

    yield
    # ARP module cleanup
    st.log("ARP module cleanup.")
    ip_obj.clear_ip_configuration(dut1,
                                  family="ipv4",
                                  thread=data.clear_parallel)
    vlan_obj.clear_vlan_configuration(dut1, thread=data.clear_parallel)
def test_ft_ztp_firmware_install_uninstall(ztp_func_hooks):
    # ################ Author Details ################
    # Name: Chaitanya Vella
    # Email: [email protected]
    # ################################################
    # ############## Test bed details ################
    #  D1 ---- DHCP Server
    # ft_ztp_firmware_install: Verify that SONiC ZTP successfully installs firmware image
    # #################################################
    vars = st.ensure_min_topology("D1")
    config_params.config_file = "ztp_firmware.json"
    config_params.static_ip = ztp_params.dhcp.static_ip
    config_params.config_path = ztp_params.config_path
    config_params.dhcp_config_file = ztp_params.dhcp.config_file
    config_params.type = "http"
    config_params.dhcp_service_name = data.dhcp_service_name
    config_params.action = "restart"
    config_params.device = 'server'
    config_params.device_action = "run"
    config_params.ztp_log_path = data.ztp_log_path
    config_params.file_names = ["firmware", "01-configdb-json"]
    config_params.option_type = "67"
    config_params.result = "pass"
    config_params.config_db_path = data.config_db_path
    config_params.config_db_temp = data.config_db_temp
    firmware_url = "http://{}{}/{}".format(ztp_params.dhcp.static_ip,
                                           ztp_params.firmware_path,
                                           ztp_params.build_file_name)
    config_params.json_content = {
        "ztp": {
            "firmware": {
                "install": {
                    "url": firmware_url,
                    "set-default": True
                },
                "remove": {
                    "version": ztp_params.uninstall_image
                },
                "plugin": "firmware",
                "reboot-on-failure": "false",
                "reboot-on-success": "true"
            },
            "01-configdb-json": {
                "url": {
                    "source": "file://{}".format(data.config_db_temp),
                    "timeout": 300
                }
            }
        }
    }
    ztp_obj.config_and_verify_dhcp_option(ssh_conn_obj,
                                          vars.D1,
                                          ztp_params,
                                          config_params,
                                          expect_reboot=True,
                                          reboot_on_success=["firmware"])
Exemple #28
0
def rbac_module_hooks():
    global vars
    vars = st.ensure_min_topology("D1 D2")
    rbac_variables_init()
    rbac_module_prolog()
    rbac_variables()
    st.log("Getting IP address of the DUT")
    ensure_device_ipaddress()
    yield
    rbac_module_epilog()
Exemple #29
0
def bootup_module_hooks(request):
    global vars
    vars = st.ensure_min_topology("D1")
    st.log("Ensure HTTP server details")
    data.http_ip = mutils.ensure_service_params(vars.D1, 'http', 'ip')
    data.build_path = mutils.ensure_service_params(vars.D1, 'http', 'path')
    data.build_name = mutils.ensure_service_params(vars.D1, 'http', 'image1')
    st.log("Fetching Present build(Current active build)")
    data.build_details_list = bootup_obj.sonic_installer_list(vars.D1)
    data.initial_build = data.build_details_list['Current'][0]
    yield
Exemple #30
0
def vlan_module_hooks(request):
    global vars
    vars = st.ensure_min_topology("D1D2:2", "D1T1:2", "D2T1:2")
    sc_data.version_data = basic_obj.show_version(vars.D1)
    vlan_variables()
    if not st.is_feature_supported("vlan-range", vars.D1):
        sc_data.max_vlan = 100
    [_, exceptions] = exec_all(True, [[config_tg_stream], [vlan_module_prolog]], first_on_main=True)
    ensure_no_exception(exceptions)
    yield
    vlan.clear_vlan_configuration(st.get_dut_names(), thread=False)