How to use _check_lis_version_hex method in lisa

Best Python code snippet using lisa_python

lissuite.py

Source:lissuite.py Github

copy

Full Screen

...77 source_version_hex = get_matched_str(78 source_version_hex, self.hex_version_pattern79 )80 self._check_lis_version(node, version, source_version, log)81 self._check_lis_version_hex(node, version, source_version_hex, log)82 @TestCaseMetadata(83 description="""84 This test case is to verify LIS RPM installation script to check the disk85 space before proceeding to LIS install.86 This avoids half / corrupted installations.87 Steps:88 1. Test leaves "bare minimum" size available for LIS install and checks if89 LIS installation is successful.90 """,91 priority=2,92 )93 def verify_lis_preinstall_disk_size_positive(self, node: Node, log: Logger) -> None:94 self._verify_lis_preinstall_disk_size(node, log)95 @TestCaseMetadata(96 description="""97 This test case is to verify LIS RPM installation script to check the disk98 space before proceeding to LIS install.99 This avoids half / corrupted installations.100 Steps:101 1. Test leaves "non installable" size on disk and checks if ./install.sh102 script skips the installation of not.103 """,104 priority=2,105 )106 def verify_lis_preinstall_disk_size_negative(self, node: Node, log: Logger) -> None:107 self._verify_lis_preinstall_disk_size(node, log, test_type="negative")108 def _verify_lis_preinstall_disk_size(109 self, node: Node, log: Logger, test_type: str = "positive"110 ) -> None:111 lisdriver = self._check_lis_installable(node)112 fallocate = node.tools[Fallocate]113 stat = node.tools[Stat]114 df = node.tools[Df]115 rpm = node.tools[Rpm]116 cmd_result = lisdriver.uninstall_from_iso()117 cmd_result.assert_exit_code(0, "failed to uninstall lis")118 self._clean_up_files(node)119 lib_module_folder = "/lib/modules"120 boot_folder = "/boot"121 # fetched from spec122 min_space_for_ramfs_creation = 157286400123 # 9MB to hit rpm limit124 min_sz_root_partition_not_root = 9437184125 # 10MB for log file creation126 root_partition_buffer_space = 10485760127 # allowed limit of +- 1MB128 boot_partition_buffer_space = 1048576129 root_partition = df.get_partition_by_mountpoint("/")130 boot_partition = df.get_partition_by_mountpoint("/boot")131 assert root_partition, "fail to get root partition"132 assert boot_partition, "fail to get boot partition"133 ramdisk_size_factor = 1134 if root_partition.name != boot_partition.name:135 ramdisk_size_factor = 2136 lis_path = lisdriver.download()137 os_version = node.os.information.release.split(".")138 version = os_version[0] + os_version[1]139 lib_module_required_space = rpm.get_file_size(140 f"{lis_path}/RPMS{version}/kmod-microsoft-hyper*x86_64.rpm"141 )142 uname = node.tools[Uname]143 kernel_version = uname.get_linux_information().kernel_version_raw144 ramdisk_required_space = stat.get_total_size(145 f"/boot/initramfs-{kernel_version}.img"146 )147 boot_part_required_space = ramdisk_required_space + boot_partition_buffer_space148 root_part_required_space = (149 min_space_for_ramfs_creation150 + ramdisk_size_factor * ramdisk_required_space151 + lib_module_required_space152 + root_partition_buffer_space153 )154 node.execute("sync")155 fblock_non_root = stat.get_fs_available_size(lib_module_folder)156 fblock_root = stat.get_fs_free_blocks(lib_module_folder)157 boot_part_avail_space = stat.get_fs_block_size(158 boot_folder159 ) * stat.get_fs_available_size(boot_folder)160 root_part_avail_space = (161 stat.get_fs_block_size(lib_module_folder) * fblock_non_root162 )163 if test_type == "negative":164 boot_part_required_space = int(boot_part_required_space / 2)165 root_part_required_space = int(root_part_required_space / 2)166 # 6.X distro RPM does not use root user space free space.167 # Hence setting the min limit.168 if fblock_non_root != fblock_root:169 root_part_required_space = min_sz_root_partition_not_root170 single_partition_file_size = (171 root_part_avail_space - root_part_required_space172 )173 fallocate.create_file(single_partition_file_size, "/lib/modules/file.out")174 if boot_partition != root_partition:175 single_partition_file_size_boot = (176 boot_part_avail_space - boot_part_required_space177 )178 fallocate.create_file(single_partition_file_size_boot, "/boot/file.out")179 result = lisdriver.install_from_iso()180 if test_type == "negative":181 if result.exit_code == 0:182 raise LisaException(183 "lis should fail to be installed for insufficient space"184 )185 else:186 log.debug(f"fail to install lis for reason {result.stdout}")187 self._clean_up_files(node)188 if test_type == "positive":189 lisdriver.uninstall_from_iso()190 # Returns true if version and source_version are the same191 def _check_lis_version(192 self, node: Node, version: str, source_version: str, log: Logger193 ) -> None:194 log.debug("Detected modinfo version is {version}")195 log.debug("Version found in source code is {source_version}")196 assert_that(version).described_as(197 "Detected version and Source version are different. Expected LIS version:"198 f" {source_version}, Actual LIS version: {version}"199 )200 # Returns true if version and source_version_hex are the same201 def _check_lis_version_hex(202 self, node: Node, version: str, source_version_hex: str, log: Logger203 ) -> None:204 log.debug("Detected modinfo version is {version}")205 log.debug("Version found in source code is {source_version}")206 # The below two lines are converting the inputted LIS version to hex207 version_hex = version.replace(".", "")208 version_hex = str(hex(int(version_hex))).lower()209 # Converting to lower for consistency210 source_version_hex = source_version_hex.lower()211 assert_that(version).described_as(212 "Detected version and Source version are different for hex value. Expected"213 f" LIS version: {source_version_hex}, Actual LIS version: {version_hex}"214 )215 def _check_lis_installable(self, node: Node) -> LisDriver:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful