Skip to content

Commit

Permalink
[tests/copp]: Update copp mgmt tests to support new rate-limits
Browse files Browse the repository at this point in the history
 * Rate limits are being set for bgp, lacp, dhcp, lldp,
   udld and macsec via a copp cfg change. This is the corresponding
   sonic-mgmt change

Signed-off-by: Prabhat Aravind <[email protected]>
  • Loading branch information
prabhataravind committed Oct 16, 2023
1 parent c071a76 commit ce9cfe7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 62 deletions.
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
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
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

0 comments on commit ce9cfe7

Please sign in to comment.