Skip to content

Commit

Permalink
Fix rebase issue and make the vxlan port used for inner hashing confi…
Browse files Browse the repository at this point in the history
…gured from the top level (#4780)
  • Loading branch information
anish-n authored Dec 7, 2021
1 parent 1f05e4d commit bd06538
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
16 changes: 12 additions & 4 deletions ansible/roles/test/files/ptftests/fg_ecmp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ def setUp(self):
self.inner_hashing = graph['inner_hashing']
self.src_ipv4_interval = lpm.LpmDict.IpInterval(ipaddress.ip_address(unicode(IPV4_SRC_IP_RANGE[0])), ipaddress.ip_address(unicode(IPV4_SRC_IP_RANGE[1])))
self.src_ipv6_interval = lpm.LpmDict.IpInterval(ipaddress.ip_address(unicode(IPV6_SRC_IP_RANGE[0])), ipaddress.ip_address(unicode(IPV6_SRC_IP_RANGE[1])))
self.vxlan_port = graph['vxlan_port']

self.log(self.net_ports)
self.log(self.serv_ports)
self.log(self.exp_port_set_one)
Expand All @@ -174,6 +176,7 @@ def setUp(self):
self.log(self.num_flows)
self.log(self.inner_hashing)
self.log(self.exp_flow_count)
self.log(self.vxlan_port)

if self.test_case != 'hash_check_warm_boot':
# We send bi-directional traffic during warm boot due to
Expand Down Expand Up @@ -227,10 +230,11 @@ def fg_ecmp(self):
# and generate a flow to port map
self.log("Creating flow to port map ...")
for i in range(0, self.num_flows):
if ipv4:
if ipv4 or self.inner_hashing:
src_ip = self.src_ipv4_interval.get_random_ip()
else:
src_ip = self.src_ipv6_interval.get_random_ip()

if self.inner_hashing:
in_port = random.choice(self.net_ports)
else:
Expand Down Expand Up @@ -274,7 +278,11 @@ def fg_ecmp(self):
self.log("Ensure that all packets were received ...")
total_num_pkts_lost = 0
for i in range(0, self.num_flows):
src_ip = str(base_ip + i)
if ipv4 or self.inner_hashing:
src_ip = self.src_ipv4_interval.get_random_ip()
else:
src_ip = self.src_ipv6_interval.get_random_ip()

if self.inner_hashing:
in_port = random.choice(self.net_ports)
else:
Expand Down Expand Up @@ -485,7 +493,7 @@ def send_rcv_ipv4_pkt(self, in_port, sport, dport,
ip_dst=self.dst_ip,
ip_ttl=64,
udp_sport=rand_int,
udp_dport=4789,
udp_dport=self.vxlan_port,
vxlan_vni=20000+rand_int,
with_udp_chksum=False,
inner_frame=pkt)
Expand Down Expand Up @@ -521,7 +529,7 @@ def send_rcv_ipv6_pkt(self, in_port, sport, dport,
ipv6_src='2:2:2::' + str(rand_int),
ipv6_dst=self.dst_ip,
udp_sport=rand_int,
udp_dport=4789,
udp_dport=self.vxlan_port,
vxlan_vni=20000+rand_int,
with_udp_chksum=False,
inner_frame=pkt)
Expand Down
24 changes: 23 additions & 1 deletion tests/ecmp/test_fgnhg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
NUM_FLOWS = 1000
ptf_to_dut_port_map = {}

VXLAN_PORT = 13330
DUT_VXLAN_PORT_JSON_FILE = '/tmp/vxlan.switch.json'

pytestmark = [
pytest.mark.topology('t0'),
pytest.mark.asic('mellanox'),
Expand Down Expand Up @@ -166,7 +169,8 @@ def create_fg_ptf_config(ptfhost, ip_to_port, port_list, bank_0_port, bank_1_por
"dut_mac": router_mac,
"net_ports": net_ports,
"inner_hashing": USE_INNER_HASHING,
"num_flows": NUM_FLOWS
"num_flows": NUM_FLOWS,
"vxlan_port": VXLAN_PORT
}

logger.info("fg_ecmp config sent to PTF: " + str(fg_ecmp))
Expand All @@ -182,6 +186,21 @@ def setup_test_config(duthost, ptfhost, cfg_facts, router_mac, net_ports, vlan_i
return port_list, ip_to_port, bank_0_port, bank_1_port


def configure_switch_vxlan_cfg(duthost):
vxlan_switch_config = [{
"SWITCH_TABLE:switch": {
"vxlan_port": VXLAN_PORT
},
"OP": "SET"
}]

logger.info("Copying vxlan.switch.json with data: " + str(vxlan_switch_config))

duthost.copy(content=json.dumps(vxlan_switch_config, indent=4), dest=DUT_VXLAN_PORT_JSON_FILE)
duthost.shell("docker cp {} swss:/vxlan.switch.json".format(DUT_VXLAN_PORT_JSON_FILE))
duthost.shell("docker exec swss sh -c \"swssconfig /vxlan.switch.json\"")


def configure_dut(duthost, cmd):
logger.info("Configuring dut with " + cmd)
duthost.shell(cmd, executable="/bin/bash")
Expand Down Expand Up @@ -575,6 +594,9 @@ def common_setup_teardown(tbinfo, duthosts, rand_one_dut_hostname, ptfhost):
for name, val in mg_facts['minigraph_portchannels'].items():
members = [mg_facts['minigraph_ptf_indices'][member] for member in val['members']]
net_ports.extend(members)
if USE_INNER_HASHING is True:
configure_switch_vxlan_cfg(duthost)

yield duthost, cfg_facts, router_mac, net_ports

finally:
Expand Down

0 comments on commit bd06538

Please sign in to comment.