Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions tests/common/dualtor/data_plane_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def arp_setup(ptfhost):


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

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


def verify_and_report(tor_IO, verify, delay, allowed_disruption,
allow_disruption_before_traffic=False, allowed_duplication=None):
allow_disruption_before_traffic=False):
# Wait for the IO to complete before doing checks
if verify:
validate_traffic_results(tor_IO, allowed_disruption=allowed_disruption, delay=delay,
allow_disruption_before_traffic=allow_disruption_before_traffic,
allowed_duplication=allowed_duplication)
allow_disruption_before_traffic=allow_disruption_before_traffic)
return tor_IO.get_test_results()


Expand Down Expand Up @@ -274,8 +267,7 @@ def send_t1_to_server_with_action(duthosts, ptfhost, ptfadapter, tbinfo,

def t1_to_server_io_test(activehost, tor_vlan_port=None,
delay=0, allowed_disruption=0, action=None, verify=False, send_interval=0.1,
stop_after=None, allow_disruption_before_traffic=False,
allowed_duplication=None):
stop_after=None, allow_disruption_before_traffic=False):
"""
Helper method for `send_t1_to_server_with_action`.
Starts sender and sniffer before performing the action on the tor host.
Expand Down Expand Up @@ -310,8 +302,7 @@ def t1_to_server_io_test(activehost, tor_vlan_port=None,
if delay and not allowed_disruption:
allowed_disruption = 1

return verify_and_report(tor_IO, verify, delay, allowed_disruption, allow_disruption_before_traffic,
allowed_duplication=allowed_duplication)
return verify_and_report(tor_IO, verify, delay, allowed_disruption, allow_disruption_before_traffic)

yield t1_to_server_io_test

Expand Down Expand Up @@ -425,7 +416,7 @@ def send_t1_to_soc_with_action(duthosts, ptfhost, ptfadapter, tbinfo,

def t1_to_soc_io_test(activehost, tor_vlan_port=None,
delay=0, allowed_disruption=0, action=None, verify=False, send_interval=0.01,
stop_after=None, allowed_duplication=None):
stop_after=None):

tor_IO = run_test(duthosts, activehost, ptfhost, ptfadapter, vmhost,
action, tbinfo, tor_vlan_port, send_interval,
Expand All @@ -441,8 +432,7 @@ def t1_to_soc_io_test(activehost, tor_vlan_port=None,
if asic_type == "vs":
logging.info("Skipping verify on VS platform")
return
return verify_and_report(tor_IO, verify, delay, allowed_disruption,
allowed_duplication=allowed_duplication)
return verify_and_report(tor_IO, verify, delay, allowed_disruption)

yield t1_to_soc_io_test

Expand Down
34 changes: 7 additions & 27 deletions tests/common/dualtor/dual_tor_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import six
import scapy.all as scapyall
import ptf.testutils as testutils
from operator import itemgetter
from itertools import groupby

from tests.common.dualtor.dual_tor_common import CableType
Expand Down Expand Up @@ -792,37 +793,16 @@ def examine_each_packet(self, server_ip, packets):
logger.error("Sniffer failed to filter any traffic from DUT")
else:
# Find ranges of consecutive packets that have been duplicated
# All consecutive packets with the same payload will be grouped as one
# duplication group.
# For example, for the duplication list as the following:
# [(70, 1744253633.499116), (70, 1744253633.499151), (70, 1744253633.499186),
# (81, 1744253635.49922), (81, 1744253635.499255)]
# two duplications will be reported:
# "duplications": [
# {
# "start_time": 1744253633.499116,
# "end_time": 1744253633.499186,
# "start_id": 70,
# "end_id": 70,
# "duplication_count": 3
# },
# {
# "start_time": 1744253635.49922,
# "end_time": 1744253635.499255,
# "start_id": 81,
# "end_id": 81,
# "duplication_count": 2
# }
# ]
for _, grouper in groupby(duplicate_packet_list, lambda d: d[0]):
duplicates = list(grouper)
duplicate_start, duplicate_end = duplicates[0], duplicates[-1]
# All packets within the same consecutive range will have the same
# difference between the packet index and the sequence number
for _, grouper in groupby(enumerate(duplicate_packet_list), lambda t: t[0] - t[1][0]):
group = list(map(itemgetter(1), grouper))
duplicate_start, duplicate_end = group[0], group[-1]
duplicate_dict = {
'start_time': duplicate_start[1],
'end_time': duplicate_end[1],
'start_id': duplicate_start[0],
'end_id': duplicate_end[0],
'duplication_count': len(duplicates)
'end_id': duplicate_end[0]
}
duplicate_ranges.append(duplicate_dict)

Expand Down
6 changes: 2 additions & 4 deletions tests/dualtor_io/test_link_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ def test_active_link_down_downstream_active(
if cable_type == CableType.active_active:
send_t1_to_server_with_action(
upper_tor_host, verify=True, delay=MUX_SIM_ALLOWED_DISRUPTION_SEC,
allowed_disruption=1, allowed_duplication=1,
action=shutdown_fanout_upper_tor_intfs
allowed_disruption=1, action=shutdown_fanout_upper_tor_intfs
)
verify_tor_states(
expected_active_host=lower_tor_host,
Expand Down Expand Up @@ -333,8 +332,7 @@ def test_active_link_down_downstream_active_soc(
if cable_type == CableType.active_active:
send_t1_to_soc_with_action(
upper_tor_host, verify=True, delay=MUX_SIM_ALLOWED_DISRUPTION_SEC,
allowed_disruption=1, allowed_duplication=1,
action=shutdown_fanout_upper_tor_intfs
allowed_disruption=1, action=shutdown_fanout_upper_tor_intfs
)
verify_tor_states(
expected_active_host=lower_tor_host,
Expand Down
Loading