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
57 changes: 42 additions & 15 deletions ansible/roles/test/files/ptftests/fib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import ptf
import ptf.packet as scapy

from collections import Iterable
from collections import Iterable, defaultdict

from ptf import config
from ptf.base_tests import BaseTest
Expand Down Expand Up @@ -73,6 +73,7 @@ class FibTest(BaseTest):
DEFAULT_BALANCING_TEST_NUMBER = 1
ACTION_FWD = 'fwd'
ACTION_DROP = 'drop'
DEFAULT_SWITCH_TYPE = 'voq'

_required_params = [
'fib_info_files',
Expand Down Expand Up @@ -134,6 +135,7 @@ def setUp(self):
self.balancing_test_times = self.test_params.get('balancing_test_times', self.BALANCING_TEST_TIMES)
self.balancing_test_number = self.test_params.get('balancing_test_number', self.DEFAULT_BALANCING_TEST_NUMBER)
self.balancing_test_count = 0
self.switch_type = self.test_params.get('switch_type', self.DEFAULT_SWITCH_TYPE)

self.pkt_action = self.test_params.get('pkt_action', self.ACTION_FWD)
self.ttl = self.test_params.get('ttl', 64)
Expand Down Expand Up @@ -479,26 +481,51 @@ def check_hit_count_map(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

asic_list = defaultdict(list)
if self.switch_type == "voq":
asic_list['voq'] = dest_port_list
else:
for port in dest_port_list:
if type(port) == list:
port_map = self.ptf_test_port_map[str(port[0])]
asic_id = port_map.get('asic_idx',0)
member = asic_list.get(asic_id)
if member is None:
member = []
member.append(port)
asic_list[asic_id] = member
else:
port_map = self.ptf_test_port_map[str(port)]
asic_id = port_map.get('asic_idx',0)
member = asic_list.get(asic_id)
if member is None:
member = []
member.append(port)
asic_list[asic_id] = member

total_hit_cnt = 0
for ecmp_entry in dest_port_list:
for member in ecmp_entry:
total_hit_cnt += port_hit_cnt.get(member, 0)

for ecmp_entry in dest_port_list:
total_entry_hit_cnt = 0
for member in ecmp_entry:
total_entry_hit_cnt += port_hit_cnt.get(member, 0)
(p, r) = self.check_within_expected_range(total_entry_hit_cnt, float(total_hit_cnt)/len(dest_port_list))
logging.info("%-10s \t %-10s \t %10d \t %10d \t %10s"
% ("ECMP", str(ecmp_entry), total_hit_cnt//len(dest_port_list), total_entry_hit_cnt, str(round(p, 4)*100) + '%'))
result &= r
if len(ecmp_entry) == 1 or total_entry_hit_cnt == 0:
continue
for member in ecmp_entry:
(p, r) = self.check_within_expected_range(port_hit_cnt.get(member, 0), float(total_entry_hit_cnt)/len(ecmp_entry))

total_hit_cnt = total_hit_cnt//len(asic_list.keys())

for asic_member in asic_list.values():
for ecmp_entry in asic_member:
total_entry_hit_cnt = 0
for member in ecmp_entry:
total_entry_hit_cnt += port_hit_cnt.get(member, 0)
(p, r) = self.check_within_expected_range(total_entry_hit_cnt, float(total_hit_cnt)/len(asic_member))
logging.info("%-10s \t %-10s \t %10d \t %10d \t %10s"
% ("LAG", str(member), total_entry_hit_cnt//len(ecmp_entry), port_hit_cnt.get(member, 0), str(round(p, 4)*100) + '%'))
% ("ECMP", str(ecmp_entry), total_hit_cnt//len(asic_member), total_entry_hit_cnt, str(round(p, 4)*100) + '%'))
result &= r
if len(ecmp_entry) == 1 or total_entry_hit_cnt == 0:
continue
for member in ecmp_entry:
(p, r) = self.check_within_expected_range(port_hit_cnt.get(member, 0), float(total_entry_hit_cnt)/len(ecmp_entry))
logging.info("%-10s \t %-10s \t %10d \t %10d \t %10s"
% ("LAG", str(member), total_entry_hit_cnt//len(ecmp_entry), port_hit_cnt.get(member, 0), str(round(p, 4)*100) + '%'))
result &= r

assert result

Expand Down
57 changes: 42 additions & 15 deletions ansible/roles/test/files/ptftests/py3/hash_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import six
import itertools

from collections import Iterable
from collections import Iterable, defaultdict
from ipaddress import ip_address, ip_network

import ptf
Expand All @@ -36,6 +36,7 @@ class HashTest(BaseTest):
#---------------------------------------------------------------------
DEFAULT_BALANCING_RANGE = 0.25
BALANCING_TEST_TIMES = 625
DEFAULT_SWITCH_TYPE = 'voq'

_required_params = [
'fib_info_files',
Expand Down Expand Up @@ -85,6 +86,7 @@ def setUp(self):

self.balancing_range = self.test_params.get('balancing_range', self.DEFAULT_BALANCING_RANGE)
self.balancing_test_times = self.test_params.get('balancing_test_times', self.BALANCING_TEST_TIMES)
self.switch_type = self.test_params.get('switch_type', self.DEFAULT_SWITCH_TYPE)

self.ignore_ttl = self.test_params.get('ignore_ttl', False)
self.single_fib = self.test_params.get('single_fib_for_duts', 'multiple-fib')
Expand Down Expand Up @@ -403,26 +405,51 @@ 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

asic_list = defaultdict(list)
if self.switch_type == "voq":
asic_list['voq'] = dest_port_list
else:
for port in dest_port_list:
if type(port) == list:
port_map = self.ptf_test_port_map[str(port[0])]
asic_id = port_map.get('asic_idx',0)
member = asic_list.get(asic_id)
if member is None:
member = []
member.append(port)
asic_list[asic_id] = member
else:
port_map = self.ptf_test_port_map[str(port)]
asic_id = port_map.get('asic_idx',0)
member = asic_list.get(asic_id)
if member is None:
member = []
member.append(port)
asic_list[asic_id] = member

total_hit_cnt = 0
for ecmp_entry in dest_port_list:
for member in ecmp_entry:
total_hit_cnt += port_hit_cnt.get(member, 0)

for ecmp_entry in dest_port_list:
total_entry_hit_cnt = 0
for member in ecmp_entry:
total_entry_hit_cnt += port_hit_cnt.get(member, 0)
(p, r) = self.check_within_expected_range(total_entry_hit_cnt, float(total_hit_cnt)/len(dest_port_list))
logging.info("%-10s \t %-10s \t %10d \t %10d \t %10s"
% ("ECMP", str(ecmp_entry), total_hit_cnt//len(dest_port_list), total_entry_hit_cnt, str(round(p, 4)*100) + '%'))
result &= r
if len(ecmp_entry) == 1 or total_entry_hit_cnt == 0:
continue
for member in ecmp_entry:
(p, r) = self.check_within_expected_range(port_hit_cnt.get(member, 0), float(total_entry_hit_cnt)/len(ecmp_entry))

total_hit_cnt = total_hit_cnt//len(asic_list.keys())

for asic_member in asic_list.values():
for ecmp_entry in asic_member:
total_entry_hit_cnt = 0
for member in ecmp_entry:
total_entry_hit_cnt += port_hit_cnt.get(member, 0)
(p, r) = self.check_within_expected_range(total_entry_hit_cnt, float(total_hit_cnt)/len(asic_member))
logging.info("%-10s \t %-10s \t %10d \t %10d \t %10s"
% ("LAG", str(member), total_entry_hit_cnt//len(ecmp_entry), port_hit_cnt.get(member, 0), str(round(p, 4)*100) + '%'))
% ("ECMP", str(ecmp_entry), total_hit_cnt//len(asic_member), total_entry_hit_cnt, str(round(p, 4)*100) + '%'))
result &= r
if len(ecmp_entry) == 1 or total_entry_hit_cnt == 0:
continue
for member in ecmp_entry:
(p, r) = self.check_within_expected_range(port_hit_cnt.get(member, 0), float(total_entry_hit_cnt)/len(ecmp_entry))
logging.info("%-10s \t %-10s \t %10d \t %10d \t %10s"
% ("LAG", str(member), total_entry_hit_cnt//len(ecmp_entry), port_hit_cnt.get(member, 0), str(round(p, 4)*100) + '%'))
result &= r

assert result

Expand Down
8 changes: 6 additions & 2 deletions tests/fib/test_fib.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def test_basic_fib(duthosts, ptfhost, ipv4, ipv6, mtu,
wait(30, 'Wait some time for mux active/standby state to be stable after toggled mux state')

timestamp = datetime.now().strftime('%Y-%m-%d-%H:%M:%S')
switch_type = duthosts[0].facts.get('switch_type')

# do not test load balancing for vs platform as kernel 4.9
# can only do load balance base on L3
Expand Down Expand Up @@ -106,7 +107,8 @@ def test_basic_fib(duthosts, ptfhost, ipv4, ipv6, mtu,
"testbed_mtu": mtu,
"test_balancing": test_balancing,
"ignore_ttl": ignore_ttl,
"single_fib_for_duts": single_fib_for_duts
"single_fib_for_duts": single_fib_for_duts,
"switch_type": switch_type
},
log_file=log_file,
qlen=PTF_QLEN,
Expand Down Expand Up @@ -276,6 +278,7 @@ def test_hash(add_default_route_to_dut, duthosts, fib_info_files_per_function, s
if 'dualtor' in updated_tbinfo['topo']['name']:
wait(30, 'Wait some time for mux active/standby state to be stable after toggled mux state')

switch_type = duthosts[0].facts.get('switch_type')
timestamp = datetime.now().strftime('%Y-%m-%d-%H:%M:%S')
log_file = "/tmp/hash_test.HashTest.{}.{}.log".format(ipver, timestamp)
logging.info("PTF log file: %s" % log_file)
Expand All @@ -301,7 +304,8 @@ def test_hash(add_default_route_to_dut, duthosts, fib_info_files_per_function, s
"dst_ip_range": ",".join(dst_ip_range),
"vlan_ids": VLANIDS,
"ignore_ttl":ignore_ttl,
"single_fib_for_duts": single_fib_for_duts
"single_fib_for_duts": single_fib_for_duts,
"switch_type": switch_type
},
log_file=log_file,
qlen=PTF_QLEN,
Expand Down