diff --git a/ansible/roles/test/files/ptftests/py3/copp_tests.py b/ansible/roles/test/files/ptftests/py3/copp_tests.py index 7207e364b47..aa5421a80fb 100644 --- a/ansible/roles/test/files/ptftests/py3/copp_tests.py +++ b/ansible/roles/test/files/ptftests/py3/copp_tests.py @@ -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) @@ -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") @@ -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") @@ -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") @@ -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") @@ -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") @@ -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") diff --git a/tests/copp/test_copp.py b/tests/copp/test_copp.py index 7f977f50b85..209407c8f78 100644 --- a/tests/copp/test_copp.py +++ b/tests/copp/test_copp.py @@ -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,