Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copp infra enhancement to support multi-asic #2627

Merged
merged 9 commits into from
Dec 7, 2020
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
35 changes: 11 additions & 24 deletions ansible/roles/test/files/ptftests/copp_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,9 @@ def __init__(self):

self.timeout_thr = None

self.minig_bgp = test_params.get('minig_bgp', None)
idx = 0
self.myip = {}
self.peerip = {}
self.myip = test_params.get('myip', None)
self.peerip = test_params.get('peerip', None)

for peer in self.minig_bgp:
if str(peer['peer_addr']).find('10.0.0') == 0:#filter IPv6 info.
self.myip[idx] = peer['addr']
self.peerip[idx] = peer['peer_addr']
idx = idx+1
#if port number is out of the total of IPv4, take the last IPv4
if int(target_port_str) > idx-1:
self.myip[self.target_port] = self.myip[idx-1]
self.peerip[self.target_port] = self.peerip[idx-1]

return

def log(self, message, debug=False):
Expand Down Expand Up @@ -244,8 +232,8 @@ def runTest(self):

def contruct_packet(self, port_number):
src_mac = self.my_mac[port_number]
src_ip = self.myip[port_number]
dst_ip = self.peerip[port_number]
src_ip = self.myip
dst_ip = self.peerip

packet = simple_arp_packet(
eth_dst='ff:ff:ff:ff:ff:ff',
Expand Down Expand Up @@ -377,7 +365,7 @@ def runTest(self):

def contruct_packet(self, port_number):
dst_mac = self.peer_mac[port_number]
dst_ip = self.peerip[port_number]
dst_ip = self.peerip
packet = simple_tcp_packet(
eth_dst=dst_mac,
ip_dst=dst_ip,
Expand Down Expand Up @@ -417,7 +405,7 @@ def runTest(self):
def contruct_packet(self, port_number):
src_mac = self.my_mac[port_number]
dst_mac = self.peer_mac[port_number]
dst_ip = self.peerip[port_number]
dst_ip = self.peerip
packet = simple_udp_packet(
eth_dst=dst_mac,
ip_dst=dst_ip,
Expand All @@ -437,8 +425,8 @@ def runTest(self):

def contruct_packet(self, port_number):
dst_mac = self.peer_mac[port_number]
src_ip = self.myip[port_number]
dst_ip = self.peerip[port_number]
src_ip = self.myip
dst_ip = self.peerip

packet = simple_tcp_packet(
eth_dst=dst_mac,
Expand Down Expand Up @@ -473,7 +461,7 @@ def one_port_test(self, port_number):
def contruct_packet(self, port_number):
src_mac = self.my_mac[port_number]
dst_mac = self.peer_mac[port_number]
dst_ip = self.peerip[port_number]
dst_ip = self.peerip

packet = simple_tcp_packet(
eth_src=src_mac,
Expand All @@ -494,9 +482,8 @@ def runTest(self):

def contruct_packet(self, port_number):
dst_mac = self.peer_mac[port_number]
src_ip = self.myip[port_number]
dst_port_number = (port_number + 1) % self.MAX_PORTS
dst_ip = self.peerip[dst_port_number]
src_ip = self.myip
dst_ip = self.peerip

packet = simple_tcp_packet(
eth_dst=dst_mac,
Expand Down
8 changes: 0 additions & 8 deletions tests/copp/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ def pytest_addoption(parser):
Adds options to pytest that are used by the COPP tests.
"""

parser.addoption(
"--nn_target_port",
action="store",
type=int,
default=3,
help="Which port to send traffic to",
)

parser.addoption(
"--pkt_tx_count",
action="store",
Expand Down
6 changes: 3 additions & 3 deletions tests/copp/copp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def restore_ptf(ptf):

ptf.supervisorctl(name="ptf_nn_agent", state="restarted")

def configure_syncd(dut, nn_target_port, creds):
def configure_syncd(dut, nn_target_port, nn_target_interface, creds):
"""
Configures syncd to run the NN agent on the specified port.

Expand All @@ -125,11 +125,11 @@ def configure_syncd(dut, nn_target_port, creds):
Args:
dut (SonicHost): The target device.
nn_target_port (int): The port to run NN agent on.
nn_target_interface (str): The Interface remote NN agents listens.
creds (dict): Credential information according to the dut inventory
"""

facts = {"nn_target_port": nn_target_port,
"nn_target_interface": _map_port_number_to_interface(dut, nn_target_port)}
facts = {"nn_target_port": nn_target_port, "nn_target_interface": nn_target_interface}
dut.host.options["variable_manager"].extra_vars.update(facts)

_install_nano(dut, creds)
Expand Down
42 changes: 29 additions & 13 deletions tests/copp/test_copp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
of these test cases.

Parameters:
--nn_target_port <port> (int): Which port you want the test to send traffic
to. Default is 3.

Note that this is not the same as the interface name. For example, Ethernet12
may not be the 12th port in your system depending on the HWSKU under test.

--pkt_tx_count <n> (int): How many packets to send during each individual test case.
Default is 100000.

Expand All @@ -27,6 +21,7 @@

"""

import ipaddr
import logging
import pytest
import json
Expand All @@ -50,9 +45,11 @@
"pkt_tx_count",
"swap_syncd",
"topo",
"bgp_graph"])
"myip",
"peerip",
"nn_target_interface"])
_SUPPORTED_PTF_TOPOS = ["ptf32", "ptf64"]
_SUPPORTED_T1_TOPOS = ["t1", "t1-lag"]
_SUPPORTED_T1_TOPOS = ["t1", "t1-lag", "t1-64-lag"]
_TOR_ONLY_PROTOCOL = ["DHCP"]
_TEST_RATE_LIMIT = 600

Expand Down Expand Up @@ -168,7 +165,8 @@ def _copp_runner(dut, ptf, protocol, test_params, dut_type):
params = {"verbose": False,
"pkt_tx_count": test_params.pkt_tx_count,
"target_port": test_params.nn_target_port,
"minig_bgp": test_params.bgp_graph}
"myip": test_params.myip,
"peerip": test_params.peerip}

dut_ip = dut.setup()["ansible_facts"]["ansible_eth0"]["ipv4"]["address"]
device_sockets = ["0-{}@tcp://127.0.0.1:10900".format(test_params.nn_target_port),
Expand All @@ -194,17 +192,35 @@ def _gather_test_params(tbinfo, duthost, request):
Fetches the test parameters from pytest.
"""

nn_target_port = request.config.getoption("--nn_target_port")
pkt_tx_count = request.config.getoption("--pkt_tx_count")
swap_syncd = request.config.getoption("--copp_swap_syncd")
topo = tbinfo["topo"]["name"]
bgp_graph = duthost.get_extended_minigraph_facts(tbinfo)["minigraph_bgp"]
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)
port_index_map = {
k: v
for k, v in mg_facts["minigraph_port_indices"].items()
if k in mg_facts["minigraph_ports"]
}
nn_target_port = port_index_map[random.choice(port_index_map.keys())]
nn_target_interface = copp_utils._map_port_number_to_interface(duthost, nn_target_port)
myip = None
peerip = None

for bgp_peer in mg_facts["minigraph_bgp"]:
if bgp_peer["name"] == mg_facts["minigraph_neighbors"][nn_target_interface]["name"] and ipaddr.IPAddress(bgp_peer["addr"]).version == 4:
myip = bgp_peer["addr"]
peerip = bgp_peer["peer_addr"]
break

logging.info("nn_target_port {} nn_target_interface {}".format(nn_target_port, nn_target_interface))

return _COPPTestParameters(nn_target_port=nn_target_port,
pkt_tx_count=pkt_tx_count,
swap_syncd=swap_syncd,
topo=topo,
bgp_graph=bgp_graph)
myip=myip,
peerip = peerip,
nn_target_interface=nn_target_interface)

def _setup_testbed(dut, creds, ptf, test_params):
"""
Expand All @@ -227,7 +243,7 @@ def _setup_testbed(dut, creds, ptf, test_params):
config_reload(dut)

logging.info("Configure syncd RPC for testing")
copp_utils.configure_syncd(dut, test_params.nn_target_port, creds)
copp_utils.configure_syncd(dut, test_params.nn_target_port, test_params.nn_target_interface, creds)

def _teardown_testbed(dut, creds, ptf, test_params):
"""
Expand Down