How to use get_ib_interfaces method in lisa

Best Python code snippet using lisa_python

infinibandsuit.py

Source:infinibandsuit.py Github

copy

Full Screen

...129 )130 except (UnsupportedDistroException, UnsupportedKernelException) as err:131 raise SkippedException(err)132 server_infiniband = server_node.features[Infiniband]133 server_ib_interfaces = server_infiniband.get_ib_interfaces()134 client_infiniband = client_node.features[Infiniband]135 client_ib_interfaces = client_infiniband.get_ib_interfaces()136 client_ib_device_name = client_ib_interfaces[0].ib_device_name137 for interface in server_ib_interfaces:138 ib_device_name = interface.ib_device_name139 ip_addr = interface.ip_addr140 for test in ping_pong_tests:141 server_process = server_node.execute_async(142 f"{test} -g 0 -d {ib_device_name}"143 )144 client_process = client_node.execute_async(145 f"{test} -g 0 -d {client_ib_device_name} {ip_addr}"146 )147 client_result = client_process.wait_result()148 client_result.assert_exit_code(149 0,150 f"Client ping-pong test {test} failed with exit code "151 f"{client_result.exit_code} and output {client_result.stdout}",152 )153 server_result = server_process.wait_result()154 server_result.assert_exit_code(155 0,156 f"Server ping-pong test {test} failed with exit code "157 f"{server_result.exit_code} and output {server_result.stdout}",158 )159 @TestCaseMetadata(160 description="""161 This test case will162 1. Ensure RDMA is setup163 2. Install Intel MPI164 3. Set up ssh keys of server/client connection165 4. Run MPI pingpong tests166 5. Run other MPI tests167 """,168 priority=4,169 requirement=simple_requirement(170 supported_features=[Infiniband],171 min_count=2,172 ),173 )174 def verify_intel_mpi(self, environment: Environment, log: Logger) -> None:175 server_node = environment.nodes[0]176 client_node = environment.nodes[1]177 # Ensure RDMA is setup178 try:179 run_in_parallel(180 [181 lambda: client_node.features[Infiniband],182 lambda: server_node.features[Infiniband],183 ]184 )185 except (UnsupportedDistroException, UnsupportedKernelException) as err:186 raise SkippedException(err)187 server_ib = server_node.features[Infiniband]188 client_ib = client_node.features[Infiniband]189 run_in_parallel([server_ib.install_intel_mpi, client_ib.install_intel_mpi])190 # Restart the ssh sessions for changes to /etc/security/limits.conf191 # to take effect192 server_node.close()193 client_node.close()194 # Get the ip adresses and device name of ib device195 server_ib_interfaces = server_ib.get_ib_interfaces()196 client_ib_interfaces = client_ib.get_ib_interfaces()197 server_nic_name = server_ib_interfaces[0].nic_name198 server_ip = server_ib_interfaces[0].ip_addr199 client_ip = client_ib_interfaces[0].ip_addr200 # Test relies on machines being able to ssh into each other201 server_ssh = server_node.tools[Ssh]202 client_ssh = client_node.tools[Ssh]203 server_ssh.enable_public_key(client_ssh.generate_key_pairs())204 client_ssh.enable_public_key(server_ssh.generate_key_pairs())205 server_ssh.add_known_host(client_ip)206 client_ssh.add_known_host(server_ip)207 # Note: Using bash because script is not supported by Dash208 # sh points to dash on Ubuntu209 server_node.execute(210 "bash /opt/intel/oneapi/mpi/2021.1.1/bin/mpirun "211 f"-hosts {server_ip},{server_ip} -iface {server_nic_name} -ppn 1 -n 2 "212 "-env I_MPI_FABRICS=shm:ofi -env SECS_PER_SAMPLE=600 "213 "-env FI_PROVIDER=mlx -env I_MPI_DEBUG=5 -env I_MPI_PIN_DOMAIN=numa "214 "/opt/intel/oneapi/mpi/2021.1.1/bin/IMB-MPI1 pingpong",215 expected_exit_code=0,216 expected_exit_code_failure_message="Failed intra-node pingpong test "217 "with intel mpi",218 )219 server_node.execute(220 "bash /opt/intel/oneapi/mpi/2021.1.1/bin/mpirun "221 f"-hosts {server_ip},{client_ip} -iface {server_nic_name} -ppn 1 -n 2 "222 "-env I_MPI_FABRICS=shm:ofi -env SECS_PER_SAMPLE=600 "223 "-env FI_PROVIDER=mlx -env I_MPI_DEBUG=5 -env I_MPI_PIN_DOMAIN=numa "224 "/opt/intel/oneapi/mpi/2021.1.1/bin/IMB-MPI1 pingpong",225 expected_exit_code=0,226 expected_exit_code_failure_message="Failed inter-node pingpong test "227 "with intel mpi",228 )229 tests = ["IMB-MPI1 allreduce", "IMB-RMA", "IMB-NBC"]230 for test in tests:231 server_node.execute(232 "bash /opt/intel/oneapi/mpi/2021.1.1/bin/mpirun "233 f"-hosts {server_ip},{client_ip} -iface {server_nic_name} -ppn 22 "234 "-n 44 -env I_MPI_FABRICS=shm:ofi -env SECS_PER_SAMPLE=600 "235 "-env FI_PROVIDER=mlx -env I_MPI_DEBUG=5 -env I_MPI_PIN_DOMAIN=numa "236 f"/opt/intel/oneapi/mpi/2021.1.1/bin/{test}",237 expected_exit_code=0,238 expected_exit_code_failure_message=f"Failed {test} test with intel mpi",239 timeout=1200,240 )241 @TestCaseMetadata(242 description="""243 This test case will244 1. Ensure RDMA is setup245 2. Install Open MPI246 3. Set up ssh keys of server/client connection247 4. Run MPI pingpong tests248 5. Run other MPI tests249 """,250 priority=4,251 requirement=simple_requirement(252 supported_features=[Infiniband],253 min_count=2,254 ),255 )256 def verify_open_mpi(self, environment: Environment, log: Logger) -> None:257 server_node = environment.nodes[0]258 client_node = environment.nodes[1]259 # Ensure RDMA is setup260 try:261 run_in_parallel(262 [263 lambda: client_node.features[Infiniband],264 lambda: server_node.features[Infiniband],265 ]266 )267 except (UnsupportedDistroException, UnsupportedKernelException) as err:268 raise SkippedException(err)269 server_ib = server_node.features[Infiniband]270 client_ib = client_node.features[Infiniband]271 run_in_parallel([server_ib.install_open_mpi, client_ib.install_open_mpi])272 server_node.execute("ldconfig", sudo=True)273 client_node.execute("ldconfig", sudo=True)274 # Restart the ssh sessions for changes to /etc/security/limits.conf275 # to take effect276 server_node.close()277 client_node.close()278 # Get the ip adresses and device name of ib device279 server_ib_interfaces = server_ib.get_ib_interfaces()280 client_ib_interfaces = client_ib.get_ib_interfaces()281 server_ip = server_ib_interfaces[0].ip_addr282 client_ip = client_ib_interfaces[0].ip_addr283 # Test relies on machines being able to ssh into each other284 server_ssh = server_node.tools[Ssh]285 client_ssh = client_node.tools[Ssh]286 server_ssh.enable_public_key(client_ssh.generate_key_pairs())287 client_ssh.enable_public_key(server_ssh.generate_key_pairs())288 server_ssh.add_known_host(client_ip)289 client_ssh.add_known_host(server_ip)290 # Ping Pong test291 find = server_node.tools[Find]292 find_results = find.find_files(293 server_node.get_pure_path("/usr"), "IMB-MPI1", sudo=True294 )295 assert_that(len(find_results)).described_as(296 "Could not find location of IMB-MPI1 for Open MPI"297 ).is_greater_than(0)298 test_path = find_results[0]299 assert_that(test_path).described_as(300 "Could not find location of IMB-MPI1 for Open MPI"301 ).is_not_empty()302 server_node.execute(303 f"/usr/local/bin/mpirun --host {server_ip},{server_ip} "304 "-n 2 --mca btl self,vader,openib --mca btl_openib_cq_size 4096 "305 "--mca btl_openib_allow_ib 1 --mca "306 f"btl_openib_warn_no_device_params_found 0 {test_path} pingpong",307 expected_exit_code=0,308 expected_exit_code_failure_message="Failed intra-node ping pong test "309 "with Open MPI",310 )311 # IMB-MPI Tests312 find_results = find.find_files(313 server_node.get_pure_path("/usr"), "IMB-MPI1", sudo=True314 )315 assert_that(len(find_results)).described_as(316 "Could not find location of Open MPI test: IMB-MPI1"317 ).is_greater_than(0)318 test_path = find_results[0]319 assert_that(test_path).described_as(320 "Could not find location of Open MPI test: IMB-MPI1"321 ).is_not_empty()322 server_node.execute(323 f"/usr/local/bin/mpirun --host {server_ip},{client_ip} "324 "-n 2 --mca btl self,vader,openib --mca btl_openib_cq_size 4096 "325 "--mca btl_openib_allow_ib 1 --mca "326 f"btl_openib_warn_no_device_params_found 0 {test_path}",327 expected_exit_code=0,328 expected_exit_code_failure_message="Failed " "IMB-MPI1 test with Open MPI",329 )330 @TestCaseMetadata(331 description="""332 This test case will333 1. Ensure RDMA is setup334 2. Install IBM MPI335 3. Set up ssh keys of server/client connection336 4. Run MPI pingpong tests337 """,338 priority=4,339 requirement=simple_requirement(340 supported_features=[Infiniband],341 min_count=2,342 ),343 )344 def verify_ibm_mpi(self, environment: Environment, log: Logger) -> None:345 server_node = environment.nodes[0]346 client_node = environment.nodes[1]347 # Ensure RDMA is setup348 try:349 run_in_parallel(350 [351 lambda: client_node.features[Infiniband],352 lambda: server_node.features[Infiniband],353 ]354 )355 except (UnsupportedDistroException, UnsupportedKernelException) as err:356 raise SkippedException(err)357 server_ib = server_node.features[Infiniband]358 client_ib = client_node.features[Infiniband]359 run_in_parallel([server_ib.install_ibm_mpi, client_ib.install_ibm_mpi])360 # Restart the ssh sessions for changes to /etc/security/limits.conf361 # to take effect362 server_node.close()363 client_node.close()364 # Get the ip adresses and device name of ib device365 server_ib_interfaces = server_ib.get_ib_interfaces()366 client_ib_interfaces = client_ib.get_ib_interfaces()367 server_ip = server_ib_interfaces[0].ip_addr368 client_ip = client_ib_interfaces[0].ip_addr369 # Test relies on machines being able to ssh into each other370 server_ssh = server_node.tools[Ssh]371 client_ssh = client_node.tools[Ssh]372 server_ssh.enable_public_key(client_ssh.generate_key_pairs())373 client_ssh.enable_public_key(server_ssh.generate_key_pairs())374 server_ssh.add_known_host(client_ip)375 client_ssh.add_known_host(server_ip)376 server_node.execute(377 "/opt/ibm/platform_mpi/bin/mpirun "378 f"-hostlist {server_ip}:1,{server_ip}:1 -np 2 -e "379 f"MPI_IB_PKEY={server_ib.get_pkey()} -ibv /opt/ibm/platform_mpi/help/"380 "ping_pong 4096",381 expected_exit_code=0,382 expected_exit_code_failure_message="Infiniband intra-node ping pong "383 "test failed with IBM MPI",384 )385 server_node.execute(386 "/opt/ibm/platform_mpi/bin/mpirun "387 f"-hostlist {server_ip}:1,{client_ip}:1 -np 2 -e "388 f"MPI_IB_PKEY={server_ib.get_pkey()} -ibv /opt/ibm/platform_mpi/help/"389 "ping_pong 4096",390 expected_exit_code=0,391 expected_exit_code_failure_message="Infiniband inter-node ping pong "392 "test failed with IBM MPI",393 )394 @TestCaseMetadata(395 description="""396 This test case will397 1. Ensure RDMA is setup398 2. Install MVAPICH MPI399 3. Set up ssh keys of server/client connection400 4. Run MPI pingpong tests401 5. Run other MPI tests402 """,403 priority=4,404 requirement=simple_requirement(405 supported_features=[Infiniband],406 min_count=2,407 ),408 )409 def verify_mvapich_mpi(self, environment: Environment, log: Logger) -> None:410 server_node = environment.nodes[0]411 client_node = environment.nodes[1]412 # Ensure RDMA is setup413 try:414 run_in_parallel(415 [416 lambda: client_node.features[Infiniband],417 lambda: server_node.features[Infiniband],418 ]419 )420 except (UnsupportedDistroException, UnsupportedKernelException) as err:421 raise SkippedException(err)422 server_ib = server_node.features[Infiniband]423 client_ib = client_node.features[Infiniband]424 run_in_parallel([server_ib.install_mvapich_mpi, client_ib.install_mvapich_mpi])425 # Restart the ssh sessions for changes to /etc/security/limits.conf426 # to take effect427 server_node.close()428 client_node.close()429 # Get the ip adresses and device name of ib device430 server_ib_interfaces = server_ib.get_ib_interfaces()431 client_ib_interfaces = client_ib.get_ib_interfaces()432 server_ip = server_ib_interfaces[0].ip_addr433 client_ip = client_ib_interfaces[0].ip_addr434 # Test relies on machines being able to ssh into each other435 server_ssh = server_node.tools[Ssh]436 client_ssh = client_node.tools[Ssh]437 server_ssh.enable_public_key(client_ssh.generate_key_pairs())438 client_ssh.enable_public_key(server_ssh.generate_key_pairs())439 server_ssh.add_known_host(client_ip)440 client_ssh.add_known_host(server_ip)441 # Run MPI tests442 find = server_node.tools[Find]443 test_names = ["IMB-MPI1", "IMB-RMA", "IMB-NBC"]444 for test in test_names:445 find_results = find.find_files(...

