Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spytest/Doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
* The exact file used for validating SPyTest is: [IxNetwork 8.42](http://downloads.ixiacom.com/support/downloads_and_updates/public/ixnetwork/IxNetwork8.42EA.exe)
* The IxNetwork Server IP address needs to be given in testbed file as "ix_server"
* The IxNetwork API Server needs to be launched before launching SPyTest
* For Scapy traffic generator refer to [README.testbed.Setup.md](/docs/testbed/README.testbed.Setup.md)
* For Scapy traffic generator refer to [README.testbed.Setup.md](https://github.com/Azure/sonic-mgmt/blob/master/ansible/doc/README.testbed.Setup.md)

4 changes: 2 additions & 2 deletions spytest/Doc/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ The SPyTest supports executing tests in standalone environment and PTF environme

#### PTF Mode

Refer to [README.testbed.md](/docs/ansible/README.testbed.md) for setting up PTF-32 or PTF-64 topology.
Refer to [README.testbed.md](https://github.com/Azure/sonic-mgmt/blob/master/ansible/README.testbed.md) for setting up PTF-32 or PTF-64 topology.

#### Standalone Mode

Expand All @@ -306,7 +306,7 @@ In standalone mode, the DUTs can be connected to each other and TGen.
Environment - PTF Mode
==============================

Refer to [README.testbed.Overview.md](/docs/testbed/README.testbed.Overview.md) for setting up PTF environment details.
Refer to [README.testbed.Overview.md](https://github.com/Azure/sonic-mgmt/blob/master/ansible/doc/README.testbed.Overview.md) for setting up PTF environment details.

Environment - Standalone Mode
==============================
Expand Down
110 changes: 105 additions & 5 deletions spytest/apis/common/asic.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

from spytest import st
import re
from spytest import st, cutils

def bcm_show(dut, cmd, skip_tmpl=True):
def bcm_show(dut, cmd, skip_tmpl=True, max_time=0):
if not st.is_feature_supported("bcmcmd", dut): return ""
return st.show(dut, cmd, skip_tmpl=skip_tmpl)
return st.show(dut, cmd, skip_tmpl=skip_tmpl, max_time=max_time)

def bcm_config(dut, cmd, skip_error_check=True):
if not st.is_feature_supported("bcmcmd", dut): return ""
Expand Down Expand Up @@ -39,15 +40,79 @@ def dump_ports_info(dut):
def dump_trunk(dut):
bcm_config(dut, 'bcmcmd "trunk show"')

def dump_counters(dut):
bcm_show(dut, 'bcmcmd "show c"', skip_tmpl=False)
def dump_l3_defip(dut):
bcm_show(dut, "bcmcmd 'l3 defip show'")

def dump_l3_ip6route(dut):
bcm_show(dut, "bcmcmd 'l3 ip6route show'")

def dump_l3_l3table(dut):
bcm_show(dut, "bcmcmd 'l3 l3table show'")

def dump_l3_ip6host(dut):
bcm_show(dut, "bcmcmd 'l3 ip6host show'")

def dump_counters(dut, interface=None):
if not interface:
command = 'bcmcmd "show c"'
else:
command = 'bcmcmd "show c {}"'.format(interface)
bcm_show(dut, command, skip_tmpl=True)

def clear_counters(dut):
bcm_config(dut, 'bcmcmd "clear c"')

def get_counters(dut, interface=None, skip_tmpl=False):
if not interface:
command = 'bcmcmd "show c"'
else:
command = 'bcmcmd "show c {}"'.format(interface)
return bcm_show(dut, command, skip_tmpl=skip_tmpl)

def get_ipv4_route_count(dut, timeout=120):
command = 'bcmcmd "l3 defip show" | wc -l'
output = bcm_show(dut, command, skip_tmpl=True, max_time=timeout)
x = re.search(r"\d+", output)
if x:
return int(x.group()) - 5
else:
return -1

def get_ipv6_route_count(dut, timeout=120):
command = 'sudo bcmcmd "l3 ip6route show" | wc -l'
output = st.show(dut, command, skip_tmpl=True, max_time=timeout)
x = re.search(r"\d+", output)
if x:
return int(x.group()) - 7
else:
return -1

def bcmcmd_show_ps(dut):
return bcm_show(dut, 'bcmcmd "ps"')

def get_pmap(dut):
command = 'bcmcmd "show pmap"'
return bcm_show(dut, command)

def exec_search(dut,command,param_list,match_dict,**kwargs):
output = bcm_show(dut, 'bcmcmd "{}"'.format(command))
if not output:
st.error("output is empty")
return False
for key in match_dict.keys():
if not cutils.filter_and_select(output,param_list,{key:match_dict[key]}):
st.error("No match for key {} with value {}".format(key, match_dict[key]))
return False
else:
st.log("Match found for key {} with value {}".format(key, match_dict[key]))
return cutils.filter_and_select(output,param_list,{key:match_dict[key]})

def get_l2_out(dut, mac):
return exec_search(dut,'l2 show',["gport"],{"mac":mac})

def get_l3_out(dut, mac):
return exec_search(dut,'l3 egress show',["port"],{"mac":mac})

def dump_threshold_info(dut, test, platform, mode):
"""
BCMCMD debug prints for Threshold feature.
Expand Down Expand Up @@ -148,3 +213,38 @@ def dump_threshold_info(dut, test, platform, mode):
for each_cmd in ['bcmcmd "{}"'.format(e) for e in cmd]:
bcm_config(dut, each_cmd, skip_error_check=True)

def get_intf_pmap(dut, interface_name=None):
"""
Author: Chaitanya Vella (chaitanya.vella-kumar@broadcom.com)
This API is used to get the interface pmap details
:param dut: dut
:param interface_name: List of interface names
:return:
"""
import apis.system.interface as interface_obj
##Passing the cli_type as click in the API call "interface_status_show" because the lanes information is available only in click CLI.
##Please refer the JIRA: SONIC-22102 for more information.
interfaces = cutils.make_list(interface_name) if interface_name else ''
if interfaces:
if any("/" in interface for interface in interfaces):
interfaces = st.get_other_names(dut, interfaces)
key = 'alias'
else:
key = 'interface'
st.debug("The interfaces list is: {}".format(interfaces))
interface_list = interface_obj.interface_status_show(dut, interfaces=interfaces, cli_type='click')
else:
key = 'alias' if interface_obj.show_ifname_type(dut, cli_type='klish') else 'interface'
interface_list = interface_obj.interface_status_show(dut, cli_type='click')
interface_pmap = dict()
pmap_list = get_pmap(dut)
for detail in cutils.iterable(interface_list):
lane = detail["lanes"].split(",")[0] if "," in detail["lanes"] else detail["lanes"]
for pmap in pmap_list:
if pmap["physical"] == lane:
interface_pmap[detail[key]] = pmap["interface"]
return interface_pmap

def remove_vlan_1(dut):
bcm_config(dut, 'bcmcmd "vlan remove 1 PortBitMap=all"')

Loading