Exemple #1
0
def gen_tech_supp(**kwargs):
    if not gen_tech_support_flag:
        print_log(
            "Inside gen_tech_sup: gen_tech_support_flag is set to False...")
        return True
    leaf1, leaf2, client1, client2 = kwargs['duts']
    print_log("TAKING TECH SUPPORT ON ALL DUTS...", "MED")
    f1 = lambda x: st.generate_tech_support(leaf1, 'leaf1')
    f2 = lambda x: st.generate_tech_support(leaf2, 'leaf2')
    f3 = lambda x: st.generate_tech_support(client1, 'client1')
    f4 = lambda x: st.generate_tech_support(client2, 'client2')
    [res, exceptions] = utils.exec_all(True,
                                       [[f1, 1], [f2, 1], [f3, 1], [f4, 1]])
    print_log(res, "MED")
    print_log(exceptions, "MED")
    print_log("END OF TECH SUPPORT")
Exemple #2
0
def test_mgmt_vrf_reboot_cfgreload():
    st.banner('mgmt_vrf_reboot, mgmt_vrf_cfgreload')
    st.log("Config reload the DUT")
    report_flag = 0
    config_save_reload(vars.D1)
    ip_addr = get_ifconfig_inet(vars.D1, 'eth0')
    if not ip_addr:
        st.report_fail('ip_verification_fail')
    if not ping(vars.D1, mgmt_vrf.extip, interface=mgmt_vrf.vrfname):
        report_flag = 1
    if not ping(vars.D1, ip_addr[0], external=True):
        report_flag = 1
    if report_flag == 1:
        st.report_tc_fail("ft_mgmtVrf_cfgreload", "mgmt_vrf_cfgreload_fail")
        st.generate_tech_support(vars.D1, "ft_mgmtVrf_cfgreload")
    else:
        st.report_tc_pass("ft_mgmtVrf_cfgreload", "mgmt_vrf_cfgreload_pass")
    config_save(vars.D1, "sonic")
    config_save(vars.D1, "vtysh")
    st.reboot(vars.D1)
    ip_addr = get_ifconfig_inet(vars.D1, 'eth0')
    if not ip_addr:
        st.report_fail('ip_verification_fail')
    if not ping(vars.D1, mgmt_vrf.extip, interface=mgmt_vrf.vrfname):
        report_flag = 2
    if not ping(vars.D1, ip_addr[0], external=True):
        report_flag = 2
    if report_flag == 2:
        st.report_tc_fail("ft_mgmtVrf_reboot", "mgmt_vrf_reboot_fail")
        st.generate_tech_support(vars.D1, "ft_mgmtVrf_reboot")
    else:
        st.report_tc_pass("ft_mgmtVrf_reboot", "mgmt_vrf_reboot_pass")
    if report_flag:
        st.report_fail("test_case_failed")
    else:
        st.report_pass("test_case_passed")
