Skip to content

Commit ff86a89

Browse files
author
Shuotian Cheng
committed
[FIB]: Add more logging messages
1 parent 3db159c commit ff86a89

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

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

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class FibTest(BaseTest):
5959
# Class variables
6060
#---------------------------------------------------------------------
6161
DEFAULT_BALANCING_RANGE = 0.25
62-
BALANCING_TEST_TIMES = 5000
62+
BALANCING_TEST_TIMES = 10000
6363
DEFAULT_BALANCING_TEST_RATIO = 0.0001
6464

6565
def __init__(self):
@@ -105,14 +105,17 @@ def check_ip_range(self, ipv4=True):
105105
ip_ranges = self.fib.ipv6_ranges()
106106

107107
for ip_range in ip_ranges:
108+
108109
# Get the expected list of ports that would receive the packets
109110
exp_port_list = self.fib[ip_range.get_first_ip()].get_next_hop_list()
110111
# Choose random one source port from all ports excluding the expected ones
111112
src_port = random.choice([port for port in self.src_ports if port not in exp_port_list])
112113

113-
if not len(exp_port_list):
114+
if not exp_port_list:
114115
continue
115116

117+
logging.info("Check IP range:" + str(ip_range) + " on " + str(exp_port_list) + "...")
118+
116119
# Send a packet with the first IP in the range
117120
self.check_ip_route(src_port, ip_range.get_first_ip(), exp_port_list, ipv4)
118121
# Send a packet with the last IP in the range
@@ -124,6 +127,7 @@ def check_ip_range(self, ipv4=True):
124127

125128
# Test traffic balancing across ECMP/LAG members
126129
if len(exp_port_list) > 1 and random.random() < self.balancing_test_ratio:
130+
logging.info("Check IP range balancing...")
127131
dst_ip = ip_range.get_random_ip()
128132
hit_count_map = {}
129133
for i in range(0, self.BALANCING_TEST_TIMES):
@@ -222,9 +226,6 @@ def check_within_expected_range(self, actual, expected):
222226
@return (percentage, bool)
223227
'''
224228
percentage = (actual - expected) / float(expected)
225-
'''
226-
print "%10s" % str(round(percentage, 4)*100) + '%'
227-
'''
228229
return (percentage, abs(percentage) <= self.balancing_range)
229230

230231
#---------------------------------------------------------------------
@@ -236,24 +237,24 @@ def check_balancing(self, dest_port_list, port_hit_cnt):
236237
@return bool
237238
'''
238239

239-
logging.info("%-10s \t %10s \t %10s \t %10s" % ("port(s)", "exp_cnt", "act_cnt", "diff(%)"))
240+
logging.info("%10s \t %-10s \t %10s \t %10s \t %10s" % ("type", "port(s)", "exp_cnt", "act_cnt", "diff(%)"))
240241
result = True
241242

242-
total_hit_cnt = float(sum(port_hit_cnt.values()))
243+
total_hit_cnt = sum(port_hit_cnt.values())
243244
for ecmp_entry in dest_port_list:
244-
total_entry_hit_cnt = 0.0
245+
total_entry_hit_cnt = 0
245246
for member in ecmp_entry:
246247
total_entry_hit_cnt += port_hit_cnt.get(member, 0)
247-
(p, r) = self.check_within_expected_range(total_entry_hit_cnt, total_hit_cnt/len(dest_port_list))
248-
logging.info("%-10s \t %10d \t %10d \t %10s"
249-
% (str(ecmp_entry), total_hit_cnt/len(dest_port_list), total_entry_hit_cnt, str(round(p, 4)*100) + '%'))
248+
(p, r) = self.check_within_expected_range(total_entry_hit_cnt, float(total_hit_cnt)/len(dest_port_list))
249+
logging.info("%10s \t %-10s \t %10d \t %10d \t %10s"
250+
% ("ECMP", str(ecmp_entry), total_hit_cnt/len(dest_port_list), total_entry_hit_cnt, str(round(p, 4)*100) + '%'))
250251
result &= r
251-
if len(ecmp_entry) == 1:
252+
if len(ecmp_entry) == 1 or total_entry_hit_cnt == 0:
252253
continue
253254
for member in ecmp_entry:
254-
(p, r) = self.check_within_expected_range(port_hit_cnt.get(member, 0), total_entry_hit_cnt/len(ecmp_entry))
255-
logging.info("%-10s \t %10d \t %10d \t %10s"
256-
% (str(member), total_entry_hit_cnt/len(ecmp_entry), port_hit_cnt.get(member, 0), str(round(p, 4)*100) + '%'))
255+
(p, r) = self.check_within_expected_range(port_hit_cnt.get(member, 0), float(total_entry_hit_cnt)/len(ecmp_entry))
256+
logging.info("%10s \t %-10s \t %10d \t %10d \t %10s"
257+
% ("LAG", str(member), total_entry_hit_cnt/len(ecmp_entry), port_hit_cnt.get(member, 0), str(round(p, 4)*100) + '%'))
257258
result &= r
258259

259260
assert result

ansible/roles/test/tasks/fib.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@
6262
- fib_info='/root/fib_info.txt'
6363
- ipv4={{ipv4}}
6464
- ipv6={{ipv6}}
65-
ptf_extra_options: "--relax --log-dir /tmp/"
65+
ptf_extra_options: "--relax --debug info --log-file /tmp/fib_test.FibTest.ipv4.{{ipv4}}.ipv6.{{ipv6}}.{{ansible_date_time.iso8601}}.log "

0 commit comments

Comments
 (0)