Beispiel #1
0
    def prep_source_files(self, device_to_deploy):
        device_folder = ConfigLoader.get_test_run_config(
            "Source_Values")["Device_Folder"]
        source_folder = FileTools.get_device_source_folder(
            device_to_deploy, device_folder)

        if source_folder is None:
            exception_message = "Haven't found any source files that match build number: {0}."
            raise Exception(
                exception_message.format(device_to_deploy.version.build))

        PrintMessage("Device found: {0}".format(source_folder))

        source_file = self._get_source_file(source_folder, device_to_deploy)

        if source_file is None:
            exception_message = "Failed to retrieve source file from: {0} for device: {1}"
            raise Exception(
                exception_message.format(source_file,
                                         device_to_deploy.device_type))

        build_number = Common.Utilities.DeploymentUtils.DeploymentHelper.get_build_version(
            source_file)
        PrintMessage("Extracted build number from zip file {0} > {1}".format(
            source_file, build_number))

        device_temp_folder = self._unzip_to_temp_folder(
            source_file, source_folder)
        PrintMessage("Source files dropped to temp folder: {0}".format(
            device_temp_folder))

        return build_number, device_temp_folder
    def __init__(self):
        test_rail_info = ConfigLoader.get_test_report_config()
        self.test_rail = TestRailAPIClient(test_rail_info['URL'],
                                           test_rail_info['User'],
                                           test_rail_info['Password'])

        self.test_sections = {}
        self.build_number = None
    def __init__(self, test_run_id, tested_build_version):
        self.tested_build_version = tested_build_version
        self.test_run_id = test_run_id

        test_rail_info = ConfigLoader.get_test_report_config()
        self.test_rail = TestRailAPIClient(
            test_rail_info['URL'],
            test_rail_info['User'],
            test_rail_info['Password'])
Beispiel #4
0
    def process_arguments_support_login():
        parser = argparse.ArgumentParser(prefix_chars='-')
        CommandLineArgumentsParser.add_argument_host_address(parser)

        parsed_args = parser.parse_args()

        Test_Context.connection_details = ConfigLoader.get_general_config(
            'DeviceConnectionDetails')

        return parsed_args
    def __init__(self):
        server_config = ConfigLoader.get_test_run_config("KVM_Server")
        self.user = UserWrapper(server_config['User'],
                                server_config['Password'], None)

        super(KVMServer, self).__init__(self.user, server_config['Host'])
        self.delaybeforesend = 0.2

        self.virsh_comm = VirshComm(self)
        self.temp_folder = None
Beispiel #6
0
    def _copy_tar_file(self, build_number, ntd_release_version):
        version_to_deploy = Version(ntd_release_version)
        version_to_deploy.build = build_number
        herc_machine = ConfigLoader.get_deployment_config("Test_Machine")

        package_path = InstallationPackageHandling.get_gx_ntd_package_path_ips(version_to_deploy,
                                                                               tar_file=True)
        package_name = FileTools.copy_file_to_remote_location_scp(self.shell, package_path, herc_machine)

        return package_name
