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_l3_perf_tc_14_3(): if (data.result_14_3 is True): #measure_v4_route_scale_time(80000, True) st.report_pass("test_case_passed")
def test_l3_perf_tc_13_4(): if (data.result[3] == 1): st.report_pass("test_case_passed") else: st.report_fail("test_case_failed")
def rest_rbac_call(dut, **kwargs): """ Call to test REST sessions using diff users w.r.t RBAC. Author : Prudvi Mangadu ([email protected]) :param dut: :param kwargs: :return: """ st.log('Performing REST call using - {}'.format(kwargs)) for each in ['login_type', 'username', 'password', 'mode']: if not kwargs.get(each): st.error("Mandatory argument is not found - {}".format(each)) return False result = {'get': True, 'put': True} result2 = True pass_status = [200, 204] fail_status = [401, 403] username = kwargs.get('username') password = kwargs.get('password') login_type = kwargs.get('login_type') mode = kwargs.get('mode') cert = kwargs.get("cert") model = kwargs.get('model') url = kwargs.get('url') if model == 'oc-yang': operation1 = {"openconfig-interfaces:mtu": 9216} operation2 = {"openconfig-interfaces:mtu": 9100} else: operation1 = {"sonic-port:admin_status": "down"} operation2 = {"sonic-port:admin_status": "up"} if login_type == 'cred': headers1 = {'Content-Type': 'application/yang-data+json', 'Accept': 'application/yang-data+json'} rest_get_out = rest_call(dut, headers=headers1, username=username, password=password, url=url, call_type='get') st.log(rest_get_out) rest_put_out = rest_call(dut, headers=headers1, username=username, password=password, url=url, call_type='put', data=operation1) st.log(rest_put_out) elif login_type == 'token': headers2 = {'Content-Type': 'application/yang-data+json', 'Accept': 'application/yang-data+json', 'Authorization': 'Bearer {}'} tocken = get_jwt_token(dut, username=username, password=password) if not tocken: st.report_fail('rbac_test_jwt_token_fail', mode, login_type) headers2['Authorization'] = headers2['Authorization'].format(tocken) rest_get_out = rest_call(dut, headers=headers2, url=url, call_type='get') st.log(rest_get_out) rest_put_out = rest_call(dut, headers=headers2, url=url, call_type='put', data=operation2) st.log(rest_put_out) elif login_type == 'cert': port1 = st.get_free_ports(dut)[0].replace("/", "%2F") url2 = '/restconf/data/sonic-port:sonic-port/PORT/PORT_LIST={}/admin_status'.format(port1) get_curl = 'curl --key {} --cert {} ' "'https://localhost{}'" ' -k'.format(cert[0], cert[1], url2) out = st.show(dut, get_curl, skip_tmpl=True, skip_error_check=True) rest_get_out = {'status': 401} rest_put_out = {'status': 200} if 'sonic-port:admin_status' in out: rest_get_out = {'status': 200} else: st.error("Invalid 'login_type' used = {}".format(login_type)) return False if not (rest_get_out and rest_put_out): st.report_fail('rbac_call_fail', "REST", mode, login_type) msg = 'Failed to authenticate using rest session with mode- {mode}, type- {login_type}' if mode == 'rw' and not (rest_get_out["status"] in pass_status and rest_put_out["status"] in pass_status): st.error(msg.format(**kwargs)) result2 = False if mode == 'ro' and not (rest_get_out["status"] in pass_status and rest_put_out["status"] in fail_status): st.error(msg.format(**kwargs)) result2 = False if not result2: st.report_fail('rbac_test_status', 'Fail', mode, 'REST', login_type, result) st.report_pass('rbac_test_status', 'Pass', mode, 'REST', login_type, result)
def test_l3_perf_tc_11_3(): measure_v4_route_scale_time(60000, False) st.report_pass("test_case_passed")
def test_l2_to_l3_port(): data.my_dut_list = st.get_dut_names() dut1 = data.my_dut_list[0] data.vlan = '10' data.vlan_int = 'Vlan' + '10' result_flag = 1 # configure from L3 to L2 port vapi.create_vlan(dut1, data.vlan) ipfeature.delete_ip_interface(dut1, vars.D1D2P1, data.d1d2_ip_addr, data.mask) ipfeature.delete_ip_interface(dut1, vars.D1D2P1, data.d1d2_ip_addr_v6, data.mask_v6, family='ipv6') ipfeature.config_ip_addr_interface(dut1, data.vlan_int, data.d1d2_ip_addr, data.mask) ipfeature.config_ip_addr_interface(dut1, data.vlan_int, data.d1d2_ip_addr_v6, data.mask_v6, family='ipv6') vapi.add_vlan_member(dut1, data.vlan, vars.D1D2P1, False) if not vapi.verify_vlan_config(dut1, str(data.vlan), None, vars.D1D2P1): result_flag = 0 ipfeature.get_interface_ip_address(dut1, family="ipv4") ipfeature.get_interface_ip_address(dut1, family="ipv6") result1 = ipfeature.ping(dut1, data.d2t1_ip_addr) result2 = ipfeature.ping(dut1, data.d2t1_ip_addr_v6, 'ipv6') if not result1 or not result2: result_flag = 0 # Revert back from L2 to L3 port vapi.delete_vlan_member(dut1, data.vlan, [vars.D1D2P1]) ipfeature.delete_ip_interface(dut1, data.vlan_int, data.d1d2_ip_addr, data.mask) ipfeature.delete_ip_interface(dut1, data.vlan_int, data.d1d2_ip_addr_v6, data.mask_v6, family='ipv6') vapi.delete_vlan(dut1, [data.vlan]) ipfeature.config_ip_addr_interface(dut1, vars.D1D2P1, data.d1d2_ip_addr, data.mask) ipfeature.config_ip_addr_interface(dut1, vars.D1D2P1, data.d1d2_ip_addr_v6, data.mask_v6, family='ipv6') waitapi.vsonic_ip_apply(vars.D1) ping_result = ipfeature.ping(dut1, data.d2t1_ip_addr) if ping_result and result_flag: st.report_pass("operation_successful") else: st.report_fail("operation_failed")
def test_ft_mclag_with_rpvst_failover_tests_2_tier(): if lib_stp.lib_stp_mclag_failover_tests(): st.report_pass('test_case_passed') else: st.report_fail('test_case_failed')
def test_ft_bgp_unnumbered_manual_ll(): """ # ################ Author Details ################ # Name: Sesha Reddy Koilkonda # Email: [email protected] # ################################################ :return: """ utils_obj.banner_log( 'FtOtSoRtBgpUnFn013,FtOtSoRtBgpUnFn014,FtOtSoRtBgpUnFn015') result = 0 # Configure the Link-local manually on Dut1 and auto link-local on DUT2 and verify the neighbourship. bgp_obj.cleanup_router_bgp(st.get_dut_names()) ip_obj.config_ip_addr_interface(vars.D1, vars.D1D2P1, data.ip6_addr_manual_ll[0], 96, family='ipv6') dict1 = { 'config': 'yes', 'router_id': data.d1_rid, 'addr_family': 'ipv6', 'local_as': data.d1_local_as, 'remote_as': 'external', 'config_type_list': ["remote-as", "activate"], 'interface': vars.D1D2P1, 'neighbor': vars.D1D2P1 } dict2 = { 'config': 'yes', 'router_id': data.d2_rid, 'addr_family': 'ipv6', 'local_as': data.d2_local_as, 'remote_as': 'external', 'config_type_list': ["remote-as", "activate"], 'interface': vars.D2D1P1, 'neighbor': vars.D2D1P1 } parallel.exec_parallel(True, [vars.D1, vars.D2], bgp_obj.config_bgp, [dict1, dict2]) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, state='Established'): st.error( "Failed to form BGP unnumbered peering using IPv6 link local with the Manual-Auto link-local address combination." ) result += 1 # with the manual link-local on Dut1 and configure the link-local on DUT2 also manually and verify the neighbourship. bgp_obj.cleanup_router_bgp(st.get_dut_names()) ip_obj.config_ip_addr_interface(vars.D2, vars.D2D1P1, data.ip6_addr_manual_ll[1], 96, family='ipv6') parallel.exec_parallel(True, [vars.D1, vars.D2], bgp_obj.config_bgp, [dict1, dict2]) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, state='Established'): st.error( "Failed to form BGP unnumbered peering using IPv6 link local with the manual-manual link-local address combination." ) result += 1 # update the manual link-local on Dut2 and verify the neighbourship. bgp_obj.cleanup_router_bgp(st.get_dut_names()) data.ip6_addr_ll3 = 'FE80:0:0:0:204:5FF:FE00:500' ip_obj.config_ip_addr_interface(vars.D2, vars.D2D1P1, data.ip6_addr_manual_ll[2], 96, family='ipv6') parallel.exec_parallel(True, [vars.D1, vars.D2], bgp_obj.config_bgp, [dict1, dict2]) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, state='Established'): st.error( "Failed to form BGP unnumbered peering using IPv6 link local, after uodating the manual link-local address on peer DUT.." ) result += 1 bgp_obj.cleanup_router_bgp(st.get_dut_names()) ip_obj.config_ip_addr_interface(vars.D1, vars.D1D2P1, data.ip6_addr_manual_ll[0], 96, family='ipv6', config='remove') ip_obj.config_ip_addr_interface(vars.D2, vars.D2D1P1, data.ip6_addr_manual_ll[1], 96, family='ipv6', config='remove') ip_obj.config_ip_addr_interface(vars.D2, vars.D2D1P1, data.ip6_addr_manual_ll[2], 96, family='ipv6', config='remove') if result == 0: st.report_pass("test_case_passed") else: st.error( "BGP unnumbered neighborship failed with the manual link-local address configuration." ) st.report_fail("test_case_failed")
def test_ft_bgp_unnumbered_nondefault_vrf(): """ # ################ Author Details ################ # Name: Sesha Reddy Koilkonda # Email: [email protected] # ################################################ :return: """ utils_obj.banner_log("FtOtSoRtBgpUnFn016,FtOtSoRtBgpUnFn017") result = 0 bgp_obj.cleanup_router_bgp(st.get_dut_names()) dict1 = {'vrf_name': data.vrf_name, 'skip_error': True} parallel.exec_parallel(True, [vars.D1, vars.D2], vrf_api.config_vrf, [dict1, dict1]) utils.exec_all(True, [[ ip_obj.config_interface_ip6_link_local, vars.D1, vars.D1D2P1, "disable" ], [ ip_obj.config_interface_ip6_link_local, vars.D2, vars.D2D1P1, "disable" ]]) dict1 = { 'vrf_name': data.vrf_name, 'intf_name': vars.D1D2P1, 'skip_error': True } dict2 = { 'vrf_name': data.vrf_name, 'intf_name': vars.D2D1P1, 'skip_error': True } parallel.exec_parallel(True, [vars.D1, vars.D2], vrf_api.bind_vrf_interface, [dict1, dict2]) utils.exec_all( True, [[ip_obj.config_interface_ip6_link_local, vars.D1, vars.D1D2P1], [ip_obj.config_interface_ip6_link_local, vars.D2, vars.D2D1P1]]) utils.exec_all(True, [[ip_obj.get_interface_ip_address, vars.D1, None, "ipv6"], [ip_obj.get_interface_ip_address, vars.D2, None, "ipv6"]]) dict1 = { 'vrf_name': data.vrf_name, 'router_id': data.d1_rid, 'local_as': data.d1_local_as, 'addr_family': 'ipv6', 'neighbor': vars.D1D2P1, 'remote_as': 'external', 'config_type_list': ["remote-as", "activate"], 'interface': vars.D1D2P1 } dict2 = { 'vrf_name': data.vrf_name, 'router_id': data.d2_rid, 'local_as': data.d2_local_as, 'addr_family': 'ipv6', 'neighbor': vars.D2D1P1, 'remote_as': 'external', 'config_type_list': ["remote-as", "activate"], 'interface': vars.D2D1P1 } parallel.exec_parallel(True, [vars.D1, vars.D2], bgp_obj.config_bgp, [dict1, dict2]) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, vrf=data.vrf_name, state='Established'): st.error( "BGP unnumbered neighbourship with the non-default vrf configuration failed." ) result += 1 st.log('######------Save and reboot------######') reboot_obj.config_save(vars.D1, "sonic") reboot_obj.config_save(vars.D1, "vtysh") st.reboot(vars.D1) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, vrf=data.vrf_name, state='Established'): st.error( "BGP unnumbered neighbourship with the non-default vrf configuration failed after save and reboot." ) result += 1 st.log('######------Config reload with BGP unnumbered------######') st.log("Config reload the DUT") reboot_obj.config_save_reload(vars.D1) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, vrf=data.vrf_name, state='Established'): st.error( "BGP unnumbered neighbourship with the non-default vrf configuration failed after config reload." ) result += 1 # unconfig part: dict1 = { 'vrf_name': data.vrf_name, 'local_as': data.d1_local_as, 'config': 'no', 'removeBGP': 'yes', 'config_type_list': ['removeBGP'] } dict2 = { 'vrf_name': data.vrf_name, 'local_as': data.d2_local_as, 'config': 'no', 'removeBGP': 'yes', 'config_type_list': ['removeBGP'] } parallel.exec_parallel(True, [vars.D1, vars.D2], bgp_obj.config_bgp, [dict1, dict2]) utils.exec_all(True, [[ ip_obj.config_interface_ip6_link_local, vars.D1, vars.D1D2P1, "disable" ], [ ip_obj.config_interface_ip6_link_local, vars.D2, vars.D2D1P1, "disable" ]]) dict1 = { 'vrf_name': data.vrf_name, 'intf_name': vars.D1D2P1, 'skip_error': True, 'config': 'no' } dict2 = { 'vrf_name': data.vrf_name, 'intf_name': vars.D2D1P1, 'skip_error': True, 'config': 'no' } parallel.exec_parallel(True, [vars.D1, vars.D2], vrf_api.bind_vrf_interface, [dict1, dict2]) dict1 = {'vrf_name': data.vrf_name, 'skip_error': True, 'config': 'no'} parallel.exec_parallel(True, [vars.D1, vars.D2], vrf_api.config_vrf, [dict1, dict1]) bgp_obj.cleanup_router_bgp(st.get_dut_names()) utils.exec_all( True, [[ip_obj.config_interface_ip6_link_local, vars.D1, d1_int_ipv6_list], [ip_obj.config_interface_ip6_link_local, vars.D2, d2_int_ipv6_list]]) if result == 0: st.report_pass("test_case_passed") else: st.error( "BGP unnumbered neighborship failed with the non-default vrf configuration." ) st.report_fail("test_case_failed")
def test_ft_bgp_unnumbered_rmap(): """ # ################ Author Details ################ # Name: Sesha Reddy Koilkonda # Email: [email protected] # ################################################ :return: """ utils_obj.banner_log('FtOtSoRtBgpUnFn010,FtOtSoRtBgpUnFn016') result = 0 network_ipv6 = '6002:1::0/64' bgp_obj.config_bgp(config='yes', dut=vars.D2, local_as=data.d2_local_as, addr_family='ipv6', neighbor=vars.D2D1P1, weight='35000', config_type_list=["weight"]) bgp_obj.config_bgp_network_advertise(vars.D1, data.d1_local_as, network_ipv6, addr_family='ipv6', config='yes', network_import_check=True) st.wait(60) n1 = ip_obj.verify_ip_route(vars.D2, family='ipv6', shell='sonic', ip_address='6002:1::/64') if (n1 is False): st.error("Failed to advertise the ipv6 network to the peer") result += 1 bgp_obj.get_ip_bgp_route(vars.D2, family="ipv6", network="6002:1/64") # Add route-map to advertised network ip_obj.config_access_list(vars.D1, 'Ubgp-access-list1', network_ipv6, 'deny', family='ipv6', seq_num="1") ip_obj.config_route_map_match_ip_address(vars.D1, 'Ubgp-rmap', 'deny', '10', 'Ubgp-access-list1', family='ipv6') bgp_obj.advertise_bgp_network(vars.D1, data.d1_local_as, network_ipv6, 'Ubgp-rmap', family='ipv6') # verify route-map to advertised network n1 = ip_obj.verify_ip_route(vars.D2, family='ipv6', shell='sonic', ip_address='6002:1::/64') if (n1 is True): st.error( "Advertised network is not filtered by the configured route map") result += 1 else: st.log("As expected, advertised network is filtered by the route map.") # Veirfy the BGP unnumbered neighbourship post r-map config if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, state='Established'): st.error( "Failed to form BGP unnumbered peering using IPv6 link local, with the route map configuration." ) result += 1 # Unconfig the r-map and verify the BGP neighbourship ip_obj.config_route_map_mode(vars.D1, 'Ubgp-rmap', 'deny', '10', config='no') ip_obj.config_access_list(vars.D1, 'Ubgp-access-list1', network_ipv6, 'deny', config='no', family='ipv6', seq_num="1") bgp_obj.config_bgp(config='no', dut=vars.D2, local_as=data.d2_local_as, addr_family='ipv6', neighbor=vars.D2D1P1, weight='35000', config_type_list=["weight"]) bgp_obj.config_bgp_network_advertise(vars.D1, data.d1_local_as, network_ipv6, addr_family='ipv6', config='no') if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, state='Established'): st.error( "Failed to form BGP unnumbered peering using IPv6 link local, after route map un-configuration." ) result += 1 if result == 0: st.report_pass("test_case_passed") else: st.error( "BGP unnumbered neighborship failed with the route map configuration." ) st.report_fail("test_case_failed")
def test_ft_bgp_unnumbered_rr(): """ # ################ Author Details ################ # Name: Sesha Reddy Koilkonda # Email: [email protected] # ################################################ :return: """ utils_obj.banner_log('FtOtSoRtBgpUnFn011,FtOtSoRtBgpUnFn012') result = 0 bgp_obj.cleanup_router_bgp(st.get_dut_names()) dict1 = { 'config': 'yes', 'router_id': data.d1_rid, 'addr_family': 'ipv6', 'local_as': data.d1_local_as, 'remote_as': 'internal', 'config_type_list': ["remote-as", "activate"], 'interface': vars.D1D2P1, 'neighbor': vars.D1D2P1 } dict2 = { 'config': 'yes', 'router_id': data.d2_rid, 'addr_family': 'ipv6', 'local_as': data.d1_local_as, 'remote_as': 'internal', 'config_type_list': ["remote-as", "activate"], 'interface': vars.D2D1P1, 'neighbor': vars.D2D1P1 } parallel.exec_parallel(True, [vars.D1, vars.D2], bgp_obj.config_bgp, [dict1, dict2]) result_rr = bgp_obj.create_bgp_route_reflector_client( vars.D1, data.d1_local_as, 'ipv6', vars.D1D2P1, 'yes') if not result_rr: st.error( "BGP SP - Configuring client reflection on {} {} bgp {} Failed". format(vars.D1, 'ipv6', data.d1_local_as)) result += 1 if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, state='Established'): st.error( "Failed to form iBGP unnumbered peering using IPv6 link local with Route-reflector-client config" ) result += 1 # Unconfiguration bgp_obj.create_bgp_route_reflector_client(vars.D1, data.d1_local_as, 'ipv6', vars.D1D2P1, config='no') bgp_obj.cleanup_router_bgp(st.get_dut_names()) if result == 0: st.report_pass("test_case_passed") else: st.error( "BGP unnumbered neighborship failed with the Route-reflector-client configuration failed." ) st.report_fail("test_case_failed")
def test_ft_bgp_unnumbered_traffic(): """ # ################ Author Details ################ # Name: Sesha Reddy Koilkonda # Email: [email protected] # ################################################ :return: """ utils_obj.banner_log('FtOtSoRtBgpUnFn021') (tg1, tg2, tg_ph_1, tg_ph_2) = get_handles() dut1_mac = basic_obj.get_ifconfig_ether(vars.D1, vars.D1T1P1) h1 = tg1.tg_interface_config(port_handle=tg_ph_1, mode='config', intf_ip_addr=data.tg_ip4_addr_l[0], gateway=data.tgd_ip4_addr_l[0], src_mac_addr='00:0a:01:00:00:01', arp_send_req='1') h2 = tg2.tg_interface_config(port_handle=tg_ph_2, mode='config', intf_ip_addr=data.tg_ip4_addr_l[1], gateway=data.tgd_ip4_addr_l[1], src_mac_addr='00:0a:01:00:00:01', arp_send_req='1') # Advertise a network to peer network = '55.1.1.0/24' bgp_obj.advertise_bgp_network(vars.D2, data.d2_local_as, network) stream_tg1 = tg1.tg_traffic_config(port_handle=tg_ph_1, mode='create', transmit_mode="single_burst", length_mode='fixed', pkts_per_burst=1000, mac_src='00.00.00.11.12.53', mac_dst=dut1_mac, l3_protocol='ipv4', ip_src_addr=data.tg_ip4_addr_l[0], ip_dst_addr=data.tg_ip4_addr_l[1], port_handle2=tg_ph_2) stream_id = stream_tg1['stream_id'] tg1.tg_traffic_control(action='run', stream_handle=stream_id) st.wait(5) tg1.tg_traffic_control(action='stop', stream_handle=stream_id) traffic_details = { '1': { 'tx_ports': [vars.T1D1P1], 'tx_obj': [tg1], 'exp_ratio': [1], 'rx_ports': [vars.T1D2P1], 'rx_obj': [tg2], 'stream_list': [(stream_id)], } } # verify statistics aggrResult = validate_tgen_traffic(traffic_details=traffic_details, mode='aggregate', comp_type='packet_count') tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) tg1.tg_interface_config(port_handle=tg_ph_1, handle=h1['handle'], mode='destroy') tg2.tg_interface_config(port_handle=tg_ph_2, handle=h2['handle'], mode='destroy') bgp_obj.advertise_bgp_network(vars.D2, data.d2_local_as, network, config='no') if aggrResult: st.log("IPv4 traffic over BGPv6 unnumbered neighbour is passed") st.report_pass("test_case_passed") else: st.error("IPv4 traffic over BGPv6 unnumbered neighbour is failed.") st.report_fail("test_case_failed")
def test_ft_bgp_unnumbered_clear_bgp_ndp(): # ################ Author Details ################ # Name: Kiran Vedula # Email: [email protected] # ################################################ utils_obj.banner_log( 'FtOtSoRtBgpUnFn004,FtOtSoRtBgpUnFn005,FtOtSoRtBgpUnFn007') result = 0 st.log('######------Clear BGP on both nodes------######') utils.exec_all(True, [[arp_obj.clear_ndp_table, vars.D1], [arp_obj.clear_ndp_table, vars.D2]]) utils.exec_all(True, [[arp_obj.show_ndp, vars.D1], [arp_obj.show_ndp, vars.D2]]) utils.exec_all(True, [[bgp_obj.clear_ip_bgp_vtysh, vars.D1], [bgp_obj.clear_ip_bgp_vtysh, vars.D2]]) utils.exec_all(True, [[arp_obj.show_ndp, vars.D1], [arp_obj.show_ndp, vars.D2]]) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, state='Established'): st.log("Failed to form BGP unnumbered peering after clear NDP/BGP") result += 1 if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D2, family='ipv6', shell=bgp_cli_type, neighbor=vars.D2D1P1, state='Established'): st.log("Failed to form BGP unnumbered peering after clear NDP/BGP") result += 1 utils.exec_all(True, [[ip_obj.config_ipv6, vars.D1, "disable"], [ip_obj.config_ipv6, vars.D2, "disable"]]) utils.exec_all(True, [[bgp_obj.clear_ip_bgp_vtysh, vars.D1], [bgp_obj.clear_ip_bgp_vtysh, vars.D2]]) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D2, family='ipv6', shell=bgp_cli_type, neighbor=vars.D2D1P1, state='Active'): st.log("BGP unnumbered peers established even after disable IPv6") result += 1 utils.exec_all(True, [[ip_obj.config_ipv6, vars.D1, "enable"], [ip_obj.config_ipv6, vars.D2, "enable"]]) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D2, family='ipv6', shell=bgp_cli_type, neighbor=vars.D2D1P1, state='Established'): st.log("Failed to form BGP unnumbered peering after enable IPv6") result += 1 if result == 0: st.report_pass("test_case_passed") else: st.log("BGP unnumbered neighborship failed after config state toggle") st.report_fail("test_case_failed")
def report_result(status): if status: st.report_pass('test_case_passed') else: st.report_fail('test_case_failed')
def test_ft_hw_watchdog(): min_hw_watchdog_time = 180 max_hw_watchdog_time = 370 reboot_sleep = 60 st.log("Verify whether feature is supported or not") platform_check() hw_watchdog_expiry = min_hw_watchdog_time + reboot_sleep st.log("Disabling the hw watchdog") if not box.hw_watchdog_config(vars.D1, mode='disable'): st.report_fail("hw_watchdog_disable_fail") st.log("Enabling the hw watchdog") if not box.hw_watchdog_config(vars.D1, mode='enable'): st.report_fail("hw_watchdog_enable_fail") st.log("Resetting the Hw watch daemon") if not box.hw_watchdog_config(vars.D1, mode='reset'): st.report_fail("hw_watchdog_reset_fail") st.log("Wait for watchdog timer to expire") st.wait(hw_watchdog_expiry) st.log("Getting status of hw watchdog") if not box.hw_watchdog_config(vars.D1, mode='status'): st.report_fail("hw_watchdog_status_fail") st.log("Get the hw watchdog reboot cause") if not reboot_obj.get_reboot_cause(vars.D1): st.report_fail("verify_hard_reboot_show_reboot_cause_fail") cause = reboot_obj.get_reboot_cause(vars.D1) cause = cause[0]['message'] if not cause == 'Hardware Watchdog Reset': if data.version_data.lower() in data.hw_constants_DUT[ 'HW_WATCHDOG_REBOOT_CAUSE_SUPPORTED_PLATFORMS']: st.log("Reboot reason is invalid") st.report_tc_fail("ft_hw_watchdog_reset", 'test_case_id_failed') else: st.log( "Reboot reason is invalid because platform not have reboot cause support specific to Hw watchdog" ) st.log("Getting timeout of hw watchdog") if not box.hw_watchdog_config(vars.D1, mode='timeout'): st.report_fail("hw_watchdog_timeout_fail") st.log("Verifying the running status of hw watchdog feature") if not box.hw_watchdog_config(vars.D1, mode='running_status'): st.report_fail("hw_watchdog_running_status") st.log("Generating kdump collections") if not box.hw_watchdog_config(vars.D1, mode='kdump'): st.report_fail("hw_watchdog_kdump_fail") if not reboot_obj.get_reboot_cause(vars.D1): st.report_fail("verify_hard_reboot_show_reboot_cause_fail") cause = reboot_obj.get_reboot_cause(vars.D1) cause = cause[0]['message'] if not cause == 'Hardware Watchdog Reset': if data.version_data.lower() in data.hw_constants_DUT[ 'HW_WATCHDOG_REBOOT_CAUSE_SUPPORTED_PLATFORMS']: st.log("Reboot reason is invalid") st.report_tc_fail("ft_hw_watchdog_reset", 'test_case_id_failed') else: st.log( "Reboot reason is invalid because platform not have reboot cause support specific to Hw watchdog" ) st.log("Changing the timeout value and verifying watchdog feature") value = random.randint(min_hw_watchdog_time, max_hw_watchdog_time) st.log("configurung the timeout value and verifying the functionality") if not box.hw_watchdog_timeout_config(vars.D1, timeout_value=value): st.report_fail("hw_watchdog_timeout_fail") sleep_time = value + reboot_sleep if not box.hw_watchdog_config(vars.D1, mode='reset'): st.report_fail("hw_watchdog_reset_fail") st.log("Wait for watchdog timer to expire") st.wait(sleep_time) if not reboot_obj.get_reboot_cause(vars.D1): st.report_fail("verify_hard_reboot_show_reboot_cause_fail") cause = reboot_obj.get_reboot_cause(vars.D1) cause = cause[0]['message'] if not cause == 'Hardware Watchdog Reset': if data.version_data.lower() in data.hw_constants_DUT[ 'HW_WATCHDOG_REBOOT_CAUSE_SUPPORTED_PLATFORMS']: st.log("Reboot reason is invalid") st.report_tc_fail("ft_hw_watchdog_reset", 'test_case_id_failed') else: st.log( "Reboot reason is invalid because platform not have reboot cause support specific to Hw watchdog" ) st.log("Changing back to default value") if not box.hw_watchdog_timeout_config(vars.D1, timeout_value=min_hw_watchdog_time): st.report_fail("hw_watchdog_timeout_fail") st.report_pass("test_case_passed")
def test_ft_bgp_unnumbered_warmboot(): # ################ Author Details ################ # Name: Kiran Vedula # Email: [email protected] # ################################################ utils_obj.banner_log('FtOtSoRtBgpUnFn009') utils.exec_all(True, [[bgp_obj.show_bgp_ipv6_summary_vtysh, vars.D1], [bgp_obj.show_bgp_ipv6_summary_vtysh, vars.D2]]) utils.exec_all( True, [[arp_obj.show_ndp, vars.D1, None], [arp_obj.show_ndp, vars.D2, None]]) result = 0 st.log('######------Warm reboot with BGP unnumbered------######') platform = basic_obj.get_hwsku(vars.D1) common_constants = st.get_datastore(vars.D1, "constants", "default") if not platform.lower( ) in common_constants['WARM_REBOOT_SUPPORTED_PLATFORMS']: st.error("Warm-Reboot is not supported for this platform {}".format( platform)) st.report_unsupported('Warmboot_unsupported_platform', platform) reboot_obj.config_save(vars.D1, "sonic") reboot_obj.config_save(vars.D1, "vtysh") st.reboot(vars.D1, 'warm') st.wait(data.wait) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D2, family='ipv6', shell=bgp_cli_type, neighbor=vars.D2D1P1, state='Established'): st.log("Failed to form BGP unnumbered peering after warm reboot") result += 1 st.wait(data.wait) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D2, family='ipv6', shell=bgp_cli_type, neighbor=data.vlan_in_1, state='Established'): st.log("Failed to form BGP unnumbered peering after warm reboot") result += 1 st.wait(data.wait) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D2, family='ipv6', shell=bgp_cli_type, neighbor=data.portchannel_name, state='Established'): st.log("Failed to form BGP unnumbered peering after warm reboot") result += 1 if result == 0: st.report_pass("test_case_passed") else: st.log("BGP unnumbered neighborship failed warm reboot") utils.exec_all(True, [[arp_obj.show_ndp, vars.D1, None], [arp_obj.show_ndp, vars.D2, None]]) utils.exec_all(True, [[bgp_obj.show_bgp_ipv6_neighbor_vtysh, vars.D1], [bgp_obj.show_bgp_ipv6_neighbor_vtysh, vars.D2]]) st.report_fail("test_case_failed")
def test_l3_fwding(): #pre_test_l3_fwding() data.my_dut_list = st.get_dut_names() dut1 = vars.D1 ipfeature.get_interface_ip_address(dut1, family="ipv4") ipfeature.get_interface_ip_address(dut1, family="ipv6") ipfeature.show_ip_route(dut1) # L3 traffic streams (tg1, _, tg_ph_1, tg_ph_2) = get_handles() tg1.tg_traffic_control(action='reset', port_handle=[tg_ph_1, tg_ph_2]) res = tg1.tg_interface_config(port_handle=tg_ph_1, mode='config', intf_ip_addr=data.t1d1_ip_addr, gateway=data.d1t1_ip_addr, src_mac_addr='00:0a:01:00:11:01', arp_send_req='1') st.log("INTFCONF: " + str(res)) handle1 = res['handle'] res = tg1.tg_interface_config(port_handle=tg_ph_2, mode='config', intf_ip_addr=data.t1d2_ip_addr, gateway=data.d2t1_ip_addr, src_mac_addr='00:0a:01:00:12:01', arp_send_req='1') st.log("INTFCONF: " + str(res)) handle2 = res['handle'] rv = tg1.tg_traffic_config(port_handle=tg_ph_1, port_handle2=tg_ph_2, mode='create', transmit_mode='continuous', length_mode='fixed', l3_length=data.tgen_l3_len, rate_pps=data.tgen_rate_pps, emulation_src_handle=handle1, emulation_dst_handle=handle2) tg_info['tg1_stream_id'] = rv['stream_id'] rv_1 = tg1.tg_traffic_config(port_handle=tg_ph_2, port_handle2=tg_ph_1, mode='create', transmit_mode='continuous', length_mode='fixed', l3_length=data.tgen_l3_len, rate_pps=data.tgen_rate_pps, emulation_src_handle=handle2, emulation_dst_handle=handle1) tg_info['tg2_stream_id'] = rv_1['stream_id'] tg1.tg_traffic_control(action='clear_stats', port_handle=[tg_ph_1, tg_ph_2]) papi.clear_interface_counters(dut1) tg1.tg_traffic_control( action='run', stream_handle=[tg_info['tg1_stream_id'], tg_info['tg2_stream_id']]) st.wait(data.traffic_run_time) tg1.tg_traffic_control( action='stop', stream_handle=[tg_info['tg1_stream_id'], tg_info['tg2_stream_id']]) traffic_details = { '1': { 'tx_ports': [vars.T1D1P1], 'tx_obj': [tg1], 'exp_ratio': [1], 'rx_ports': [vars.T1D2P1], 'rx_obj': [tg1], 'stream_list': [[tg_info['tg1_stream_id']]] }, '2': { 'tx_ports': [vars.T1D2P1], 'tx_obj': [tg1], 'exp_ratio': [1], 'rx_ports': [vars.T1D1P1], 'rx_obj': [tg1], 'stream_list': [[tg_info['tg2_stream_id']]] } } if not tgapi.validate_tgen_traffic(traffic_details=traffic_details, mode='streamblock', comp_type='packet_count'): st.report_fail("failed_traffic_verification") # read interface counters rx_counters = intapi.get_interface_counters(dut1, vars.D1T1P1, "rx_ok") tx_counters = intapi.get_interface_counters(dut1, vars.D1D2P1, "tx_ok") # process interface counters p1_rcvd, p2_txmt = 0, 0 for i in rx_counters: p1_rcvd = int(i['rx_ok'].replace(",", "")) for i in tx_counters: p2_txmt = int(i['tx_ok'].replace(",", "")) diff_count = abs(p1_rcvd - p2_txmt) st.log("ingress rx_ok = {} egress tx_ok = {} diff = {}".format( p1_rcvd, p2_txmt, diff_count)) # verify interface counters if p1_rcvd == 0: st.report_fail("msg", "rx_ok is invalid") if p2_txmt == 0: st.report_fail("msg", "tx_ok is invalid") #if diff_count > data.counters_threshold: st.report_fail("msg", "unexpected counter values") # verify the ipv4 ping result = ipfeature.ping(dut1, data.d2t1_ip_addr) if not result: st.report_fail("msg", "IPv4 Ping Failed") # verify the ipv6 ping result = ipfeature.ping(dut1, data.d2t1_ip_addr_v6, 'ipv6') if not result: st.report_fail("msg", "IPv6 Ping Failed") st.report_pass("operation_successful")
def test_ft_bgp_unnumbered_peer_basic(): # ################ Author Details ################ # Name: Kiran Vedula # Email: [email protected] # ################################################ utils_obj.banner_log( 'FtOtSoRtBgpUnFn001,FtOtSoRtBgpUnFn002,FtOtSoRtBgpUnFn018,FtOtSoRtBgpUnFn019' ) st.log('######------Configure Unnumbered BGP peers------######') result = 0 if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, state='Established'): st.log("Failed to form BGP unnumbered peering using IPv6 link local") result += 1 bgp_obj.config_bgp_neighbor_properties(vars.D1, data.d1_local_as, vars.D1D2P1, family="ipv6", neighbor_shutdown='', no_form='') if utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, state='Established'): st.log("unnumbered BGP peering is established even after shutdown") result += 1 bgp_obj.config_bgp_neighbor_properties(vars.D1, data.d1_local_as, vars.D1D2P1, family="ipv6", neighbor_shutdown='', no_form='no') if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, state='Established'): st.log( "Failed to form BGP unnumbered peering using IPv6 link local after no shutdown" ) result += 1 if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=data.vlan_in_1, state='Established'): st.log( "Failed to form BGP unnumbered peering using IPv6 link local on a VLAN" ) result += 1 # Get show ndp output st.log('######------shut/no shut link with unnumbered BGP------######') utils.exec_all( True, [[arp_obj.show_ndp, vars.D1, None], [arp_obj.show_ndp, vars.D2, None]]) intf_obj.interface_operation(vars.D1, vars.D1D2P1, operation="shutdown", skip_verify=True) st.wait(data.wait) intf_obj.interface_status_show(vars.D1, vars.D1D2P1) intf_obj.interface_operation(vars.D1, vars.D1D2P1, operation="startup", skip_verify=True) st.wait(data.wait) if not utils.poll_wait(bgp_obj.verify_bgp_summary, data.wait_timer, vars.D1, family='ipv6', shell=bgp_cli_type, neighbor=vars.D1D2P1, state='Established'): st.log("Failed to form BGP unnumbered peering using IPv6 link local") result += 1 if result == 0: st.report_pass("test_case_passed") else: st.log("BGP IPv6 unnumbered neighborship failure") st.report_fail("test_case_failed")
def test_ft_mclag_with_rpvst_stp_disable_enable_2_tier(): if lib_stp.lib_stp_mclag_disable_enable_stp(): st.report_pass('test_case_passed') else: st.report_fail('test_case_failed')
def test_Ceta_31902(ceta_31902_fixture): success = True mac_obj.config_mac(dut=vars.D1, mac=data.host1_mac, vlan=data.host1_vlan, intf=vars.D1T1P1) arp_obj.add_static_arp(dut=vars.D1, ipaddress=data_tg_ip, macaddress=data.host1_mac, interface="Vlan" + data.host1_vlan) arp_obj.add_static_arp(dut=vars.D1, ipaddress=data_tg_ip, macaddress=data.host2_mac, interface="Vlan" + data.host2_vlan) arp_obj.delete_static_arp(dut=vars.D1, ipaddress=data_tg_ip, interface="Vlan" + data.host2_vlan, mac=data.host2_mac) arp_obj.add_static_arp(dut=vars.D1, ipaddress=data_tg_ip, macaddress=data.host2_mac, interface="Vlan" + data.host1_vlan) arp_obj.delete_static_arp(dut=vars.D1, ipaddress=data_tg_ip, interface="Vlan" + data.host1_vlan, mac=data.host2_mac) mac_obj.config_mac(dut=vars.D1, mac=data.host2_mac, vlan=data.host1_vlan, intf=vars.D1T1P2) arp_obj.add_static_arp(dut=vars.D1, ipaddress=data_tg_ip, macaddress=data.host2_mac, interface="Vlan" + data.host1_vlan) mac_obj.delete_mac(dut=vars.D1, mac=data.host1_mac, vlan=data.host1_vlan) mac_obj.config_mac(dut=vars.D1, mac=data.host1_mac, vlan=data.host1_vlan, intf=vars.D1T1P1) l2_out = asicapi.get_l2_out(vars.D1, data.host2_mac) l3_out = asicapi.get_l3_out(vars.D1, data.host2_mac) if l2_out and l3_out: l2_gport = l2_out[0]["gport"][9] l3_port = l3_out[0]["port"] if l2_gport == l3_port: st.log("MAC {} points port {} correctly in both ARP and MAC table". format(data.host2_mac, l2_gport)) else: success = False st.error("MAC and ARP table are NOT in SYNC; " "MAC {} points to gport {} in \"l2 show\"" "but in \"l3 egress show\" it is port {}".format( data.host2_mac, l2_gport, l3_port)) else: success = False st.error("MAC NOT present in \"l2 show\" or \"l3 egress show\" output") arp_obj.delete_static_arp(dut=vars.D1, ipaddress=data_tg_ip, interface="Vlan" + data.host1_vlan, mac=data.host2_mac) mac_obj.delete_mac(dut=vars.D1, mac=data.host1_mac, vlan=data.host1_vlan) mac_obj.delete_mac(dut=vars.D1, mac=data.host2_mac, vlan=data.host1_vlan) if success: st.report_pass("test_case_id_passed", "test_Ceta_31902") else: st.report_fail("test_case_id_failed", "test_Ceta_31902")
def test_ft_mclag_with_rpvst_config_reload_2_tier(): if lib_stp.lib_stp_mclag_config_reload(): st.report_pass('test_case_passed') else: st.report_fail('test_case_failed')
def test_ft_ping__v4_v6_after_ip_change_pc(): # Objective - Verify that ping is successful between L3 interfaces when Ip address is removed and new ip # is assigned st.log("In {} check portchannel is UP or not".format(vars.D2)) if not pc_obj.verify_portchannel_state( vars.D2, data.port_channel, state="up"): st.report_fail("portchannel_state_fail", data.port_channel, vars.D2, "Up") st.log( "Checking IPv4 ping from {} to {} over portchannel routing interface". format(vars.D1, vars.D2)) if not ipfeature.ping_poll( vars.D1, data.ip4_addr[5], family=data.af_ipv4, iter=5, count=1): st.report_fail("ping_fail", data.ip4_addr[4], data.ip4_addr[5]) st.log( "Checking IPv6 ping from {} to {} over portchannel routing interface". format(vars.D1, vars.D2)) if not ipfeature.ping_poll( vars.D2, data.ip6_addr[4], family=data.af_ipv6, iter=5, count=1): st.report_fail("ping_fail", data.ip6_addr[5], data.ip6_addr[4]) st.log("Removing the Ipv4 address on portchannel") ipfeature.delete_ip_interface(vars.D1, data.port_channel, data.ip4_addr[4], 24, family=data.af_ipv4) ipfeature.delete_ip_interface(vars.D2, data.port_channel, data.ip4_addr[5], 24, family=data.af_ipv4) st.log("Removing the Ipv6 address on portchannel") ipfeature.delete_ip_interface(vars.D1, data.port_channel, data.ip6_addr[4], 96, family=data.af_ipv6) ipfeature.delete_ip_interface(vars.D2, data.port_channel, data.ip6_addr[5], 96, family=data.af_ipv6) st.log("configuring new Ipv4 address on portchannel") ipfeature.config_ip_addr_interface(vars.D1, data.port_channel, data.ip4_addr[10], 24, family=data.af_ipv4) ipfeature.config_ip_addr_interface(vars.D2, data.port_channel, data.ip4_addr[11], 24, family=data.af_ipv4) st.log("configuring new Ipv6 address on portchannel") ipfeature.config_ip_addr_interface(vars.D1, data.port_channel, data.ip6_addr[10], 96, family=data.af_ipv6) ipfeature.config_ip_addr_interface(vars.D2, data.port_channel, data.ip6_addr[11], 96, family=data.af_ipv6) st.log( "After Ipv4 address change, checking IPv4 ping from {} to {} over portchannel " "routing interface".format(vars.D1, vars.D2)) if not ipfeature.ping_poll( vars.D1, data.ip4_addr[11], family=data.af_ipv4, iter=5, count=1): st.report_fail("ping_fail", data.ip4_addr[10], data.ip4_addr[11]) st.log( "After Ipv6 address change, checking IPv6 ping from {} to {} over portchannel " "routing interface".format(vars.D1, vars.D2)) if not ipfeature.ping_poll( vars.D1, data.ip6_addr[11], family=data.af_ipv6, iter=5, count=1): st.report_fail("ping_fail", data.ip6_addr[10], data.ip6_addr[11]) st.report_pass("test_case_passed")
def gnmi_call(dut, **kwargs): """ Call to test gnmi session using diff users w.r.t RBAC. Author : Prudvi Mangadu ([email protected]) :param dut: :param kwargs: :return: """ st.log('Performing gnmi operations using - {}'.format(kwargs)) for each in ['login_type', 'username', 'password', 'mode']: if not kwargs.get(each): st.error("Mandatory argument is not found - {}".format(each)) return False dut_ip = "127.0.0.1" result = {'gnmi_get_out': True, 'gnmi_set_out': True} result2 = True username = kwargs.get('username') password = kwargs.get('password') cert = kwargs.get('cert') login_type = kwargs.get('login_type') mode = kwargs.get('mode') port = st.get_free_ports(dut)[0] if "/" in port: port = st.get_other_names(dut, [port])[0] xpath = '/openconfig-interfaces:interfaces/interface[name={}]/config/description'.format(port) json_content = {"openconfig-interfaces:description": "Eth"} if login_type == 'cred': gnmi_set_out = gnmi_set(dut, xpath, json_content=json_content, ip_address=dut_ip, username=username, password=password) st.log(gnmi_set_out) gnmi_get_out = gnmi_get(dut, xpath, ip_address=dut_ip, username=username, password=password) st.log(gnmi_get_out) elif login_type == 'cert': gnmi_set_out = gnmi_set(dut, xpath, json_content=json_content, ip_address=dut_ip, cert=cert, username=None, password=None, insecure='none', target_name='admin') st.log(gnmi_set_out) gnmi_get_out = gnmi_get(dut, xpath, ip_address=dut_ip, cert=cert, username=None, password=None, insecure='none', target_name='admin') st.log(gnmi_get_out) else: st.error("Invalid 'login_type' used = {}".format(login_type)) return False if mode == 'rw': if not (gnmi_set_out and gnmi_get_out): st.report_fail('rbac_call_fail', "gNMI", mode, login_type) else: if not (not gnmi_set_out and gnmi_get_out): st.report_fail('rbac_call_fail', "gNMI", mode, login_type) msg = 'Failed to execute set command using gNMI session with mode- {mode}, type- {login_type}' if mode == 'rw' and "op: UPDATE" not in str(gnmi_set_out) and "description" not in str(gnmi_get_out): st.error(msg.format(**kwargs)) result2 = False if mode == 'ro' and not gnmi_set_out and "description" not in str(gnmi_get_out): st.error(msg.format(**kwargs)) result2 = False if not result2: st.report_fail('rbac_test_status', 'Fail', mode, 'gNMI', login_type, result) st.report_pass('rbac_test_status', 'Pass', mode, 'gNMI', login_type, result)
def test_ft_ip6_static_route_traffic_forward_blackhole(): # Objective - Verify the Ipv6 traffic forwarding over static route. tg_handler = tgapi.get_handles_byname("T1D1P2", "T1D2P2") tg = tg_handler["tg"] tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"]) tg.tg_traffic_control(action="clear_stats", port_handle=tg_handler["tg_ph_list"]) dut_rt_int_mac1 = basic_obj.get_ifconfig_ether(vars.D1, vars.D1T1P2) h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"], mode='config', ipv6_intf_addr=data.ip6_addr[0], \ ipv6_prefix_length='64', ipv6_gateway=data.ip6_addr[1], src_mac_addr=data.tg_mac1, arp_send_req='1') st.log("INTFCONF: " + str(h1)) h2 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"], mode='config', ipv6_intf_addr=data.ip6_addr[9], \ ipv6_prefix_length='64', ipv6_gateway=data.ip6_addr[8], src_mac_addr=data.tg_mac2, arp_send_req='1') st.log("INTFCONF: " + str(h2)) # Ping from tgen to DUT. res = tgapi.verify_ping(src_obj=tg, port_handle=tg_handler["tg_ph_1"], dev_handle=h1['handle'], dst_ip=data.ip6_addr[1], \ ping_count='1', exp_count='1') if res: st.log("Ping succeeded.") else: st.warn("Ping failed.") tr1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='create', transmit_mode='single_burst', pkts_per_burst=data.pkts_per_burst, \ length_mode='fixed', rate_pps=data.rate_pps, l3_protocol='ipv6', mac_src=data.tg_mac1, \ mac_dst=dut_rt_int_mac1, ipv6_src_addr=data.ip6_addr[0], ipv6_dst_addr=data.ip6_addr[9]) st.log("TRAFCONF: " + str(tr1)) res = tg.tg_traffic_control(action='run', stream_handle=tr1['stream_id']) st.log("TR_CTRL: " + str(res)) tg.tg_traffic_control(action='stop', stream_handle=tr1['stream_id']) st.log("Checking the stats and verifying the traffic flow") traffic_details = { '1': { 'tx_ports': [vars.T1D1P2], 'tx_obj': [tg_handler["tg"]], 'exp_ratio': [1], 'rx_ports': [vars.T1D2P2], 'rx_obj': [tg_handler["tg"]], } } # verify statistics aggrResult = tgapi.validate_tgen_traffic(traffic_details=traffic_details, mode='aggregate', comp_type='packet_count') if not aggrResult: st.report_fail("traffic_verification_failed") ipfeature.delete_static_route(vars.D1, data.ip6_addr[7], data.static_ip6_rt, shell=data.shell_vtysh, family=data.af_ipv6) st.log("Create a static route with nexthop as blackhole") ipfeature.create_static_route(vars.D1, data.static_ip6_rt_drop, data.static_ip6_rt, shell=data.shell_vtysh, family=data.af_ipv6) tg.tg_traffic_control(action="clear_stats", port_handle=tg_handler["tg_ph_list"]) res = tg.tg_traffic_control(action='run', stream_handle=tr1['stream_id']) st.log("TR_CTRL: " + str(res)) tg.tg_traffic_control(action='stop', stream_handle=tr1['stream_id']) st.log("Checking the stats and verifying the traffic flow") traffic_details = { '1': { 'tx_ports': [vars.T1D1P2], 'tx_obj': [tg_handler["tg"]], 'exp_ratio': [1], 'rx_ports': [vars.T1D2P2], 'rx_obj': [tg_handler["tg"]], } } # verify statistics aggrResult = tgapi.validate_tgen_traffic(traffic_details=traffic_details, mode='aggregate', comp_type='packet_count') if aggrResult: st.report_fail("traffic_verification_failed") st.report_pass("test_case_passed")
def test_l3_perf_tc_11_4(): measure_v4_route_scale_time(90000, True) st.report_pass("test_case_passed")
def test_ft_ip_v4_v6_L2_L3_translation(): # Objective - Verify that L2 port to IPv4 L3 port transition and vice-versa is successful. st.log("Checking IPv4 ping from {} to {} over routing interface".format( vars.D1, vars.D2)) if not ipfeature.ping( vars.D1, data.ip4_addr[7], family=data.af_ipv4, count=1): st.report_fail("ping_fail", data.ip4_addr[6], data.ip4_addr[7]) st.log( "Checking IPv6 ping from {} to {} over vlan routing interface".format( vars.D1, vars.D2)) if not ipfeature.ping( vars.D2, data.ip6_addr[6], family=data.af_ipv6, count=1): st.report_fail("ping_fail", data.ip6_addr[7], data.ip6_addr[6]) st.log("L3 to L2 port transition") st.log("Removing ipv4,ipv6 address from interface") ipfeature.delete_ip_interface(vars.D1, vars.D1D2P4, data.ip4_addr[6], 24, family=data.af_ipv4) ipfeature.delete_ip_interface(vars.D2, vars.D2D1P4, data.ip4_addr[7], 24, family=data.af_ipv4) ipfeature.delete_ip_interface(vars.D1, vars.D1D2P4, data.ip6_addr[6], 96, family=data.af_ipv6) ipfeature.delete_ip_interface(vars.D2, vars.D2D1P4, data.ip6_addr[7], 96, family=data.af_ipv6) ipfeature.delete_ip_interface(vars.D1, vars.D1T1P1, data.ip4_addr[1], 24, family=data.af_ipv4) ipfeature.delete_ip_interface(vars.D2, vars.D2T1P1, data.ip4_addr[8], 24, family=data.af_ipv4) st.log("Removing the static routes") ipfeature.delete_static_route(vars.D1, data.ip4_addr[7], data.static_ip_rt, shell=data.shell_vtysh, family=data.af_ipv4) ipfeature.delete_static_route(vars.D1, data.static_ip6_rt_drop, data.static_ip6_rt, shell=data.shell_vtysh, family=data.af_ipv6) st.log("Vlan creation and port association configuration") vlan_obj.create_vlan(vars.D1, data.vlan_2) st.log("Adding back to back connecting ports to vlan {}".format( data.vlan_2)) vlan_obj.add_vlan_member(vars.D1, data.vlan_2, [vars.D1D2P4], tagging_mode=True) vlan_obj.create_vlan(vars.D2, data.vlan_2) vlan_obj.add_vlan_member(vars.D2, data.vlan_2, [vars.D2D1P4], tagging_mode=True) st.log("Adding TG connecting ports to vlan {}".format(data.vlan_1)) vlan_obj.add_vlan_member(vars.D1, data.vlan_2, vars.D1T1P1, tagging_mode=True) vlan_obj.add_vlan_member(vars.D2, data.vlan_2, vars.D2T1P1, tagging_mode=True) tg_handler = tgapi.get_handles_byname("T1D1P1", "T1D2P1") tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"]) tg.tg_traffic_control(action="clear_stats", port_handle=tg_handler["tg_ph_list"]) tr2 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_2"], mode='create', rate_pps=data.rate_pps, mac_src_mode="fixed", transmit_mode="single_burst", pkts_per_burst=data.pkts_per_burst, length_mode='fixed', l2_encap='ethernet_ii_vlan', vlan_id=data.vlan_2, mac_dst_mode="fixed", vlan="enable", mac_src="00:a1:bb:cc:dd:01", mac_dst="00:b1:bb:cc:dd:01") st.log("TRAFCONF: " + str(tr2)) res = tg.tg_traffic_control(action='run', stream_handle=tr2['stream_id']) tg.tg_traffic_control(action='stop', stream_handle=tr2['stream_id']) st.wait(data.wait_tgstats) st.log("TR_CTRL: " + str(res)) st.log("Fetching TGen statistics") stats_tg1 = tgapi.get_traffic_stats(tg_handler["tg"], mode="aggregate", port_handle=tg_handler["tg_ph_2"]) total_tx_tg1 = stats_tg1.tx.total_packets stats_tg2 = tgapi.get_traffic_stats(tg_handler["tg"], mode="aggregate", port_handle=tg_handler["tg_ph_1"]) total_rx_tg2 = stats_tg2.rx.total_packets st.log("total_tx_tg1 = {}".format(total_tx_tg1)) total_tx_tg1_95_percentage = int(total_tx_tg1) * 0.95 st.log("total_tx_tg1_95_percentage= {}".format(total_tx_tg1_95_percentage)) st.log("total_rx_tg2 = {}".format(total_rx_tg2)) if int(total_tx_tg1_95_percentage) > int(total_rx_tg2): st.report_fail("traffic_verification_failed") st.log("Removing vlan configuration") vlan_obj.delete_vlan_member(vars.D1, data.vlan_2, [vars.D1D2P4, vars.D1T1P1], True) vlan_obj.delete_vlan_member(vars.D2, data.vlan_2, [vars.D2D1P4, vars.D2T1P1], True) st.log("L2 to L3 port transition") ipfeature.config_ip_addr_interface(vars.D1, vars.D1D2P4, data.ip4_addr[6], 24, family=data.af_ipv4) ipfeature.config_ip_addr_interface(vars.D2, vars.D2D1P4, data.ip4_addr[7], 24, family=data.af_ipv4) ipfeature.create_static_route(vars.D1, data.ip4_addr[7], data.static_ip_rt, shell=data.shell_vtysh, family=data.af_ipv4) st.log("Checking IPv4 ping from {} to {} over routing interface".format( vars.D1, vars.D2)) if not ipfeature.ping( vars.D1, data.ip4_addr[7], family=data.af_ipv4, count=1): st.report_fail("ping_fail", data.ip4_addr[6], data.ip4_addr[7]) ipfeature.config_ip_addr_interface(vars.D1, vars.D1D2P4, data.ip6_addr[6], 96, family=data.af_ipv6) ipfeature.config_ip_addr_interface(vars.D2, vars.D2D1P4, data.ip6_addr[7], 96, family=data.af_ipv6) ipfeature.create_static_route(vars.D1, data.static_ip6_rt_drop, data.static_ip6_rt, shell=data.shell_vtysh, family=data.af_ipv6) st.log( "Checking IPv6 ping from {} to {} over vlan routing interface".format( vars.D1, vars.D2)) if not ipfeature.ping( vars.D2, data.ip6_addr[6], family=data.af_ipv6, count=1): st.report_fail("ping_fail", data.ip6_addr[7], data.ip6_addr[6]) st.report_pass("test_case_passed")
def test_l3_perf_tc_11_7(): measure_v6_route_learning_time(60000) st.report_pass("test_case_passed")
def test_ft_verify_interfaces_order(): ''' @author: Ramprakash Reddy ([email protected]) ipv4_intf_order : Verify order of interfaces in "show ip interfaces" ipv6_intf_order : Verify order of interfaces in "show ipv6 interfaces' Verify order of interfaces in "show ip/ipv6 interfaces" in sorted order or not :return: ''' flag = 1 st.log( "This test is to ensure that interfaces are listed in sorted order by 'interface name' in 'show ip/ipv6 " "interfaces'") free_ports = st.get_free_ports(vars.D1) if len(free_ports) < data.no_of_ports: data.no_of_ports = len(free_ports) req_ports = random.sample(free_ports, data.no_of_ports) ipv4_addr = data.ip4_addr[11] + '/' + data.ipv4_mask ipv6_addr = data.ip6_addr[0] + '/' + data.ipv6_mask intf_list = [] for i in range(int(math.ceil(float(data.no_of_ports) / 2))): _, ipv4_addr = ipfeature.increment_ip_addr(ipv4_addr, "network") ipfeature.config_ip_addr_interface(vars.D1, interface_name=req_ports[i], ip_address=ipv4_addr.split('/')[0], subnet=data.ipv4_mask, family="ipv4") for i in range(int(math.floor(float(data.no_of_ports) / 2))): _, ipv6_addr = ipfeature.increment_ip_addr(ipv6_addr, "network", family="ipv6") ipfeature.config_ip_addr_interface( vars.D1, interface_name=req_ports[ i + int(math.ceil(float(data.no_of_ports) / 2))], ip_address=ipv6_addr.split('/')[0], subnet=data.ipv6_mask, family="ipv6") output = ipfeature.get_interface_ip_address(vars.D1) for each in output: intf_list.append(each['interface']) temp = lambda text: int(text) if text.isdigit() else text alphanum_key = lambda key: [temp(c) for c in re.split('([0-9]+)', key)] intf_list_sorted = sorted(intf_list, key=alphanum_key) if intf_list == intf_list_sorted: st.log("Ipv4 interfaces are in sorted order") else: st.error("Ipv4 interfaces are not in soretd order") flag = 0 del intf_list[:] del intf_list_sorted[:] output = ipfeature.get_interface_ip_address(vars.D1, family="ipv6") for each in output: intf_list.append(each['interface']) temp = lambda text: int(text) if text.isdigit() else text alphanum_key = lambda key: [temp(c) for c in re.split('([0-9]+)', key)] intf_list_sorted = sorted(intf_list, key=alphanum_key) if intf_list == intf_list_sorted: st.log("Ipv6 interfaces are in sorted order") else: st.error("Ipv6 interfaces are not in soretd order") flag = 0 #Unconfig ipv4_addr = data.ip4_addr[11] + '/' + data.ipv4_mask ipv6_addr = data.ip6_addr[0] + '/' + data.ipv6_mask for i in range(int(math.ceil(float(data.no_of_ports) / 2))): _, ipv4_addr = ipfeature.increment_ip_addr(ipv4_addr, "network") ipfeature.delete_ip_interface(vars.D1, interface_name=req_ports[i], ip_address=ipv4_addr.split('/')[0], subnet=data.ipv4_mask, family="ipv4") for i in range(int(math.floor(float(data.no_of_ports) / 2))): _, ipv6_addr = ipfeature.increment_ip_addr(ipv6_addr, "network", family="ipv6") ipfeature.delete_ip_interface( vars.D1, interface_name=req_ports[ i + int(math.ceil(float(data.no_of_ports) / 2))], ip_address=ipv6_addr.split('/')[0], subnet=data.ipv6_mask, family="ipv6") if flag == 0: st.report_fail("test_case_failed") st.report_pass("test_case_passed")
def test_l3_intf_scaling_tc_6_5(): if data.tc6_xresult[4]: st.report_pass("test_case_passed") else: st.report_fail("test_case_failed")
def test_ft_ztp_config_check_with_option_59_v6_inband(ztp_func_hooks): # ################ Author Details ################ # Name: Chaitanya Vella # Email: [email protected] # ################################################ # ############## Test bed details ################ # D1 ---- DHCP Server # ft_ztp_config_section_check_with_option_67_with_inband : # Verify that SONiC ZTP is successful through in-band ports using ZTP # URL provided in DHCP option 59 received over IPv6 network. # ################################################# vars = st.ensure_min_topology("D1") config_params.home_path = dhcp6_home_path config_params.static_ip = dhcp6_static_ip config_params.dhcp_config_file = dhcp6_config_file config_params.ztp_operation = "run" config_params.result = "" config_params.dut = vars.D1 config_params.dut_ztp_cfg_file = "{}/{}".format(ztp_params.dut_path, ztp_params.ztp_cfg_file_name) config_params.network_port = dhcp6_port config_params.json_content = { "ztp": { "02-configdb-json": {"url": {"source": "file://{}".format(config_params.config_db_temp), "timeout": 300}, "clear-config": "False","save-config": "True"}, "01-provisioning-script": { "plugin": { "url": "http://[{}]{}/{}".format(config_params.static_ip, ztp_params.provision_script_path, config_params.option_239_sh_file) } }, "06-snmp": { "communities-ro": ["sonic", "buzznik"], "snmp-location": "Hyderabad", "snmp-syscontact": "admin", "ignore-result": "true", "restart-agent": True } } } source_path = "{}{}".format(config_params.local_provision_scripts_folder, config_params.option_239_sh_file) destination_path = "{}{}/{}".format(ztp_params.home_path, ztp_params.provision_script_path, config_params.option_239_sh_file) basic_obj.copy_file_from_client_to_server(ssh_conn_obj, src_path=source_path, dst_path=destination_path, persist=True) # options={"reboot_on_success": "01-configdb-json"} ztp_obj.config_dhcpv6_options(ssh_conn_obj, ztp_params, config_params) ztp_status = ztp_obj.show_ztp_status(vars.D1) if "dhcp6-opt59" not in ztp_status["source"] or dhcp6_port not in ztp_status["source"]: st.log("ZTP source verification failed with {} against dhcp6-opt59 or port {}".format(ztp_status["source"], dhcp6_port)) st.report_fail("ztp_source_verification_failed", "dhcp6-opt59", ztp_status["source"]) snmp_params = {"rocommunityv6": "sonic", "rocommunity": "sonic"} if not verify_snmp_details_using_docker(vars.D1, **snmp_params): st.report_fail("snmp_params_verification_failed") snmp_params = {"rocommunityv6": "buzznik", "rocommunity": "buzznik"} if not verify_snmp_details_using_docker(vars.D1, **snmp_params): st.report_fail("snmp_params_verification_failed") snmp_params = {"syslocation": "Hyderabad"} if not verify_snmp_details_using_docker(vars.D1, **snmp_params): st.report_fail("snmp_params_verification_failed") snmp_params = {"syscontact": "admin"} if not verify_snmp_details_using_docker(vars.D1, **snmp_params): st.report_fail("snmp_params_verification_failed") st.report_pass("test_case_passed")