Skip to content

Commit

Permalink
Add support for choosing between Arista and Sonic implementation base…
Browse files Browse the repository at this point in the history
…d on neighbor type

Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
  • Loading branch information
saiarcot895 committed Apr 12, 2023
1 parent fa88a5a commit 747353d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions ansible/roles/test/files/ptftests/advanced-reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def __init__(self):
self.check_param('bgp_v4_v6_time_diff', 40, required=False)
self.check_param('asic_type', '', required=False)
self.check_param('logfile_suffix', None, required=False)
self.check_param('neighbor_type', 'eos', required=False)
if not self.test_params['preboot_oper'] or self.test_params['preboot_oper'] == 'None':
self.test_params['preboot_oper'] = None
if not self.test_params['inboot_oper'] or self.test_params['inboot_oper'] == 'None':
Expand Down Expand Up @@ -1438,7 +1439,7 @@ def neigh_lag_status_check(self):
"""
for neigh in self.ssh_targets:
self.test_params['port_channel_intf_idx'] = [x['ptf_ports'][0] for x in self.vm_dut_map if x['mgmt_addr'] == neigh][0]
self.neigh_handle = HostDevice.getHostDeviceInstance(neigh, None, self.test_params)
self.neigh_handle = HostDevice.getHostDeviceInstance(self.test_params['neighbor_type'], neigh, None, self.test_params)
self.neigh_handle.connect()
fails, flap_cnt = self.neigh_handle.verify_neigh_lag_no_flap()
self.neigh_handle.disconnect()
Expand Down Expand Up @@ -1584,7 +1585,7 @@ def cmd(self, cmds):
def peer_state_check(self, ip, queue):
self.log('SSH thread for VM {} started'.format(ip))
self.test_params['port_channel_intf_idx'] = [x['ptf_ports'][0] for x in self.vm_dut_map.values() if x['mgmt_addr'] == ip][0]
ssh = HostDevice.getHostDeviceInstance(ip, queue, self.test_params, log_cb=self.log)
ssh = HostDevice.getHostDeviceInstance(self.test_params['neighbor_type'], ip, queue, self.test_params, log_cb=self.log)
self.fails[ip], self.info[ip], self.cli_info[ip], self.logs_info[ip], self.lacp_pdu_times[ip] = ssh.run()
self.log('SSH thread for VM {} finished'.format(ip))

Expand Down
10 changes: 7 additions & 3 deletions ansible/roles/test/files/ptftests/host_device.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
class HostDevice(object):

@staticmethod
def getHostDeviceInstance(*args, **kwargs):
return sonic.Sonic(*args, **kwargs)
#return arista.Arista(*args, **kwargs)
def getHostDeviceInstance(neighbor_type, *args, **kwargs):
if neighbor_type == "eos":
return arista.Arista(*args, **kwargs)
elif neighbor_type == "sonic":
return sonic.Sonic(*args, **kwargs)
else:
raise NotImplementedError

def connect(self):
raise NotImplementedError
Expand Down
2 changes: 2 additions & 0 deletions tests/common/fixtures/advanced_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def __extractTestParam(self):
self.postRebootCheckScript = self.request.config.getoption("--post_reboot_check_script")
self.bgpV4V6TimeDiff = self.request.config.getoption("--bgp_v4_v6_time_diff")
self.new_docker_image = self.request.config.getoption("--new_docker_image")
self.neighborType = self.request.config.getoption("--neighbor_type")

# Set default reboot limit if it is not given
if self.rebootLimit is None:
Expand Down Expand Up @@ -709,6 +710,7 @@ def __runPtfRunner(self, rebootOper=None):
._hostvars[self.duthost.hostname].get("ansible_altpassword"),
"service_list": None if self.rebootType != 'service-warm-restart' else self.service_list,
"service_data": None if self.rebootType != 'service-warm-restart' else self.service_data,
"neighbor_type": self.neighborType,
}

if self.dual_tor_mode:
Expand Down

0 comments on commit 747353d

Please sign in to comment.