Beispiel #7
0
def update_test_context_with_device_details(current_config_file_name):
    """
    This method needs to be run before executing tests or any other methods that are config dependant
    :param current_config_file_name:
    :return:
    """
    Test_Context.current_config_file_name = './ConfigFiles/TestRunConfig_{0}.json'.format(
        current_config_file_name)
    Test_Context.run_config = ConfigLoader.get_test_run_config()

    Test_Context.def_mode = Test_Context.run_config.load(
        'TestPremise')['DefMode']
    Test_Context.connection_details = ConfigLoader.get_general_config(
        'DeviceConnectionDetails')
    deployment_values = Test_Context.run_config.load('Deployment_Values')

    for device_name in deployment_values.keys():
        Test_Context.deployed_devices[
            device_name] = DeviceManager.create_device_template_from_config(
                device_name)
    def _get_current_version(self, device_ip):
        connection_details = ConfigLoader.get_general_config(
            'DeviceConnectionDetails')
        user = UserWrapper(connection_details["User"],
                           connection_details["Password"], None)

        with ActionsProvisionalCLI(user, device_ip) as device_pcli_action:
            device_pcli_action.send_cmd('show version')
            device_version = PExpectWrapper.get_text_after_value(
                device_pcli_action.cli, 'Application Version : ')

        return Version(device_version)
    def get_source_file_path(self, device):
        source_device_path = ConfigLoader.get_test_run_config(
            "Source_Values")["Device_Folder"]
        source_folder_path = FileTools.get_device_source_folder(
            device, source_device_path)
        source_file_name = self._get_source_file(source_folder_path, device)

        build_number = Common.Utilities.DeploymentUtils.DeploymentHelper.get_build_version(
            source_file_name)
        PrintMessage("Extracted build number from zip file {0} > {1}".format(
            source_file_name, build_number))

        return source_folder_path + '/' + source_file_name, build_number
    def _copy_tar_file(self, build_number, ntd_release_version):
        version_to_deploy = Version(ntd_release_version)
        version_to_deploy.build = build_number
        herc_machine = ConfigLoader.get_deployment_config("Test_Machine")

        package_path = InstallationPackageHandling.get_intd_package_path_ips(
            version_to_deploy, tar_file=True)
        FileTools.copy_file_to_remote_location_scp(self.shell, package_path,
                                                   herc_machine)

        # splitting path by slash and getting last part - file name
        package_name = package_path.split('/')[-1]

        return package_name
Beispiel #11
0
    def process_arguments_group_test_run():
        parser = argparse.ArgumentParser(prefix_chars='-')
        CommandLineArgumentsParser.add_argument_configuration_file(parser)
        CommandLineArgumentsParser.add_argument_build_number(parser)
        CommandLineArgumentsParser.add_argument_list_of_report_recipients(
            parser)
        CommandLineArgumentsParser.add_argument_run_type(parser)

        parsed_args = parser.parse_args()

        Test_Context.current_config_file_name = './ConfigFiles/TestRunConfig_{0}.json'.format(
            parsed_args.config_file)
        Test_Context.run_config = ConfigLoader.get_test_run_config()

        return parsed_args
Beispiel #12
0
    def process_arguments_single_test_run():
        parser = argparse.ArgumentParser(prefix_chars='-')
        CommandLineArgumentsParser.add_argument_configuration_file(parser)
        CommandLineArgumentsParser.add_argument_list_of_test_ids(parser)
        CommandLineArgumentsParser.add_argument_list_of_class_names(parser)

        parsed_args = parser.parse_args()

        if len(parsed_args.test_ids) == 0 and len(
                parsed_args.test_class_names) == 0:
            parser.error(TestClassNameOrTestCaseID)

        Test_Context.current_config_file_name = './ConfigFiles/TestRunConfig_{0}.json'.format(
            parsed_args.config_file)
        Test_Context.run_config = ConfigLoader.get_test_run_config()

        return parsed_args.test_ids, parsed_args.test_class_names
def get_ips_folder_path(device_version, prefix='', zero_fill=4):
    """
    Returns path to ips folder where packages are located
    :param device_version:
    :param prefix: GX has 'V' pefix in release and version folder names
    :param zero_fill: GX uses 3 digits to indicate build number
    :return:
    """
    release_folder = prefix + "{0}/"
    version_folder = prefix + "{1}/"
    package_path = release_folder + version_folder + "packages/"
    ips_path = ConfigLoader.get_test_run_config(
        "Source_Values")["Package_Folder"] + package_path

    return ips_path.format(
        device_version.release_version,
        device_version.get_as_string(fill_with_zeros=zero_fill))
    def create_device_template_from_config(device_name):
        deployment_values = ConfigLoader.get_test_run_config(
            'Deployment_Values')

        device = Device(device_name,
                        DeviceManager.get_device_type_from_name(device_name),
                        deployment_values[device_name]['IP_ADDRESS'],
                        deployment_values[device_name]['Deployment_Type'],
                        deployment_values[device_name]['Device_Release'])

        for key in deployment_values[device_name].keys():
            if key in ['IP_ADDRESS', 'Deployment_Type', 'Device_Release']:
                continue

            device.deployment_config[key] = deployment_values[device_name][key]

        return device