Exemple #3
0
def test_ft_ssh_add_user_verify():
    """
    Author : Prudvi Mangadu ([email protected])
    """
    user_ssh = 0
    acl_sshv4 = 0
    acl_sshv6 = 0
    acl_snmp = 0

    if not snmp_config(config='add'): acl_snmp = +1

    ipaddress = st.get_mgmt_ip(vars.D1)
    if not ipaddress:
        st.report_env_fail("ip_verification_fail")

    snmp_cmd = "snmpget -Oqv -v 2c -c {} {} {}".format(ssh_data.ro_community,
                                                       ipaddress,
                                                       ssh_data.oid_sysName)

    out = config_nondefault_user()
    if not out: user_ssh = +1

    st.log("connecting to device with username={},password={}".format(
        ssh_data.usr_default, ssh_data.pwd_final))
    if not st.exec_ssh(vars.D1, ssh_data.usr_default, ssh_data.pwd_final,
                       ssh_data.commands_to_verify):
        st.error('Cannot SSH into Device with default credentials')
        user_ssh = +1

    st.log('connecting to device with username={},password={}'.format(
        ssh_data.usr_non_default, ssh_data.pwd_non_default))
    if not st.exec_ssh(vars.D1, ssh_data.usr_non_default,
                       ssh_data.pwd_non_default, ssh_data.commands_to_verify):
        st.error('Cannot SSH into Device with non-default credentials')
        user_ssh = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output:
        user_ssh = +1

    IPAddr = ensure_service_params(vars.D1, "snmptrap", "ip") + "/32"
    change_acl_rules(acl_data.acl_json_config_control_plane, "SNMP_SSH|RULE_1",
                     "SRC_IP", IPAddr)
    change_acl_rules(acl_data.acl_json_config_control_plane, "SNMP_SSH|RULE_2",
                     "SRC_IP", IPAddr)
    change_acl_rules(acl_data.acl_json_config_control_plane, "SNMP_SSH|RULE_3",
                     "SRC_IP", ssh_data.ipv4_network)
    change_acl_rules(acl_data.acl_json_config_control_plane,
                     "V6_SSH_ONLY|RULE_1", "SRC_IPV6",
                     ssh_data.ipv6_network_D1)
    acl_config = acl_data.acl_json_config_control_plane
    st.log("ACL_DATA: {}".format(acl_config))
    acl_obj.apply_acl_config(vars.D1, acl_config)
    acl_obj.show_acl_table(vars.D1)
    acl_obj.show_acl_rule(vars.D1)

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "SNMP_SSH",
                     "RULE_1"):
        st.error("Failed to create ACL rule '{}' ".format("SNMP_SSH"))
        acl_snmp = +1

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "SNMP_SSH",
                     "RULE_2"):
        st.error("Failed to create ACL rule '{}' ".format("SNMP_SSH"))
        acl_sshv4 = +1

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "V6_SSH_ONLY",
                     "RULE_1"):
        st.error("Failed to create ACL rule '{}' ".format("V6_SSH_ONLY"))
        acl_sshv6 = +1

    hostname = get_hostname(vars.D1)
    st.log("HOSTNAME: {}".format(hostname))
    snmp_out = execute_command(ssh_conn_obj, snmp_cmd)
    if hostname not in snmp_out:
        st.error("SNMP walk operation is failed")
        acl_snmp = +1

    st.log("connecting to device with default username={},password={}".format(
        ssh_data.usr_default, ssh_data.pwd_final))
    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if output: acl_sshv6 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P1,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P1,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output: acl_sshv6 = +1

    st.log(
        "connecting to device with non default username={},password={}".format(
            ssh_data.usr_non_default, ssh_data.pwd_non_default))
    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P1,
                                   ssh_data.usr_non_default,
                                   ssh_data.pwd_non_default)
    if not output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P1,
                                   ssh_data.usr_non_default,
                                   ssh_data.pwd_non_default)
    if not output: acl_sshv6 = +1

    config_save(vars.D1)
    st.log('rebooting the device.')
    st.reboot(vars.D1, 'fast')

    acl_obj.show_acl_table(vars.D1)
    acl_obj.show_acl_rule(vars.D1)

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "SNMP_SSH",
                     "RULE_2"):
        st.log("Failed to create ACL rule '{}' ".format("SSH_SSH"))
        acl_sshv4 = +1

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "V6_SSH_ONLY",
                     "RULE_1"):
        st.log("Failed to create ACL rule '{}' ".format("V6_SSH_ONLY"))
        acl_sshv4 = +1

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "SNMP_SSH",
                     "RULE_1"):
        st.error("Failed to create ACL rule '{}' ".format("SNMP_SSH"))
        acl_snmp = +1

    ipaddress = st.get_mgmt_ip(vars.D1)
    if not ipaddress or not ip_obj.ping(vars.D1, IPAddr.strip('/32')):
        st.error(
            "Ping to SNMP server or getting ip address to the dut is failed after reload"
        )
        acl_obj.acl_delete(vars.D1)
        config_nondefault_user(config='remove')
        st.report_fail("ip_verification_fail")

    snmp_cmd = "snmpget -Oqv -v 2c -c {} {} {}".format(ssh_data.ro_community,
                                                       ipaddress,
                                                       ssh_data.oid_sysName)

    hostname = get_hostname(vars.D1)
    snmp_out = execute_command(ssh_conn_obj, snmp_cmd)
    if hostname not in snmp_out:
        st.error("SNMP walk operation is failed after reload")
        acl_snmp = +1

    st.log('Verifying SNMP ACL with invalid source address')
    change_acl_rules(acl_data.acl_json_config_control_plane, "SNMP_SSH|RULE_1",
                     "SRC_IP", "2.2.2.0/24")
    acl_config = acl_data.acl_json_config_control_plane
    acl_obj.acl_delete(vars.D1)
    acl_obj.apply_acl_config(vars.D1, acl_config)
    st.wait(3, "Waiting to apply acl rules")
    snmp_out = execute_command(ssh_conn_obj, snmp_cmd)
    if "Timeout" not in snmp_out: acl_snmp = +1

    st.log("connecting to device with default username={},password={}".format(
        ssh_data.usr_default, ssh_data.pwd_final))
    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if output: acl_sshv6 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P1,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P1,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output: acl_sshv6 = +1

    if acl_sshv4:
        st.report_tc_fail("test_ft_controlplane_acl_service_sshv4",
                          "ssh_failed",
                          "with control plane ACL service SSHv4 after reboot")
    else:
        st.report_tc_pass("test_ft_controlplane_acl_service_sshv4",
                          "ssh_failed",
                          "with control plane ACL service SSHv4 after reboot")

    if acl_sshv6:
        st.report_tc_fail("test_ft_controlplane_acl_service_sshv6",
                          "ssh_failed",
                          "with control plane ACL service SSHv6 after reboot")
    else:
        st.report_tc_pass("test_ft_controlplane_acl_service_sshv6",
                          "ssh_failed",
                          "with control plane ACL service SSHv6 after reboot")

    if acl_snmp:
        st.report_tc_fail("test_ft_controlplane_acl_service_snmp",
                          "snmp_output_failed",
                          "with control plane ACL service SNMP after reboot")
    else:
        st.report_tc_pass("test_ft_controlplane_acl_service_snmp",
                          "snmp_output_failed",
                          "with control plane ACL service SNMP after reboot")

    acl_obj.acl_delete(vars.D1)

    if acl_sshv4 or acl_sshv6 or acl_snmp:
        st.generate_tech_support(vars.D1,
                                 "controlplane_acl_services_after_reboot")

    st.log('Verifying SSH connection after removing control plane ACLs')
    st.log("connecting to device with username={},password={}".format(
        ssh_data.usr_default, ssh_data.pwd_final))
    if not st.exec_ssh(vars.D1, ssh_data.usr_default, ssh_data.pwd_final,
                       ssh_data.commands_to_verify):
        st.error(
            'Cannot SSH into Device with default credentials after reboot')
        user_ssh = +1

    st.log('connecting to device with username={},password={}'.format(
        ssh_data.usr_non_default, ssh_data.pwd_non_default))
    if not st.exec_ssh(vars.D1, ssh_data.usr_non_default,
                       ssh_data.pwd_non_default, ssh_data.commands_to_verify):
        st.error(
            'Cannot SSH into Device with non-default credentials after reboot')
        user_ssh = +1

    config_nondefault_user(config='remove')

    if (user_ssh or acl_snmp or acl_sshv4 or acl_sshv6):
        st.report_fail("test_case_failed")
    st.report_pass("test_case_passed")
