Skip to content

Commit 6aeff47

Browse files
neethajohnAntonHryshchuk
authored andcommitted
Revert "Add test case for trap flow counter feature (sonic-net#4456)" (sonic-net#4747)
This reverts commit c630ea1 Reverts sonic-net#4456 This feature has not yet been reviewed sonic-net/SONiC#858 Affecting nighty run results because of this new testcase without feature support
1 parent 17a1712 commit 6aeff47

File tree

2 files changed

+32
-218
lines changed

2 files changed

+32
-218
lines changed

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

+24-95
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ def __init__(self):
5555
self.myip = test_params.get('myip', None)
5656
self.peerip = test_params.get('peerip', None)
5757
self.default_server_send_rate_limit_pps = test_params.get('send_rate_limit', 2000)
58-
59-
# For counter test
60-
self.expect_send_pkt_number = test_params.get('sent_pkt_number', None)
61-
self.send_duration = test_params.get('send_duration', None)
62-
self.is_counter_test = self.expect_send_pkt_number is not None and self.send_duration is not None
6358

6459
self.needPreSend = None
6560

@@ -115,9 +110,6 @@ def copp_test(self, packet, send_intf, recv_intf):
115110
'''
116111
Pre-send some packets for a second to absorb the CBS capacity.
117112
'''
118-
if self.is_counter_test:
119-
return self.copp_counter_test(packet, send_intf, recv_intf)
120-
121113
if self.needPreSend:
122114
pre_send_count = 0
123115
end_time = datetime.datetime.now() + datetime.timedelta(seconds=self.DEFAULT_PRE_SEND_INTERVAL_SEC)
@@ -186,67 +178,6 @@ def copp_test(self, packet, send_intf, recv_intf):
186178

187179
return send_count, recv_count, time_delta, time_delta_ms, tx_pps, rx_pps
188180

189-
def copp_counter_test(self, packet, send_intf, recv_intf):
190-
pre_test_ptf_tx_counter = self.dataplane.get_counters(*send_intf)
191-
pre_test_ptf_rx_counter = self.dataplane.get_counters(*recv_intf)
192-
pre_test_nn_tx_counter = self.dataplane.get_nn_counters(*send_intf)
193-
pre_test_nn_rx_counter = self.dataplane.get_nn_counters(*recv_intf)
194-
195-
send_count = 0
196-
start_time = datetime.datetime.now()
197-
send_window = float(self.send_duration) / float(self.expect_send_pkt_number)
198-
while send_count < self.expect_send_pkt_number:
199-
begin = time.time()
200-
testutils.send_packet(self, send_intf, packet)
201-
send_count += 1
202-
elapse = time.time() - begin
203-
204-
# Depending on the server/platform combination it is possible for the server to
205-
# overwhelm the DUT, so we add an artificial delay here to rate-limit the server.
206-
if elapse > 0:
207-
time.sleep(send_window - elapse)
208-
209-
end_time = datetime.datetime.now()
210-
time.sleep(self.DEFAULT_RECEIVE_WAIT_TIME) # Wait a little bit for all the packets to make it through
211-
recv_count = testutils.count_matched_packets(self, packet, recv_intf[1], recv_intf[0])
212-
213-
post_test_ptf_tx_counter = self.dataplane.get_counters(*send_intf)
214-
post_test_ptf_rx_counter = self.dataplane.get_counters(*recv_intf)
215-
post_test_nn_tx_counter = self.dataplane.get_nn_counters(*send_intf)
216-
post_test_nn_rx_counter = self.dataplane.get_nn_counters(*recv_intf)
217-
218-
ptf_tx_count = int(post_test_ptf_tx_counter[1] - pre_test_ptf_tx_counter[1])
219-
nn_tx_count = int(post_test_nn_tx_counter[1] - pre_test_nn_tx_counter[1])
220-
ptf_rx_count = int(post_test_ptf_rx_counter[0] - pre_test_ptf_rx_counter[0])
221-
nn_rx_count = int(post_test_nn_rx_counter[0] - pre_test_nn_rx_counter[0])
222-
223-
self.log("", True)
224-
self.log("Counters before the test:", True)
225-
self.log("If counter (0, n): %s" % str(pre_test_ptf_tx_counter), True)
226-
self.log("NN counter (0, n): %s" % str(pre_test_nn_tx_counter), True)
227-
self.log("If counter (1, n): %s" % str(pre_test_ptf_rx_counter), True)
228-
self.log("NN counter (1, n): %s" % str(pre_test_nn_rx_counter), True)
229-
self.log("", True)
230-
self.log("Counters after the test:", True)
231-
self.log("If counter (0, n): %s" % str(post_test_ptf_tx_counter), True)
232-
self.log("NN counter (0, n): %s" % str(post_test_nn_tx_counter), True)
233-
self.log("If counter (1, n): %s" % str(post_test_ptf_rx_counter), True)
234-
self.log("NN counter (1, n): %s" % str(post_test_nn_rx_counter), True)
235-
self.log("")
236-
self.log("Sent through NN to local ptf_nn_agent: %d" % ptf_tx_count)
237-
self.log("Sent through If to remote ptf_nn_agent: %d" % nn_tx_count)
238-
self.log("Recv from If on remote ptf_nn_agent: %d" % ptf_rx_count)
239-
self.log("Recv from NN on from remote ptf_nn_agent: %d" % nn_rx_count)
240-
241-
time_delta = end_time - start_time
242-
self.log("Sent out %d packets in %ds" % (send_count, time_delta.seconds))
243-
time_delta_ms = (time_delta.microseconds + time_delta.seconds * 10**6) / 1000
244-
tx_pps = int(send_count / (float(time_delta_ms) / 1000))
245-
rx_pps = int(recv_count / (float(time_delta_ms) / 1000))
246-
247-
return send_count, recv_count, time_delta, time_delta_ms, tx_pps, rx_pps
248-
249-
250181
def contruct_packet(self, port_number):
251182
raise NotImplementedError
252183

@@ -283,22 +214,21 @@ def __init__(self):
283214
self.needPreSend = False
284215

285216
def check_constraints(self, send_count, recv_count, time_delta_ms, rx_pps):
286-
if not self.is_counter_test:
287-
pkt_rx_limit = send_count * 0.90
217+
pkt_rx_limit = send_count * 0.90
288218

289-
self.log("")
290-
self.log("Checking constraints (NoPolicy):")
291-
self.log(
292-
"rx_pps (%d) > NO_POLICER_LIMIT (%d): %s" %
293-
(int(rx_pps), int(self.NO_POLICER_LIMIT), str(rx_pps > self.NO_POLICER_LIMIT))
294-
)
295-
self.log(
296-
"recv_count (%d) > pkt_rx_limit (%d): %s" %
297-
(int(recv_count), int(pkt_rx_limit), str(recv_count > pkt_rx_limit))
298-
)
219+
self.log("")
220+
self.log("Checking constraints (NoPolicy):")
221+
self.log(
222+
"rx_pps (%d) > NO_POLICER_LIMIT (%d): %s" %
223+
(int(rx_pps), int(self.NO_POLICER_LIMIT), str(rx_pps > self.NO_POLICER_LIMIT))
224+
)
225+
self.log(
226+
"recv_count (%d) > pkt_rx_limit (%d): %s" %
227+
(int(recv_count), int(pkt_rx_limit), str(recv_count > pkt_rx_limit))
228+
)
299229

300-
assert(rx_pps > self.NO_POLICER_LIMIT)
301-
assert(recv_count > pkt_rx_limit)
230+
assert(rx_pps > self.NO_POLICER_LIMIT)
231+
assert(recv_count > pkt_rx_limit)
302232

303233

304234
class PolicyTest(ControlPlaneBaseTest):
@@ -307,18 +237,17 @@ def __init__(self):
307237
self.needPreSend = True
308238

309239
def check_constraints(self, send_count, recv_count, time_delta_ms, rx_pps):
310-
if not self.is_counter_test:
311-
self.log("")
312-
self.log("Checking constraints (PolicyApplied):")
313-
self.log(
314-
"PPS_LIMIT_MIN (%d) <= rx_pps (%d) <= PPS_LIMIT_MAX (%d): %s" %
315-
(int(self.PPS_LIMIT_MIN),
316-
int(rx_pps),
317-
int(self.PPS_LIMIT_MAX),
318-
str(self.PPS_LIMIT_MIN <= rx_pps <= self.PPS_LIMIT_MAX))
319-
)
320-
321-
assert(self.PPS_LIMIT_MIN <= rx_pps <= self.PPS_LIMIT_MAX)
240+
self.log("")
241+
self.log("Checking constraints (PolicyApplied):")
242+
self.log(
243+
"PPS_LIMIT_MIN (%d) <= rx_pps (%d) <= PPS_LIMIT_MAX (%d): %s" %
244+
(int(self.PPS_LIMIT_MIN),
245+
int(rx_pps),
246+
int(self.PPS_LIMIT_MAX),
247+
str(self.PPS_LIMIT_MIN <= rx_pps <= self.PPS_LIMIT_MAX))
248+
)
249+
250+
assert(self.PPS_LIMIT_MIN <= rx_pps <= self.PPS_LIMIT_MAX)
322251

323252

324253
# SONIC config contains policer CIR=600 for ARP

tests/copp/test_copp.py

+8-123
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@
2323
import logging
2424
import pytest
2525
import json
26-
import random
27-
import threading
28-
import time
2926
from collections import namedtuple
3027

3128
from tests.copp import copp_utils
3229
from tests.ptf_runner import ptf_runner
3330
from tests.common import config_reload, constants
3431
from tests.common.system_utils import docker
35-
from tests.common.utilities import wait_until
3632

3733
# Module-level fixtures
3834
from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # lgtm[py/unused-import]
@@ -58,8 +54,6 @@
5854
_SUPPORTED_T2_TOPOS = ["t2"]
5955
_TOR_ONLY_PROTOCOL = ["DHCP"]
6056
_TEST_RATE_LIMIT = 600
61-
_SEND_PACKET_NUMBER = 1500
62-
_SEND_DURATION = 30
6357

6458

6559
class TestCOPP(object):
@@ -104,51 +98,6 @@ def test_no_policer(self, protocol, duthosts, enum_rand_one_per_hwsku_frontend_h
10498
copp_testbed,
10599
dut_type)
106100

107-
@pytest.mark.parametrize("protocol", ["LACP",
108-
"LLDP",
109-
"UDLD",
110-
"IP2ME"])
111-
def test_counter(self, protocol, duthosts, rand_one_dut_hostname, ptfhost, copp_testbed, dut_type, counter_test):
112-
duthost = duthosts[rand_one_dut_hostname]
113-
trap_type = protocol.lower()
114-
115-
# wait until the trap counter is enabled
116-
assert wait_until(10, 1, 0, _check_trap_counter_enabled, duthost, trap_type), 'counter is not created for {}'.format(trap_type)
117-
118-
# clean previous counter value
119-
duthost.command('sonic-clear flowcnt-trap')
120-
121-
# start a thread to collect the max PPS value
122-
actual_rate = []
123-
t = threading.Thread(target=_collect_counter_rate, args=(duthost, trap_type, actual_rate))
124-
t.start()
125-
126-
# init and start PTF
127-
_copp_runner(duthost,
128-
ptfhost,
129-
protocol,
130-
copp_testbed,
131-
dut_type,
132-
True)
133-
134-
# wait for thread finish
135-
t.join()
136-
137-
# get final packet count from CLI
138-
expect_rate = float(_SEND_PACKET_NUMBER / _SEND_DURATION)
139-
actual_packet_number = None
140-
cli_data = duthost.show_and_parse('show flowcnt-trap stats')
141-
for line in cli_data:
142-
if 'trap name' in line and line['trap name'] == trap_type:
143-
actual_packet_number = int(line['packets'].replace(',', ''))
144-
break
145-
146-
assert actual_packet_number == _SEND_PACKET_NUMBER, 'Trap {} expect send packet number: {}, but actual: {}'.format(trap_type, _SEND_PACKET_NUMBER, actual_packet_number)
147-
assert len(actual_rate) == 1, 'Failed to collect PPS value for trap {}'.format(trap_type)
148-
# Allow a 10 percent threshold for trap rate
149-
assert (expect_rate * 0.9) < actual_rate[0] < (expect_rate * 1.1), 'Trap {} expect send packet rate: {}, but actual: {}'.format(trap_type, expect_rate, actual_rate)
150-
151-
152101
@pytest.fixture(scope="class")
153102
def dut_type(duthosts, enum_rand_one_per_hwsku_frontend_hostname):
154103
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
@@ -208,33 +157,17 @@ def ignore_expected_loganalyzer_exceptions(enum_rand_one_per_hwsku_frontend_host
208157
if loganalyzer: # Skip if loganalyzer is disabled
209158
loganalyzer[enum_rand_one_per_hwsku_frontend_hostname].ignore_regex.extend(ignoreRegex)
210159

211-
@pytest.fixture(scope="function")
212-
def counter_test(duthosts, rand_one_dut_hostname):
213-
duthost = duthosts[rand_one_dut_hostname]
214-
duthost.command('counterpoll flowcnt-trap enable')
215-
216-
yield
217-
218-
duthost.command('counterpoll flowcnt-trap disable')
219-
220-
def _copp_runner(dut, ptf, protocol, test_params, dut_type, counter_test=False):
160+
def _copp_runner(dut, ptf, protocol, test_params, dut_type):
221161
"""
222162
Configures and runs the PTF test cases.
223163
"""
224-
if not counter_test:
225-
params = {"verbose": False,
226-
"target_port": test_params.nn_target_port,
227-
"myip": test_params.myip,
228-
"peerip": test_params.peerip,
229-
"send_rate_limit": test_params.send_rate_limit}
230-
else:
231-
params = {"verbose": False,
232-
"target_port": test_params.nn_target_port,
233-
"myip": test_params.myip,
234-
"peerip": test_params.peerip,
235-
"send_rate_limit": test_params.send_rate_limit,
236-
"sent_pkt_number": _SEND_PACKET_NUMBER,
237-
"send_duration": _SEND_DURATION}
164+
165+
params = {"verbose": False,
166+
"target_port": test_params.nn_target_port,
167+
"myip": test_params.myip,
168+
"peerip": test_params.peerip,
169+
"send_rate_limit": test_params.send_rate_limit}
170+
238171
dut_ip = dut.mgmt_ip
239172
device_sockets = ["0-{}@tcp://127.0.0.1:10900".format(test_params.nn_target_port),
240173
"1-{}@tcp://{}:10900".format(test_params.nn_target_port, dut_ip)]
@@ -398,51 +331,3 @@ def _teardown_multi_asic_proxy(dut, creds, test_params, tbinfo):
398331
ns_ip = dut.shell("sudo ip -n {} -4 -o addr show eth0".format(test_params.nn_target_namespace) + " | awk '{print $4}' | cut -d'/' -f1")["stdout"]
399332
dut.command("sudo iptables -t nat -D PREROUTING -p tcp --dport 10900 -j DNAT --to-destination {}".format(ns_ip))
400333
dut.command("sudo ip -n {} rule delete from {} to {} pref 3 lookup default".format(test_params.nn_target_namespace, ns_ip, tbinfo["ptf_ip"]))
401-
402-
def _check_trap_counter_enabled(duthost, trap_type):
403-
lines = duthost.command('show flowcnt-trap stats')['stdout']
404-
return trap_type in lines
405-
406-
def _collect_counter_rate(duthost, trap_type, actual_rate):
407-
rate_values = []
408-
# Wait up to _SEND_DURATION + 5 seconds for PTF to stop sending packet,
409-
# as it might take some time for PTF to initialize itself
410-
max_wait = _SEND_DURATION + 5
411-
packets = None
412-
while max_wait > 0:
413-
cli_data = duthost.show_and_parse('show flowcnt-trap stats')
414-
for line in cli_data:
415-
if 'trap name' in line and line['trap name'] == trap_type:
416-
packets = line['packets']
417-
if packets == 'N/A':
418-
# Packets value is not available yet
419-
logging.debug('Trap {} packets value is not available yet'.format(trap_type))
420-
break
421-
422-
pps_value = line['pps']
423-
if pps_value == 'N/A':
424-
# PPS value is not available yet
425-
logging.debug('Trap {} PPS value is not available yet'.format(trap_type))
426-
break
427-
428-
packets = int(packets.replace(',', ''))
429-
if packets == 0:
430-
# PTF has not started yet
431-
logging.debug('Trap {} packets value is still 0, PTF has not started yet'.format(trap_type))
432-
break
433-
434-
logging.info('Trap {} current PPS value is {}, packets value is {}'.format(trap_type, pps_value, packets))
435-
rate_values.append(float(pps_value[:-2]))
436-
break
437-
if packets == _SEND_PACKET_NUMBER:
438-
# Enough packets are sent, stop
439-
break
440-
time.sleep(0.5)
441-
max_wait -= 0.5
442-
443-
if rate_values:
444-
# Calculate max PPS
445-
max_pps = max(rate_values)
446-
logging.info('Trap {} max PPS is {}'.format(trap_type, max_pps))
447-
actual_rate.append(max_pps)
448-

0 commit comments

Comments
 (0)