Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
16 changes: 8 additions & 8 deletions ansible/roles/test/files/ptftests/advanced-reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ def handle_post_reboot_test_reports(self):
self.assertTrue(is_good, errors)

def runTest(self):
self.pre_reboot_test_setup()
self.pre_reboot_test_setup()
try:
self.log("Check that device is alive and pinging")
self.fails['dut'].add("DUT is not ready for test")
Expand All @@ -989,6 +989,8 @@ def runTest(self):
self.handle_warm_reboot_health_check()
self.handle_post_reboot_health_check()

# Check sonic version after reboot
self.check_sonic_version_after_reboot()
except Exception as e:
self.fails['dut'].add(e)
finally:
Expand Down Expand Up @@ -1019,10 +1021,8 @@ def check_sonic_version_after_reboot(self):
current_version = str(stdout[0]).replace('\n', '')
self.log("Current={} Target={}".format(current_version, target_version))
if current_version != target_version:
self.fails['dut'].add("Sonic upgrade failed. Target={} Current={}".format(\
raise Exception("Sonic upgrade failed. Target={} Current={}".format(\
target_version, current_version))
return False
return True

def extract_no_cpu_replies(self, arr):
"""
Expand All @@ -1047,9 +1047,6 @@ def reboot_dut(self):
if stderr != []:
self.log("stderr from %s: %s" % (self.reboot_type, str(stderr)))
self.log("return code from %s: %s" % (self.reboot_type, str(return_code)))
# Check sonic version after reboot
if not self.check_sonic_version_after_reboot():
thread.interrupt_main()

# Note: a timeout reboot in ssh session will return a 255 code
if return_code not in [0, 255]:
Expand Down Expand Up @@ -1323,12 +1320,15 @@ def check_forwarding_resume(self):
return self.asic_state.get_state_time(state), self.get_asic_vlan_reachability()

def ping_data_plane(self, light_probe=True):
self.apply_filter_all_ports("tcp dst port 5000")
self.dataplane.flush()
replies_from_servers = self.pingFromServers()
if replies_from_servers > 0 or not light_probe:
replies_from_upper = self.pingFromUpperTier()
else:
replies_from_upper = 0

self.apply_filter_all_ports("")
return replies_from_servers, replies_from_upper

def wait_dut_to_warm_up(self):
Expand All @@ -1354,7 +1354,7 @@ def wait_dut_to_warm_up(self):
up_time = datetime.datetime.now()
up_secs = (datetime.datetime.now() - up_time).total_seconds()
if up_secs > dut_stabilize_secs:
break;
break
else:
# reset up_time
up_time = None
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/arp_responder.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __del__(self):
self.socket.close()

def bind(self):
self.socket = scapy2.conf.L2listen(iface=self.iface)
self.socket = scapy2.conf.L2listen(iface=self.iface, filter='arp')

def handler(self):
return self.socket
Expand Down
22 changes: 9 additions & 13 deletions tests/upgrade_path/test_upgrade_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
from datetime import datetime

from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # lgtm[py/unused-import]
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # lgtm[py/unused-import]
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

This required as all interface on new ptfdocker would have the same mac address.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. I'll recover it back.

from tests.common.fixtures.ptfhost_utils import remove_ip_addresses # lgtm[py/unused-import]
from tests.common.fixtures.ptfhost_utils import copy_arp_responder_py # lgtm[py/unused-import]

pytestmark = [
pytest.mark.topology('any')
pytest.mark.topology('any'),
pytest.mark.sanity_check(skip_sanity=True),
pytest.mark.disable_loganalyzer
]

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -49,9 +52,6 @@ def cleanup(localhost, ptfhost, duthost, upgrade_path_lists):

def prepare_ptf(ptfhost, duthost):
logger.info("Preparing ptfhost")
ptfhost.script("./scripts/remove_ip.sh")
ptfhost.copy(src="../ansible/roles/test/files/helpers/arp_responder.py",
dest="/opt")

# Prapare vlan conf file
mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
Expand Down Expand Up @@ -80,7 +80,7 @@ def prepare_ptf(ptfhost, duthost):


@pytest.fixture(scope="module")
def ptf_params(duthost, nbrhosts):
def ptf_params(duthost, nbrhosts, creds):

mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
lo_v6_prefix = ""
Expand All @@ -96,14 +96,10 @@ def ptf_params(duthost, nbrhosts):
#TODO:Update to vm_hosts.append(value['host'].host.mgmt_ip)
vm_hosts.append(value['host'].host.options['inventory_manager'].get_host(value['host'].hostname).vars['ansible_host'])

hostVars = duthost.host.options['variable_manager']._hostvars[duthost.hostname]
inventory = hostVars['inventory_file'].split('/')[-1]
secrets = duthost.host.options['variable_manager']._hostvars[duthost.hostname]['secret_group_vars']

ptf_params = {
"verbose": False,
"dut_username": secrets[inventory]['sonicadmin_user'],
"dut_password": secrets[inventory]['sonicadmin_password'],
"dut_username": creds.get('sonicadmin_user'),
"dut_password": creds.get('sonicadmin_password'),
"dut_hostname": duthost.host.options['inventory_manager'].get_host(duthost.hostname).vars['ansible_host'],
"reboot_limit_in_seconds": 30,
"reboot_type": "warm-reboot",
Expand Down Expand Up @@ -161,6 +157,6 @@ def test_upgrade_path(localhost, duthost, ptfhost, upgrade_path_lists, ptf_param
platform_dir="ptftests",
params=test_params,
platform="remote",
qlen=1000,
qlen=10000,
log_file=log_file)