Skip to content

[Advanced_reboot] Add test for two loopbacks in warm reboot test #7324

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
20 changes: 14 additions & 6 deletions ansible/roles/test/files/ptftests/advanced-reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def __init__(self):
self.check_param('default_ip_range', '', required=True)
self.check_param('vlan_ip_range', '', required=True)
self.check_param('lo_prefix', '', required=False)
self.check_param('lo_prefix2', '', required=False)
self.check_param('lo_v6_prefix', 'fc00:1::/64', required=False)
self.check_param('arista_vms', [], required=True)
self.check_param('min_bgp_gr_timeout', 15, required=False)
Expand Down Expand Up @@ -569,7 +570,10 @@ def setUp(self):
raise ValueError('Not supported reboot_type %s' % self.reboot_type)
self.dut_mac = self.test_params['dut_mac']
self.vlan_mac = self.test_params['vlan_mac']
self.ping_dut_packets = []
self.ping_dut_macjump_packet = []
self.lo_prefix = self.test_params['lo_prefix']
self.lo_prefix2 = self.test_params['lo_prefix2']

if self.kvm_test:
self.log("This test is for KVM platform")
Expand Down Expand Up @@ -617,7 +621,9 @@ def setUp(self):

self.generate_from_t1()
self.generate_from_vlan()
self.generate_ping_dut_lo()
self.generate_ping_dut_lo(self.lo_prefix)
if self.lo_prefix2 != '':
self.generate_ping_dut_lo(self.lo_prefix2)
self.generate_arp_ping_packet()

if 'warm-reboot' in self.reboot_type:
Expand Down Expand Up @@ -749,9 +755,8 @@ def generate_from_vlan(self):

self.from_vlan_packet = str(packet)

def generate_ping_dut_lo(self):
self.ping_dut_packets = []
dut_lo_ipv4 = self.lo_prefix.split('/')[0]
def generate_ping_dut_lo(self, lo_prefix):
dut_lo_ipv4 = lo_prefix.split('/')[0]
for src_port in self.vlan_host_ping_map:
src_addr = random.choice(self.vlan_host_ping_map[src_port].keys())
src_mac = self.hex_to_mac(self.vlan_host_ping_map[src_port][src_addr])
Expand All @@ -765,9 +770,11 @@ def generate_ping_dut_lo(self):
ip_src=dut_lo_ipv4,
icmp_type='echo-reply')

self.ping_dut_macjump_packet = simple_icmp_packet(eth_dst=self.dut_mac,
packet = simple_icmp_packet(eth_dst=self.dut_mac,
ip_src=self.from_server_src_addr,
ip_dst=dut_lo_ipv4)

self.ping_dut_macjump_packet.append(packet)

self.ping_dut_exp_packet = Mask(exp_packet)
self.ping_dut_exp_packet.set_do_not_care_scapy(scapy.Ether, "dst")
Expand Down Expand Up @@ -1975,7 +1982,8 @@ def pingFromUpperTier(self):
def pingDut(self):
if "allow_mac_jumping" in self.test_params and self.test_params['allow_mac_jumping']:
for i in xrange(self.ping_dut_pkts):
testutils.send_packet(self, self.random_port(self.vlan_ports), self.ping_dut_macjump_packet)
for i in range(ping_dut_macjump_packet):
testutils.send_packet(self, self.random_port(self.vlan_ports), self.ping_dut_macjump_packet[i])
else:
for i in xrange(self.ping_dut_pkts):
src_port, packet = random.choice(self.ping_dut_packets)
Expand Down
5 changes: 5 additions & 0 deletions tests/common/fixtures/advanced_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ def __buildTestbedData(self, tbinfo):
self.rebootData['vlan_mac'] = vlan_mac
self.rebootData['lo_prefix'] = "%s/%s" % (self.mgFacts['minigraph_lo_interfaces'][0]['addr'],
self.mgFacts['minigraph_lo_interfaces'][0]['prefixlen'])
self.rebootData['lo_prefix2'] = ""
for data in self.mgFacts['minigraph_lo_interfaces'][1:]:
if (data['prefixlen'] == 32):
self.rebootData['lo_prefix2'] = "%s/%s" % (data['addr'], data['prefixlen'])

vlan_ip_range = dict()
for vlan in self.mgFacts['minigraph_vlan_interfaces']:
Expand Down Expand Up @@ -673,6 +677,7 @@ def __runPtfRunner(self, rebootOper=None):
"dut_mac": self.rebootData['dut_mac'],
"vlan_mac": self.rebootData['vlan_mac'],
"lo_prefix": self.rebootData['lo_prefix'],
"lo_prefix2": self.rebootData['lo_prefix2'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will throw KeyError when lo_prefix2 key is not found in dict. That can happen when len(self.mgFacts['minigraph_lo_interfaces']) <= 1

"default_ip_range": self.rebootData['default_ip_range'],
"vlan_ip_range": self.rebootData['vlan_ip_range'],
"lo_v6_prefix": self.rebootData['lo_v6_prefix'],
Expand Down