Full Screen

Full Screen

infiniband.py

Source:infiniband.py Github

copy

Full Screen

...62 def _is_legacy_device(self) -> bool:63 lspci = self._node.tools[Lspci]64 device_list = lspci.get_devices()65 return any("ConnectX-3" in device.device_info for device in device_list)66 def get_ib_interfaces(self) -> List[IBDevice]:67 """Gets the list of Infiniband devices68 excluding any ethernet devices69 and get their corresponding network interface70 Returns list of IBDevice(ib_device_name, nic_name, ip_addr)71 Example IBDevice("mlx5_ib0", "ib0", "172.16.1.23")"""72 ib_devices = []73 device_info = self._get_ib_device_info()74 for device in device_info:75 if device["link_layer"].strip() == "InfiniBand" and "node_guid" in device:76 device_name = device["hca_id"].strip()77 guid = device["node_guid"].strip()78 # Get the last three bytes of guid79 # Example80 # guid = 0015:5dff:fe33:ff0c81 # mpat = 33:ff:0c (This will match the ib device)82 mpat = f"{guid[12:17]}:{guid[17:19]}"83 for (nic_name, nic_info) in self._node.nics.nics.items():84 result = self._node.execute(f"/sbin/ip addr show {nic_name}")85 if mpat in result.stdout and "ib" in nic_name:86 assert_that(nic_info.ip_addr).described_as(87 f"NIC {nic_name} does not have an ip address."88 ).is_not_empty()89 ib_devices.append(90 IBDevice(device_name, nic_name, nic_info.ip_addr)91 )92 assert_that(ib_devices).described_as(93 "Failed to get any InfiniBand device / interface pairs"94 ).is_not_empty()95 return ib_devices96 def _get_ib_device_info(self) -> List[Dict[str, str]]:97 device_info = []98 devices = self._get_ib_device_names()99 for device_name in devices:100 result = self._node.execute(101 f"ibv_devinfo -d {device_name}",102 expected_exit_code=0,103 expected_exit_code_failure_message="Failed to get device info from "104 f"ibv_devinfo for infiniband device {device_name}",105 )106 d = {107 match.group("id"): match.group("value")108 for match in self._ib_info_pattern.finditer(result.stdout)109 }110 if "hca_id" in d:111 device_info.append(d)112 assert_that(device_info).described_as(113 "Failed to get device info for any InfiniBand devices"114 ).is_not_empty()115 return device_info116 def _get_ib_device_names(self) -> List[str]:117 node = self._node118 result = node.execute(119 "ls /sys/class/infiniband",120 expected_exit_code=0,121 expected_exit_code_failure_message="Failed to get InfiniBand"122 " devices from /sys/class/infiniband",123 )124 assert_that(result.stdout).described_as(125 "No infiniband devices found in /sys/class/infiniband"126 ).is_not_empty()127 return result.stdout.split()128 def _get_mofed_version(self) -> str:129 node = self._node130 default = "5.4-3.0.3.0"131 if self._is_legacy_device():132 return "4.9-5.1.0.0"133 if (134 isinstance(node.os, Ubuntu) and node.os.information.version >= "20.4.0"135 ) or (isinstance(node.os, Redhat) and node.os.information.version >= "8.2.0"):136 return "5.7-1.0.2.0"137 return default138 def get_pkey(self) -> str:139 ib_device_name = self.get_ib_interfaces()[0].ib_device_name140 cat = self._node.tools[Cat]141 return cat.read(f"/sys/class/infiniband/{ib_device_name}/ports/1/pkeys/0")142 def setup_rdma(self) -> None:143 node = self._node144 # Dependencies145 kernel = node.tools[Uname].get_linux_information().kernel_version_raw146 ubuntu_required_packages = [147 "build-essential",148 "numactl",149 "rpm",150 "libnuma-dev",151 "libmpc-dev",152 "libmpfr-dev",153 "libxml2-dev",...

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