Skip to content

Commit

Permalink
Select only ports belonging to same asic - chassis-packet (sonic-net#…
Browse files Browse the repository at this point in the history
…10365)

In case of chassis-packet switch type, when src port of the traffic is on the same DUT and same asic as destination port, it sends out traffic only on the ports that belong to the same asic. Currently both fib_test and hash_test was set to send out on ports that belonged to different asic causing the balancing test to fail. THis change pertains only to chassis-packet switch type
  • Loading branch information
vperumal authored Oct 31, 2023
1 parent ac5eccc commit db8c150
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 5 deletions.
36 changes: 34 additions & 2 deletions ansible/roles/test/files/ptftests/fib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ def get_src_and_exp_ports(self, dst_ip):
# Because the MACsec is session based channel but the injected ports are stateless ports
if src_port in macsec.MACSEC_INFOS.keys():
continue
if self.switch_type == "chassis-packet":
exp_port_lists = self.check_same_asic(src_port, exp_port_lists)
logging.info('src_port={}, exp_port_lists={}, active_dut_indexes={}'.format(
src_port, exp_port_lists, active_dut_indexes))
break
Expand Down Expand Up @@ -284,7 +286,7 @@ def check_balancing(self, ip_ranges, dut_index, ipv4=True):
for next_hop in next_hops:
# only check balance on a DUT
self.check_hit_count_map(
next_hop.get_next_hop(), hit_count_map)
next_hop.get_next_hop(), hit_count_map, src_port)
self.balancing_test_count += 1
if self.balancing_test_count >= self.balancing_test_number:
break
Expand Down Expand Up @@ -508,7 +510,34 @@ def check_within_expected_range(self, actual, expected):
percentage = (actual - expected) / float(expected)
return (percentage, abs(percentage) <= self.balancing_range)

def check_hit_count_map(self, dest_port_list, port_hit_cnt):
def check_same_asic(self, src_port, exp_port_list):
updated_exp_port_list = list()
for port in exp_port_list:
if type(port) == list:
per_port_list = list()
for per_port in port:
if self.ptf_test_port_map[str(per_port)]['target_dut'] \
!= self.ptf_test_port_map[str(src_port)]['target_dut']:
return exp_port_list
else:
if self.ptf_test_port_map[str(per_port)]['asic_idx'] \
== self.ptf_test_port_map[str(src_port)]['asic_idx']:
per_port_list.append(per_port)
if per_port_list:
updated_exp_port_list.append(per_port_list)
else:
if self.ptf_test_port_map[str(port)]['target_dut'] \
!= self.ptf_test_port_map[str(src_port)]['target_dut']:
return exp_port_list
else:
if self.ptf_test_port_map[str(port)]['asic_idx'] \
== self.ptf_test_port_map[str(src_port)]['asic_idx']:
updated_exp_port_list.append(port)
if updated_exp_port_list:
exp_port_list = updated_exp_port_list
return exp_port_list

def check_hit_count_map(self, dest_port_list, port_hit_cnt, src_port):
'''
@summary: Check if the traffic is balanced across the ECMP groups and the LAG members
@param dest_port_list : a list of ECMP entries and in each ECMP entry a list of ports
Expand All @@ -519,6 +548,9 @@ def check_hit_count_map(self, dest_port_list, port_hit_cnt):
("type", "port(s)", "exp_cnt", "act_cnt", "diff(%)"))
result = True

if self.switch_type == "chassis-packet":
dest_port_list = self.check_same_asic(src_port, dest_port_list)

asic_list = defaultdict(list)
if self.switch_type == "voq":
asic_list['voq'] = dest_port_list
Expand Down
39 changes: 36 additions & 3 deletions ansible/roles/test/files/ptftests/py3/hash_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ def check_hash(self, hash_key):
dst_ip = self.dst_ip_interval.get_random_ip()
src_port, exp_port_lists, next_hops = self.get_src_and_exp_ports(
dst_ip)
if self.switch_type == "chassis-packet":
exp_port_lists = self.check_same_asic(src_port, exp_port_lists)
logging.info("dst_ip={}, src_port={}, exp_port_lists={}".format(
dst_ip, src_port, exp_port_lists))
for exp_port_list in exp_port_lists:
Expand Down Expand Up @@ -201,7 +203,7 @@ def check_hash(self, hash_key):
hash_key, hit_count_map))

for next_hop in next_hops:
self.check_balancing(next_hop.get_next_hop(), hit_count_map)
self.check_balancing(next_hop.get_next_hop(), hit_count_map, src_port)

def check_ip_route(self, hash_key, src_port, dst_ip, dst_port_lists):
if ip_network(six.text_type(dst_ip)).version == 4:
Expand Down Expand Up @@ -443,7 +445,34 @@ def check_within_expected_range(self, actual, expected):
percentage = (actual - expected) / float(expected)
return (percentage, abs(percentage) <= self.balancing_range)

def check_balancing(self, dest_port_list, port_hit_cnt):
def check_same_asic(self, src_port, exp_port_list):
updated_exp_port_list = list()
for port in exp_port_list:
if type(port) == list:
per_port_list = list()
for per_port in port:
if self.ptf_test_port_map[str(per_port)]['target_dut'] \
!= self.ptf_test_port_map[str(src_port)]['target_dut']:
return exp_port_list
else:
if self.ptf_test_port_map[str(per_port)]['asic_idx'] \
== self.ptf_test_port_map[str(src_port)]['asic_idx']:
per_port_list.append(per_port)
if per_port_list:
updated_exp_port_list.append(per_port_list)
else:
if self.ptf_test_port_map[str(port)]['target_dut'] \
!= self.ptf_test_port_map[str(src_port)]['target_dut']:
return exp_port_list
else:
if self.ptf_test_port_map[str(port)]['asic_idx'] \
== self.ptf_test_port_map[str(src_port)]['asic_idx']:
updated_exp_port_list.append(port)
if updated_exp_port_list:
exp_port_list = updated_exp_port_list
return exp_port_list

def check_balancing(self, dest_port_list, port_hit_cnt, src_port):
'''
@summary: Check if the traffic is balanced across the ECMP groups and the LAG members
@param dest_port_list : a list of ECMP entries and in each ECMP entry a list of ports
Expand All @@ -454,6 +483,8 @@ def check_balancing(self, dest_port_list, port_hit_cnt):
logging.info("%-10s \t %-10s \t %10s \t %10s \t %10s" %
("type", "port(s)", "exp_cnt", "act_cnt", "diff(%)"))
result = True
if self.switch_type == "chassis-packet":
dest_port_list = self.check_same_asic(src_port, dest_port_list)

asic_list = defaultdict(list)
if self.switch_type == "voq":
Expand Down Expand Up @@ -743,6 +774,8 @@ def check_hash(self, hash_key):
outer_dst_ip = '80.1.0.32'
src_port, exp_port_lists, next_hops = self.get_src_and_exp_ports(
outer_dst_ip)
if self.switch_type == "chassis-packet":
exp_port_lists = self.check_same_asic(src_port, exp_port_lists)

logging.info("outer_src_ip={}, outer_dst_ip={}, src_port={}, exp_port_lists={}".format(
outer_src_ip, outer_dst_ip, src_port, exp_port_lists))
Expand Down Expand Up @@ -791,7 +824,7 @@ def check_hash(self, hash_key):
hash_key, hit_count_map))

for next_hop in next_hops:
self.check_balancing(next_hop.get_next_hop(), hit_count_map)
self.check_balancing(next_hop.get_next_hop(), hit_count_map, src_port)

def runTest(self):
"""
Expand Down

0 comments on commit db8c150

Please sign in to comment.