def no_test_convergence_orphan_traffic(evpn_underlay_hooks):
    #st.log("create static ARP in DUT4 for DUT3's orphan traffic")
    #Arp.add_static_arp(evpn_dict["mlag_node_list"][1], evpn_dict["leaf3"]["v4_prefix"][0], evpn_dict["orphan_mac"],
    #                             interface=evpn_dict["leaf1"]["iccpd_pch_intf_list"][0])
    if data.config_tgen_bgp is False:
        tgen_emulate_bgp()
        data.config_tgen_bgp = True
    tech_support = True
    func_result = True
    err_list = []
    data['table'] = list()
    trigger_list = ['shut_all_uplinks_active']
    data.tc_list = ['orphan_traffic']
    for tc in data.tc_list:
        tc_result = True
        ############################################
        st.banner('Testcase - {}'.format(tc))
        ############################################
        data['table_{}'.format(tc)] = list()
        for trigger in trigger_list:
            ##########################################################
            st.banner('Testcase -{} : Trigger - {}'.format(tc, trigger))
            ###########################################################
            data[trigger] = {}
            data['table_{}'.format(trigger)] = [tc, trigger]

            for iter in range(data.iteration_count):
                ##################################################
                st.banner('Testcase -{} : Trigger - {},Iteration -{}'.format(
                    tc, trigger, (iter + 1)))
                ###################################################
                convergence_time = convergence_measure(tc,
                                                       trigger=trigger,
                                                       streams=stream_dict[tc],
                                                       iteration=(iter + 1))
                if type(convergence_time
                        ) is bool and convergence_time is False:
                    data[trigger]['convergence_{}'.format(iter)] = None
                else:
                    data[trigger]['convergence_{}'.format(iter)] = float(
                        convergence_time)
                if data[trigger]['convergence_{}'.format(
                        iter)] > data.threshold or data[trigger][
                            'convergence_{}'.format(iter)] is None:
                    err = "Average Traffic convergence after {} : {} sec".format(
                        trigger, data[trigger]['convergence_{}'.format(iter)])
                    st.error(err)
                    st.report_tc_fail(tc, 'test_case_failure_message', err)
                    if tech_support:
                        st.generate_tech_support(
                            dut=None, name='test_convergence_on_fail')
                    tech_support = False
                    tc_result = False
                    err_list.append(err)
                    func_result = False

                table_append = data[trigger]['convergence_{}'.format(iter)]
                data['table_{}'.format(trigger)].append(table_append)
            get_average_convergence(data[trigger], trigger)

            if tc_result:
                st.report_tc_pass(tc, 'test_case_passed')
            data['table_{}'.format(tc)].append(
                data['table_{}'.format(trigger)])
        #Append each testcase along with all trigger result to data.table
        data['table'].append(data['table_{}'.format(tc)])
    #Tabulate results
    tabulate_results(data['table'])
    if not func_result:
        st.report_fail('test_case_failure_message', err_list[0])
    st.report_pass('test_case_passed')
