Skip to content

Commit c6a94a0

Browse files
authored
Revert "[dualtor_io] Allow duplications for link down downstream I/O (sonic-net#17909)" (sonic-net#18192)
This reverts commit 7c31e46.
1 parent de454d5 commit c6a94a0

3 files changed

Lines changed: 17 additions & 49 deletions

File tree

tests/common/dualtor/data_plane_utils.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def arp_setup(ptfhost):
4141

4242

4343
def validate_traffic_results(tor_IO, allowed_disruption, delay,
44-
allow_disruption_before_traffic=False,
45-
allowed_duplication=None):
44+
allow_disruption_before_traffic=False):
4645
"""
4746
Generates a report (dictionary) of I/O metrics that were calculated as part
4847
of the dataplane test. This report is to be used by testcases to verify the
@@ -108,12 +107,7 @@ def validate_traffic_results(tor_IO, allowed_disruption, delay,
108107
"Maximum allowed disruption: {}s"
109108
.format(server_ip, longest_disruption, delay))
110109

111-
# NOTE: Not all testcases set the allowed duplication threshold and the duplication check
112-
# uses the allowed disruption threshold here.q So let's set the allowed duplication to
113-
# allowed disruption if the allowed duplication is provided here.
114-
if allowed_duplication is None:
115-
allowed_duplication = allowed_disruption
116-
if total_duplications > allowed_duplication:
110+
if total_duplications > allowed_disruption:
117111
failures.append("Traffic to server {} was duplicated {} times. "
118112
"Allowed number of duplications: {}"
119113
.format(server_ip, total_duplications, allowed_disruption))
@@ -156,12 +150,11 @@ def _validate_long_disruption(disruptions, allowed_disruption, delay):
156150

157151

158152
def verify_and_report(tor_IO, verify, delay, allowed_disruption,
159-
allow_disruption_before_traffic=False, allowed_duplication=None):
153+
allow_disruption_before_traffic=False):
160154
# Wait for the IO to complete before doing checks
161155
if verify:
162156
validate_traffic_results(tor_IO, allowed_disruption=allowed_disruption, delay=delay,
163-
allow_disruption_before_traffic=allow_disruption_before_traffic,
164-
allowed_duplication=allowed_duplication)
157+
allow_disruption_before_traffic=allow_disruption_before_traffic)
165158
return tor_IO.get_test_results()
166159

167160

@@ -274,8 +267,7 @@ def send_t1_to_server_with_action(duthosts, ptfhost, ptfadapter, tbinfo,
274267

275268
def t1_to_server_io_test(activehost, tor_vlan_port=None,
276269
delay=0, allowed_disruption=0, action=None, verify=False, send_interval=0.1,
277-
stop_after=None, allow_disruption_before_traffic=False,
278-
allowed_duplication=None):
270+
stop_after=None, allow_disruption_before_traffic=False):
279271
"""
280272
Helper method for `send_t1_to_server_with_action`.
281273
Starts sender and sniffer before performing the action on the tor host.
@@ -310,8 +302,7 @@ def t1_to_server_io_test(activehost, tor_vlan_port=None,
310302
if delay and not allowed_disruption:
311303
allowed_disruption = 1
312304

313-
return verify_and_report(tor_IO, verify, delay, allowed_disruption, allow_disruption_before_traffic,
314-
allowed_duplication=allowed_duplication)
305+
return verify_and_report(tor_IO, verify, delay, allowed_disruption, allow_disruption_before_traffic)
315306

316307
yield t1_to_server_io_test
317308

@@ -425,7 +416,7 @@ def send_t1_to_soc_with_action(duthosts, ptfhost, ptfadapter, tbinfo,
425416

426417
def t1_to_soc_io_test(activehost, tor_vlan_port=None,
427418
delay=0, allowed_disruption=0, action=None, verify=False, send_interval=0.01,
428-
stop_after=None, allowed_duplication=None):
419+
stop_after=None):
429420

430421
tor_IO = run_test(duthosts, activehost, ptfhost, ptfadapter, vmhost,
431422
action, tbinfo, tor_vlan_port, send_interval,
@@ -441,8 +432,7 @@ def t1_to_soc_io_test(activehost, tor_vlan_port=None,
441432
if asic_type == "vs":
442433
logging.info("Skipping verify on VS platform")
443434
return
444-
return verify_and_report(tor_IO, verify, delay, allowed_disruption,
445-
allowed_duplication=allowed_duplication)
435+
return verify_and_report(tor_IO, verify, delay, allowed_disruption)
446436

447437
yield t1_to_soc_io_test
448438

tests/common/dualtor/dual_tor_io.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import six
1212
import scapy.all as scapyall
1313
import ptf.testutils as testutils
14+
from operator import itemgetter
1415
from itertools import groupby
1516

1617
from tests.common.dualtor.dual_tor_common import CableType
@@ -792,37 +793,16 @@ def examine_each_packet(self, server_ip, packets):
792793
logger.error("Sniffer failed to filter any traffic from DUT")
793794
else:
794795
# Find ranges of consecutive packets that have been duplicated
795-
# All consecutive packets with the same payload will be grouped as one
796-
# duplication group.
797-
# For example, for the duplication list as the following:
798-
# [(70, 1744253633.499116), (70, 1744253633.499151), (70, 1744253633.499186),
799-
# (81, 1744253635.49922), (81, 1744253635.499255)]
800-
# two duplications will be reported:
801-
# "duplications": [
802-
# {
803-
# "start_time": 1744253633.499116,
804-
# "end_time": 1744253633.499186,
805-
# "start_id": 70,
806-
# "end_id": 70,
807-
# "duplication_count": 3
808-
# },
809-
# {
810-
# "start_time": 1744253635.49922,
811-
# "end_time": 1744253635.499255,
812-
# "start_id": 81,
813-
# "end_id": 81,
814-
# "duplication_count": 2
815-
# }
816-
# ]
817-
for _, grouper in groupby(duplicate_packet_list, lambda d: d[0]):
818-
duplicates = list(grouper)
819-
duplicate_start, duplicate_end = duplicates[0], duplicates[-1]
796+
# All packets within the same consecutive range will have the same
797+
# difference between the packet index and the sequence number
798+
for _, grouper in groupby(enumerate(duplicate_packet_list), lambda t: t[0] - t[1][0]):
799+
group = list(map(itemgetter(1), grouper))
800+
duplicate_start, duplicate_end = group[0], group[-1]
820801
duplicate_dict = {
821802
'start_time': duplicate_start[1],
822803
'end_time': duplicate_end[1],
823804
'start_id': duplicate_start[0],
824-
'end_id': duplicate_end[0],
825-
'duplication_count': len(duplicates)
805+
'end_id': duplicate_end[0]
826806
}
827807
duplicate_ranges.append(duplicate_dict)
828808

tests/dualtor_io/test_link_failure.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ def test_active_link_down_downstream_active(
8484
if cable_type == CableType.active_active:
8585
send_t1_to_server_with_action(
8686
upper_tor_host, verify=True, delay=MUX_SIM_ALLOWED_DISRUPTION_SEC,
87-
allowed_disruption=1, allowed_duplication=1,
88-
action=shutdown_fanout_upper_tor_intfs
87+
allowed_disruption=1, action=shutdown_fanout_upper_tor_intfs
8988
)
9089
verify_tor_states(
9190
expected_active_host=lower_tor_host,
@@ -333,8 +332,7 @@ def test_active_link_down_downstream_active_soc(
333332
if cable_type == CableType.active_active:
334333
send_t1_to_soc_with_action(
335334
upper_tor_host, verify=True, delay=MUX_SIM_ALLOWED_DISRUPTION_SEC,
336-
allowed_disruption=1, allowed_duplication=1,
337-
action=shutdown_fanout_upper_tor_intfs
335+
allowed_disruption=1, action=shutdown_fanout_upper_tor_intfs
338336
)
339337
verify_tor_states(
340338
expected_active_host=lower_tor_host,

0 commit comments

Comments
 (0)