def test_warm_upgrade_sad_path(localhost, duthosts, ptfhost, rand_one_dut_hostname, nbrhosts, fanouthosts, vmhost, tbinfo, restore_image, get_advanced_reboot, verify_dut_health, advanceboot_loganalyzer, upgrade_path_lists, backup_and_restore_config_db, advanceboot_neighbor_restore, sad_case_type): duthost = duthosts[rand_one_dut_hostname] upgrade_type, from_list_images, to_list_images, _ = upgrade_path_lists from_list = from_list_images.split(',') to_list = to_list_images.split(',') assert (from_list and to_list) for from_image in from_list: for to_image in to_list: logger.info("Test upgrade path from {} to {}".format(from_image, to_image)) # Install base image logger.info("Installing {}".format(from_image)) target_version = install_sonic(duthost, from_image, tbinfo) # Perform a cold reboot logger.info("Cold reboot the DUT to make the base image as current") reboot(duthost, localhost) check_sonic_version(duthost, target_version) # Install target image logger.info("Upgrading to {}".format(to_image)) install_sonic(duthost, to_image, tbinfo) advancedReboot = get_advanced_reboot(rebootType=get_reboot_command(duthost, "warm"),\ advanceboot_loganalyzer=advanceboot_loganalyzer) sad_preboot_list, sad_inboot_list = get_sad_case_list(duthost, nbrhosts, fanouthosts, vmhost, tbinfo, sad_case_type) advancedReboot.runRebootTestcase( prebootList=sad_preboot_list, inbootList=sad_inboot_list ) reboot_cause = get_reboot_cause(duthost) logger.info("Check reboot cause. Expected cause {}".format(upgrade_type)) pytest_assert(reboot_cause == upgrade_type, "Reboot cause {} did not match the trigger - {}".format(reboot_cause, upgrade_type)) check_services(duthost)
def test_upgrade_path(localhost, duthosts, ptfhost, rand_one_dut_hostname, nbrhosts, fanouthosts, tbinfo, restore_image, get_advanced_reboot, verify_dut_health, advanceboot_loganalyzer, upgrade_path_lists): duthost = duthosts[rand_one_dut_hostname] upgrade_type, from_list_images, to_list_images, _ = upgrade_path_lists from_list = from_list_images.split(',') to_list = to_list_images.split(',') assert (from_list and to_list) for from_image in from_list: for to_image in to_list: logger.info("Test upgrade path from {} to {}".format(from_image, to_image)) # Install base image logger.info("Installing {}".format(from_image)) target_version = install_sonic(duthost, from_image, tbinfo) # Perform a cold reboot logger.info("Cold reboot the DUT to make the base image as current") reboot(duthost, localhost) check_sonic_version(duthost, target_version) # Install target image logger.info("Upgrading to {}".format(to_image)) install_sonic(duthost, to_image, tbinfo) if upgrade_type == REBOOT_TYPE_COLD: # advance-reboot test (on ptf) does not support cold reboot yet reboot(duthost, localhost) else: advancedReboot = get_advanced_reboot(rebootType=get_reboot_command(duthost, upgrade_type),\ advanceboot_loganalyzer=advanceboot_loganalyzer) advancedReboot.runRebootTestcase() reboot_cause = get_reboot_cause(duthost) logger.info("Check reboot cause. Expected cause {}".format(upgrade_type)) pytest_assert(reboot_cause == upgrade_type, "Reboot cause {} did not match the trigger - {}".format(reboot_cause, upgrade_type)) check_services(duthost)
def check_reboot_type(self): """ Perform a match of reboot-cause and reboot-trigger """ logging.info("Check reboot cause") reboot_cause = get_reboot_cause(self.duthost) if reboot_cause != self.reboot_type: raise RebootHealthError("Reboot cause {} did not match the trigger {}".format(reboot_cause, self.reboot_type))
def test_upgrade_path(localhost, duthosts, rand_one_dut_hostname, ptfhost, upgrade_path_lists, setup, creds, tbinfo): duthost = duthosts[rand_one_dut_hostname] upgrade_type, from_list_images, to_list_images, _ = upgrade_path_lists from_list = from_list_images.split(',') to_list = to_list_images.split(',') assert (from_list and to_list) for from_image in from_list: for to_image in to_list: logger.info("Test upgrade path from {} to {}".format( from_image, to_image)) # Install base image logger.info("Installing {}".format(from_image)) target_version = install_sonic(duthost, from_image, tbinfo) # Perform a cold reboot logger.info( "Cold reboot the DUT to make the base image as current") reboot(duthost, localhost) check_sonic_version(duthost, target_version) # Install target image logger.info("Upgrading to {}".format(to_image)) target_version = install_sonic(duthost, to_image, tbinfo) test_params = ptf_params(duthost, creds, tbinfo, upgrade_type) test_params['target_version'] = target_version prepare_testbed_ssh_keys(duthost, ptfhost, test_params['dut_username']) log_file = "/tmp/advanced-reboot.ReloadTest.{}.log".format( datetime.now().strftime('%Y-%m-%d-%H:%M:%S')) if test_params['reboot_type'] == reboot_ctrl_dict.get( REBOOT_TYPE_COLD).get("command"): # advance-reboot test (on ptf) does not support cold reboot yet reboot(duthost, localhost) else: if test_params['reboot_type'] == reboot_ctrl_dict.get( REBOOT_TYPE_SOFT).get("command"): # advance-reboot test (on ptf) does not support SOFT reboot yet reboot(duthost, localhost, REBOOT_TYPE_SOFT) else: ptf_runner(ptfhost, "ptftests", "advanced-reboot.ReloadTest", platform_dir="ptftests", params=test_params, platform="remote", qlen=10000, log_file=log_file) reboot_cause = get_reboot_cause(duthost) logger.info( "Check reboot cause. Expected cause {}".format(upgrade_type)) pytest_assert( reboot_cause == upgrade_type, "Reboot cause {} did not match the trigger - {}".format( reboot_cause, upgrade_type)) check_services(duthost)
def check_reboot_cause(duthost, expected_cause): reboot_cause = get_reboot_cause(duthost) logging.info("Checking cause from dut {} to expected {}".format( reboot_cause, expected_cause)) return reboot_cause == expected_cause