def test_convergence_l3_scale(evpn_underlay_hooks):
    func_result = True
    err_list = []
    data['table'] = list()
    tgen_emulate_bgp()
    data.config_tgen_bgp = True
    data.tc_list = ['scale']
    for tc in data.tc_list:
        tc_result = True
        ############################################
        st.banner('Testcase - {}'.format(tc))
        ############################################
        data['table_{}'.format(tc)] = list()
        for trigger in trigger_list:
            tech_support = True
            ##########################################################
            st.banner('Testcase -{} : Trigger - {}'.format(tc, trigger))
            ###########################################################
            data[trigger] = {}
            data['table_{}'.format(trigger)] = [tc, trigger]
            if 'uplink' in trigger:
                st.log(
                    "\n\n>>> Keep only one uplink port between Leaf and Spine nodes <<<<\n\n"
                )
                st.exec_all([[
                    port_api.shutdown, evpn_dict['leaf_node_list'][0],
                    [
                        evpn_dict["leaf1"]["intf_list_spine"][0],
                        evpn_dict["leaf1"]["intf_list_spine"][3],
                        evpn_dict["leaf1"]["intf_list_spine"][4],
                        evpn_dict["leaf1"]["intf_list_spine"][7]
                    ]
                ],
                             [
                                 port_api.shutdown,
                                 evpn_dict['leaf_node_list'][1],
                                 [
                                     evpn_dict["leaf2"]["intf_list_spine"][0],
                                     evpn_dict["leaf2"]["intf_list_spine"][3],
                                     evpn_dict["leaf2"]["intf_list_spine"][4],
                                     evpn_dict["leaf2"]["intf_list_spine"][7]
                                 ]
                             ]])
            for iter in range(data.iteration_count):
                ##################################################
                st.banner('Testcase -{} : Trigger - {},Iteration -{}'.format(
                    tc, trigger, (iter + 1)))
                ###################################################
                convergence_time = convergence_measure(tc,
                                                       trigger=trigger,
                                                       streams=stream_dict[tc],
                                                       iteration=(iter + 1))
                if type(convergence_time
                        ) is bool and convergence_time is False:
                    data[trigger]['convergence_{}'.format(iter)] = None
                else:
                    data[trigger]['convergence_{}'.format(iter)] = float(
                        convergence_time)
                if data[trigger]['convergence_{}'.format(
                        iter)] > data.threshold or data[trigger][
                            'convergence_{}'.format(iter)] is None:
                    err = "Average Traffic convergence after {} : {} sec".format(
                        trigger, data[trigger]['convergence_{}'.format(iter)])
                    st.error(err)
                    st.report_tc_fail(tc, 'test_case_failure_message', err)
                    if tech_support:
                        st.generate_tech_support(dut=None,
                                                 name='{}_{}_{}'.format(
                                                     tc, trigger, iter))
                    tech_support = False
                    tc_result = False
                    err_list.append(err)
                    func_result = False
                revert_trigger_change(trigger, iteration=(iter + 1))
                table_append = data[trigger]['convergence_{}'.format(iter)]
                data['table_{}'.format(trigger)].append(table_append)
            get_average_convergence(data[trigger], trigger)

            if 'uplink' in trigger:
                st.log(
                    ">>> \n\nBring back all uplink ports between Leaf and SPine nodes <<<<\n\n"
                )
                st.exec_all([[
                    port_api.noshutdown, evpn_dict['leaf_node_list'][0],
                    [
                        evpn_dict["leaf1"]["intf_list_spine"][0],
                        evpn_dict["leaf1"]["intf_list_spine"][3],
                        evpn_dict["leaf1"]["intf_list_spine"][4],
                        evpn_dict["leaf1"]["intf_list_spine"][7]
                    ]
                ],
                             [
                                 port_api.noshutdown,
                                 evpn_dict['leaf_node_list'][1],
                                 [
                                     evpn_dict["leaf2"]["intf_list_spine"][0],
                                     evpn_dict["leaf2"]["intf_list_spine"][3],
                                     evpn_dict["leaf2"]["intf_list_spine"][4],
                                     evpn_dict["leaf2"]["intf_list_spine"][7]
                                 ]
                             ]])
                if 'link_down_uplink' not in trigger:
                    st.log("verify BGP EVPN neighborship for all nodes ")
                    st.exec_all([[leaf1_verify_evpn], [leaf2_verify_evpn]])
            if tc_result:
                st.report_tc_pass(tc, 'test_case_passed')
            data['table_{}'.format(tc)].append(
                data['table_{}'.format(trigger)])
        #Append each testcase along with all trigger result to data.table
        data['table'].append(data['table_{}'.format(tc)])
    #Tabulate results
    tabulate_results(data['table'])
    if not func_result:
        st.report_fail('test_case_failure_message', err_list[0])
    st.report_pass('test_case_passed')