Skip to content

Commit

Permalink
[tests/copp]: Update copp mgmt tests to support new rate-limits (#8199)
Browse files Browse the repository at this point in the history
* [tests/copp]: Update copp mgmt tests to support new rate-limits
* 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
  • Loading branch information
prabhataravind authored Oct 25, 2023
1 parent b0be3f5 commit 7e03ae9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 69 deletions.
65 changes: 18 additions & 47 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 @@ -350,10 +322,10 @@ def contruct_packet(self, port_number):
return packet


# SONIC configuration has no policer limiting for DHCP
class DHCPTest(NoPolicyTest):
# SONIC config contains policer CIR=300 for DHCP
class DHCPTest(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("DHCPTest")
Expand Down Expand Up @@ -384,10 +356,10 @@ def contruct_packet(self, port_number):
return packet


# SONIC configuration has no policer limiting for DHCPv6
class DHCP6Test(NoPolicyTest):
# SONIC config contains policer CIR=300 for DHCPv6
class DHCP6Test(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("DHCP6Test")
Expand Down Expand Up @@ -436,12 +408,11 @@ def contruct_packet(self, port_number):

return packet

# SONIC configuration has no policer limiting for LLDP


class LLDPTest(NoPolicyTest):
# SONIC config contains policer CIR=300 for LLDP
class LLDPTest(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("LLDPTest")
Expand All @@ -459,10 +430,10 @@ def contruct_packet(self, port_number):
return packet


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

def runTest(self):
self.log("UDLDTest")
Expand All @@ -485,10 +456,10 @@ def contruct_packet(self, port_number):
return packet


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

def runTest(self):
self.log("BGPTest")
Expand All @@ -508,10 +479,10 @@ def contruct_packet(self, port_number):
return packet


# SONIC configuration has no policer limiting for LACP
class LACPTest(NoPolicyTest):
# SONIC config contains policer CIR=6000 for LACP
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 7e03ae9

Please sign in to comment.