Skip to content

Commit 2c56e37

Browse files
prabhataravindmssonicbld
authored andcommitted
[tests/copp]: Update copp mgmt tests to support new rate-limits (#8199)
* [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
1 parent 2536959 commit 2c56e37

File tree

2 files changed

+25
-69
lines changed

2 files changed

+25
-69
lines changed

ansible/roles/test/files/ptftests/py3/copp_tests.py

+18-47
Original file line numberDiff line numberDiff line change
@@ -238,34 +238,6 @@ def printStats(self, pkt_send_count, recv_count, time_delta, tx_pps, rx_pps):
238238
self.log('RX PPS = %d' % rx_pps)
239239

240240

241-
class NoPolicyTest(ControlPlaneBaseTest):
242-
def __init__(self):
243-
ControlPlaneBaseTest.__init__(self)
244-
self.needPreSend = False
245-
246-
def check_constraints(self, send_count, recv_count, time_delta_ms, rx_pps):
247-
pkt_rx_limit = send_count * 0.90
248-
249-
self.log("")
250-
self.log("Checking constraints (NoPolicy):")
251-
self.log(
252-
"rx_pps (%d) > NO_POLICER_LIMIT (%d): %s" %
253-
(int(rx_pps), int(self.NO_POLICER_LIMIT),
254-
str(rx_pps > self.NO_POLICER_LIMIT))
255-
)
256-
self.log(
257-
"recv_count (%d) > pkt_rx_limit (%d): %s" %
258-
(int(recv_count), int(pkt_rx_limit), str(recv_count > pkt_rx_limit))
259-
)
260-
261-
if self.has_trap:
262-
assert (rx_pps > self.NO_POLICER_LIMIT)
263-
assert (recv_count > pkt_rx_limit)
264-
else:
265-
assert (rx_pps < self.NO_POLICER_LIMIT)
266-
assert (recv_count < pkt_rx_limit)
267-
268-
269241
class PolicyTest(ControlPlaneBaseTest):
270242
def __init__(self):
271243
ControlPlaneBaseTest.__init__(self)
@@ -350,10 +322,10 @@ def contruct_packet(self, port_number):
350322
return packet
351323

352324

353-
# SONIC configuration has no policer limiting for DHCP
354-
class DHCPTest(NoPolicyTest):
325+
# SONIC config contains policer CIR=300 for DHCP
326+
class DHCPTest(PolicyTest):
355327
def __init__(self):
356-
NoPolicyTest.__init__(self)
328+
PolicyTest.__init__(self)
357329

358330
def runTest(self):
359331
self.log("DHCPTest")
@@ -384,10 +356,10 @@ def contruct_packet(self, port_number):
384356
return packet
385357

386358

387-
# SONIC configuration has no policer limiting for DHCPv6
388-
class DHCP6Test(NoPolicyTest):
359+
# SONIC config contains policer CIR=300 for DHCPv6
360+
class DHCP6Test(PolicyTest):
389361
def __init__(self):
390-
NoPolicyTest.__init__(self)
362+
PolicyTest.__init__(self)
391363

392364
def runTest(self):
393365
self.log("DHCP6Test")
@@ -436,12 +408,11 @@ def contruct_packet(self, port_number):
436408

437409
return packet
438410

439-
# SONIC configuration has no policer limiting for LLDP
440411

441-
442-
class LLDPTest(NoPolicyTest):
412+
# SONIC config contains policer CIR=300 for LLDP
413+
class LLDPTest(PolicyTest):
443414
def __init__(self):
444-
NoPolicyTest.__init__(self)
415+
PolicyTest.__init__(self)
445416

446417
def runTest(self):
447418
self.log("LLDPTest")
@@ -459,10 +430,10 @@ def contruct_packet(self, port_number):
459430
return packet
460431

461432

462-
# SONIC configuration has no policer limiting for UDLD
463-
class UDLDTest(NoPolicyTest):
433+
# SONIC config contains policer CIR=300 for UDLD
434+
class UDLDTest(PolicyTest):
464435
def __init__(self):
465-
NoPolicyTest.__init__(self)
436+
PolicyTest.__init__(self)
466437

467438
def runTest(self):
468439
self.log("UDLDTest")
@@ -485,10 +456,10 @@ def contruct_packet(self, port_number):
485456
return packet
486457

487458

488-
# SONIC configuration has no policer limiting for BGP
489-
class BGPTest(NoPolicyTest):
459+
# SONIC config contains policer CIR=6000 for BGP
460+
class BGPTest(PolicyTest):
490461
def __init__(self):
491-
NoPolicyTest.__init__(self)
462+
PolicyTest.__init__(self)
492463

493464
def runTest(self):
494465
self.log("BGPTest")
@@ -508,10 +479,10 @@ def contruct_packet(self, port_number):
508479
return packet
509480

510481

511-
# SONIC configuration has no policer limiting for LACP
512-
class LACPTest(NoPolicyTest):
482+
# SONIC config contains policer CIR=6000 for LACP
483+
class LACPTest(PolicyTest):
513484
def __init__(self):
514-
NoPolicyTest.__init__(self)
485+
PolicyTest.__init__(self)
515486

516487
def runTest(self):
517488
self.log("LACPTest")

tests/copp/test_copp.py

+7-22
Original file line numberDiff line numberDiff line change
@@ -74,35 +74,20 @@ class TestCOPP(object):
7474
@pytest.mark.parametrize("protocol", ["ARP",
7575
"IP2ME",
7676
"SNMP",
77-
"SSH"])
78-
def test_policer(self, protocol, duthosts, enum_rand_one_per_hwsku_frontend_hostname,
79-
ptfhost, copp_testbed, dut_type):
80-
"""
81-
Validates that rate-limited COPP groups work as expected.
82-
83-
Checks that the policer enforces the rate limit for protocols
84-
that have a set rate limit.
85-
"""
86-
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
87-
_copp_runner(duthost,
88-
ptfhost,
89-
protocol,
90-
copp_testbed,
91-
dut_type)
92-
93-
@pytest.mark.parametrize("protocol", ["BGP",
77+
"SSH",
9478
"DHCP",
9579
"DHCP6",
80+
"BGP",
9681
"LACP",
9782
"LLDP",
9883
"UDLD"])
99-
def test_no_policer(self, protocol, duthosts, enum_rand_one_per_hwsku_frontend_hostname,
100-
ptfhost, copp_testbed, dut_type):
84+
def test_policer(self, protocol, duthosts, enum_rand_one_per_hwsku_frontend_hostname,
85+
ptfhost, copp_testbed, dut_type):
10186
"""
102-
Validates that non-rate-limited COPP groups work as expected.
87+
Validates that rate-limited COPP groups work as expected.
10388
104-
Checks that the policer does not enforce a rate limit for protocols
105-
that do not have any set rate limit.
89+
Checks that the policer enforces the rate limit for protocols
90+
that have a set rate limit.
10691
"""
10792
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
10893
_copp_runner(duthost,

0 commit comments

Comments
 (0)