def test_mgmt_vrf_ping_traceroute(): report_flag = 0 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: st.report_tc_fail("ft_mgmtVrf_ping", "mgmt_vrf_ping_fail") else: st.report_tc_pass("ft_mgmtVrf_ping", "mgmt_vrf_ping_pass") report_flag = 0 if not traceroute(vars.D1, mgmt_vrf.extip, vrf_name=mgmt_vrf.vrfname): report_flag = 1 if not traceroute(vars.D1, ip_addr[0], external=True): report_flag = 1 if report_flag: st.report_tc_fail("ft_mgmtVrf_traceroute", "mgmt_vrf_tr_fail") else: st.report_tc_pass("ft_mgmtVrf_traceroute", "mgmt_vrf_tr_pass") if report_flag: st.report_fail("mgmt_vrf_tr_fail") else: st.report_pass("mgmt_vrf_tr_pass")
def test_warm_reboot_ip_unnumbered(): ##################################################################################################################################### result = 0 st.banner( 'FtOpSoRoIPunRel002 - Verify unnumbered interface accross a warm reboot' ) st.log('Enable warm restart for dockers') reboot_obj.config_warm_restart(data.dut2, oper="enable") reboot_obj.config_warm_restart(data.dut2, oper="enable", tasks=["swss", "teamd", "system"]) st.log("Save the running config in sonic and vtysh modes") reboot_obj.config_save(data.dut2) st.vtysh(data.dut2, "copy running startup") if not loc_lib.retry_api(ip_obj.ping, data.dut1, addresses=dut3_loopback_ip[0], retry_count=5, delay=10): st.error('IPv4 Ping from DUT1 to DUT3 failed before warm_restart') result += 1 aggrResult = loc_lib.send_verify_traffic(type='ipv4') if not aggrResult: st.error( 'IPv4 traffic with IPv4 unnumbered failed before warm_restart') result += 1 st.reboot(data.dut2, 'warm') if not loc_lib.retry_api(ip_obj.ping, data.dut1, addresses=dut3_loopback_ip[0], retry_count=4, delay=10): st.error('IPv4 Ping from DUT1 to DUT2 failed') result += 1 aggrResult = loc_lib.send_verify_traffic(type='ipv4') if not aggrResult: st.error('IPv4 traffic with IPv4 unnumbered failed') result += 1 reboot_obj.config_warm_restart(data.dut2, oper="disable") reboot_obj.config_warm_restart(data.dut2, oper="disable", tasks=["swss", "teamd", "system"]) if result == 0: st.report_tc_pass('FtOpSoRoIPunRel002', 'test_case_passed') else: st.report_tc_fail('FtOpSoRoIPunRel002', 'test_case_failed') if result == 0: st.report_pass('test_case_passed') else: st.report_fail('test_case_failed')
def test_cli_validation_ip_address(): vlan.config_vlan_range(dut, vlan_range="101 121", config="add", skip_verify=False) st.banner("click cli validation for ip address config") start_time = datetime.datetime.now() st.log("IP address config on 20 vlan routing interface using click") for each in range(101, 121): cmd = [ "config interface ip add Vlan{} 192.168.{}.1/31".format( each, each) ] st.config(dut, cmd, type="click") end_time = datetime.datetime.now() time_diff = end_time - start_time st.banner( "time taken for IP address config on 20 vlan routing interface using click: {}" .format(time_diff)) st.log("IP address unconfig on 20 vlan routing interface using click") for each in range(101, 121): cmd = [ "config interface ip remove Vlan{} 192.168.{}.1/31".format( each, each) ] st.config(dut, cmd, type="click") st.report_tc_pass("FtOpSoRtPerfFn054", "test_case_passed") if st.is_feature_supported("klish"): st.banner("klish cli validation for ip address config") start_time = datetime.datetime.now() for each in range(101, 121): cmd = [ "interface Vlan {}".format(each), 'ip address 192.168.{}.1/31'.format(each), 'exit' ] st.config(dut, cmd, type="klish") end_time = datetime.datetime.now() time_diff = end_time - start_time st.banner( "time taken for IP address config on 20 vlan routing interface using klish: {}" .format(time_diff)) for each in range(101, 121): cmd = [ "interface Vlan {}".format(each), 'no ip address 192.168.{}.1/31'.format(each), 'exit' ] st.config(dut, cmd, type="klish") st.report_tc_pass("FtOpSoRtPerfFn055", "test_case_passed") st.report_pass("test_case_passed")
def test_mgmt_vrf_curl_snmp(): report_flag, module_flag = 0, 0 ip_addr = get_ifconfig_inet(vars.D1, 'eth0') if not ip_addr: st.report_fail('ip_verification_fail') set_snmp_config(vars.D1, snmp_rocommunity=mgmt_vrf.ro_community, snmp_location=mgmt_vrf.location) config_snmp_agent(vars.D1, ip_addr=ip_addr[0], vrf='mgmt') if not poll_for_snmp(vars.D1, mgmt_vrf.wait_time, 1, ipaddress=ip_addr[0], oid=mgmt_vrf.oid_sysName, community_name=mgmt_vrf.ro_community): st.log( "Post MGMT VRF creation and snmpagent addition, snmp is not working" ) config_snmp_agent(vars.D1, ip_addr=ip_addr[0], vrf='mgmt', no_form=True) report_flag, module_flag = 1, 1 config_snmp_agent(vars.D1, ip_addr=mgmt_vrf.secondagent, vrf='mgmt') if not poll_for_snmp(vars.D1, mgmt_vrf.wait_time, 1, ipaddress=ip_addr[0], oid=mgmt_vrf.oid_sysName, community_name=mgmt_vrf.ro_community): st.log("After second agent within same VRF, snmp is not working") config_snmp_agent(vars.D1, ip_addr=mgmt_vrf.secondagent, vrf='mgmt', no_form=True) report_flag, module_flag = 1, 1 config_snmp_agent(vars.D1, ip_addr=ip_addr[0], vrf='mgmt', no_form=True) if report_flag: st.report_tc_fail("ft_mgmtVrf_snmp", "mgmt_vrf_snmp_fail") else: st.report_tc_pass("ft_mgmtVrf_snmp", "mgmt_vrf_snmp_pass") if module_flag: st.report_fail("test_case_failed") else: st.report_pass("test_case_passed")
def storm_control_verify(): status = 1 platform_check() st.log( "Removing mirror session related information to ensure that BUM is unaffected due to mirror sessions" ) mirror.delete_session(vars.D1, mirror_session=data.session_name_port) st.log("Creating vlan in device and adding members ...") vlan_data = [{ "dut": [vars.D1], "vlan_id": data.vlan, "tagged": [vars.D1T1P1, vars.D1T1P2] }] vlan.create_vlan_and_add_members(vlan_data) msg_id = "storm_control_reboot_successful" interface_list = [vars.D1T1P1, vars.D1T1P2] storm_control_type = ["broadcast", "unknown-multicast", "unknown-unicast"] for interface_li in interface_list: for stc_type in storm_control_type: if not scapi.verify_config(vars.D1, interface_name=interface_li, type=stc_type, rate=data.kbps): st.report_fail("storm_control_config_verify_failed", stc_type, interface_li) if not verify_bum_traffic_mode( 'broadcast', tg_info['tg1_stream_id'], skip_traffic_verify=False): st.error("Broadcast traffic verification got failed") status = 0 if not verify_bum_traffic_mode('unknown-unicast', tg_info['tg1_stream_id'], skip_traffic_verify=False): st.error("Unknown-unicast traffic verification got failed") status = 0 if not verify_bum_traffic_mode('unknown-multicast', tg_info['tg1_stream_id'], skip_traffic_verify=False): st.error("Unknown-multicast traffic verification got failed") status = 0 if not status: msg_id = "storm_control_reboot_failed" if status: st.report_tc_pass('ft_stormcontrol_cold_reboot', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_cold_reboot', 'test_case_failed') report_result(status, msg_id)
def show_ip_route_validation_cli(type='click'): st.log("{} validation".format(type)) test_case = 'FtOpSoRtPerfFn053' if type == 'click' else 'FtOpSoRtPerfFn052' start_time = datetime.datetime.now() if "via" not in st.show(dut, "show ip route", type=type, skip_tmpl=True, max_time=300): st.report_tc_fail(test_case, 'test_case_failed') end_time = datetime.datetime.now() st.log("start_time for route display using {}: {} ".format( type, start_time)) st.log("end_time for route display using {}: {} ".format(type, end_time)) time_diff_in_secs = end_time - start_time st.log("time_diff_in_secs: {}".format(time_diff_in_secs)) st.report_tc_pass(test_case, 'test_case_passed')
def test_mgmt_vrf_warmboot(): st.log("Warmboot the DUT") report_flag = 0 st.reboot(vars.D1, "warm") 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: st.report_tc_fail("ft_mgmtVrf_warmboot", "mgmt_vrf_warmboot", "failed") else: st.report_tc_pass("ft_mgmtVrf_warmboot", "mgmt_vrf_warmboot", "successful") if report_flag: st.report_fail("test_case_failed") else: st.report_pass("test_case_passed")
def test_ft_snapshot_interval(): """ Author : Phani kumar R ([email protected]) """ st.banner( 'ft_sf_snapshot_interval, ft_sf_verify_default_snapshot_interval') result1 = result2 = 0 if not sfapi.config_snapshot_interval( vars.D1, snap="interval", interval_val=sf_data.snapshot_interval): st.error("Failed to configure snapshot interval") result1 += 1 match = [{'snapshotinterval': sf_data.snapshot_interval}] if not sfapi.verify(vars.D1, 'snapshot_interval', verify_list=match): st.error("Failed to verify the configured snapshot interval") result1 += 1 st.report_tc_fail("ft_sf_snapshot_interval", "snapshot_interval_config", "failed") else: st.report_tc_pass("ft_sf_snapshot_interval", "snapshot_interval_config", "successful") if not sfapi.config_snapshot_interval(vars.D1, snap="clear_snaphot_interval"): st.error("Failed to clear the snapshot interval") result2 += 1 match = [{'snapshotinterval': sf_data.default_snapshot_interval}] if not sfapi.verify(vars.D1, 'snapshot_interval', verify_list=match): st.error( "Failed to reset the snapshot interval to default value after clear" ) result2 += 1 st.report_tc_fail("ft_sf_verify_default_snapshot_interval", "snapshot_verify_default_interval", "failed") else: st.report_tc_pass("ft_sf_verify_default_snapshot_interval", "snapshot_verify_default_interval", "successful") if not (result1 or result2): st.report_pass("snapshot_interval_config_and_reset", "successful") else: st.report_fail("snapshot_interval_config_and_reset", "failed")
def test_cli_validation_bgp_router_config(): st.banner("vtysh cli validation for bgp router config") start_time = datetime.datetime.now() bgp_router_cli_validation(dut, type="vtysh") end_time = datetime.datetime.now() time_diff = end_time - start_time st.banner( "time taken for BGP router config on 20 vlan routing interface using vtysh: {}" .format(time_diff)) st.report_tc_pass("FtOpSoRtPerfFn056", "test_case_passed") if st.is_feature_supported("klish"): st.banner("klish cli validation for bgp router config") start_time = datetime.datetime.now() bgp_router_cli_validation(dut, type="klish") end_time = datetime.datetime.now() time_diff = end_time - start_time st.banner( "time taken for BGP router config on 20 vlan routing interface using klish: {}" .format(time_diff)) st.report_tc_pass("FtOpSoRtPerfFn057", "test_case_passed") st.report_pass("test_case_passed")
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")
def test_ft_stormcontrol_warm_reboot(): status = 1 interface_list = [vars.D1T1P1, vars.D1T1P2] storm_control_type = ["broadcast", "unknown-multicast", "unknown-unicast"] msg_id = "storm_control_reboot_successful" utils.banner_log("Verifying BUM storm control before warm reboot") if not verify_bum_traffic_mode('broadcast', tg_info['tg1_stream_id'], skip_traffic_verify=False): st.error("Broadcast traffic verification got failed") status = 0 st.log("performing Config save") reboot.config_save(vars.D1) ############################################################################################# utils.banner_log("Performing warm-reboot operation --STARTED") ############################################################################################# st.log("performing warm-reboot") st.reboot(vars.D1, 'warm') ############################################################################################# utils.banner_log("Performing warm-reboot operation --COMPLETED") ############################################################################################# for interface in interface_list: for stc_type in storm_control_type: if not scapi.verify_config(vars.D1, interface_name=interface, type=stc_type, rate=sc_data.kbps): st.report_fail("storm_control_config_verify_failed", stc_type, interface) status = 0 st.log("Traffic Config for verifying BUM storm control feature") tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"]) tg_1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='create', rate_pps=5000, duration=10, l2_encap = 'ethernet_ii_vlan', vlan_id = sc_data.vlan, mac_src = "00:00:00:00:00:01", mac_dst = "ff:ff:ff:ff:ff:ff", high_speed_result_analysis = 0, vlan = "enable", port_handle2 = tg_handler["tg_ph_2"], frame_size = sc_data.frame_size, length_mode='fixed') tg_info['tg1_stream_id'] = tg_1['stream_id'] utils.banner_log("Verifying BUM storm control after warm reboot") if not verify_bum_traffic_mode('broadcast', tg_info['tg1_stream_id'], skip_traffic_verify=False): st.error("Broadcast traffic verification got failed") status = 0 if not status: msg_id = "storm_control_reboot_failed" if status: st.report_tc_pass('ft_stormcontrol_config_active_intf_warmboot', 'test_case_passed') st.report_tc_pass('ft_stormcontrol_rate_limit_across_warmboot', 'test_case_passed') st.report_tc_pass('ft_stormcontrol_config_restore_warmboot', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_config_active_intf_warmboot', 'test_case_failed') st.report_tc_fail('ft_stormcontrol_rate_limit_across_warmboot', 'test_case_failed') st.report_tc_fail('ft_stormcontrol_config_restore_warmboot', 'test_case_failed') report_result(status, msg_id)
def test_mgmt_vrf_bind(): report_flag = 0 #intf = ['mgmt','eth0'] intf = ['eth0'] if not mvrf.verify(vars.D1, mvrfstate='Enabled', interfaces=intf): st.log("FAILED") report_flag = 1 if report_flag: st.report_tc_fail("ft_mgmtVrf_bind", "mgmt_vrf_eth0_bind_fail") else: st.report_tc_pass("ft_mgmtVrf_bind", "mgmt_vrf_eth0_bind_success") report_flag = 0 intf_li = get_all_interfaces(vars.D1) if not mvrf.verify( vars.D1, mvrfstate='Enabled', interfaces=intf_li, dataport=True): report_flag = 1 if report_flag: st.report_tc_fail("ft_mgmtVrf_dataport", "mgmt_vrf_dataport_bind") else: st.report_tc_pass("ft_mgmtVrf_dataport", "mgmt_vrf_dataport_nobind") report_flag = 0 ip_addr = get_ifconfig_inet(vars.D1, 'eth0') if not ip_addr: st.log("IP Address not found on eth0") report_flag = 1 ssh_conn_obj = connect_to_device(ip_addr[0], mgmt_vrf.username_default, mgmt_vrf.password_default) if not ssh_conn_obj: if not connect_to_device(ip_addr[0], mgmt_vrf.username_default, mgmt_vrf.password_alt): report_flag = 1 if report_flag: st.report_tc_fail("ft_mgmtVrf_ssh", "mgmt_vrf_ssh_fail") else: st.report_tc_pass("ft_mgmtVrf_ssh", "mgmt_vrf_ssh_pass") if report_flag: st.report_fail("mgmt_vrf_eth0_bind_fail") else: st.report_pass("mgmt_vrf_eth0_bind_success")
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 test_unnumvrf_bfd(fixture_unnumvrf_test_bfd): tc_list = [ 'FtOpSoRoIPnumvrfFun004', 'FtOpSoRoIPnumvrfFun005', 'FtOpSoRoIPnumvrfFun006' ] final_result = 0 error_list = [] st.banner('FtOpSoRoIPnumvrfFun004 -- to -- FtOpSoRoIPnumvrfFun006') st.banner( 'Verify OSPF BFD over all the unnumbered interfaces over non-default vrf' ) tc_result = True st.log('Verify OSPF is up for all interfaces') loc_lib.verify_ospf() st.log('Configure BFD on PortChannel, Physical interface and vlan') dict1 = { "interface": data.d1_d2_ports[0], 'neighbor_ip': data.dut2_loopback_ip[0], 'config': 'yes', 'noshut': 'yes', 'vrf_name': data.dut1_vrf[0] } dict2 = { "interface": data.d2_d1_ports[0], 'neighbor_ip': data.dut1_loopback_ip[0], 'config': 'yes', 'noshut': 'yes' } parallel.exec_parallel(True, [data.dut1, data.dut2], bfd_obj.configure_bfd, [dict1, dict2]) result = retry_api(ip_obj.ping, data.dut1, addresses=data.dut2_loopback_ip[0], interface=data.dut1_vrf[0], retry_count=2, delay=10) if result is False: error = "Ping on IP unnumbered physical interface over non-default vrf failed" tc_result = False error_list.append(error) result = retry_api(bfd_obj.verify_bfd_peer, data.dut1, peer=data.dut2_loopback_ip[0], interface=data.d1_d2_ports[0], vrf_name=data.dut1_vrf[0], status='up', retry_count=3, delay=2) if result is False: error = "BFD on IP unnumbered physical interface over non-default vrf failed" tc_result = False error_list.append(error) if tc_result: st.report_tc_pass(tc_list[0], 'tc_passed') else: final_result += 1 st.report_tc_fail(tc_list[0], 'test_case_failure_message', error) tc_result = True dict1 = { "interface": data.portchannel, 'neighbor_ip': data.dut2_loopback_ip[2], 'config': 'yes', 'noshut': 'yes', 'vrf_name': data.dut1_vrf[0] } dict2 = { "interface": data.portchannel, 'neighbor_ip': data.dut1_loopback_ip[2], 'config': 'yes', 'noshut': 'yes' } parallel.exec_parallel(True, [data.dut1, data.dut2], bfd_obj.configure_bfd, [dict1, dict2]) result = retry_api(ip_obj.ping, data.dut1, addresses=data.dut2_loopback_ip[2], interface=data.dut1_vrf[0], retry_count=2, delay=10) if result is False: error = "Ping on IP unnumbered portchannel over non-default vrf failed" tc_result = False error_list.append(error) result = retry_api(bfd_obj.verify_bfd_peer, data.dut1, peer=data.dut2_loopback_ip[2], interface=data.portchannel, status='up', vrf_name=data.dut1_vrf[0], retry_count=3, delay=2) if result is False: error = "BFD on IP unnumbered portchannel over non-default vrf failed" tc_result = False error_list.append(error) if tc_result: st.report_tc_pass(tc_list[1], 'tc_passed') else: final_result += 1 st.report_tc_fail(tc_list[1], 'test_case_failure_message', error) tc_result = True dict1 = { "interface": 'Vlan' + data.dut1_dut2_vlan[0], 'neighbor_ip': data.dut2_loopback_ip[1], 'config': 'yes', 'noshut': 'yes', 'vrf_name': data.dut1_vrf[0] } dict2 = { "interface": 'Vlan' + data.dut1_dut2_vlan[0], 'neighbor_ip': data.dut1_loopback_ip[1], 'config': 'yes', 'noshut': 'yes' } parallel.exec_parallel(True, [data.dut1, data.dut2], bfd_obj.configure_bfd, [dict1, dict2]) result = retry_api(ip_obj.ping, data.dut1, addresses=data.dut2_loopback_ip[1], interface=data.dut1_vrf[0], retry_count=2, delay=10) if result is False: error = "Ping on IP unnumbered vlan over non-default vrf failed" tc_result = False error_list.append(error) result = retry_api(bfd_obj.verify_bfd_peer, data.dut1, peer=data.dut2_loopback_ip[1], interface='Vlan' + data.dut1_dut2_vlan[0], status='up', vrf_name=data.dut1_vrf[0], retry_count=3, delay=2) if result is False: error = "BFD on IP unnumbered vlan over non-default vrf failed" tc_result = False error_list.append(error) if tc_result: st.report_tc_pass(tc_list[2], 'tc_passed') else: final_result += 1 st.report_tc_fail(tc_list[2], 'test_case_failure_message', error) if final_result != 0: st.report_fail('test_case_failure_message', error_list) else: st.report_pass('test_case_passed')
def test_unnumvrf_basic(fixture_test_unnumvrf_basic): tc_list = [ 'FtOpSoRoIPnumvrfFun001', 'FtOpSoRoIPnumvrfFun002', 'FtOpSoRoIPnumvrfFun003' ] final_result = 0 error_list = [] st.banner('FtOpSoRoIPnumvrfFun001 -- to -- FtOpSoRoIPnumvrfFun003') st.banner( 'Configure and verify IP unnumbered over non-default vrf and default-vrf on a physical interface ' ) tc_result = True result = utils.exec_all(True, [[loc_lib.dut1_config_unnumbered, 'phy', ''], [loc_lib.dut2_config_unnumbered, 'phy', '']]) if result is False: error = "IP unnumbered configuration on a physical interface failed" tc_result = False error_list.append(error) result = utils.exec_all(True, [[loc_lib.dut1_verify_unnumbered, 'phy'], [loc_lib.dut2_verify_unnumbered, 'phy']]) if result is False: error = "IP unnumbered verification on a physical interface failed" tc_result = False error_list.append(error) st.log('On DUT1 verify routes on non default vrf use physical interface') result = retry_api(ip_obj.verify_ip_route, data.dut1, vrf_name=data.dut1_vrf[0], type='O', nexthop=data.dut2_loopback_ip[0], interface=data.d1_d2_ports[0], ip_address=data.dut2_loopback_ip[0] + '/' + data.ip_loopback_prefix, family="ipv4", retry_count=7, delay=5) if result is False: error = "IP routes on non-default vrf failed" tc_result = False error_list.append(error) result = loc_lib.send_verify_traffic(type='ipv4') if result is False: error = 'IPv4 traffic with IPv4 unnumbered over physical interface on a non-default vrf failed' tc_result = False error_list.append(error) if tc_result: st.report_tc_pass(tc_list[0], 'tc_passed') else: final_result += 1 st.report_tc_fail(tc_list[0], 'test_case_failure_message', error) st.banner( 'Configure and verify IP unnumbered over non-default vrf and default-vrf on a portchannel interface ' ) st.log( 'On DUT1 disable physical interface for the routes to be learnt from portchannel' ) port_obj.shutdown(data.dut1, data.d1_d2_ports[0]) tc_result = True result = utils.exec_all(True, [[loc_lib.dut1_config_unnumbered, 'pc', ''], [loc_lib.dut2_config_unnumbered, 'pc', '']]) if result is False: error = "IP unnumbered configuration on a portchannel interface failed" tc_result = False error_list.append(error) result = utils.exec_all(True, [[loc_lib.dut1_verify_unnumbered, 'pc'], [loc_lib.dut2_verify_unnumbered, 'pc']]) if result is False: error = "IP unnumbered verification on a portchannel interface failed" tc_result = False error_list.append(error) st.log('On DUT1 verify routes on non default vrf use portchannel') result = retry_api(ip_obj.verify_ip_route, data.dut1, vrf_name=data.dut1_vrf[0], type='O', nexthop=data.dut2_loopback_ip[2], interface=data.portchannel, ip_address=data.dut2_loopback_ip[2] + '/' + data.ip_loopback_prefix, family="ipv4", retry_count=7, delay=5) if result is False: error = "IP routes on non-default vrf using portchannel failed" tc_result = False error_list.append(error) result = loc_lib.send_verify_traffic(type='ipv4') if result is False: error = 'IPv4 traffic with IPv4 unnumbered over portchannel on a non-default vrf failed' tc_result = False error_list.append(error) if tc_result: st.report_tc_pass(tc_list[1], 'tc_passed') else: final_result += 1 st.report_tc_fail(tc_list[1], 'test_case_failure_message', error) st.log( 'Configure and verify IP unnumbered over non-default vrf and default-vrf on a vlan interface ' ) st.log( 'On DUT1 disable physical interface for the routes to be learnt from portchannel' ) port_obj.shutdown(data.dut1, [data.d1_d2_ports[2], data.d1_d2_ports[3]]) tc_result = True result = utils.exec_all(True, [[loc_lib.dut1_config_unnumbered, 'vlan', ''], [loc_lib.dut2_config_unnumbered, 'vlan', '']]) if result is False: error = "IP unnumbered configuration on a vlan interface failed" tc_result = False error_list.append(error) result = utils.exec_all(True, [[loc_lib.dut1_verify_unnumbered, 'vlan'], [loc_lib.dut2_verify_unnumbered, 'vlan']]) if result is False: error = "IP unnumbered verification on a vlan interface failed" tc_result = False error_list.append(error) st.log('On DUT1 verify routes on non default vrf use vlan') result = retry_api(ip_obj.verify_ip_route, data.dut1, vrf_name=data.dut1_vrf[0], type='O', nexthop=data.dut2_loopback_ip[1], interface='Vlan' + data.dut1_dut2_vlan[0], ip_address=data.dut2_loopback_ip[1] + '/' + data.ip_loopback_prefix, family="ipv4", retry_count=7, delay=5) if result is False: error = "IP routes on non-default vrf using vlan failed" tc_result = False error_list.append(error) result = loc_lib.send_verify_traffic(type='ipv4') if result is False: error = 'IPv4 traffic with IPv4 unnumbered over vlan interface on a non-default vrf failed' tc_result = False error_list.append(error) if tc_result: st.report_tc_pass(tc_list[2], 'tc_passed') else: final_result += 1 st.report_tc_fail(tc_list[2], 'test_case_failure_message', error) if final_result != 0: st.report_fail('test_case_failure_message', error_list) else: st.report_pass('test_case_passed')
def test_unnumvrf_reboot_reload(): ###################################################################################################################################### tc_list = ['FtOpSoRoIPnumvrfFun010', 'FtOpSoRoIPnumvrfFun011'] final_result = 0 error_list = [] st.banner('FtOpSoRoIPnumvrfFun010 -- to -- FtOpSoRoIPnumvrfFun011') st.banner( 'FtOpSoRoIPnumvrfFun010 - Verify unnumbered interface accross a fast reboot' ) tc_result = True st.log("Save the running config in sonic and vtysh modes") reboot_obj.config_save(data.dut1) reboot_obj.config_save(data.dut1, shell='vtysh') st.reboot(data.dut1, 'fast') result = retry_api(ip_obj.ping, data.dut1, addresses=data.dut2_loopback_ip[0], interface=data.dut1_vrf[0], retry_count=3, delay=10) if result is False: error = "After reload Ping on IP unnumbered physical interface over non-default vrf failed" tc_result = False error_list.append(error) result = retry_api(ip_obj.ping, data.dut1, addresses=data.dut2_loopback_ip[1], interface=data.dut1_vrf[0], retry_count=2, delay=10) if result is False: error = "After reload Ping on IP unnumbered physical interface over non-default vrf failed" tc_result = False error_list.append(error) result = retry_api(ip_obj.ping, data.dut1, addresses=data.dut2_loopback_ip[2], interface=data.dut1_vrf[0], retry_count=2, delay=10) if result is False: error = "After reload Ping on IP unnumbered physical interface over non-default vrf failed" tc_result = False error_list.append(error) st.log('Verify OSPF is up for all interfaces') result = loc_lib.verify_ospf() if result is False: error = "After reload OSPF neighbors are not up for all/some of the unnumbered interfaces" tc_result = False error_list.append(error) result = loc_lib.send_verify_traffic() if result is False: error = "After fast reboot IPv4 traffic on unnumbered interface failed" tc_result = False error_list.append(error) if tc_result: st.report_tc_pass(tc_list[0], 'tc_passed') else: final_result += 1 st.report_tc_fail(tc_list[0], 'test_case_failure_message', error) st.banner( 'FtOpSoRoIPnumvrfFun011 - Verify unnumbered interface across a config reload' ) tc_result = True reboot_obj.config_reload(data.dut1) result = retry_api(ip_obj.ping, data.dut1, addresses=data.dut2_loopback_ip[0], interface=data.dut1_vrf[0], retry_count=3, delay=10) if result is False: error = "After reload Ping on IP unnumbered physical interface over non-default vrf failed" tc_result = False error_list.append(error) result = retry_api(ip_obj.ping, data.dut1, addresses=data.dut2_loopback_ip[1], interface=data.dut1_vrf[0], retry_count=2, delay=10) if result is False: error = "After reload Ping on IP unnumbered physical interface over non-default vrf failed" tc_result = False error_list.append(error) result = retry_api(ip_obj.ping, data.dut1, addresses=data.dut2_loopback_ip[2], interface=data.dut1_vrf[0], retry_count=2, delay=10) if result is False: error = "After reload Ping on IP unnumbered physical interface over non-default vrf failed" tc_result = False error_list.append(error) st.log('Verify OSPF is up for all interfaces') result = loc_lib.verify_ospf() if result is False: error = "After reload OSPF neighbors are not up for all/some of the unnumbered interfaces" tc_result = False error_list.append(error) result = loc_lib.send_verify_traffic() if result is False: error = "After config reload IPv4 traffic on unnumbered interface failed" tc_result = False error_list.append(error) if tc_result: st.report_tc_pass(tc_list[1], 'tc_passed') else: final_result += 1 st.report_tc_fail(tc_list[1], 'test_case_failure_message', error) if final_result != 0: st.report_fail('test_case_failure_message', error_list) else: st.report_pass('test_case_passed')
def test_unnumvrf_donar(fixture_unnumvrf_test_donar): tc_list = [ 'FtOpSoRoIPnumvrfFun007', 'FtOpSoRoIPnumvrfFun008', 'FtOpSoRoIPnumvrfFun009' ] final_result = 0 result = True error_list = [] st.banner('FtOpSoRoIPnumvrfFun007 -- to -- FtOpSoRoIPnumvrfFun009') st.banner( 'Verify unnumbered interface for non default vrf after unbind and rebind vrf' ) tc_result = True st.log('Remove the unnumbered configuration on DUT1') loc_lib.dut1_config_unnumbered('phy', 'no') loc_lib.dut1_config_unnumbered('vlan', 'no') loc_lib.dut1_config_unnumbered('pc', 'no') st.log( 'Remove the OSPF configuration for the unnumbered interfaces on DUT1') ospf_obj.config_interface_ip_ospf_network_type(data.dut1, data.d1_d2_ports[0], 'point-to-point', data.dut1_vrf[0], 'no') ospf_obj.config_interface_ip_ospf_network_type( data.dut1, 'Vlan' + data.dut1_dut2_vlan[0], 'point-to-point', data.dut1_vrf[0], 'no') ospf_obj.config_interface_ip_ospf_network_type(data.dut1, data.portchannel, 'point-to-point', data.dut1_vrf[0], 'no') st.log('Remove the IP addresses for the unnumbered interfaces on DUT1') ip_obj.delete_ip_interface(data.dut1, data.dut1_loopback[2], data.dut1_loopback_ip[2], data.ip_loopback_prefix, "ipv4") ip_obj.delete_ip_interface(data.dut1, data.dut1_loopback[1], data.dut1_loopback_ip[1], data.ip_loopback_prefix, "ipv4") ip_obj.delete_ip_interface(data.dut1, data.dut1_loopback[0], data.dut1_loopback_ip[0], data.ip_loopback_prefix, "ipv4") st.log('Remove the VRF binding for the unnumbered interfaces on DUT1') vrf_obj.bind_vrf_interface( dut=data.dut1, vrf_name=[data.dut1_vrf[0], data.dut1_vrf[0], data.dut1_vrf[0]], intf_name=[ data.d1_d2_ports[0], 'Vlan' + data.dut1_dut2_vlan[0], data.portchannel ], config='no') st.log('Bind the back to the unnumbered interfaces on DUT1') vrf_obj.bind_vrf_interface( dut=data.dut1, vrf_name=[data.dut1_vrf[0], data.dut1_vrf[0], data.dut1_vrf[0]], intf_name=[ data.d1_d2_ports[0], 'Vlan' + data.dut1_dut2_vlan[0], data.portchannel ], config='yes') st.banner('On DUT1 verify vrf bindings for all the interfaces') output = vrf_obj.get_vrf_verbose(dut=data.dut1, vrfname=data.dut1_vrf[0]) if data.dut1_vrf[0] in output['vrfname']: st.log('VRF configured on DUT1 is as expected', data.dut1_vrf[0]) else: st.error('VRF name configured on DUT1 is as not expected', data.dut1_vrf[0]) result = False for value in output['interfaces']: if data.dut1_tg_ports[0] or data.dut1_loopback[ 0] or data.dut1_loopback[1] or data.dut1_loopback[ 2] or data.d1_d2_ports[0] or 'Vlan' + data.dut1_dut2_vlan[ 0] or data.portchannel == value: st.log('Bind to VRF is as expected', value) else: st.error('Bind to VRF is not as expected', value) result = False if result is False: error = "Unbind/Rebind of unnumbered interfaces failed" tc_result = False error_list.append(error) if tc_result: st.report_tc_pass(tc_list[0], 'tc_passed') else: final_result += 1 st.report_tc_fail(tc_list[0], 'test_case_failure_message', error) st.banner( 'Verify unnumbered interface for non default vrf after adding and removing donar IP' ) tc_result = True st.log('On DUT1 configure back the ip addresses on the loopbacks') ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[1], data.dut1_loopback_ip[1], data.ip_loopback_prefix, 'ipv4') ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[2], data.dut1_loopback_ip[2], data.ip_loopback_prefix, 'ipv4') st.log('On DUT1 add the interfaces back in the ospf network') ospf_obj.config_interface_ip_ospf_network_type( data.dut1, 'Vlan' + data.dut1_dut2_vlan[0], 'point-to-point', data.dut1_vrf[0], 'yes') ospf_obj.config_interface_ip_ospf_network_type(data.dut1, data.portchannel, 'point-to-point', data.dut1_vrf[0], 'yes') st.log( 'On DUT1 configure and verify portchannel and vlan as unnumbered interfaces' ) loc_lib.dut1_config_unnumbered('vlan', '') result = loc_lib.dut1_verify_unnumbered('vlan') if result is False: error = "Verification of unnumbered interfaces over vrf on a vlan failed after adding/removing the donar interface" tc_result = False error_list.append(error) loc_lib.dut1_config_unnumbered('pc', '') result = loc_lib.dut1_verify_unnumbered('pc') if result is False: error = "Verification of unnumbered interfaces over vrf on a portchannel failed after adding/removing the donar interface" tc_result = False error_list.append(error) if tc_result: st.report_tc_pass(tc_list[1], 'tc_passed') else: final_result += 1 st.report_tc_fail(tc_list[1], 'test_case_failure_message', error) st.banner( 'Verify unnumbered interface for non default vrf after modifying the donar IP' ) tc_result = True st.log( 'On DUT1 modify the donar interface address, add them to the ospf network and configure the physical interface as unnumbered for the new donar IP' ) ip_obj.config_ip_addr_interface(data.dut1, data.dut1_loopback[0], data.dut1_loopback_ip[3], data.ip_loopback_prefix, 'ipv4') ospf_obj.config_interface_ip_ospf_network_type(data.dut1, data.d1_d2_ports[0], 'point-to-point', data.dut1_vrf[0], 'yes') ospf_obj.config_ospf_network( data.dut1, data.dut1_loopback_ip[3] + '/' + data.ip_loopback_prefix, 0, data.dut1_vrf[0], '', 'yes') ip_obj.config_unnumbered_interface(data.dut1, family='ipv4', action='add', interface=data.d1_d2_ports[0], loop_back=data.dut1_loopback[0]) st.log('Verify OSPF is up for all interfaces') result = loc_lib.verify_ospf() if result is False: error = "OSPF neighbors are not up for all/some of the unnumbered interfaces" tc_result = False error_list.append(error) result = ip_obj.verify_interface_ip_address( data.dut1, data.d1_d2_ports[0], data.dut1_loopback_ip[3] + '/' + data.ip_loopback_prefix, 'ipv4', data.dut1_vrf[0], 'U') if result is False: error = "Verification of unnumbered interfaces over vrf on a physical interface failed after modifying the donar IP" tc_result = False error_list.append(error) st.log( 'Shutting the other ports for traffic to take new configured donar address' ) port_obj.shutdown( data.dut1, [data.d1_d2_ports[1], data.d1_d2_ports[2], data.d1_d2_ports[3]]) result = retry_api(ip_obj.verify_ip_route, data.dut2, type='O', nexthop=data.dut1_loopback_ip[3], interface=data.d2_d1_ports[0], ip_address=data.dut1_loopback_ip[3] + '/' + data.ip_loopback_prefix, family="ipv4", retry_count=7, delay=5) if result is False: error = "IP routes on non-default vrf with new IP failed" tc_result = False error_list.append(error) result = loc_lib.send_verify_traffic() if result is False: error = "Traffic over vrf on a physical interface failed after modifying the donar IP" tc_result = False error_list.append(error) if tc_result: st.report_tc_pass(tc_list[2], 'tc_passed') else: final_result += 1 st.report_tc_fail(tc_list[2], 'test_case_failure_message', error) if final_result != 0: st.report_fail('test_case_failure_message', error_list) else: st.report_pass('test_case_passed')
def test_warm_reboot_dynmaic_neigh(fixture_test_warm_reboot): ##################################################################################################################################### errs = [] st.banner( 'FtOpSoRoDynReb002 - Verify BGP unnumbererd and listen range on default after a warm reboot' ) st.log(" Add graceful restart and preserve_state state configuration") dict1 = {'local_asn': dut1_as, 'config': 'add', 'preserve_state': '1'} dict2 = {'local_asn': dut2_as, 'config': 'add', 'preserve_state': '1'} dict3 = {'local_asn': dut3_as, 'config': 'add', 'preserve_state': '1'} parallel.exec_parallel(True, [data.dut1, data.dut2, data.dut3], bgp_obj.config_bgp_graceful_restart, [dict1, dict2, dict3]) st.log('FtOpSoRoDynReb002 - Enable warm restart for dockers') reboot_obj.config_warm_restart(data.dut2, oper="enable") reboot_obj.config_warm_restart(data.dut2, oper="enable", tasks=["bgp", "swss", "teamd", "system"]) st.log("Verify ping and BGP session before warm reboot") if not loc_lib.retry_api(bgp_obj.verify_bgp_summary, data.dut2, family='ipv4', shell=bgp_cli_type, neighbor='Vlan2', state='Established', retry_count=10, delay=15): errs.append( st.error( "Failed to form BGP unnumbered session using IPv6 link local address over vlan" )) if not loc_lib.retry_api(ip_obj.ping, data.dut1, addresses=dut3_tg_ip[0], retry_count=10, delay=10, source_ip=dut1_tg_ip[0]): errs.append(st.error('IPv4 Ping from DUT1 to DUT3 failed')) st.log("Save the running config in sonic and vtysh modes") reboot_obj.config_save(data.dut2) st.vtysh(data.dut2, "copy running startup") st.reboot(data.dut2, 'warm') if not loc_lib.retry_api(ip_obj.ping, data.dut1, addresses=dut3_tg_ip[0], retry_count=10, delay=10, source_ip=dut1_tg_ip[0]): errs.append(st.error('IPv4 Ping from DUT1 to DUT3 failed')) aggrResult = loc_lib.send_verify_traffic() if not aggrResult: errs.append( st.error( 'IPv4 traffic over default VRF with BGP unnumbered and Dynamic Discovery failed' )) if not errs: st.report_tc_pass('FtOpSoRoDynReb002', 'test_case_passed') else: st.report_tc_fail('FtOpSoRoDynReb002', 'test_case_failed') if not errs: st.report_pass('test_case_passed') else: st.report_fail('test_case_failed_msg', ", ".join(errs))
def test_dynamic_unnumbered_scale(): ########################################################################################################################################## result = 0 st.banner('FtOpSoRoAutoSc001 - Verify maximum BGP unnumbered sessions') st.banner('FtOpSoRoAutoSc002 - Verify maximum sessions with listen range') vlan_list_d1_d2 = ['%s' % x for x in range(1, 101)] ip_list_dut2 = loc_lib.ip_range('2.0.0.1', 2, 100) ip_list_dut3 = loc_lib.ip_range('2.0.0.2', 2, 100) loc_lib.bgp_router_id() loc_lib.redistribute_routes() st.log( 'Configure BGP unnumbered sessions or 100 vlans between DUT1 and DUT2') for vlan in vlan_list_d1_d2: dict1 = { 'addr_family': 'ipv6', 'local_as': dut1_as, 'remote_as': dut2_as, 'config_type_list': ['remote-as', 'activate'], 'interface': 'Vlan' + vlan, 'neighbor': 'Vlan' + vlan } dict2 = { 'addr_family': 'ipv6', 'local_as': dut2_as, 'remote_as': dut1_as, 'config_type_list': ['remote-as', 'activate'], 'interface': 'Vlan' + vlan, 'neighbor': 'Vlan' + vlan } putils.exec_parallel(True, [data.dut1, data.dut2], bgp_obj.config_bgp, [dict1, dict2]) st.log('Configure IPv4 peer groups on DUT2 and DUT3') utils.exec_all(True, [[ bgp_obj.create_bgp_peergroup, data.dut2, dut2_as, 'd2d3_v4_peer', dut3_as ], [ bgp_obj.create_bgp_peergroup, data.dut3, dut3_as, 'd2d3_v4_peer', dut2_as ]]) st.log('Configure listen range on DUT2') bgp_obj.config_bgp_listen_range(dut=data.dut2, local_asn=dut2_as, neighbor_address='2.0.0.0', subnet=16, peer_grp_name='d2d3_v4_peer', limit=100, config='yes') st.log('Configure IPv4 and IPv6 BGP sessions on DUT2 and DUT3') st.log('Configure neighbors on DUT3') for ip in ip_list_dut2: bgp_obj.create_bgp_neighbor_use_peergroup(dut=data.dut3, local_asn=dut3_as, peer_grp_name='d2d3_v4_peer', neighbor_ip=ip, family="ipv4") bgp_obj.activate_bgp_neighbor(data.dut3, dut3_as, ip, 'ipv4', remote_asn=dut2_as) bgp_obj.activate_bgp_neighbor(data.dut3, dut3_as, ip, 'ipv6', remote_asn=dut2_as) st.log('Configure 100 BGP sessions with listen range') if not loc_lib.retry_api(bgp_obj.verify_bgp_summary, data.dut2, family='ipv4', shell=bgp_cli_type, neighbor=['Vlan2', '*' + ip_list_dut3[0]], state='Established', retry_count=10, delay=15): st.error( "Failed to form BGP unnumbered session using IPv6 link local address over vlan" ) result += 1 ip_obj.show_ip_route(data.dut1, family="ipv4") if not loc_lib.retry_api(ip_obj.ping, data.dut1, addresses=dut3_tg_ip[0], retry_count=10, delay=10, source_ip=dut1_tg_ip[0]): st.error('IPv4 Ping from DUT1 to DUT3 failed') result += 1 aggrResult = loc_lib.send_verify_traffic() if not aggrResult: st.error( 'IPv4 and IPv6 traffic over vlan with BGP unnumbered and Dynamic Discovery failed' ) result += 1 st.log("Reduce the limit and verify the neighbor is removed") bgp_obj.config_bgp_listen_range(dut=data.dut2, local_asn=dut2_as, limit=1) bgp_obj.clear_ip_bgp_vtysh(data.dut2, value="*") bgp_obj.config_bgp_listen_range(dut=data.dut2, local_asn=dut2_as, limit=100) bgp_obj.clear_ip_bgp_vtysh(data.dut2, value="*") st.wait(2) if not loc_lib.retry_api(bgp_obj.verify_bgp_summary, data.dut2, family='ipv4', shell=bgp_cli_type, neighbor=['Vlan2', '*' + ip_list_dut3[0]], state='Established', retry_count=10, delay=15): st.error( "Failed to form BGP unnumbered session using IPv6 link local address over vlan" ) result += 1 if result == 0: st.report_tc_pass('FtOpSoRoAutoSc001', 'test_case_passed') else: st.report_tc_fail('FtOpSoRoAutoSc001', 'test_case_failed') if result == 0: st.report_tc_pass('FtOpSoRoAutoSc002', 'test_case_passed') else: st.report_tc_fail('FtOpSoRoAutoSc002', 'test_case_failed') if result == 0: st.report_pass('test_case_passed') else: st.report_fail('test_case_failed')
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')
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_ft_stormcontrol_verification(): status = 1 msg_id = "storm_control_traffic_verification_successful" new_kbps_value = 1010 st.log("Module config got passed") st.report_tc_pass('ft_stormcontrol_config_all_same_interface', 'test_case_passed') if not verify_bum_traffic_mode( 'broadcast', tg_info['tg1_stream_id'], skip_traffic_verify=False): st.error("Broadcast traffic verification got failed") status = 0 if not verify_bum_traffic_mode('unknown-unicast', tg_info['tg1_stream_id'], skip_traffic_verify=False): st.error("Unknown-unicast traffic verification got failed") status = 0 if not verify_bum_traffic_mode('unknown-multicast', tg_info['tg1_stream_id'], skip_traffic_verify=False): st.error("Unknown-multicast traffic verification got failed") status = 0 if status: st.report_tc_pass('ft_stormcontrol_BUM_traffic_policer_params', 'test_case_passed') st.report_tc_pass('ft_stormcontrol_traffic_rate_limited_bpsvalue', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_BUM_traffic_policer_params', 'test_case_failed') st.report_tc_fail('ft_stormcontrol_traffic_rate_limited_bpsvalue', 'test_case_failed') status = 1 st.log( "Configuring kbps value on interface to verify kpbs value is independent of interface" ) scapi.config(vars.D1, type="broadcast", action="add", interface_name=vars.D1T1P1, bits_per_sec=new_kbps_value) if not scapi.verify_config(vars.D1, interface_name=vars.D1T1P1, type="broadcast", rate=new_kbps_value): st.error( "KBPS value configured on interface is dependent to other interface" ) status = 0 if status: st.report_tc_pass('ft_stormcontrol_bps_intf_indp', 'test_case_passed') st.report_tc_pass('ft_stormcontrol_bps_overwrite_new_bps_value', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_bps_intf_indp', 'test_case_failed') st.report_tc_fail('ft_stormcontrol_bps_overwrite_new_bps_value', 'test_case_failed') status = 1 st.log("configuring back to previous config") scapi.config(vars.D1, type="broadcast", action="add", interface_name=vars.D1T1P1, bits_per_sec=sc_data.kbps) scapi.verify_config(vars.D1, interface_name=vars.D1T1P1, type="broadcast", rate=sc_data.kbps) if not verify_bum_traffic_mode( 'broadcast', tg_info['tg1_stream_id'], skip_traffic_verify=False): st.error("Broadcast traffic verification got failed") status = 0 if status: st.report_tc_pass('ft_stormcontrol_config_clear_noaffect_traffic', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_config_clear_noaffect_traffic', 'test_case_failed') status = 1 st.log( "clearing bum traffic type to verify othertraffic does not effect bum storm-control" ) scapi.config(vars.D1, type="unknown-unicast", action="del", interface_name=vars.D1T1P1, bits_per_sec=sc_data.kbps) st.log("verifying the other traffic is not get effected.") if not verify_bum_traffic_mode('unknown-unicast', tg_info['tg1_stream_id'], skip_traffic_verify=True): st.error("Other_traffic traffic verification got failed") status = 0 if status: st.report_tc_pass('ft_stormcontrol_config_unaffect_other_traffic', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_config_unaffect_other_traffic', 'test_case_failed') st.log("configuring back to previous config") scapi.config(vars.D1, type="unknown-unicast", action="add", interface_name=vars.D1T1P1, bits_per_sec=sc_data.kbps) if not status: msg_id = "storm_control_traffic_verification_failed" report_result(status, msg_id)
def test_ft_stormcontrol_portchannel_intf(): status = 1 msg_id = "storm_control_portchannel_verification_successful" portchannel_name = 'PortChannel13' vlan_info = [{ "dut": [vars.D2], "vlan_id": sc_data.vlan, "tagged": [vars.D2T1P1, vars.D2T1P2, portchannel_name] }] portchannel_interfaces_dut1 = [vars.D1D2P1, vars.D1D2P2] portchannel_interfaces_dut2 = [vars.D2D1P1, vars.D2D1P2] portchannel.config_portchannel(vars.D1, vars.D2, portchannel_name, portchannel_interfaces_dut1, portchannel_interfaces_dut2, config="add", thread=True) vlan.add_vlan_member(vars.D1, sc_data.vlan, portchannel_name, tagging_mode=True) vlan.create_vlan_and_add_members(vlan_info) st.log( "Verifying whether stormcontrol config can be applied on portchannel {} interfaces" .format(portchannel_name)) if scapi.config(vars.D1, type="broadcast", action="add", interface_name=portchannel_name, rate=sc_data.kbps, skip_error_check=True): st.error( "storm-control config can be applied on portchannel interface") status = 0 else: st.log( "storm-control config cannot be applied on portchannel interface.") if status: st.report_tc_pass('ft_stormcontrol_neg_config_vlan_portchannel', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_neg_config_vlan_portchannel', 'test_case_failed') status = 1 st.log("configuring bum stormcontrol on portchannel interfaces") scapi.config(vars.D1, type="broadcast", action="del", interface_name=vars.D1T1P1, bits_per_sec=sc_data.kbps) scapi.config(vars.D1, type="broadcast", action="del", interface_name=vars.D1T1P2, bits_per_sec=sc_data.kbps) scapi.config(vars.D2, type="broadcast", action="add", interface_name=vars.D2D1P1, bits_per_sec=sc_data.kbps) scapi.config(vars.D2, type="broadcast", action="add", interface_name=vars.D2D1P2, bits_per_sec=sc_data.kbps) verify_bum_traffic_mode('broadcast', tg_info['tg1_stream_id'], skip_traffic_verify=True) st.log("Clearing interface counters") ifapi.clear_interface_counters(vars.D2) tg.tg_traffic_control(action='run', stream_handle=tg_info['tg1_stream_id'], duration=10) st.wait(sc_data.wait_stream_run) st.log("Stopping of traffic from TGen to get interface counters") tg.tg_traffic_control(action='stop', stream_handle=tg_info['tg1_stream_id']) st.wait(sc_data.wait_for_stats) tg_1_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_1"]) tg_3_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_3"]) counter = tg_3_stats.rx.total_packets counter2 = tg_1_stats.tx.total_packets try: time = int(counter2 / sc_data.rate_pps) counters_avg = counter / time except Exception: counters_avg = 0 st.log("Average of counters are : {}".format(counters_avg)) st.log("Higher packet count value is : {}".format( sc_data.higher_pkt_count)) st.log("Lower packet count value is : {}".format(sc_data.lower_pkt_count)) st.log("value of status is : {}".format(status)) if counters_avg > sc_data.higher_pkt_count or counters_avg < sc_data.lower_pkt_count: st.error("storm control traffic verification failed") status = 0 if status: st.report_tc_pass('ft_stormcontrol_portchannel_intf', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_portchannel_intf', 'test_case_failed') status = 1 st.log("Configuring stormcontrol without providing bps value") if scapi.config(vars.D1, type="broadcast", action="add", interface_name=vars.D1T1P1, skip_error_check=True): st.error("Storm-control config is accepting not throwing any error") status = 0 else: st.log("Config is not accepted and thrown an error") if status: st.report_tc_pass('ft_stormcontrol_neg_config_without_bpsvalue', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_neg_config_without_bpsvalue', 'test_case_failed') status = 1 st.log("unconfiguring of bum stormcontrol type by providing bps value") if scapi.config(vars.D1, type="broadcast", action="del", interface_name=vars.D1T1P1, rate=sc_data.kbps, skip_error_check=True): st.error("Storm-control config is removed and not throwing any error") status = 0 else: st.log("Config is not accepted and thrown an error") if status: st.report_tc_pass('ft_stormcontrol_neg_unconfig_with_bpsvalue', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_neg_unconfig_with_bpsvalue', 'test_case_failed') st.log("Back to module config") scapi.config(vars.D2, type="broadcast", action="del", interface_name=vars.D2D1P1, bits_per_sec=sc_data.kbps) scapi.config(vars.D2, type="broadcast", action="del", interface_name=vars.D2D1P2, bits_per_sec=sc_data.kbps) scapi.config(vars.D1, type="broadcast", action="add", interface_name=vars.D1T1P1, bits_per_sec=sc_data.kbps) scapi.config(vars.D1, type="broadcast", action="add", interface_name=vars.D1T1P2, bits_per_sec=sc_data.kbps) st.log( "Unconfiguring portchannel config in both devices and only vlan configuration in device2" ) vlan.clear_vlan_configuration(vars.D2) vlan.delete_vlan_member(vars.D1, sc_data.vlan, portchannel_name, tagging_mode=True) portchannel.clear_portchannel_configuration(st.get_dut_names(), thread=True) if not status: msg_id = "storm_control_portchannel_verification_failed" report_result(status, msg_id)
def test_ft_ansible_playbooks_chk_use_vdi(): device_ip = st.get_mgmt_ip(vars.D1) result = True if not ansible_obj.verify_ansible_playbook_vdi( vars.D1, "ping.yml", host=device_ip, ok="1", fail="0"): result = False st.report_tc_fail("ft_ansible_host_ping_playbook", "ansible_fail") st.report_tc_fail("ft_ansible_host_ping_using_pwd", "ansible_fail") st.report_tc_fail("ft_ansible_host_ping_using_ssh", "ansible_fail") st.report_tc_fail("ft_ansible_host_multiple_grp_ping", "ansible_fail") else: st.report_tc_pass("ft_ansible_host_ping_playbook", "ansible_playbook_success") st.report_tc_pass("ft_ansible_host_ping_using_pwd", "ansible_playbook_success") st.report_tc_pass("ft_ansible_host_ping_using_ssh", "ansible_playbook_success") st.report_tc_pass("ft_ansible_host_multiple_grp_ping", "ansible_playbook_success") if not ansible_obj.verify_ansible_playbook_vdi( vars.D1, "fact.yml", host=device_ip, ok="2", fail="0"): result = False st.report_tc_fail("ft_ansible_host_fact_playbook", "ansible_fail") else: st.report_tc_pass("ft_ansible_host_fact_playbook", "ansible_playbook_success") if not ansible_obj.verify_ansible_playbook_vdi( vars.D1, "fact_false.yml", host=device_ip, ok="1", fail="0"): result = False st.report_tc_fail("ft_ansible_fact_cmd_line", "ansible_fail") st.report_tc_fail("ft_ansible_host_adhoc_cmd", "ansible_fail") else: st.report_tc_pass("ft_ansible_fact_cmd_line", "ansible_playbook_success") st.report_tc_pass("ft_ansible_host_adhoc_cmd", "ansible_playbook_success") if not ansible_obj.verify_ansible_playbook_vdi( vars.D1, "copy.yml", host=device_ip, ok="2", fail="0"): result = False st.report_tc_fail("ft_ansible_copy_playbook", "ansible_fail") else: st.report_tc_pass("ft_ansible_copy_playbook", "ansible_playbook_success") if not ansible_obj.verify_ansible_playbook_vdi( vars.D1, "role_test.yml", host=device_ip, fail="0"): result = False st.report_tc_fail("ft_ansible_playbook_role", "ansible_fail") st.report_tc_fail("ft_ansible_playbook_tags", "ansible_fail") st.report_tc_fail("ft_ansible_package_chk_using_cmd", "ansible_fail") else: st.report_tc_pass("ft_ansible_playbook_role", "ansible_playbook_success") st.report_tc_pass("ft_ansible_playbook_tags", "ansible_playbook_success") st.report_tc_pass("ft_ansible_package_chk_using_cmd", "ansible_playbook_success") if not ansible_obj.verify_ansible_playbook_vdi( vars.D1, "handler.yml", host=device_ip, fail="0"): result = False st.report_tc_fail("ft_ansible_playbook_handler", "ansible_fail") else: st.report_tc_pass("ft_ansible_playbook_handler", "ansible_playbook_success") if result: st.report_pass("ansible_playbook_success") else: st.report_fail("ansible_fail")
def test_ecmp_vxlan_func003(): tc_list = ['FtOpSoRoLBFunc004', 'FtOpSoRoLBFunc008', 'FtOpSoRoLBFunc010'] st.banner( "Testcase: Verify IPv4 and IPv6 ECMP Loadbalance and Hash polarization in VxLAN topology.\n TCs:{}." .format(tc_list)) retvar = True fail_msgs = '' tc_res = {} for tc in tc_list: tc_res[tc] = True spine1 = data.dut1 spine2 = data.dut2 leaf1 = data.dut3 leaf2 = data.dut4 leaf3 = data.dut5 vxlan_tolerance = 30 st.banner("Step T1: Verify default show cli.") def f3_t1_1(): res1 = ip.verify_ip_loadshare(spine1, ip=ecmpv4, ipv6=ecmpv6, seed=data.seed_def) if res1 is False: fail_msg = "ERROR: Step T1 Default show failed on spine1." st.log(fail_msg) return False return True def f3_t1_2(): res1 = ip.verify_ip_loadshare(spine2, ip=ecmpv4, ipv6=ecmpv6, seed=data.seed_def) if res1 is False: fail_msg = "ERROR: Step T1 Default show failed on spine2." st.log(fail_msg) return False return True def f3_t1_3(): res1 = ip.verify_ip_loadshare(leaf1, ip=ecmpv4, ipv6=ecmpv6, seed=data.seed_def) if res1 is False: fail_msg = "ERROR: Step T1 Default show failed on leaf1." st.log(fail_msg) return False return True def f3_t1_4(): res1 = ip.verify_ip_loadshare(leaf2, ip=ecmpv4, ipv6=ecmpv6, seed=data.seed_def) if res1 is False: fail_msg = "ERROR: Step T1 Default show failed on leaf2." st.log(fail_msg) return False return True def f3_t1_5(): res1 = ip.verify_ip_loadshare(leaf3, ip=ecmpv4, ipv6=ecmpv6, seed=data.seed_def) if res1 is False: fail_msg = "ERROR: Step T1 Default show failed on leaf3." st.log(fail_msg) return False return True [res, _] = utils.exec_all( True, [[f3_t1_1], [f3_t1_2], [f3_t1_3], [f3_t1_4], [f3_t1_5]]) if False in set(res): fail_msg = "ERROR: Step T1 show cli for default values failed." fail_msgs += fail_msg st.log(fail_msg) tc_res[tc_list[0]] = False retvar = False ''' st.log("Step T1a: Fine tuning the config and verification.") f3_f2_1=lambda x: intf.interface_shutdown(spine1, [vars.D1D3P2, vars.D1D4P2, vars.D1D5P2]) f3_f2_2=lambda x: intf.interface_shutdown(spine2, [vars.D2D3P2, vars.D2D4P2, vars.D2D5P2]) [res, _] = utils.exec_all(True, [[f3_f2_1, 1], [f3_f2_2, 1]]) st.wait(waitvar) ''' st.banner("Step T2: Start all IPv4 and IPv6 Streams.") tg_v4s = [tg_l3l1_1['stream_id']] tg_v6s = [tg_l3l1_6_1['stream_id']] tg_strs = tg_v4s + tg_v6s f3_f1_1 = lambda x: intf.clear_interface_counters(spine1) f3_f1_2 = lambda x: intf.clear_interface_counters(spine2) f3_f1_3 = lambda x: intf.clear_interface_counters(leaf1) f3_f1_4 = lambda x: intf.clear_interface_counters(leaf2) f3_f1_5 = lambda x: intf.clear_interface_counters(leaf3) [res, _] = utils.exec_all( True, [[f3_f1_1, 1], [f3_f1_2, 1], [f3_f1_3, 1], [f3_f1_4, 1], [f3_f1_5, 1]]) tg.tg_traffic_control(action='clear_stats', port_handle=tg_all) res = tg.tg_traffic_control(action='run', handle=tg_strs) st.wait(waitvar) res = tg.tg_traffic_control(action='stop', handle=tg_strs) st.wait(waitvar / 2) st.banner("Step T3: Verify ECMP.") leaf_tg_ports = [[leaf1, vars.D3T1P1], [leaf1, vars.D3T1P2], [leaf2, vars.D4T1P1], [leaf2, vars.D4T1P2]] l3_spine_ports = [[leaf3, vars.D5D1P1], [leaf3, vars.D5D1P2], [leaf3, vars.D5D2P1], [leaf3, vars.D5D2P2]] spine_leaf_ports = [[spine1, vars.D1D3P1], [spine1, vars.D1D3P2], [spine1, vars.D1D4P1], [spine1, vars.D1D4P2], [spine2, vars.D2D3P1], [spine2, vars.D2D3P2], [spine2, vars.D2D4P1], [spine2, vars.D2D4P2]] res1 = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=leaf_tg_ports, ratio=[[1], [0.25, 0.25, 0.25, 0.25]], clear_save=True, tolerance=vxlan_tolerance) res2 = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=l3_spine_ports, ratio=[[1], [0.25, 0.25, 0.25, 0.25]], saved_flag=True, tolerance=vxlan_tolerance) res3 = verify_intf_counters( rx=[[leaf3, vars.D5T1P1]], tx=spine_leaf_ports, ratio=[[1], [0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125]], saved_flag=True, tolerance=vxlan_tolerance) st.log("Step T3: res1={}, res2={}, res3={} - all should be True".format( res1, res2, res3)) if res1 is False or res2 is False or res3 is False: fail_msg = "ERROR: Step T3 Initial ECMP failed." fail_msgs += fail_msg st.log(fail_msg) tc_res[tc_list[0]] = tc_res[tc_list[1]] = False retvar = False gen_tech_supp(filename='f3_t3_') more_debugs(duts=dut_list) st.banner("Step T4: Remove dst-ip on leaf3, src-l4-port from other duts.") def f3_t4_1(): ip.config_ip_loadshare_hash(spine1, key='ip', val=ecmpv4[3], config='no') ip.config_ip_loadshare_hash(spine1, key='ipv6', val=ecmpv6[3], config='no') res1 = ip.verify_ip_loadshare(spine1, ip=ecmpv4[3], ipv6=ecmpv6[3]) if res1 is True: fail_msg = "ERROR: Step T4 show failed on spine1." st.log(fail_msg) return False return True def f3_t4_2(): ip.config_ip_loadshare_hash(spine2, key='ip', val=ecmpv4[3], config='no') ip.config_ip_loadshare_hash(spine2, key='ipv6', val=ecmpv6[3], config='no') res1 = ip.verify_ip_loadshare(spine2, ip=ecmpv4[3], ipv6=ecmpv6[3]) if res1 is True: fail_msg = "ERROR: Step T4 show failed on spine2." st.log(fail_msg) return False return True def f3_t4_3(): ip.config_ip_loadshare_hash(leaf1, key='ip', val=ecmpv4[3], config='no') ip.config_ip_loadshare_hash(leaf1, key='ipv6', val=ecmpv6[3], config='no') res1 = ip.verify_ip_loadshare(leaf1, ip=ecmpv4[3], ipv6=ecmpv6[3]) if res1 is True: fail_msg = "ERROR: Step T4 show failed on leaf1." st.log(fail_msg) return False return True def f3_t4_4(): ip.config_ip_loadshare_hash(leaf2, key='ip', val=ecmpv4[3], config='no') ip.config_ip_loadshare_hash(leaf2, key='ipv6', val=ecmpv6[3], config='no') res1 = ip.verify_ip_loadshare(leaf2, ip=ecmpv4[3], ipv6=ecmpv6[3]) if res1 is True: fail_msg = "ERROR: Step T4 show failed on leaf2." st.log(fail_msg) return False return True def f3_t4_5(): ip.config_ip_loadshare_hash(leaf3, key='ip', val=ecmpv4[1], config='no') ip.config_ip_loadshare_hash(leaf3, key='ipv6', val=ecmpv6[1], config='no') res1 = ip.verify_ip_loadshare(leaf3, ip=ecmpv4[1], ipv6=ecmpv6[1]) if res1 is True: fail_msg = "ERROR: Step T4 show failed on leaf3." st.log(fail_msg) return False return True [res, _] = utils.exec_all( True, [[f3_t4_1], [f3_t4_2], [f3_t4_3], [f3_t4_4], [f3_t4_5]]) if False in set(res): fail_msg = "ERROR: Step T4 show cli failed." fail_msgs += fail_msg st.log(fail_msg) tc_res[tc_list[0]] = tc_res[tc_list[1]] = False retvar = False st.wait(waitvar, "Waiting for hardware programming to complete.") st.banner("Step T5: Start the Streams - IPv4.") [res, _] = utils.exec_all( True, [[f3_f1_1, 1], [f3_f1_2, 1], [f3_f1_3, 1], [f3_f1_4, 1], [f3_f1_5, 1]]) tg.tg_traffic_control(action='clear_stats', port_handle=tg_all) res = tg.tg_traffic_control(action='run', handle=tg_v4s) st.wait(waitvar) res = tg.tg_traffic_control(action='stop', handle=tg_v4s) st.wait(waitvar / 2) st.banner("Step T6: Verify no ECMP at leaf1 and leaf2 - IPv4.") res1a = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=leaf_tg_ports, ratio=[[1], [1, 0, 0, 0]], clear_save=True) res1b = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=leaf_tg_ports, ratio=[[1], [0, 1, 0, 0]], saved_flag=True) res1c = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=leaf_tg_ports, ratio=[[1], [0, 0, 1, 0]], saved_flag=True) res1d = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=leaf_tg_ports, ratio=[[1], [0, 0, 0, 1]], saved_flag=True) st.log( "Step T6: tx11={}, tx12={}, tx21={}, tx22={} - only one of these should be True" .format(res1a, res1b, res1c, res1d)) res1 = len([r for r in [res1a, res1b, res1c, res1d] if r is True]) ratio_list = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] res2_list = [] for r_l in ratio_list: res = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=l3_spine_ports, ratio=[[1], r_l], saved_flag=True) res2_list.append(res) st.log( "Step T6: L3S1P1,L3S1P2,L3S2P1,L3S2P2={} - only one of these should be True" .format(res2_list)) res2 = len([r for r in res2_list if r is True]) ratio_list3 = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1]] res3_list = [] for r_l in ratio_list3: res = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=spine_leaf_ports, ratio=[[1], r_l], saved_flag=True) res3_list.append(res) st.log( "Step T6: S1L1P1,S1L1P2,S1L2P1,S1L2P2,S2L1P1,S2L1P2,S2L2P1,S2L2P2={} - only one of these should be True" .format(res3_list)) res3 = len([r for r in res3_list if r is True]) st.log("Step T8: res1={}, res2={}, res3={} - all should be 1".format( res1, res2, res3)) if res1 != 1 or res2 != 1 or res3 != 1: st.log("Step T6: res1={}, res2={}, res3={} - all should be 1".format( res1, res2, res3)) st.log( "Step T6: tx11={}, tx12={}, tx21={}, tx22={} - only one of these should be True" .format(res1a, res1b, res1c, res1d)) st.log( "Step T6: L3S1P1,L3S1P2,L3S2P1,L3S2P2={} - only one of these should be True" .format(res2_list)) st.log( "Step T6: S1L1P1,S1L1P2,S1L2P1,S1L2P2,S2L1P1,S2L1P2,S2L2P1,S2L2P2={} - only one of these should be True" .format(res3_list)) fail_msg = "ERROR: Step T6 IPv4 - ECMP still working even after disabling." fail_msgs += fail_msg st.log(fail_msg) tc_res[tc_list[0]] = False retvar = False st.banner("Step T7: Start the Streams - IPv6.") [res, _] = utils.exec_all( True, [[f3_f1_1, 1], [f3_f1_2, 1], [f3_f1_3, 1], [f3_f1_4, 1], [f3_f1_5, 1]]) tg.tg_traffic_control(action='clear_stats', port_handle=tg_all) res = tg.tg_traffic_control(action='run', handle=tg_v6s) st.wait(waitvar) res = tg.tg_traffic_control(action='stop', handle=tg_v6s) st.wait(waitvar / 2) st.banner("Step T8: Verify no ECMP at leaf1 and leaf2 - IPv6.") res1a = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=leaf_tg_ports, ratio=[[1], [1, 0, 0, 0]], clear_save=True) res1b = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=leaf_tg_ports, ratio=[[1], [0, 1, 0, 0]], saved_flag=True) res1c = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=leaf_tg_ports, ratio=[[1], [0, 0, 1, 0]], saved_flag=True) res1d = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=leaf_tg_ports, ratio=[[1], [0, 0, 0, 1]], saved_flag=True) st.log( "Step T8: tx11={}, tx12={}, tx21={}, tx22={} - only one of these should be True" .format(res1a, res1b, res1c, res1d)) res1 = len([r for r in [res1a, res1b, res1c, res1d] if r is True]) res2_list = [] for r_l in ratio_list: res = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=l3_spine_ports, ratio=[[1], r_l], saved_flag=True) res2_list.append(res) st.log( "Step T8: L3S1P1,L3S1P2,L3S2P1,L3S2P2={} - only one of these should be True" .format(res2_list)) res2 = len([r for r in res2_list if r is True]) res3_list = [] for r_l in ratio_list3: res = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=spine_leaf_ports, ratio=[[1], r_l], saved_flag=True) res3_list.append(res) st.log( "Step T8: S1L1P1,S1L1P2,S1L2P1,S1L2P2,S2L1P1,S2L1P2,S2L2P1,S2L2P2={} - only one of these should be True" .format(res3_list)) res3 = len([r for r in res3_list if r is True]) st.log("Step T8: res1={}, res2={}, res3={} - all should be 1".format( res1, res2, res3)) if res1 != 1 or res2 != 1 or res3 != 1: st.log("Step T8: res1={}, res2={}, res3={} - all should be 1".format( res1, res2, res3)) st.log( "Step T8: tx11={}, tx12={}, tx21={}, tx22={} - only one of these should be True" .format(res1a, res1b, res1c, res1d)) st.log( "Step T8: L3S1P1,L3S1P2,L3S2P1,L3S2P2={} - only one of these should be True" .format(res2_list)) st.log( "Step T8: S1L1P1,S1L1P2,S1L2P1,S1L2P2,S2L1P1,S2L1P2,S2L2P1,S2L2P2={} - only one of these should be True" .format(res3_list)) fail_msg = "ERROR: Step T8 IPv6 - ECMP still working even after disabling." fail_msgs += fail_msg st.log(fail_msg) tc_res[tc_list[1]] = False retvar = False if retvar is False: gen_tech_supp(filename='f3_t8_') more_debugs(duts=dut_list) st.banner("Step T10: Reconfigure the ECMP params.") def f3_t10_1(): ip.config_ip_loadshare_hash(spine1, key='ip', val=ecmpv4[3]) ip.config_ip_loadshare_hash(spine1, key='ipv6', val=ecmpv6[3]) res1 = ip.verify_ip_loadshare(spine1, ip=ecmpv4, ipv6=ecmpv6, seed=data.seed_def) if res1 is False: fail_msg = "ERROR: Step T10 show failed on spine1." st.log(fail_msg) return False return True def f3_t10_2(): ip.config_ip_loadshare_hash(spine2, key='ip', val=ecmpv4[3]) ip.config_ip_loadshare_hash(spine2, key='ipv6', val=ecmpv6[3]) res1 = ip.verify_ip_loadshare(spine2, ip=ecmpv4, ipv6=ecmpv6, seed=data.seed_def) if res1 is False: fail_msg = "ERROR: Step T10 show failed on spine2." st.log(fail_msg) return False return True def f3_t10_3(): ip.config_ip_loadshare_hash(leaf1, key='ip', val=ecmpv4[3]) ip.config_ip_loadshare_hash(leaf1, key='ipv6', val=ecmpv6[3]) res1 = ip.verify_ip_loadshare(leaf1, ip=ecmpv4, ipv6=ecmpv6, seed=data.seed_def) if res1 is False: fail_msg = "ERROR: Step T10 show failed on leaf1." st.log(fail_msg) return False return True def f3_t10_4(): ip.config_ip_loadshare_hash(leaf2, key='ip', val=ecmpv4[3]) ip.config_ip_loadshare_hash(leaf2, key='ipv6', val=ecmpv6[3]) res1 = ip.verify_ip_loadshare(leaf2, ip=ecmpv4, ipv6=ecmpv6, seed=data.seed_def) if res1 is False: fail_msg = "ERROR: Step T10 show failed on leaf2." st.log(fail_msg) return False return True def f3_t10_5(): ip.config_ip_loadshare_hash(leaf3, key='ip', val=ecmpv4[1]) ip.config_ip_loadshare_hash(leaf3, key='ipv6', val=ecmpv6[1]) res1 = ip.verify_ip_loadshare(leaf3, ip=ecmpv4, ipv6=ecmpv6, seed=data.seed_def) if res1 is False: fail_msg = "ERROR: Step T10 show failed on leaf3." st.log(fail_msg) return False return True [res, _] = utils.exec_all( True, [[f3_t10_1], [f3_t10_2], [f3_t10_3], [f3_t10_4], [f3_t10_5]]) if False in set(res): fail_msg = "ERROR: Step T10 show cli failed." fail_msgs += fail_msg st.log(fail_msg) tc_res[tc_list[0]] = tc_res[tc_list[1]] = tc_res[tc_list[2]] = False retvar = False st.wait(waitvar, "Waiting for hardware programming to complete.") st.banner("Step T11: Start the Streams.") [res, _] = utils.exec_all( True, [[f3_f1_1, 1], [f3_f1_2, 1], [f3_f1_3, 1], [f3_f1_4, 1], [f3_f1_5, 1]]) tg.tg_traffic_control(action='clear_stats', port_handle=tg_all) res = tg.tg_traffic_control(action='run', handle=tg_strs) st.wait(waitvar) res = tg.tg_traffic_control(action='stop', handle=tg_strs) st.wait(waitvar / 2) st.banner("Step T12: Verify ECMP is restored.") res1 = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=leaf_tg_ports, ratio=[[1], [0.25, 0.25, 0.25, 0.25]], clear_save=True, tolerance=vxlan_tolerance) res2 = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]], tx=l3_spine_ports, ratio=[[1], [0.25, 0.25, 0.25, 0.25]], saved_flag=True, tolerance=vxlan_tolerance) res3 = verify_intf_counters( rx=[[leaf3, vars.D5T1P1]], tx=spine_leaf_ports, ratio=[[1], [0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125]], saved_flag=True, tolerance=vxlan_tolerance) st.log("Step T12: res1={}, res2={}, res3={} - all should be True".format( res1, res2, res3)) if res1 is False or res2 is False or res3 is False: fail_msg = "ERROR: Step T12 ECMP restoration failed." fail_msgs += fail_msg st.log(fail_msg) tc_res[tc_list[0]] = tc_res[tc_list[1]] = tc_res[tc_list[2]] = False retvar = False gen_tech_supp(filename='f3_t12_') more_debugs(duts=dut_list) for tc in tc_list: if tc_res[tc]: st.report_tc_pass(tc, "tc_passed") if retvar is False: st.report_fail("test_case_failure_message", fail_msgs) st.report_pass("test_case_passed")
def test_ft_sf_all_buffer_stats_using_unicast_traffic(): """ Author : prudviraj k ([email protected]) and phani kumar ravula([email protected]) """ result = 0 per_result = 0 clr_result = 0 if not sfapi.config_snapshot_interval( vars.D1, snap="interval", interval_val=sf_data.snapshot_interval): st.error("Failed to configure snapshot interval") result += 1 match = [{'snapshotinterval': sf_data.snapshot_interval}] if not sfapi.verify(vars.D1, 'snapshot_interval', verify_list=match): st.error("Failed to verify the configured snapshot interval") result += 1 st.log("configuring the QOS maps") if not cos_api.config_dot1p_to_tc_map(vars.D1, sf_data.obj_name[0], sf_data.dot1p_to_tc_map_dict): st.error("Failed to configure qos map of type dot1p to tc") if not cos_api.config_tc_to_pg_map(vars.D1, sf_data.obj_name[1], sf_data.tc_to_pg_map_dict): st.error("Failed to configure qos map of type tc to pg") if not cos_api.verify_qos_map_table( vars.D1, 'dot1p_to_tc_map', sf_data.obj_name[0], { '0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7' }): st.error("Failed to verify configured dot1p to tc map values") result += 1 if not cos_api.verify_qos_map_table( vars.D1, 'tc_to_pg_map', sf_data.obj_name[1], { '0': '7', '1': '7', '2': '7', '3': '7', '4': '7', '5': '7', '6': '7', '7': '7' }): st.error("Failed to verify configured tc to pg map values") result += 1 if not cos_api.config_port_qos_map_all(vars.D1, sf_data.dot1p_tc_bind_map): st.error( "Failed to bind the configured qos map of type dot1p to tc on interface" ) if not cos_api.config_port_qos_map_all(vars.D1, sf_data.tc_pg_bind_map): st.error( "Failed to bind the configured qos map of type tc to pg on interface" ) sf_tg_traffic_start_stop(sf_data.unicast, True) st.wait(2 * sf_data.snapshot_interval) st.banner('#### PG_shared_for_user_watermark####') st.banner('TC name :::: ft_sf_pg_shared_using_uwm ::::') match = [{'pg7': sf_data.initial_counter_value}] if sfapi.verify(vars.D1, 'user_watermark_PG_shared', verify_list=match, port_alias=vars.D1T1P1): st.error("Failed to verify the user_watermark_PG_shared counter value") result += 1 st.report_tc_fail("ft_sf_pg_shared_using_uwm", "snapshot_tc_verify", "PG_shared_for_user_watermark", "failed") else: st.report_tc_pass("ft_sf_pg_shared_using_uwm", "snapshot_tc_verify", "PG_shared_for_user_watermark", "successful") st.banner('####verification_of_PG_shared_using_counter_DB####') st.banner('TC name :::: ft_sf_pg_shared_using_Counter_DB ::::') match = [{ 'SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES': sf_data.initial_counter_value }] if sfapi.verify(vars.D1, column_name="COUNTERS_PG_NAME_MAP", interface_name=vars.D1T1P1, queue_value=7, table_name="COUNTERS", verify_list=match): st.error( "Failed to verify the user_watermark_PG_shared counter DB value") result += 1 st.report_tc_fail("ft_sf_pg_shared_using_Counter_DB", "snapshot_tc_counter_DB_verify", "PG_shared", "failed") else: st.report_tc_pass("ft_sf_pg_shared_using_Counter_DB", "snapshot_tc_counter_DB_verify", "PG_shared", "successful") st.banner('TC name:::: ft_sf_queue_unicast_using_uwm ::::') match = [{'uc0': sf_data.initial_counter_value}] st.banner( '#### queue_unicast_for_user_watermark using percentage values####') if sfapi.verify(vars.D1, 'queue_user_watermark_unicast', verify_list=match, port_alias=vars.D1T1P4, percentage=sf_data.percentage[0]): st.error( "Failed to verify the queue_user_watermark_unicast counter value using percentage" ) result += 1 per_result += 1 st.banner('#### queue_unicast_for_user_watermark using CLI####') if sfapi.verify(vars.D1, 'queue_user_watermark_unicast', verify_list=match, port_alias=vars.D1T1P4): st.error( "Failed to verify the queue_user_watermark_unicast counter value") result += 1 per_result += 1 if per_result: st.report_tc_fail("ft_sf_queue_unicast_using_uwm", "snapshot_tc_verify", "queue_unicast_for_user_watermark", "failed") else: st.report_tc_pass("ft_sf_queue_unicast_using_uwm", "snapshot_tc_verify", "queue_unicast_for_user_watermark", "successful") st.banner( '####verification_of_queue_unicast_for_user_watermark_using_counter_DB####' ) st.banner('TC name:::: ft_sf_queue_unicast_using_Counter_DB ::::') match = [{ 'SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES': sf_data.initial_counter_value }] if sfapi.verify(vars.D1, column_name="COUNTERS_QUEUE_NAME_MAP", interface_name=vars.D1T1P4, queue_value=0, table_name="COUNTERS", verify_list=match): st.error( "Failed to verify the queue_user_watermark_unicast counter DB value" ) result += 1 st.report_tc_fail("ft_sf_queue_unicast_using_Counter_DB", "snapshot_tc_counter_DB_verify", "queue_unicast", "failed") else: st.report_tc_pass("ft_sf_queue_unicast_using_Counter_DB", "snapshot_tc_counter_DB_verify", "queue_unicast", "successful") st.banner('#### PG_shared_for_persistent_watermark####') st.banner('TC name :::: ft_sf_pg_shared_using_persistent_wm ::::') match = [{'pg7': sf_data.initial_counter_value}] if sfapi.verify(vars.D1, 'persistent_PG_shared', verify_list=match, port_alias=vars.D1T1P2): st.error( "Failed to verify the persistent_watermark_PG_shared counter value" ) result += 1 st.report_tc_fail("ft_sf_pg_shared_using_persistent_wm", "snapshot_tc_verify", "PG_shared_for_persistent_watermark", "failed") else: st.report_tc_pass("ft_sf_pg_shared_using_persistent_wm", "snapshot_tc_verify", "PG_shared_for_persistent_watermark", "successful") st.banner('#### queue_unicast_for_persistent_watermark ####') st.banner('TC name :::: ft_sf_queue_unicast_using_persistent_wm ::::') match = [{'uc0': sf_data.initial_counter_value}] if sfapi.verify(vars.D1, 'queue_persistent_watermark_unicast', verify_list=match, port_alias=vars.D1T1P4): st.error( "Failed to verify the queue_persistent_watermark_unicast counter value" ) result += 1 st.report_tc_fail("ft_sf_queue_unicast_using_persistent_wm", "snapshot_tc_verify", "queue_unicast_for_persistent_watermark", "failed") else: st.report_tc_pass("ft_sf_queue_unicast_using_persistent_wm", "snapshot_tc_verify", "queue_unicast_for_persistent_watermark", "successful") sf_tg_traffic_start_stop(sf_data.unicast, False) st.wait(2 * sf_data.snapshot_interval) st.banner('#### clear_PG_shared_for_user_watermark####') st.banner('TC name :::: ft_sf_pg_shared_clear_using_uwm ::::') if not sfapi.config_snapshot_interval(vars.D1, snap="clear_snapshot_counters", group=sf_data.group[0], table=sf_data.table[0], counter_type=sf_data.PG[0]): st.error( "Failed to execute the command clear {} snapshot counters".format( sf_data.group[0])) result += 1 match = [{'pg0': sf_data.initial_counter_value}] if not sfapi.verify(vars.D1, 'user_watermark_PG_shared', verify_list=match, port_alias=vars.D1T1P1): st.error("Failed to clear the snapshot counters") result += 1 st.report_tc_fail( "ft_sf_pg_shared_clear_using_uwm", "snapshot_clear_verify", "clearing the PG shared counters for user_watermark", "failed") else: st.report_tc_pass( "ft_sf_pg_shared_clear_using_uwm", "snapshot_clear_verify", "clearing the PG shared counters for user watermark", "successful") st.banner('TC name :::: ft_sf_queue_unicast_clear_using_uwm ::::') if not sfapi.config_snapshot_interval(vars.D1, snap="clear_snapshot_counters", group=sf_data.group[1], table=sf_data.table[0], counter_type=sf_data.PG[2]): st.error( "Failed to execute the command clear {} snapshot counters".format( sf_data.group[0])) result += 1 match = [{'uc0': sf_data.initial_counter_value}] st.banner( '#### clear_queue_unicast_percentage_Values_for_user_watermark ####') if not sfapi.verify(vars.D1, 'queue_user_watermark_unicast', verify_list=match, port_alias=vars.D1T1P4, percentage=sf_data.percentage[1]): st.error("Failed to clear percentage snapshot counters") result += 1 clr_result += 1 st.banner('#### clear_queue_unicast_for_user_watermark using CLI####') if not sfapi.verify(vars.D1, 'queue_user_watermark_unicast', verify_list=match, port_alias=vars.D1T1P4): st.error("Failed to clear the snapshot counters") result += 1 clr_result += 1 if clr_result: st.report_tc_fail( "ft_sf_queue_unicast_clear_using_uwm", "snapshot_clear_verify", "clearing the unicast queue counters for user watermark", "failed") else: st.report_tc_pass( "ft_sf_queue_unicast_clear_using_uwm", "snapshot_clear_verify", "clearing the unicast queue counters for user watermark", "successful") st.banner('#### clear_PG_shared_for_persistent_watermark ####') st.banner('TC name :::: ft_sf_pg_shared_clear_using_persistent_wm ::::') if not sfapi.config_snapshot_interval(vars.D1, snap="clear_snapshot_counters", group=sf_data.group[0], table=sf_data.table[1], counter_type=sf_data.PG[0]): st.error( "Failed to execute the command clear {} snapshot counters".format( sf_data.group[0])) result += 1 match = [{'pg0': sf_data.initial_counter_value}] if not sfapi.verify(vars.D1, 'persistent_PG_shared', verify_list=match, port_alias=vars.D1T1P2): st.error("Failed to clear the snapshot counters") result += 1 st.report_tc_fail( "ft_sf_pg_shared_clear_using_persistent_wm", "snapshot_clear_verify", "clearing the PG shared counters for persistent watermark", "failed") else: st.report_tc_pass( "ft_sf_pg_shared_clear_using_persistent_wm", "snapshot_clear_verify", "clearing the PG shared counters for persistent watermark", "successful") st.banner('#### clear_queue_unicast_for_persistent_watermark ####') st.banner( 'TC name :::: ft_sf_queue_unicast_clear_using_persistent_wm ::::') if not sfapi.config_snapshot_interval(vars.D1, snap="clear_snapshot_counters", group=sf_data.group[1], table=sf_data.table[1], counter_type=sf_data.PG[2]): st.error( "Failed to execute the command clear {} snapshot counters".format( sf_data.group[0])) result += 1 match = [{'uc0': sf_data.initial_counter_value}] if not sfapi.verify(vars.D1, 'queue_persistent_watermark_unicast', verify_list=match, port_alias=vars.D1T1P4): st.error("Failed to clear the snapshot counters") result += 1 st.report_tc_fail( "ft_sf_queue_unicast_clear_using_persistent_wm", "snapshot_clear_verify", "clearing the unicast queue counters for persistent watermark", "failed") else: st.report_tc_pass( "ft_sf_queue_unicast_clear_using_persistent_wm", "snapshot_clear_verify", "clearing the unicast queue counters for persistent watermark", "successful") clear_qos_map_config() if not result: st.report_pass("snapshot_all_buffer_counters", "unicast", "successful") else: sf_collecting_debug_logs_when_test_fails() st.report_fail("snapshot_all_buffer_counters", "unicast", "failed")
def test_ft_sf_verify_buffer_pool_counters(): """ Author : prudviraj k ([email protected]) and phani kumar ravula([email protected]) """ result = 0 per_result = 0 sf_data.platform_name_summary = get_platform_summary(vars.D1) sf_data.platform_name = sf_data.platform_name_summary["platform"] sf_data.platform_hwsku = sf_data.platform_name_summary["hwsku"] path = "/usr/share/sonic/device/{}/{}/{}".format(sf_data.platform_name, sf_data.platform_hwsku, sf_data.device_j2_file) convert_json = "sonic-cfggen -d -t " "{} > {}".format( path, sf_data.config_file) sfapi.load_json_config(vars.D1, convert_json, sf_data.config_file) reboot_api.config_save_reload(vars.D1) st.log("To make sure after reload DUT is fully operational") st.wait(sf_data.reload_interval) if not sfapi.config_snapshot_interval( vars.D1, snap="interval", interval_val=sf_data.snapshot_interval): st.error("Failed to configure snapshot interval") result += 1 match = [{'snapshotinterval': sf_data.snapshot_interval}] if not sfapi.verify(vars.D1, 'snapshot_interval', verify_list=match): st.error("Failed to verify the configured snapshot interval") result += 1 sf_tg_traffic_start_stop(sf_data.unicast, True) st.log( "waiting for two snapshot interval times to get the counter values reflect correctly" ) st.wait(2 * sf_data.snapshot_interval) st.banner('#### buffer_Pool_for_user_watermark####') st.banner('TC name :::: ft_sf_buffer_pool_using_uwm ::::') match = {'pool': 'ingress_lossless_pool'} value = {'bytes': sf_data.initial_counter_value} if sfapi.verify_buffer_pool(vars.D1, 'buffer_pool_watermark', verify_list=match, key=value): st.error( "Failed to verify the buffer pool counters for user watermark") result += 1 st.report_tc_fail("ft_sf_buffer_pool_using_uwm", "snapshot_tc_verify", "buffer_pool_for_user_watermark", "failed") else: st.report_tc_pass("ft_sf_buffer_pool_using_uwm", "snapshot_tc_verify", "buffer_pool_for_user_watermark", "successful") st.banner('TC name :::: ft_sf_buffer_pool_using_persistent_wm ::::') st.banner('#### buffer_pool_for_persistent_watermark using percentage####') match = {'pool': 'egress_lossless_pool'} value = {'percent': sf_data.initial_counter_value} if sfapi.verify_buffer_pool(vars.D1, 'buffer_pool_persistent-watermark', verify_list=match, key=value, percent=sf_data.percentage[0]): st.error( "Failed to verify the buffer pool counters for persistent watermark" ) result += 1 per_result += 1 st.banner('#### buffer_pool_for_persistent_watermark using CLI####') match = {'pool': 'egress_lossless_pool'} value = {'bytes': sf_data.initial_counter_value} if sfapi.verify_buffer_pool(vars.D1, 'buffer_pool_persistent-watermark', verify_list=match, key=value): st.error( "Failed to verify the buffer pool counters for persistent watermark" ) result += 1 per_result += 1 if per_result: st.report_tc_fail("ft_sf_buffer_pool_using_persistent_wm", "snapshot_tc_verify", "buffer_pool_for_persistent_watermark", "failed") else: st.report_tc_pass("ft_sf_buffer_pool_using_persistent_wm", "snapshot_tc_verify", "buffer_pool_for_persistent_watermark", "successful") st.banner('#### buffer_pool_using_counter_DB ####') st.banner('TC name :::: ft_sf_buffer_pool_using_counter_DB ::::') match = [{ 'SAI_BUFFER_POOL_STAT_WATERMARK_BYTES': sf_data.initial_counter_value }] if sfapi.verify(vars.D1, 'buffer_pool_counters_DB', oid_type='ingress_lossless_pool', verify_list=match): st.error( "Failed to verify the ingress lossless buffer pool counter using counter DB value" ) result += 1 st.report_tc_fail("ft_sf_buffer_pool_using_counter_DB", "snapshot_tc_verify", "ingress lossless buffer pool", "failed") else: st.report_tc_pass("ft_sf_buffer_pool_using_counter_DB", "snapshot_tc_verify", "ingress lossless buffer pool", "successful") sf_tg_traffic_start_stop(sf_data.unicast, False) st.log( "waiting for two snapshot interval times to get the counter values reflect correctly" ) st.wait(2 * sf_data.snapshot_interval) st.banner('#### clear_buffer_Pool_for_user_watermark####') st.banner('TC name :::: ft_sf_buffer_pool_clear_using_uwm ::::') if not sfapi.config_snapshot_interval(vars.D1, snap="clear_buffer-pool watermark"): st.error("Failed to clear buffer-pool watermark") st.log( "After clear buffer_pool checking the stats with 10 cells tolerance") counters = sfapi.get(vars.D1, 'buffer_pool_watermark', get_value='bytes', match={'pool': 'ingress_lossless_pool'}) if counters > sf_data.buffer_pool_tolerance: st.error("Failed to clear the buffer pool counters for user watermark") result += 1 st.report_tc_fail("ft_sf_buffer_pool_clear_using_uwm", "snapshot_tc_verify", "buffer_pool_clear_for_user_watermark", "failed") else: st.report_tc_pass("ft_sf_buffer_pool_clear_using_uwm", "snapshot_tc_verify", "buffer_pool_clear_for_user_watermark", "successful") st.banner('#### clear_buffer_pool_for_persistent_watermark ####') st.banner('TC name :::: ft_sf_buffer_pool_clear_using_persistent_wm ::::') if not sfapi.config_snapshot_interval( vars.D1, snap="clear_buffer-pool persistent-watermark"): st.error("Failed to clear_buffer-pool persistent-watermark") st.log( "After clear buffer_pool checking the stats with 10 cells tolerance") counters = sfapi.get(vars.D1, 'buffer_pool_watermark', get_value='bytes', match={'pool': 'egress_lossless_pool'}) if counters > sf_data.buffer_pool_tolerance: st.error( "Failed to clear the buffer pool counters for persistent watermark" ) result += 1 st.report_tc_fail("ft_sf_buffer_pool_clear_using_persistent_wm", "snapshot_tc_verify", "buffer_pool_clear_for_persistent_watermark", "failed") else: st.report_tc_pass("ft_sf_buffer_pool_clear_using_persistent_wm", "snapshot_tc_verify", "buffer_pool_clear_for_persistent_watermark", "successful") if not result: st.report_pass("snapshot_tc_verify", "buffer pool", "successful") else: sf_collecting_debug_logs_when_test_fails() st.report_fail("snapshot_tc_verify", "buffer pool", "failed")
def test_ft_sf_all_buffer_stats_using_multicast_traffic(): """ Author : prudviraj k ([email protected]) and phani kumar ravula([email protected]) """ result = 0 if not sfapi.config_snapshot_interval( vars.D1, snap="interval", interval_val=sf_data.snapshot_interval): st.error("Failed to configure snapshot interval") result += 1 match = [{'snapshotinterval': sf_data.snapshot_interval}] if not sfapi.verify(vars.D1, 'snapshot_interval', verify_list=match): st.error("Failed to verify the configured snapshot interval") result += 1 if sfapi.multicast_queue_start_value(vars.D1, 'queue_user_watermark_multicast', port_alias=vars.D1T1P4): match = [{'mc8': sf_data.initial_counter_value}] else: match = [{'mc10': sf_data.initial_counter_value}] sf_tg_traffic_start_stop(sf_data.multicast, True) st.wait(2 * sf_data.snapshot_interval) st.banner('#### queue_multicast_for_user_watermark ####') st.banner('TC name:::: ft_sf_queue_multicast_using_uwm ::::') if sfapi.verify(vars.D1, 'queue_user_watermark_multicast', verify_list=match, port_alias=vars.D1T1P4): st.error( "Failed to verify the queue_user_watermark_multicast counter value" ) result += 1 st.report_tc_fail("ft_sf_queue_multicast_using_uwm", "snapshot_tc_verify", "queue_multicast_for_user_watermark", "failed") else: st.report_tc_pass("ft_sf_queue_multicast_using_uwm", "snapshot_tc_verify", "queue_multicast_for_user_watermark", "successful") st.banner('#### queue_multicast_for_persistent_watermark ####') st.banner('TC name :::: ft_sf_queue_multicast_using_persistent_wm ::::') if sfapi.verify(vars.D1, 'queue_persistent_watermark_multicast', verify_list=match, port_alias=vars.D1T1P4): st.error( "Failed to verify the queue_persistent_watermark_unicast counter value" ) result += 1 st.report_tc_fail("ft_sf_queue_multicast_using_persistent_wm", "snapshot_tc_verify", "queue_multicast_for_persistent_watermark", "failed") else: st.report_tc_pass("ft_sf_queue_multicast_using_persistent_wm", "snapshot_tc_verify", "queue_multicast_for_persistent_watermark", "successful") sf_tg_traffic_start_stop(sf_data.multicast, False) st.wait(2 * sf_data.snapshot_interval) st.banner('#### clear_queue_multicast_for_user_watermark ####') st.banner('TC name :::: ft_sf_queue_multicast_clear_using_uwm ::::') if not sfapi.config_snapshot_interval(vars.D1, snap="clear_snapshot_counters", group=sf_data.group[1], table=sf_data.table[0], counter_type=sf_data.PG[3]): st.error( "Failed to execute the command clear {} snapshot counters".format( sf_data.PG[3])) result += 1 if not sfapi.verify(vars.D1, 'queue_user_watermark_multicast', verify_list=match, port_alias=vars.D1T1P4): st.error("Failed to clear the snapshot counters") result += 1 st.report_tc_fail( "ft_sf_queue_multicast_clear_using_uwm", "snapshot_clear_verify", "clearing the multicast queue counters for user watermark", "failed") else: st.report_tc_pass( "ft_sf_queue_multicast_clear_using_uwm", "snapshot_clear_verify", "clearing the multicast queue counters for user watermark", "successful") st.banner('#### clear_queue_multicast_for_persistent_watermark ####') st.banner( 'TC name :::: ft_sf_queue_multicast_clear_using_persistent_wm ::::') if not sfapi.config_snapshot_interval(vars.D1, snap="clear_snapshot_counters", group=sf_data.group[1], table=sf_data.table[1], counter_type=sf_data.PG[3]): st.error( "Failed to execute the command clear {} snapshot counters".format( sf_data.PG[3])) result += 1 if not sfapi.verify(vars.D1, 'queue_persistent_watermark_multicast', verify_list=match, port_alias=vars.D1T1P4): st.error("Failed to clear the snapshot counters") result += 1 st.report_tc_fail( "ft_sf_queue_multicast_clear_using_persistent_wm", "snapshot_clear_verify", "clearing the multicast queue counters for persistent watermark", "failed") else: st.report_tc_pass( "ft_sf_queue_multicast_clear_using_persistent_wm", "snapshot_clear_verify", "clearing the multicast queue counters for persistent watermark", "successful") if not result: st.report_pass("snapshot_all_buffer_counters", "multicast", "successful") else: sf_collecting_debug_logs_when_test_fails() st.report_fail("snapshot_all_buffer_counters", "multicast", "failed")
def test_scale_ip_unnumbered(): ########################################################################################################################################## result = 0 st.banner('FtOpSoRoIPunScl001 - Verify maximum IPv4 unnumbered interfaces') st.log( 'Configure IP unnumbered on Physical interfaces between DUT1 and DUT3') for d1port, d2port in zip(data.d1_d2_ports, data.d2_d1_ports): dict1 = { 'family': 'ipv4', 'action': 'add', 'interface': d1port, 'loop_back': dut1_loopback[0] } dict2 = { 'family': 'ipv4', 'action': 'add', 'interface': d2port, 'loop_back': dut2_loopback[0] } parallel.exec_parallel(True, [data.dut1, data.dut2], ip_obj.config_unnumbered_interface, [dict1, dict2]) st.log( 'Configure IP unnumbered on Physical interfaces between DUT2 and DUT3') for d2port, d3port in zip(data.d2_d3_ports, data.d3_d2_ports): dict2 = { 'family': 'ipv4', 'action': 'add', 'interface': d2port, 'loop_back': dut2_loopback[0] } dict3 = { 'family': 'ipv4', 'action': 'add', 'interface': d3port, 'loop_back': dut3_loopback[0] } parallel.exec_parallel(True, [data.dut2, data.dut3], ip_obj.config_unnumbered_interface, [dict2, dict3]) if not ip_obj.verify_interface_ip_address( data.dut2, data.d2_d3_ports[0], dut2_loopback_ip[0] + '/' + ip_loopback_prefix, 'ipv4', '', 'U'): st.error( 'IP Unnumbered configuration on DUT2-Physical Interface failed') result += 1 if not loc_lib.retry_api(ip_obj.ping, data.dut1, addresses=dut3_loopback_ip[0], retry_count=5, delay=10): st.error('IPv4 Ping from DUT1 to DUT3 failed') result += 1 if not arp_obj.verify_arp(dut=data.dut2, ipaddress=dut3_loopback_ip[0]): st.error( "Failed to resolve ARP for link local address over physical interface" ) result += 1 aggrResult = loc_lib.send_verify_traffic(type='ipv4') if not aggrResult: st.error('IPv4 traffic with IPv4 unnumbered failed') result += 1 port_obj.shutdown(data.dut2, [ data.d2_d1_ports[0], data.d2_d1_ports[1], data.d2_d1_ports[2], data.d2_d1_ports[3], data.d2_d3_ports[0], data.d2_d3_ports[1], data.d2_d3_ports[2], data.d2_d3_ports[3] ]) st.log('Wait for OSFP to go down') st.wait(10) port_obj.noshutdown(data.dut2, [ data.d2_d1_ports[0], data.d2_d1_ports[1], data.d2_d1_ports[2], data.d2_d1_ports[3], data.d2_d3_ports[0], data.d2_d3_ports[1], data.d2_d3_ports[2], data.d2_d3_ports[3] ]) st.log('Wait for OSFP to come up') st.wait(10) if not loc_lib.retry_api(ip_obj.ping, data.dut1, addresses=dut3_loopback_ip[0], retry_count=5, delay=10): st.error('IPv4 Ping from DUT1 to DUT2 failed') result += 1 aggrResult = loc_lib.send_verify_traffic(type='ipv4') if not aggrResult: st.error('IPv4 traffic with IPv4 unnumbered failed') result += 1 if result == 0: st.report_tc_pass('FtOpSoRoIPunScl001', 'test_case_passed') else: st.report_tc_fail('FtOpSoRoIPunScl001', 'test_case_failed') if result == 0: st.report_pass('test_case_passed') else: st.report_fail('test_case_failed')
def test_udld_loops_normal_aggressive(): ''' Verify UDLD Tx/Rx loops in normal mode with out PVST/RPVST Verify UDLD Tx/Rx loops in aggressive mode with out PVST/RPVST ''' tc_list = ['FtOpSoSwudldloopnormal001', 'FtOpSoSwudldloopaggressive001'] print_log("START of TC:test_pvst_udld_normal_aggressive ==>Sub-Test:Verify UDLD functionality with PVST\n TCs:<{}>".format(tc_list), "HIGH") final_result = True tc_result1 = 0 tc_result2 = 0 #udld_global_fail = 0 udld_mode_fail = 0 udld_interface_normal_loop_fail = 0 udld_interface_no_normal_loop_fail = 0 udld_interface_aggressive_loop_fail = 0 udld_interface_no_aggressive_loop_fail = 0 udld_neighbor_fail = 0 udld_neighbor_warm_reboot_norm_fail = 0 ##########################################NORMAL MODE UDLD RX/TX loop TESTS START####################################### st.wait(5) print_log("Verify that the port from DUT1 to DUT2 should go down in Normal Mode with UDLD TX/RX loop...",'MED') udld_interfaces = [vars.D1D2P1] state = 'down' if verify_udld_port_status(udld_interfaces,dut1,state): print_log("The ports from DUT1 to DUT3 is going to down state verification PASSED", "HIGH") else: print_log("The ports from DUT1 to DUT3 is not going to down state verification FAILED", "HIGH") udld_interface_normal_loop_fail += 1 tc_result1 += 1 final_result = False ###Disable UDLD on Interfaces dict1 = {'intf': udld_int[dut1]['udld_int'],'udld_enable': 'no', 'config': 'no'} pll.exec_parallel(True,[dut1],udld.config_intf_udld, [dict1]) ###Disable UDLD global dict1 = {'udld_enable': 'no', 'config': 'no'} pll.exec_parallel(True,[dut1],udld.config_udld_global, [dict1]) ###do shut and no shut on DUt1 to DUT2 udld_interfaces = [vars.D1D2P1] for udld_interface in udld_interfaces: intf.interface_operation(dut1, udld_interface , "shutdown") intf.interface_operation(dut1, udld_interface , "startup") st.wait(5) print_log("Verify that the port from DUT1 to DUT2 should go up in Normal Mode with UDLD TX/RX loop...",'MED') udld_interfaces = [vars.D1D2P1] state = 'up' if verify_udld_port_status(udld_interfaces,dut1,state): print_log("The ports from DUT1 to DUT2 is going to up state verification PASSED", "HIGH") else: print_log("The ports from DUT1 to DUT2 is not going to up state verification FAILED", "HIGH") udld_interface_no_normal_loop_fail += 1 tc_result1 += 1 final_result = False if tc_result1 > 0: st.report_tc_fail("FtOpSoSwudldloopnormal001", "UDLD_TX_RX_loop_Normal_Failed", "test_udld_loops_normal_aggressive") else: st.report_tc_pass("FtOpSoSwudldloopnormal001", "UDLD_TX_RX_loop_Normal_Passed", "test_udld_loops_normal_aggressive") ###Enable UDLD global dict1 = {'udld_enable': udld_global[dut1]['udld_enable'], 'config': udld_global[dut1]['config']} pll.exec_parallel(True,[dut1],udld.config_udld_global, [dict1]) ###Enable UDLD on Interfaces dict1 = {'intf': udld_int[dut1]['udld_int'],'udld_enable': udld_int[dut1]['udld_enable'], 'config': udld_int[dut1]['config']} pll.exec_parallel(True,[dut1],udld.config_intf_udld, [dict1]) ###Enable UDLD mode Aggressive print_log("Enable the UDLD Mode Agrgressive on All DUTs...", 'MED') dict1 = {'udld_mode': udld_global[dut1]['udld_enable'], 'config': udld_global[dut1]['config']} pll.exec_parallel(True,[dut1],udld.config_udld_mode, [dict1]) ### Verify UDLD mode if verify_udld_mode('Aggressive'): print_log("UDLD Mode Aggressive verification PASSED", "HIGH") else: print_log("UDLD Mode Aggressive verification FAILED", "HIGH") udld_mode_fail += 1 tc_result2 += 1 final_result = False st.wait(2) print_log("Verify that the port from DUT1 to DUT2 should go down in Aggressive Mode with UDLD TX/RX loop...",'MED') udld_interfaces = [vars.D1D2P1] state = 'down' if verify_udld_port_status(udld_interfaces,dut1,state): print_log("The ports from DUT1 to DUT2 is going to down state verification PASSED", "HIGH") else: print_log("The ports from DUT1 to DUT2 is not going to down state verification FAILED", "HIGH") udld_interface_aggressive_loop_fail += 1 tc_result2 += 1 final_result = False ###Disable UDLD on Interfaces dict1 = {'intf': udld_int[dut1]['udld_int'],'udld_enable': 'no', 'config': 'no'} pll.exec_parallel(True,[dut1],udld.config_intf_udld, [dict1]) ###Disable UDLD global dict1 = {'udld_enable': 'no', 'config': 'no'} pll.exec_parallel(True,[dut1],udld.config_udld_global, [dict1]) ###do shut and no shut on DUt1 to DUT2 udld_interfaces = [vars.D1D2P1] for udld_interface in udld_interfaces: intf.interface_operation(dut1, udld_interface , "shutdown") intf.interface_operation(dut1, udld_interface , "startup") st.wait(5) print_log("Verify that the port from DUT1 to DUT2 should go up in Aggressive Mode with UDLD TX/RX loop...",'MED') udld_interfaces = [vars.D1D2P1] state = 'up' if verify_udld_port_status(udld_interfaces,dut1,state): print_log("The ports from DUT1 to DUT2 is going to up state verification PASSED", "HIGH") else: print_log("The ports from DUT1 to DUT2 is not going to up state verification FAILED", "HIGH") udld_interface_no_aggressive_loop_fail += 1 tc_result2 += 1 final_result = False api_list = [] api_list.append([vlan.delete_vlan_member, dut2, trunk_base_vlan, [vars.D2D3P1,vars.D2D3P2]]) api_list.append([vlan.delete_vlan_member, dut3, trunk_base_vlan, [vars.D3D2P1,vars.D3D2P2]]) utils.exec_all(True, api_list) ###Enable UDLD global dict1 = {'udld_enable': udld_global[dut1]['udld_enable'], 'config': udld_global[dut1]['config']} dict2 = {'udld_enable': udld_global[dut2]['udld_enable'], 'config': udld_global[dut2]['config']} pll.exec_parallel(True,dut_list,udld.config_udld_global, [dict1, dict2]) ###Enable UDLD on Interfaces dict1 = {'intf': udld_int[dut1]['udld_int'],'udld_enable': udld_int[dut1]['udld_enable'], 'config': udld_int[dut1]['config']} dict2 = {'intf': udld_int[dut2]['udld_int'],'udld_enable': udld_int[dut2]['udld_enable'], 'config': udld_int[dut2]['config']} pll.exec_parallel(True,dut_list,udld.config_intf_udld, [dict1, dict2]) st.wait(2) ####################PDB will REMOVE after suite completion #import pdb;pdb.set_trace() if verify_udld_neighbor(udld_neighbor): print_log("UDLD neighbor verification PASSED", "HIGH") else: print_log("UDLD neighbor verification FAILED", "HIGH") udld_neighbor_fail += 1 tc_result2 += 1 final_result = False print_log("Do Warm Reboot in Aggressive Mode...", 'MED') utils.exec_foreach(True, dut_reload, reboot_api.config_warm_restart, oper="enable") utils.exec_all(True, [[st.reboot, dut, "warm"] for dut in dut_reload]) st.wait(10) if verify_udld_neighbor(udld_neighbor): print_log("UDLD neighbor in normal mode after cold reboot verification PASSED", "HIGH") else: print_log("UDLD neighbor in normal mode after cold reboot verification FAILED", "HIGH") udld_neighbor_warm_reboot_norm_fail += 1 tc_result2 += 1 final_result = False ###Disable UDLD on Interfaces dict1 = {'intf': udld_int[dut1]['udld_int'],'udld_enable': 'no', 'config': 'no'} dict2 = {'intf': udld_int[dut2]['udld_int'],'udld_enable': 'no', 'config': 'no'} pll.exec_parallel(True,dut_list,udld.config_intf_udld, [dict1, dict2]) ###Disable UDLD global dict1 = {'udld_enable': 'no', 'config': 'no'} dict2 = {'udld_enable': 'no', 'config': 'no'} pll.exec_parallel(True,dut_list,udld.config_udld_global, [dict1, dict2]) if tc_result2 > 0: st.report_tc_fail("FtOpSoSwudldloopaggressive001", "UDLD_TX_RX_loop_Aggressive_Failed", "test_udld_loops_normal_aggressive") else: st.report_tc_pass("FtOpSoSwudldloopaggressive001", "UDLD_TX_RX_loop_Aggressive_Passed", "test_udld_loops_normal_aggressive") if final_result: st.report_pass("test_case_passed") else: fail_msg = '' if udld_interface_normal_loop_fail > 0: fail_msg += 'UDLD loop port down Failed in Normal mode:' if udld_interface_no_normal_loop_fail > 0: fail_msg += 'UDLD no loop port up Failed in Normal mode:' if udld_mode_fail > 0: fail_msg += 'UDLD mode Aggressive config Failed:' if udld_interface_aggressive_loop_fail > 0: fail_msg += 'UDLD loop port down Failed in Aggressive mode:' if udld_interface_no_aggressive_loop_fail > 0: fail_msg += 'UDLD no loop port up Failed in Aggressive mode:' if udld_neighbor_fail > 0: fail_msg += 'UDLD neighbor Failed:' if udld_neighbor_warm_reboot_norm_fail > 0: fail_msg += 'UDLD neighbor Failed after warm reboot:' st.report_fail("test_case_failure_message", fail_msg.strip(':'))