Best Python code snippet using lisa_python
storageperf.py
Source:storageperf.py
...112 network_interface=Sriov(),113 ),114 )115 def perf_storage_over_nfs_sriov_tcp_4k(self, result: TestResult) -> None:116 self._perf_nfs(result)117 @TestCaseMetadata(118 description="""119 This test case uses fio to test performance of nfs server over UDP with120 VM's initialized with SRIOV network interface.121 """,122 priority=3,123 timeout=TIME_OUT,124 requirement=simple_requirement(125 min_count=2,126 disk=schema.DiskOptionSettings(127 disk_type=schema.DiskType.PremiumSSDLRS,128 data_disk_iops=search_space.IntRange(min=5000),129 data_disk_count=search_space.IntRange(min=12),130 data_disk_size=search_space.IntRange(min=10),131 ),132 network_interface=Sriov(),133 ),134 )135 def perf_storage_over_nfs_sriov_udp_4k(self, result: TestResult) -> None:136 self._perf_nfs(result, protocol="udp")137 @TestCaseMetadata(138 description="""139 This test case uses fio to test performance of nfs server over TCP with140 VM's initialized with synthetic network interface.141 """,142 priority=3,143 timeout=TIME_OUT,144 requirement=simple_requirement(145 min_count=2,146 disk=schema.DiskOptionSettings(147 disk_type=schema.DiskType.PremiumSSDLRS,148 data_disk_iops=search_space.IntRange(min=5000),149 data_disk_count=search_space.IntRange(min=12),150 data_disk_size=search_space.IntRange(min=10),151 ),152 network_interface=Synthetic(),153 ),154 )155 def perf_storage_over_nfs_synthetic_tcp_4k(self, result: TestResult) -> None:156 self._perf_nfs(result)157 @TestCaseMetadata(158 description="""159 This test case uses fio to test performance of nfs server over UDP with160 VM's initialized with synthetic network interface.161 """,162 priority=3,163 timeout=TIME_OUT,164 requirement=simple_requirement(165 min_count=2,166 disk=schema.DiskOptionSettings(167 disk_type=schema.DiskType.PremiumSSDLRS,168 data_disk_iops=search_space.IntRange(min=5000),169 data_disk_count=search_space.IntRange(min=12),170 data_disk_size=search_space.IntRange(min=10),171 ),172 network_interface=Synthetic(),173 ),174 )175 def perf_storage_over_nfs_synthetic_udp_4k(self, result: TestResult) -> None:176 self._perf_nfs(result, protocol="udp")177 def _configure_nfs(178 self,179 server: RemoteNode,180 client: RemoteNode,181 server_raid_disk_name: str = "/dev/md0",182 server_raid_disk_mount_dir: str = "/mnt",183 client_nfs_mount_dir: str = "/mnt/nfs_client_share",184 protocol: str = "tcp",185 ) -> None:186 # mount raid disk on server187 server.shell.mkdir(PurePosixPath(server_raid_disk_mount_dir), exist_ok=True)188 server.tools[Mkfs].format_disk(server_raid_disk_name, FileSystem.ext4)189 server.tools[Mount].mount(190 server_raid_disk_name, server_raid_disk_mount_dir, options="nobarrier"191 )192 # setup nfs on server193 server.tools[NFSServer].create_shared_dir(194 [client.internal_address], server_raid_disk_mount_dir195 )196 # setup raid on client197 client.tools[NFSClient].setup(198 server.internal_address,199 server_raid_disk_mount_dir,200 client_nfs_mount_dir,201 f"proto={protocol},vers=3",202 )203 def _run_fio_on_nfs(204 self,205 test_result: TestResult,206 server: RemoteNode,207 client: RemoteNode,208 server_data_disk_count: int,209 client_nfs_mount_dir: str,210 core_count: int,211 num_jobs: List[int],212 start_iodepth: int = 1,213 max_iodepth: int = 1024,214 filename: str = "fiodata",215 block_size: int = 4,216 ) -> None:217 origin_value: Dict[str, str] = {}218 for node in [server, client]:219 origin_value[node.name] = node.tools[Sysctl].get("fs.aio-max-nr")220 node.tools[Sysctl].write("fs.aio-max-nr", "1048576")221 perf_disk(222 client,223 start_iodepth,224 max_iodepth,225 filename,226 test_name=inspect.stack()[1][3],227 core_count=core_count,228 disk_count=server_data_disk_count,229 disk_setup_type=DiskSetupType.raid0,230 disk_type=DiskType.premiumssd,231 num_jobs=num_jobs,232 block_size=block_size,233 size_mb=256,234 overwrite=True,235 cwd=PurePosixPath(client_nfs_mount_dir),236 test_result=test_result,237 )238 for node in [server, client]:239 node.tools[Sysctl].write("fs.aio-max-nr", origin_value[node.name])240 def _perf_nfs(241 self,242 test_result: TestResult,243 server_raid_disk_name: str = "/dev/md0",244 server_raid_disk_mount_dir: str = "/mnt/nfs_share",245 client_nfs_mount_dir: str = "/mnt/nfs_client_share",246 protocol: str = "tcp",247 filename: str = "fiodata",248 block_size: int = 4,249 start_iodepth: int = 1,250 max_iodepth: int = 1024,251 ) -> None:252 environment = test_result.environment253 assert environment, "fail to get environment from testresult"254 server_node = cast(RemoteNode, environment.nodes[0])...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!