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

[tests/copp]: Update copp mgmt tests to support new rate-limits #8199

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
52 changes: 12 additions & 40 deletions ansible/roles/test/files/ptftests/py3/copp_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,34 +238,6 @@ def printStats(self, pkt_send_count, recv_count, time_delta, tx_pps, rx_pps):
self.log('RX PPS = %d' % rx_pps)


class NoPolicyTest(ControlPlaneBaseTest):
def __init__(self):
ControlPlaneBaseTest.__init__(self)
self.needPreSend = False

def check_constraints(self, send_count, recv_count, time_delta_ms, rx_pps):
pkt_rx_limit = send_count * 0.90

self.log("")
self.log("Checking constraints (NoPolicy):")
self.log(
"rx_pps (%d) > NO_POLICER_LIMIT (%d): %s" %
(int(rx_pps), int(self.NO_POLICER_LIMIT),
str(rx_pps > self.NO_POLICER_LIMIT))
)
self.log(
"recv_count (%d) > pkt_rx_limit (%d): %s" %
(int(recv_count), int(pkt_rx_limit), str(recv_count > pkt_rx_limit))
)

if self.has_trap:
assert (rx_pps > self.NO_POLICER_LIMIT)
assert (recv_count > pkt_rx_limit)
else:
assert (rx_pps < self.NO_POLICER_LIMIT)
assert (recv_count < pkt_rx_limit)


class PolicyTest(ControlPlaneBaseTest):
def __init__(self):
ControlPlaneBaseTest.__init__(self)
Expand Down Expand Up @@ -351,9 +323,9 @@ def contruct_packet(self, port_number):


# SONIC configuration has no policer limiting for DHCP
prabhataravind marked this conversation as resolved.
Show resolved Hide resolved
class DHCPTest(NoPolicyTest):
class DHCPTest(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("DHCPTest")
Expand Down Expand Up @@ -385,9 +357,9 @@ def contruct_packet(self, port_number):


# SONIC configuration has no policer limiting for DHCPv6
prabhataravind marked this conversation as resolved.
Show resolved Hide resolved
class DHCP6Test(NoPolicyTest):
class DHCP6Test(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("DHCP6Test")
Expand Down Expand Up @@ -439,9 +411,9 @@ def contruct_packet(self, port_number):
# SONIC configuration has no policer limiting for LLDP


class LLDPTest(NoPolicyTest):
class LLDPTest(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("LLDPTest")
Expand All @@ -460,9 +432,9 @@ def contruct_packet(self, port_number):


# SONIC configuration has no policer limiting for UDLD
class UDLDTest(NoPolicyTest):
class UDLDTest(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("UDLDTest")
Expand All @@ -486,9 +458,9 @@ def contruct_packet(self, port_number):


# SONIC configuration has no policer limiting for BGP
class BGPTest(NoPolicyTest):
class BGPTest(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("BGPTest")
Expand All @@ -509,9 +481,9 @@ def contruct_packet(self, port_number):


# SONIC configuration has no policer limiting for LACP
class LACPTest(NoPolicyTest):
class LACPTest(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("LACPTest")
Expand Down
29 changes: 7 additions & 22 deletions tests/copp/test_copp.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,35 +74,20 @@ class TestCOPP(object):
@pytest.mark.parametrize("protocol", ["ARP",
"IP2ME",
"SNMP",
"SSH"])
def test_policer(self, protocol, duthosts, enum_rand_one_per_hwsku_frontend_hostname,
ptfhost, copp_testbed, dut_type):
"""
Validates that rate-limited COPP groups work as expected.

Checks that the policer enforces the rate limit for protocols
that have a set rate limit.
"""
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
_copp_runner(duthost,
ptfhost,
protocol,
copp_testbed,
dut_type)

@pytest.mark.parametrize("protocol", ["BGP",
"SSH",
"DHCP",
"DHCP6",
"BGP",
"LACP",
"LLDP",
"UDLD"])
def test_no_policer(self, protocol, duthosts, enum_rand_one_per_hwsku_frontend_hostname,
ptfhost, copp_testbed, dut_type):
def test_policer(self, protocol, duthosts, enum_rand_one_per_hwsku_frontend_hostname,
ptfhost, copp_testbed, dut_type):
"""
Validates that non-rate-limited COPP groups work as expected.
Validates that rate-limited COPP groups work as expected.

Checks that the policer does not enforce a rate limit for protocols
that do not have any set rate limit.
Checks that the policer enforces the rate limit for protocols
that have a set rate limit.
"""
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
_copp_runner(duthost,
Expand Down