Skip to content

Commit

Permalink
Add pseudo route/link flap test
Browse files Browse the repository at this point in the history
  • Loading branch information
anish-n committed Feb 1, 2021
1 parent 63034b2 commit 6594039
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
23 changes: 23 additions & 0 deletions ansible/roles/test/files/ptftests/fg_ecmp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,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
35 changes: 34 additions & 1 deletion tests/ecmp/test_fgnhg.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def fg_ecmp(ptfhost, duthost, router_mac, net_ports, port_list, ip_to_port, bank
for port in port_list:
exp_flow_count[port] = flows_per_nh

flows_to_redist = exp_flow_count[bank_0_port[0]]
flows_to_redist = exp_flow_count[shutdown_link]
for port in bank_0_port:
if port != shutdown_link:
exp_flow_count[port] = exp_flow_count[port] + flows_to_redist/(len(bank_0_port) - 1)
Expand Down Expand Up @@ -382,6 +382,39 @@ def fg_ecmp(ptfhost, duthost, router_mac, net_ports, port_list, ip_to_port, bank
log_file=log_file)


### Simulate route and link flap conditions by toggling the route
### and ensure that there is no orch crash and data plane impact
logger.info("Simulate route and link flap conditions by toggling the route "
"and ensure that there is no orch crash and data plane impact")
nexthop_to_toggle = ip_to_port.keys()[0]

cmd = "for i in {1..50}; do "
cmd = cmd + vtysh_base_cmd
cmd = cmd + " -c 'no {} {} {}';".format(ipcmd, prefix, nexthop_to_toggle)
cmd = cmd + " sleep 0.5;"
cmd = cmd + vtysh_base_cmd
cmd = cmd + " -c '{} {} {}';".format(ipcmd, prefix, nexthop_to_toggle)
cmd = cmd + " sleep 0.5;"
cmd = cmd + " done;"

configure_dut(duthost, cmd)
time.sleep(30)

result = duthost.shell(argv=["pgrep", "orchagent"])
pytest_assert(int(result["stdout"]) > 0, "Orchagent is not running")

log_file = "/tmp/fg_ecmp_test.FgEcmpTest.{}.hash_check_post_flap_test.log".format(test_time)
ptf_runner(ptfhost,
"ptftests",
"fg_ecmp_test.FgEcmpTest",
platform_dir="ptftests",
params={"test_case": 'bank_check',
"exp_flow_count": exp_flow_count,
"config_file": FG_ECMP_CFG},
qlen=1000,
log_file=log_file)


### Send the same flows again, but disable all next-hops in a bank
### to test flow redistribution to the other bank
logger.info("Send the same flows again, but disable all next-hops in a bank "
Expand Down

0 comments on commit 6594039

Please sign in to comment.