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

Added Support for DHCP Copp based on Testbed topology type. #2066

Merged
merged 1 commit into from
Aug 8, 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
36 changes: 36 additions & 0 deletions ansible/roles/test/files/ptftests/copp_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
# ARPTest
# DHCPTest
# DHCPTopoT1Test
# LLDPTest
# BGPTest
# LACPTest
Expand Down Expand Up @@ -257,6 +258,41 @@ def contruct_packet(self, port_number):

return packet

# SONIC configuration has no packets to CPU for DHCP-T1 Topo
class DHCPTopoT1Test(PolicyTest):
def __init__(self):
PolicyTest.__init__(self)
# T1 DHCP no packet to packet to CPU so police rate is 0
self.PPS_LIMIT_MIN = 0
self.PPS_LIMIT_MAX = 0

def runTest(self):
self.log("DHCPTopoT1Test")
self.run_suite()

def contruct_packet(self, port_number):
src_mac = self.my_mac[port_number]
packet = simple_udp_packet(pktlen=100,
eth_dst='ff:ff:ff:ff:ff:ff',
eth_src=src_mac,
dl_vlan_enable=False,
vlan_vid=0,
vlan_pcp=0,
dl_vlan_cfi=0,
ip_src='0.0.0.0',
ip_dst='255.255.255.255',
ip_tos=0,
ip_ttl=64,
udp_sport=68,
udp_dport=67,
ip_ihl=None,
ip_options=False,
with_udp_chksum=True
)

return packet


# SONIC configuration has no policer limiting for DHCP
class DHCPTest(NoPolicyTest):
def __init__(self):
Expand Down
21 changes: 7 additions & 14 deletions tests/copp/test_copp.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"swap_syncd",
"topo",
"bgp_graph"])
_SUPPORTED_TOPOS = ["ptf32", "ptf64", "t1", "t1-lag"]
_SUPPORTED_PTF_TOPOS = ["ptf32", "ptf64"]
_SUPPORTED_T1_TOPOS = ["t1", "t1-lag"]
_T1_NO_COPP_PROTOCOL = ["DHCP"]
_TEST_RATE_LIMIT = 600

class TestCOPP(object):
Expand Down Expand Up @@ -85,17 +87,6 @@ def test_no_policer(self, protocol, duthost, ptfhost, copp_testbed):
Checks that the policer does not enforce a rate limit for protocols
that do not have any set rate limit.
"""
# FIXME: The DHCP COPP Policy was removed from T1 in a recent change, so no
# packets will be trapped to CPU. So, we should have two cases:
#
# 1. Verify that NO DHCP packets are trapped to CPU on T1, and
# 2. Verify that DHCP packets ARE trapped to CPU on T0
#
# Because COPP doesn't run on T0 yet and the ptf script does not support "no
# packets received", we expect the test to fail for the time being.
if protocol == "DHCP":
pytest.mark.xfail("DHCP COPP Policy has been removed from T1 config")

_copp_runner(duthost,
ptfhost,
protocol,
Expand All @@ -108,7 +99,7 @@ def copp_testbed(duthost, ptfhost, testbed, request):
"""
test_params = _gather_test_params(testbed, duthost, request)

if test_params.topo not in _SUPPORTED_TOPOS:
if test_params.topo not in (_SUPPORTED_PTF_TOPOS + _SUPPORTED_T1_TOPOS):
pytest.skip("Topology not supported by COPP tests")

_setup_testbed(duthost, ptfhost, test_params)
Expand Down Expand Up @@ -155,7 +146,9 @@ def _copp_runner(dut, ptf, protocol, test_params):
# nightly test runs.
ptf_runner(host=ptf,
testdir="ptftests",
testname="copp_tests.{}Test".format(protocol),
# Special Handling for DHCP if we are using T1 Topo
testname="copp_tests.{}Test".format((protocol+"TopoT1")
if test_params.topo in _SUPPORTED_T1_TOPOS and protocol in _T1_NO_COPP_PROTOCOL else protocol),
platform="nn",
qlen=100000,
params=params,
Expand Down