def deploy_devices(device_names, build_number_to_deploy=None):
    """
    Deploys ntd and sms VMs
    The build number is expected to be the same for both
    :param device_names:
    :param build_number_to_deploy:
    :return:
    """

    deployment_config = ConfigLoader.get_test_run_config('Deployment_Values')

    for device_name in device_names:
        device_to_deploy = DeviceManager.create_device_template_from_config(
            device_name)
        device_to_deploy.version.build = build_number_to_deploy

        device_deployment_type = deployment_config[device_name][
            'Deployment_Type']
        if device_deployment_type == DeploymentType.ntd1100:
            deployed_device = deploy_with_deployer(LannerDeviceDeploy(),
                                                   device_to_deploy)
        elif device_deployment_type == DeploymentType.vmware:
            deployed_device = deploy_with_deployer(VMWareDeviceDeploy(),
                                                   device_to_deploy)
        elif device_deployment_type == DeploymentType.kvm:
            deployed_device = deploy_with_deployer(KVMDeviceDeploy(),
                                                   device_to_deploy)
        elif device_deployment_type == DeploymentType.gx:
            deployed_device = deploy_with_deployer(GXDeviceDeploy(),
                                                   device_to_deploy)
        else:
            raise Exception("Unknown deployment type")

        Test_Context.deployed_devices[deployed_device.name] = deployed_device

        # this ensures, all subsequent devices are of the same build number
        build_number_to_deploy = deployed_device.version.build

    Test_Context.build_number = build_number_to_deploy

    connect_to_all_devices(device_names, deployment_config)

    PrintMessage('Initial deployment complete!')

    return Test_Context.build_number
def reboot_lanner_device(ip_address):
    """
    Reboot lanner device as per dev suggestion in SWALL-7668, SWALL-5845
    :return:
    """
    connection_details = ConfigLoader.get_general_config(
        'DeviceConnectionDetails')
    user = UserWrapper(connection_details["User"],
                       connection_details["Password"], None)

    with ActionsProvisionalCLI(user=user, host=ip_address) as admin_pcli:
        PrintMessage("Reboot lanner device -- as per SWALL-7668, SWALL-5845")
        admin_pcli.send_cmd(
            "reboot",
            expected_value=
            'This will reboot the device. Do you want to continue?')
        admin_pcli.send_cmd(
            "y", expected_value='The system is going down for reboot NOW!')
Beispiel #17
0
    def get_valid_previous_version(device):
        device_folder = ConfigLoader.get_test_run_config(
            "Source_Values")["Device_Folder"]
        temp_device = copy.deepcopy(device)
        temp_device.version.build -= 1

        builds_to_traverse = 20
        safe_count = 0
        while safe_count < builds_to_traverse:
            safe_count += 1

            source_folder = FileTools.get_device_source_folder(
                temp_device, device_folder)
            source_file = VMWareSource._get_source_file(source_folder, device)

            if source_file:
                return temp_device.version

            temp_device.version.build -= 1

        return None
    def get_connector():
        """
        sys.version_info returns python version (major, minor, build)
        we do not want SSL context to be used with python where build is less than 13
        :return:
        """
        run_config = ConfigLoader.get_test_run_config('VMWare_Values')

        if sys.version_info[0] == 2 and sys.version_info[2] < 13:
            esx_connection = connect.SmartConnect(
                host=run_config['Host'],
                user=run_config['ESX_User'],
                pwd=run_config['ESX_Password'])
        else:
            context = ssl.SSLContext(ssl.PROTOCOL_TLS)
            esx_connection = connect.SmartConnect(
                host=run_config['Host'],
                user=run_config['ESX_User'],
                pwd=run_config['ESX_Password'],
                sslContext=context)

        atexit.register(connect.Disconnect, esx_connection)
        return esx_connection
Beispiel #19
0
    def __init__(self):
        self._device = None

        self._ovf_file_path_to_temp = None
        self._test_run_config = ConfigLoader.get_test_run_config()
        self._day0_config_values = self._test_run_config.load("Day0_Values")
    def log_as_support(self, device_name):
        deployment_config = ConfigLoader.get_test_run_config(
            "Deployment_Values")
        device_ip_address = deployment_config[device_name]["IP_ADDRESS"]

        self.shell = ActionsShell(device_ip_address)