Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test_fgnhg] Test enhancement for link operational change and matchmode changes to fine grained ECMP #2670

Merged
merged 8 commits into from
Apr 6, 2021
66 changes: 44 additions & 22 deletions ansible/roles/test/files/ptftests/fg_ecmp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def log(self, message):
logging.info(message)


def trigger_mac_learning(self, ip_to_port):
for src_ip, src_port in ip_to_port.items():
def trigger_mac_learning(self, exp_ports):
for src_port in exp_ports:
pkt = simple_eth_packet(
eth_dst=self.router_mac,
eth_src=self.dataplane.get_mac(0, src_port),
Expand Down Expand Up @@ -90,7 +90,6 @@ def setUp(self):
self.exp_port_set_two = graph['bank_1_port']
self.dst_ip = graph['dst_ip']
self.router_mac = graph['dut_mac']
self.ip_to_port = graph['ip_to_port']
self.num_flows = graph['num_flows']
self.inner_hashing = graph['inner_hashing']

Expand All @@ -101,12 +100,11 @@ def setUp(self):
self.log(self.dst_ip)
self.log(self.router_mac)
self.log(self.test_case)
self.log(self.ip_to_port)
self.log(self.num_flows)
self.log(self.inner_hashing)
self.log(self.exp_flow_count)

self.trigger_mac_learning(self.ip_to_port)
self.trigger_mac_learning(self.exp_ports)
time.sleep(3)


Expand Down Expand Up @@ -180,6 +178,29 @@ def fg_ecmp(self):
assert port_idx == port
return

elif self.test_case == 'bank_check':
with open(PERSIST_MAP) as fp:
tuple_to_port_map = json.load(fp)
assert tuple_to_port_map
self.log("Send the same flows once again and verify that they end up on the same bank...")
for src_ip, port in tuple_to_port_map.iteritems():
if self.inner_hashing:
in_port = random.choice(self.net_ports)
else:
in_port = self.net_ports[0]
(port_idx, _) = self.send_rcv_ip_pkt(
in_port, src_port, dst_port, src_ip, dst_ip, self.exp_ports, ipv4)
if port in self.exp_port_set_one:
assert port_idx in self.exp_port_set_one
if port in self.exp_port_set_two:
assert port_idx in self.exp_port_set_two
hit_count_map[port_idx] = hit_count_map.get(port_idx, 0) + 1
tuple_to_port_map[src_ip] = port_idx
self.test_balancing(hit_count_map)

json.dump(tuple_to_port_map, open(PERSIST_MAP,"w"))
return

elif self.test_case == 'withdraw_nh':
self.log("Withdraw next-hop " + str(self.withdraw_nh_port) + " and ensure hash redistribution within correct bank")
with open(PERSIST_MAP) as fp:
Expand Down Expand Up @@ -231,6 +252,7 @@ def fg_ecmp(self):
hit_count_map[port_idx] = hit_count_map.get(port_idx, 0) + 1
if port_idx == self.add_nh_port:
assert (port in add_port_grp)
tuple_to_port_map[src_ip] = port_idx
else:
assert port_idx == port

Expand Down Expand Up @@ -364,25 +386,26 @@ def send_rcv_ipv6_pkt(self, in_port, sport, dport,
src_mac = self.dataplane.get_mac(0, in_port)
rand_int = random.randint(1, 254)


if self.inner_hashing:
pkt = simple_tcp_packet(
eth_dst=self.router_mac,
eth_src=src_mac,
ip_src=ip_src,
ip_dst=ip_dst,
tcp_sport=sport,
tcp_dport=dport,
ip_ttl=64)
eth_dst=self.router_mac,
eth_src=src_mac,
ip_src=ip_src,
ip_dst=ip_dst,
tcp_sport=sport,
tcp_dport=dport,
ip_ttl=64)
pkt = simple_vxlanv6_packet(
eth_dst=self.router_mac,
eth_src=src_mac,
ipv6_src='2:2:2::' + str(rand_int),
ipv6_dst=self.dst_ip,
udp_sport=rand_int,
udp_dport=4789,
vxlan_vni=rand_int,
with_udp_chksum=False,
inner_frame=pkt)
eth_dst=self.router_mac,
eth_src=src_mac,
ipv6_src='2:2:2::' + str(rand_int),
ipv6_dst=self.dst_ip,
udp_sport=rand_int,
udp_dport=4789,
vxlan_vni=rand_int,
with_udp_chksum=False,
inner_frame=pkt)
else:
pkt = simple_tcpv6_packet(
eth_dst=self.router_mac,
Expand All @@ -403,7 +426,6 @@ def send_rcv_ipv6_pkt(self, in_port, sport, dport,
return verify_packet_any_port(self, masked_exp_pkt, dst_port_list)


#---------------------------------------------------------------------
def runTest(self):
# Main function which triggers all the tests
self.fg_ecmp()
Loading