Example #1
0
def test_upgrade_path(localhost, duthost, ptfhost, upgrade_path_lists, ptf_params, setup):
    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)
            # Perform a cold reboot
            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)
            test_params = ptf_params
            test_params['target_version'] = target_version
            test_params['reboot_type'] = get_reboot_type(duthost)
            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'))

            ptf_runner(ptfhost,
                       "ptftests",
                       "advanced-reboot.ReloadTest",
                       platform_dir="ptftests",
                       params=test_params,
                       platform="remote",
                       qlen=10000,
                       log_file=log_file)
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)