def test_l3_perf_tc_14_1(): pre_test_l3_fwding() vars = st.get_testbed_vars() # Config 2 IPV4 interfaces on DUT. (tg1, _, tg_ph_1, _) = get_handles() dut1 = vars.D1 ipfeature.get_interface_ip_address(dut1, family="ipv4") ipfeature.show_ip_route(dut1) interface_status_show(dut1) tr1 = create_l3_host(tg1, tg_ph_1, 10000) st.wait(15) # Verified ARP and counters at the DUT. output = bcm_show(dut1, "time show arp") st.log(output) tg1.tg_traffic_control(action='stop', handle=tr1['stream_id'], max_wait_timer=10) tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) post_test_l3_fwding() st.report_pass("test_case_passed")
def test_l3_host_scaling_tc5_8(): vars = st.get_testbed_vars() # Config 2 IPV4 interfaces on DUT. (tg1, _, tg_ph_1, _) = get_handles_1() dut1 = vars.D1 ipfeature.get_interface_ip_address(dut1, family="ipv4") ipfeature.get_interface_ip_address(dut1, family="ipv6") ipfeature.show_ip_route(dut1) papi.get_status(dut1) ret = fast_reboot_node(dut1) pre_test_l3_fwding() if (ret): tg1.tg_traffic_control(action='reset',port_handle=tg_ph_1) tr1 = create_l3_host(tg1, tg_ph_1, data.max_host_1, 20) st.wait(15) total = get_arp_count(dut1) st.log("Total ARP entries: {}".format(total)) tg1.tg_traffic_control(action='stop', handle=tr1['stream_id']) tg1.tg_traffic_control(action='reset',port_handle=tg_ph_1) post_test_l3_fwding() if (total >= data.max_host_1): st.report_pass("test_case_passed") else: st.report_fail("test_case_failed") else: post_test_l3_fwding() st.report_fail("test_case_failed")
def test_l3_host_scaling_tc5_1(): pre_test_l3_fwding() vars = st.get_testbed_vars() # Config 2 IPV4 interfaces on DUT. (tg1, _, tg_ph_1, _) = get_handles() dut1 = vars.D1 ipfeature.get_interface_ip_address(dut1, family="ipv4") ipfeature.get_interface_ip_address(dut1, family="ipv6") ipfeature.show_ip_route(dut1) ifapi.interface_status_show(dut1) tr1 = create_l3_host(tg1, tg_ph_1, 8000, 5) st.wait(15) # Verified ARP and counters at the DUT. total_in_sw = arpfeature.get_arp_count(dut1) st.log("Total ARP entries: {}".format(total_in_sw)) #We expect all 8k host entries should be programmed in hw within 32secs st.wait(20) output = bcm_show(dut1, 'bcmcmd "l3 l3table show" | wc -l') total_in_hw = parse_route_output(output) tg1.tg_traffic_control(action='stop', handle=tr1['stream_id']) tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) post_test_l3_fwding() if (total_in_sw >= data.max_host_1 and total_in_hw >= data.max_host_1): st.report_pass("test_case_passed") else: st.report_fail("test_case_failed")
def test_l3_perf_tc_12_5(): pre_test_l3_fwding_v6() vars = st.get_testbed_vars() # Config 2 IPV4 interfaces on DUT. (tg1, _, tg_ph_1, _) = get_handles() dut1 = vars.D1 ipfeature.get_interface_ip_address(dut1, family="ipv4") ipfeature.get_interface_ip_address(dut1, family="ipv6") ipfeature.show_ip_route(dut1) interface_status_show(dut1) tr1 = create_l3_host_v6(tg1, tg_ph_1, 16000) # Verified ARP and counters at the DUT. default_nd = arpapi.get_ndp_count(dut1) st.log("Total NDP entries are: {}".format(default_nd)) measure_nd_learn_time(dut1, default_nd, 16000) tg1.tg_traffic_control(action='stop', handle=tr1['stream_id'], max_wait_timer=10) tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) post_test_l3_fwding_v6() st.report_pass("test_case_passed")
def test_l3_host_scaling_tc5_5(): pre_test_l3_fwding() vars = st.get_testbed_vars() # Config 2 IPV4 interfaces on DUT. (tg1, _, tg_ph_1, _) = get_handles() dut1 = vars.D1 ipfeature.get_interface_ip_address(dut1, family="ipv4") ipfeature.get_interface_ip_address(dut1, family="ipv6") ipfeature.show_ip_route(dut1) ifapi.interface_status_show(dut1) tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) tr1 = create_l3_host(tg1, tg_ph_1, 8000, 120) st.wait(15) # Verified ARP and counters at the DUT. total = arpfeature.get_arp_count(dut1) st.log("Total ARP entries: {}".format(total)) if (total): arpfeature.clear_arp_table(vars.D1) st.wait(30) total = arpfeature.get_arp_count(dut1) st.log("Total ARP entries: {}".format(total)) tg1.tg_traffic_control(action='stop', handle=tr1['stream_id']) tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) post_test_l3_fwding() if (total >= data.max_host_1): st.report_pass("test_case_passed") else: st.report_fail("test_case_failed")
def test_l3_perf_tc_12_1(): pre_test_l3_fwding() vars = st.get_testbed_vars() # Config 2 IPV4 interfaces on DUT. (tg1, _, tg_ph_1, _) = get_handles() dut1 = vars.D1 port1 = vars.D1T1P1 ipfeature.get_interface_ip_address(dut1, family="ipv4") ipfeature.get_interface_ip_address(dut1, family="ipv6") ipfeature.show_ip_route(dut1) interface_status_show(dut1) tr1 = create_l3_host(tg1, tg_ph_1, 8000) # Verified ARP and counters at the DUT. cmd = "show arp | grep Total" default_arp = arpapi.get_arp_count(dut1) st.log("Total ARP entries: {}".format(default_arp)) measure_arp_learn_time(dut1, default_arp, 8000, cmd, False) #shut the link and make sure all the entries deleted from the hw interface_operation(dut1, port1, operation="shutdown") st.wait(15) cmd = 'bcmcmd "l3 l3table show" | wc -l' output = bcm_show(dut1, cmd) st.log(output) curr_arp = parse_route_output(output) if (curr_arp != default_arp): st.log("cleaning up host entries from HW failed" + str(curr_arp) + str(default_arp)) interface_operation(dut1, port1, operation="startup") #Now measure the hardware performance cmd = 'bcmcmd "l3 l3table show" | wc -l' output = bcm_show(dut1, cmd) st.log(output) default_arp = parse_route_output(output) measure_arp_learn_time(dut1, default_arp, 8000, cmd, True) tg1.tg_traffic_control(action='stop', handle=tr1['stream_id']) tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) post_test_l3_fwding() st.report_pass("test_case_passed")
def _get_rest_brief_dhcp_relay_data(dut, family='ipv4'): """ To get the dhcp-relay brief data Author Jagadish Chatrasi ([email protected]) :param dut: :param family: :return: """ retval = list() rest_urls = st.get_datastore(dut, 'rest_urls') ip_string = '' if family == 'ipv4' else 'v6' output = get_interface_ip_address(dut, family=family) interfaces = {entry['interface'] for entry in output} interfaces.discard('eth0') for intf in interfaces: url = rest_urls['get_dhcp{}_relay_helper_address'.format(ip_string)].format(id=intf) out = get_rest(dut, rest_url=url) if isinstance(out, dict) and out.get('output') and out['output'].get('openconfig-relay-agent:helper-address') and isinstance(out['output']['openconfig-relay-agent:helper-address'], list): addresses = out['output']['openconfig-relay-agent:helper-address'] for address in addresses: temp = dict() temp['intf'] = intf temp['dhcprelay_addr'] = address retval.append(temp) st.debug(retval) return retval
def _get_rest_dhcp_relay_statistics(dut, interface="", family='ipv4'): """ To get the dhcp-relay statistics data Author Jagadish Chatrasi ([email protected]) :param dut: :param interface: :param family: :return: """ retval = list() rest_urls = st.get_datastore(dut, 'rest_urls') ip_string = '' if family == 'ipv4' else 'v6' if not interface: output = get_interface_ip_address(dut, family=family) interfaces = {entry['interface'] for entry in output} interfaces.discard('eth0') else: interfaces = make_list(interface) for intf in interfaces: url = rest_urls['get_dhcp{}_relay_counters'.format(ip_string)].format(id=intf) out = get_rest(dut, rest_url=url) if isinstance(out, dict) and out.get('output') and out['output'].get('openconfig-relay-agent:counters') and isinstance(out['output']['openconfig-relay-agent:counters'], dict): data = out['output']['openconfig-relay-agent:counters'] temp = dict() if family == 'ipv4': temp['bootrequest_msgs_received_by_the_relay_agent'] = str(data['bootrequest-received']) if data.get('bootrequest-received') else '0' temp['bootrequest_msgs_forwarded_by_the_relay_agent'] = str(data['bootrequest-sent']) if data.get('bootrequest-sent') else '0' temp['bootreply_msgs_forwarded_by_the_relay_agent'] = str(data['bootreply-sent']) if data.get('bootreply-sent') else '0' temp['dhcp_ack_msgs_sent_by_the_relay_agent'] = str(data['dhcp-ack-sent']) if data.get('dhcp-ack-sent') else '0' temp['dhcp_decline_msgs_received_by_the_relay_agent'] = str(data['dhcp-decline-received']) if data.get('dhcp-decline-received') else '0' temp['dhcp_discover_msgs_received_by_the_relay_agent'] = str(data['dhcp-discover-received']) if data.get('dhcp-discover-received') else '0' temp['dhcp_inform_msgs_received_by_the_relay_agent'] = str(data['dhcp-inform-received']) if data.get('dhcp-inform-received') else '0' temp['dhcp_nack_msgs_sent_by_the_relay_agent'] = str(data['dhcp-nack-sent']) if data.get('dhcp-nack-sent') else '0' temp['dhcp_offer_msgs_sent_by_the_relay_agent'] = str(data['dhcp-offer-sent']) if data.get('dhcp-offer-sent') else '0' temp['dhcp_release_msgs_received_by_the_relay_agent'] = str(data['dhcp-release-received']) if data.get('dhcp-release-received') else '0' temp['dhcp_request_msgs_received_by_the_relay_agent'] = str(data['dhcp-request-received']) if data.get('dhcp-request-received') else '0' temp['number_of_dhcp_pkts_drpd_due_to_an_invd_opcode'] = str(data['invalid-opcode']) if data.get('invalid-opcode') else '0' temp['number_of_dhcp_pkts_drpd_due_to_an_invd_option'] = str(data['invalid-options']) if data.get('invalid-options') else '0' temp['total_nbr_of_dhcp_pkts_drpd_by_the_relay_agent'] = str(data['total-dropped']) if data.get('total-dropped') else '0' else: temp['dhcpv6_advt_msgs_sent_by_the_relay_agent'] = str(data['dhcpv6-adverstise-sent']) if data.get('dhcpv6-adverstise-sent') else '0' temp['dhcpv6_confirm_msgs_rcvd_by_the_relay_agent'] = str(data['dhcpv6-confirm-received']) if data.get('dhcpv6-confirm-received') else '0' temp['dhcpv6_decline_msgs_rcvd_by_the_relay_agent'] = str(data['dhcpv6-decline-received']) if data.get('dhcpv6-decline-received') else '0' temp['dhcpv6_info_rqst_msgs_rcvd_by_the_relay_agent'] = str(data['dhcpv6-info-request-received']) if data.get('dhcpv6-info-request-received') else '0' temp['dhcpv6_rebind_msgs_rcvd_by_the_relay_agent'] = str(data['dhcpv6-rebind-received']) if data.get('dhcpv6-rebind-received') else '0' temp['dhcpv6_reconfig_msgs_sent_by_the_relay_agent'] = str(data['dhcpv6-reconfigure-sent']) if data.get('dhcpv6-reconfigure-sent') else '0' temp['dhcpv6_relay_fwd_msgs_sent_by_the_relay_agent'] = str(data['dhcpv6-relay-forw-sent']) if data.get('dhcpv6-relay-forw-sent') else '0' temp['dhcpv6_relay_reply_msgs_rcvd_by_the_relay_agent'] = str(data['dhcpv6-relay-reply-received']) if data.get('dhcpv6-relay-reply-received') else '0' temp['dhcpv6_release_msgs_rcvd_by_the_relay_agent'] = str(data['dhcpv6-release-received']) if data.get('dhcpv6-release-received') else '0' temp['dhcpv6_reply_msgs_sent_by_the_relay_agent'] = str(data['dhcpv6-reply-sent']) if data.get('dhcpv6-reply-sent') else '0' temp['dhcpv6_rqst_msgs_rcvd_by_the_relay_agent'] = str(data['dhcpv6-request-received']) if data.get('dhcpv6-request-received') else '0' temp['dhcpv6_solic_msgs_rcvd_by_the_relay_agent'] = str(data['dhcpv6-solicit-received']) if data.get('dhcpv6-solicit-received') else '0' temp['number_of_dhcpv6_pkts_drpd_due_to_an_inv_opcode'] = str(data['invalid-opcode']) if data.get('invalid-opcode') else '0' temp['number_of_dhcpv6_pkts_drpd_due_to_an_inv_option'] = str(data['invalid-options']) if data.get('invalid-options') else '0' temp['total_nbr_of_dhcpv6_pkts_drpd_by_the_relay_agent'] = str(data['total-dropped']) if data.get('total-dropped') else '0' retval.append(temp) st.debug(retval) return retval
def dhcp_client_stop(dut, interface, pid=None, family="ipv4", skip_error_check=False, show_interface=False): """ API to stop DHCP client either by using process id or dhclient Author Chaitanya Vella ([email protected]) :param dut: :type dut: :param portlist: :type portlist: """ if interface != None: if '/' in interface: interface = st.get_other_names(dut,[interface])[0] v6_opt = "" if family == "ipv4" else "-6" command = "kill -9 {}".format(pid) if pid else "dhclient {} -r {}".format(v6_opt, interface) st.config(dut, command, skip_error_check=skip_error_check) if show_interface: get_interface_ip_address(dut, interface_name=interface, family=family) return True
def poll_verify_interface_ip_address(dut, interface_name, ip_address, loopCnt): iter = 1 while True: out = ip_obj.get_interface_ip_address(dut, interface_name=interface_name, family="ipv6") st.debug("The ipv6 interface output is: {}".format(out)) if out and out[0]['ipaddr'] in ip_address: return True if iter > loopCnt: return False iter = iter + 1
def dhcp_relay_debug(dut, family="", interface=None): family = "ipv4" if not family else family st.banner("Start of Collecting the needed info for debugging the failure") try: get_portchannel_list(dut) interface.interface_status_show(dut) dhcp_relay_obj.dhcp_relay_detailed_show(dut) dhcp_relay_obj.get_dhcp_relay_statistics(dut, interface=interface) ip_obj.get_interface_ip_address(dut) show_arp(dut) if family == "ipv6": dhcp_relay_obj.dhcp_relay_detailed_show(dut, family="ipv6") dhcp_relay_obj.get_dhcp_relay_statistics(dut, family="ipv6", interface=interface) ip_obj.get_interface_ip_address(dut, family="ipv6") show_ndp(dut) except Exception as e: st.log(e) st.error("Failed to execute the debug commands") st.banner("End of Collecting the needed info for debugging the failure")
def test_l3_host_scaling_tc5_2(): pre_test_l3_fwding() vars = st.get_testbed_vars() (tg1, _, tg_ph_1, _) = get_handles() dut1 = vars.D1 ipfeature.get_interface_ip_address(dut1) cnt = 0 pass_flag = True host_count = 32000 curr_count = 8000 wait_time = 15 duration = 8 #Send burst of 8k upto 32k max create_l3_host(tg1, tg_ph_1, host_count, duration) while (cnt <= 3 and pass_flag): st.wait(wait_time) # Verified ARP and counters at the DUT. total = arpfeature.get_arp_count(dut1) st.log("Total ARP entries: {}".format(total)) bcm_show(dut1, 'bcmcmd "l3 l3table show" | wc -l') if (total >= curr_count): curr_count += 8000 else: pass_flag = False cnt += 1 #Make sure all the entries programmed in the hw st.wait(90) bcm_show(dut1, 'bcmcmd "l3 l3table show" | wc -l') post_test_l3_fwding() if (pass_flag): st.report_pass("test_case_passed") else: st.report_fail("test_case_failed")
def _get_rest_detailed_dhcp_relay_data(dut, interface="", family='ipv4'): """ To get the dhcp-relay detailed data Author Jagadish Chatrasi ([email protected]) :param dut: :param interface: :param family: :return: """ retval = list() rest_urls = st.get_datastore(dut, 'rest_urls') ip_string = '' if family == 'ipv4' else 'v6' if not interface: output = get_interface_ip_address(dut, family=family) interfaces = {entry['interface'] for entry in output} interfaces.discard('eth0') else: interfaces = make_list(interface) for intf in interfaces: url = rest_urls['dhcp{}_relay_config'.format(ip_string)].format(id=intf) out = get_rest(dut, rest_url=url) if isinstance(out, dict) and out.get('output') and out['output'].get('openconfig-relay-agent:config') and isinstance(out['output']['openconfig-relay-agent:config'], dict): data = out['output']['openconfig-relay-agent:config'] temp = dict() temp['intf'] = intf temp['server_addr'] = ", ".join(data['helper-address']) if data.get('helper-address') and isinstance(data['helper-address'], list) else '' temp['vrf_name'] = data['openconfig-relay-agent-ext:vrf'] if data.get('openconfig-relay-agent-ext:vrf') else 'Not Configured' temp['src_interface'] = data['openconfig-relay-agent-ext:src-intf'] if data.get('openconfig-relay-agent-ext:src-intf') else 'Not Configured' temp['vrf_select'] = data['openconfig-relay-agent-ext:vrf-select'].lower() if data.get('openconfig-relay-agent-ext:vrf-select') else 'disable' temp['max_hop_count'] = str(data['openconfig-relay-agent-ext:max-hop-count']) if data.get('openconfig-relay-agent-ext:max-hop-count') else '10' if family == 'ipv4': temp['policy_action'] = data['openconfig-relay-agent-ext:policy-action'].lower() if data.get('openconfig-relay-agent-ext:policy-action') else 'discard' temp['link_select'] = data['openconfig-relay-agent-ext:link-select'].lower() if data.get('openconfig-relay-agent-ext:link-select') else 'disable' retval.append(temp) st.debug(retval) return retval
def measure_v4_route_scale_time(route_count, show_flag): vars = st.get_testbed_vars() dut = vars.D1 default_route = 0 #TG pumps 512k per sec so to make measure route install #time more accurate we start from 600k + route_count #base_route_count = 60000 + route_count base_route_count = route_count ipfeature.clear_ip_configuration(st.get_dut_names()) ipfeature.clear_ip_configuration(st.get_dut_names(), 'ipv6') member3 = vars.D1T1P1 member4 = vars.D1T1P2 ipfeature.config_ip_addr_interface(dut, member3, data.my_ip_addr, data.ip_prefixlen, family="ipv4") ipfeature.config_ip_addr_interface(dut, member4, data.intf_ip_addr, data.ip_prefixlen, family="ipv4") ipfeature.get_interface_ip_address(dut, family="ipv4") ipfeature.show_ip_route(dut) interface_status_show(dut) bgpfeature.create_bgp_router(dut, data.as_num, '') bgpfeature.create_bgp_neighbor(dut, data.as_num, data.neigh_ip_addr, data.remote_as_num) (tg1, tg2, tg_ph_1, tg_ph_2) = get_handles() tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) tg2.tg_traffic_control(action='reset', port_handle=tg_ph_2) h1 = tg1.tg_interface_config(port_handle=tg_ph_1, mode='config', intf_ip_addr='10.10.10.2', gateway='10.10.10.1', src_mac_addr='00:0a:01:00:00:01', arp_send_req='1') st.log("INTFCONF: " + str(h1)) h2 = tg2.tg_interface_config(port_handle=tg_ph_2, mode='config', intf_ip_addr='20.20.20.2', gateway='20.20.20.1', arp_send_req='1') st.log("INTFCONF: " + str(h2)) conf_var = { 'mode': 'enable', 'active_connect_enable': '1', 'local_as': '200', 'remote_as': '100', 'remote_ip_addr': '10.10.10.1' } route_var = { 'mode': 'add', 'num_routes': base_route_count, 'prefix': '121.1.1.0', 'as_path': 'as_seq:1' } ctrl_start = {'mode': 'start'} ctrl_stop = {'mode': 'stop'} # Configuring the BGP router. bgp_rtr1 = tgapi.tg_bgp_config(tg=tg1, handle=h1['handle'], conf_var=conf_var, route_var=route_var, ctrl_var=ctrl_start) st.log("BGP_HANDLE: " + str(bgp_rtr1)) # Verified at neighbor. st.log("BGP neighborship established.") st.wait(10) tr1 = tg2.tg_traffic_config( port_handle=tg_ph_2, emulation_src_handle=h2['handle'], emulation_dst_handle=bgp_rtr1['route'][0]['handle'], circuit_endpoint_type='ipv4', mode='create', transmit_mode='continuous', length_mode='fixed', rate_pps=512000, enable_stream_only_gen='0') retval = bgpfeature.verify_bgp_summary(dut, neighbor=data.neigh_ip_addr, state='Established') if retval is True: output = bcm_show(dut, 'bcmcmd "l3 defip show" | wc -l') st.log(output) default_route = parse_route_output(output) route_count += default_route cmd = 'bcmcmd "l3 defip show" | wc -l' measure_route_learn_time(dut, default_route, route_count, cmd) if (show_flag): cmd = "time show ip route" bcm_show(dut, cmd) data.result_14_3 = True res = tg2.tg_traffic_control(action='stop', handle=tr1['stream_id']) st.log("TR_CTRL: " + str(res)) tgapi.tg_bgp_config(tg=tg1, handle=bgp_rtr1['conf']['handle'], ctrl_var=ctrl_stop) ipfeature.delete_ip_interface(dut, member4, data.intf_ip_addr, data.ip_prefixlen, family="ipv4") ipfeature.delete_ip_interface(dut, member3, data.my_ip_addr, data.ip_prefixlen, family="ipv4") bgpfeature.delete_bgp_neighbor(dut, data.as_num, data.neigh_ip_addr, data.remote_as_num) delete_bgp_router(dut, '', data.as_num) tg2.tg_traffic_control(action='reset', port_handle=tg_ph_2) 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') st.wait(20)
def test_l3_host_scaling_tc5_4(): pre_test_l3_fwding() vars = st.get_testbed_vars() 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) ifapi.interface_status_show(dut1) # L3 traffic streams (tg1, tg2, tg_ph_1, tg_ph_2) = get_handles() tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) tr1 = create_l3_host(tg1, tg_ph_1, data.max_host_1, 20) st.wait(15) # Verified ARP and counters at the DUT. total = arpfeature.get_arp_count(dut1) st.log("Total ARP entries: {}".format(total)) tg1.tg_traffic_control(action='stop', handle=tr1['stream_id']) tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) tg2.tg_traffic_control(action='reset', port_handle=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'] #tg1.tg_test_control(action='sync') res = tg2.tg_interface_config(port_handle=tg_ph_2, mode='config', intf_ip_addr=data.t1d2_ip_addr, gateway=data.d1t2_ip_addr, src_mac_addr='00:0a:01:00:12:01', arp_send_req='1') st.log("INTFCONF: " + str(res)) handle2 = res['handle'] #tg2.tg_test_control(action='sync') tr1 = tg1.tg_traffic_config(port_handle=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=handle1, emulation_dst_handle=handle2) tr2 = tg2.tg_traffic_config(port_handle=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=handle2, emulation_dst_handle=handle1) tg1.tg_packet_control(port_handle=tg_ph_1, action='start') tg2.tg_packet_control(port_handle=tg_ph_2, action='start') tg1.tg_traffic_control(action='clear_stats', handle=tr1['stream_id']) tg2.tg_traffic_control(action='clear_stats', handle=tr2['stream_id']) papi.clear_interface_counters(dut1) tg1.tg_traffic_control(action='run', handle=tr1['stream_id'], duration=2) tg2.tg_traffic_control(action='run', handle=tr2['stream_id'], duration=2) st.wait(data.traffic_run_time) tg1.tg_traffic_control(action='stop', handle=tr1['stream_id']) tg2.tg_traffic_control(action='stop', handle=tr2['stream_id']) st.wait(5) tg1.tg_packet_control(port_handle=tg_ph_1, action='stop') tg2.tg_packet_control(port_handle=tg_ph_2, action='stop') stats_tg1 = tg1.tg_traffic_stats(port_handle=tg_ph_1, mode='aggregate') total_tg1_tx = stats_tg1[tg_ph_1]['aggregate']['tx']['total_pkts'] total_tg1_rx = stats_tg1[tg_ph_1]['aggregate']['rx']['total_pkts'] stats_tg2 = tg2.tg_traffic_stats(port_handle=tg_ph_2, mode='aggregate') total_tg2_tx = stats_tg2[tg_ph_2]['aggregate']['tx']['total_pkts'] total_tg2_rx = stats_tg2[tg_ph_2]['aggregate']['rx']['total_pkts'] st.log( "Tgen Sent Packets on D1T1P1: {} and Received Packets on D2T1P1: {}". format(total_tg1_tx, total_tg2_rx)) st.log( "Tgen Sent Packets on D2T1P1: {} and Received Packets on D1T1P1: {}". format(total_tg2_tx, total_tg1_rx)) flap_interface(vars.D1T1P1) flap_interface(vars.D1T1P2) #Getting interfaces counter values on DUT DUT_rx_value = ifapi.get_interface_counters(dut1, vars.D1T1P1, "rx_ok") DUT_tx_value = ifapi.get_interface_counters(dut1, vars.D1T1P2, "tx_ok") for i in DUT_rx_value: p1_rcvd = i['rx_ok'] p1_rcvd = p1_rcvd.replace(",", "") for i in DUT_tx_value: p2_txmt = i['tx_ok'] p2_txmt = p2_txmt.replace(",", "") st.log( "rx_ok counter value on DUT Ingress port: {} and tx_ok xounter value on DUT Egress port : {}" .format(p1_rcvd, p2_txmt)) post_test_l3_fwding() if (total >= data.max_host_1): st.report_pass("test_case_passed") else: st.report_fail("test_case_failed")
def test_l3_host_scaling_tc5_3(): pre_test_l3_fwding() vars = st.get_testbed_vars() # Config 2 IPV4 interfaces on DUT. (tg1, tg2, tg_ph_1, tg_ph_2) = get_handles() dut1 = vars.D1 ipfeature.get_interface_ip_address(dut1, family="ipv4") ipfeature.get_interface_ip_address(dut1, family="ipv6") ipfeature.show_ip_route(dut1) ifapi.interface_status_show(dut1) tr1 = create_l3_host(tg1, tg_ph_1, data.max_host_1, 20) st.wait(15) # Verified ARP and counters at the DUT. total = arpfeature.get_arp_count(dut1) st.log("Total ARP entries: {}".format(total)) tg1.tg_traffic_control(action='stop', handle=tr1['stream_id']) tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) tg2.tg_traffic_control(action='reset', port_handle=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'] #tg1.tg_test_control(action='sync') res = tg2.tg_interface_config(port_handle=tg_ph_2, mode='config', intf_ip_addr=data.t1d2_ip_addr, gateway=data.d1t2_ip_addr, src_mac_addr='00:0a:01:00:12:01', arp_send_req='1') st.log("INTFCONF: " + str(res)) handle2 = res['handle'] #tg2.tg_test_control(action='sync') tr1 = tg1.tg_traffic_config(port_handle=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=handle1, emulation_dst_handle=handle2) tr2 = tg2.tg_traffic_config(port_handle=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=handle2, emulation_dst_handle=handle1) tg1.tg_packet_control(port_handle=tg_ph_1, action='start') tg2.tg_packet_control(port_handle=tg_ph_2, action='start') tg1.tg_traffic_control(action='clear_stats', handle=tr1['stream_id']) tg2.tg_traffic_control(action='clear_stats', handle=tr2['stream_id']) papi.clear_interface_counters(dut1) tg1.tg_traffic_control(action='run', handle=tr1['stream_id'], duration=2) tg2.tg_traffic_control(action='run', handle=tr2['stream_id'], duration=2) st.wait(data.traffic_run_time) tg1.tg_traffic_control(action='stop', handle=tr1['stream_id']) tg2.tg_traffic_control(action='stop', handle=tr2['stream_id']) tg1.tg_packet_control(port_handle=tg_ph_1, action='stop') tg2.tg_packet_control(port_handle=tg_ph_2, action='stop') papi.clear_interface_counters(dut1) tg2.tg_traffic_control(action='run', handle=tr1['stream_id']) st.wait(20) retval = check_intf_traffic_counters(dut1) post_test_l3_fwding() if (total >= data.max_host_1 and retval): st.report_pass("test_case_passed") else: st.report_fail("test_case_failed")
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 show(dut, cli_type=""): """ API to show sflow configuration Author: Chaitanya Vella ([email protected]) :param dut: :return: {u'agent_ip': '10.0.0.10', 'collectors': [{'port': '6343', 'collector_ip': '10.100.12.13'}, {'port': '6344', 'collector_ip': '10.144.1.2'}], u'collectors_cnt': '2', u'state': 'enabled', u'agent_id': 'loopback0', u'polling_interval': '20'} """ cli_type = st.get_ui_type(dut, cli_type=cli_type) cli_type = "klish" if cli_type in ["rest-put", "rest-patch"] else cli_type result = dict() if cli_type == "klish" or cli_type == "click": command = "show sflow" output = st.show(dut, command, type=cli_type) if output: result["collectors"] = list() for data in output: for key, value in data.items(): if value != "": if key not in [ "collector_ip", "collector_port", "collector_name" ]: result[key] = value else: result["collectors"].append({ "collector_name": data["collector_name"], "collector_ip": data["collector_ip"], "port": data["collector_port"] }) if result: result[ "collectors"] = utils_obj.remove_duplicate_dicts_from_list( result["collectors"]) else: return False elif cli_type == "rest": output = st.rest_read(dut, REST_URI) if output and output.get("status") == 200 and output.get("output"): if YANG_MODULE in output["output"]: data = output["output"][YANG_MODULE] if "SFLOW" in data: for key, value in data["SFLOW"].items(): if isinstance(value, list): for attributes in value: result.update( {"state": attributes.get("admin_state")}) result.update( {"agent_id": attributes.get("agent_id")}) result.update({ "polling_interval": attributes.get("polling_interval") }) result.update( {"sflow_key": attributes.get("sflow_key")}) if attributes.get("agent_id"): ip_address = get_interface_ip_address( dut, attributes.get("agent_id")) if ip_address: ip, _ = ip_address[0]['ipaddr'].split( '/') result.update({"agent_ip": ip}) if "SFLOW_COLLECTOR" in data: result.update({ "collectors_cnt": len(data["SFLOW_COLLECTOR"]["SFLOW_COLLECTOR_LIST"]) }) result.update({"collectors": list()}) for value in data["SFLOW_COLLECTOR"][ "SFLOW_COLLECTOR_LIST"]: collector_data = dict() collector_data.update({ "port": value.get("collector_port", DEFAULT_COLLECTOR_PORT) }) collector_data.update( {"collector_ip": value.get("collector_ip")}) collector_data.update( {"collector_name": value.get("collector_name")}) st.log("COLLECTORS {}".format(collector_data)) result["collectors"].append(collector_data) else: st.log("{} not observed in ouput".format(YANG_MODULE)) else: st.log("REST show GET CALL --- {}".format(output)) else: st.log("UNSUPPORTED CLI TYPE -- {}".format(cli_type)) return result
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 create_v6_route(route_count): vars = st.get_testbed_vars() dut = vars.D1 ipfeature.show_ip_route(dut, family='ipv6') ipfeature.get_interface_ip_address(dut, family='ipv6') bgpfeature.create_bgp_router(dut, data.as_num, '') bgpfeature.create_bgp_neighbor(dut, data.as_num, data.ip6_addr[0], data.remote_as_num, family="ipv6") create_bgp_neighbor_route_map_config(dut, data.as_num, data.ip6_addr[0], data.routemap) 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.D1T1P1) 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.") bgp_conf = tg.tg_emulation_bgp_config(handle=h1['handle'], mode='enable', ip_version='6', active_connect_enable='1', local_as=data.as_num, remote_as=data.remote_as_num, remote_ipv6_addr=data.ip6_addr[1]) tg.tg_emulation_bgp_route_config(handle=bgp_conf['handle'], mode='add', ip_version='6', num_routes=route_count, prefix='3300:1::', as_path='as_seq:1') tg.tg_emulation_bgp_control(handle=bgp_conf['handle'], mode='start') # Configuring the BGP router. st.log("BGP neighborship established.") tr1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='create', transmit_mode='single_burst', pkts_per_burst=2000, \ length_mode='fixed', rate_pps=2000, 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: return False else: return True
def create_v4_route(route_count): vars = st.get_testbed_vars() dut = vars.D1 ipfeature.show_ip_route(dut) ipfeature.get_interface_ip_address(dut) intf_obj.interface_status_show(dut) bgpfeature.create_bgp_router(dut, data.as_num, '') bgpfeature.create_bgp_neighbor(dut, data.as_num, data.ip4_addr[0], data.remote_as_num) tg_handler = tgapi.get_handles_byname("T1D1P1", "T1D2P1") 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.D1T1P1) h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"], mode='config', intf_ip_addr=data.ip4_addr[0], \ gateway=data.ip4_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', intf_ip_addr=data.ip4_addr[9], \ gateway=data.ip4_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.ip4_addr[1], \ ping_count='1', exp_count='1') if res: st.log("Ping succeeded.") else: st.warn("Ping failed.") conf_var = { 'mode': 'enable', 'active_connect_enable': '1', 'local_as': '200', 'remote_as': '100', 'remote_ip_addr': data.ip4_addr[1] } route_var = { 'mode': 'add', 'num_routes': route_count, 'prefix': '121.1.1.0', 'as_path': 'as_seq:1' } ctrl_start = {'mode': 'start'} # Configuring the BGP router. bgp_rtr1 = tgapi.tg_bgp_config(tg=tg, handle=h1['handle'], conf_var=conf_var, route_var=route_var, ctrl_var=ctrl_start) st.log("BGP_HANDLE: " + str(bgp_rtr1)) st.log( "waiting for 10 sec to get the BGP neighbor started before going for another TG operation" ) st.wait(10) # Verified at neighbor. tr1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='create', transmit_mode='single_burst', pkts_per_burst=2000, \ length_mode='fixed', rate_pps=2000, l3_protocol='ipv4', mac_src=data.tg_mac1, \ mac_dst=dut_rt_int_mac1, ip_src_addr=data.ip4_addr[0], ip_dst_addr=data.ip4_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.T1D1P1], 'tx_obj': [tg_handler["tg"]], 'exp_ratio': [1], 'rx_ports': [vars.T1D2P1], '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: return False return True
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 measure_v6_route_learning_time(route_count): vars = st.get_testbed_vars() dut = vars.D1 ipfeature.clear_ip_configuration(st.get_dut_names()) ipfeature.clear_ip_configuration(st.get_dut_names(), 'ipv6') member3 = vars.D1T1P1 member4 = vars.D1T1P2 ipfeature.config_ip_addr_interface(dut, member3, data.my_ipv6_addr, data.ipv6_prefixlen, family="ipv6") ipfeature.config_ip_addr_interface(dut, member4, data.intf_ipv6_addr, data.ipv6_prefixlen, family="ipv6") ipfeature.get_interface_ip_address(dut, family="ipv6") ipfeature.show_ip_route(dut, family="ipv6") bgpfeature.create_bgp_router(dut, data.as_num, '') bgpfeature.create_bgp_neighbor(dut, data.as_num, data.neigh_ipv6_addr, data.remote_as_num, family="ipv6") create_bgp_neighbor_route_map_config(dut, data.as_num, data.neigh_ipv6_addr, data.routemap) (tg1, tg2, tg_ph_1, tg_ph_2) = get_handles() tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1) tg2.tg_traffic_control(action='reset', port_handle=tg_ph_2) h1 = tg1.tg_interface_config(port_handle=tg_ph_1, mode='config', ipv6_intf_addr='2000::2', ipv6_prefix_length='64', ipv6_gateway='2000::1', src_mac_addr='00:0a:01:00:00:01', arp_send_req='1') st.log("INTFCONF: " + str(h1)) h2 = tg2.tg_interface_config(port_handle=tg_ph_2, mode='config', ipv6_intf_addr='2200::2', ipv6_prefix_length='64', ipv6_gateway='2200::1', arp_send_req='1') st.log("INTFCONF: " + str(h2)) bgp_conf = tg1.tg_emulation_bgp_config(handle=h1['handle'], mode='enable', ip_version='6', active_connect_enable='1', local_as='200', remote_as='100', remote_ipv6_addr='2000::1') bgp_route = tg1.tg_emulation_bgp_route_config(handle=bgp_conf['handle'], mode='add', ip_version='6', num_routes=route_count, prefix='3300:1::', as_path='as_seq:1') tg1.tg_emulation_bgp_control(handle=bgp_conf['handle'], mode='start') # Configuring the BGP router. st.log("BGP neighborship established.") tr2 = tg2.tg_traffic_config(port_handle=tg_ph_2, emulation_src_handle=h2['handle'], emulation_dst_handle=bgp_route['handle'], circuit_endpoint_type='ipv6', mode='create', transmit_mode='continuous', length_mode='fixed', rate_pps=512000, enable_stream_only_gen='0') tg2.tg_traffic_control(action='run', handle=tr2['stream_id']) output = bcm_show(dut, 'bcmcmd "l3 ip6route show" | wc -l') default_route = parse_route_output(output) #Assume default route as current number of routes in the system #and measure route_count perforamnce on top of it route_count += default_route cmd = 'bcmcmd "l3 ip6route show" | wc -l' measure_route_learn_time(dut, default_route, route_count, cmd) res = tg2.tg_traffic_control(action='stop', handle=tr2['stream_id']) st.log("TR_CTRL: " + str(res)) # Withdraw the routes. st.wait(10) bgp_ctrl = tg1.tg_emulation_bgp_control(handle=bgp_conf['handle'], mode='stop') st.log("BGPCTRL: " + str(bgp_ctrl)) tg2.tg_traffic_control(action='reset', port_handle=tg_ph_2) st.wait(50) 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')