How to use _linux_setup_nat method in lisa

Best Python code snippet using lisa_python

nestedperf.py

Source:nestedperf.py Github

copy

Full Screen

...297 nested_image_url,298 ) = parse_nested_image_variables(variables)299 try:300 # setup nested vm on server in NAT configuration301 server_l2 = self._linux_setup_nat(302 node=server_l1,303 nested_vm_name="server_l2",304 guest_username=nested_image_username,305 guest_password=nested_image_password,306 guest_port=self._SERVER_HOST_FWD_PORT,307 guest_image_url=nested_image_url,308 guest_internal_ip=self._SERVER_IP_ADDR,309 guest_default_nic=self._NIC_NAME,310 bridge_name=self._BR_NAME,311 bridge_network=self._BR_NETWORK,312 bridge_cidr=self._BR_CIDR,313 bridge_gateway=self._BR_GATEWAY,314 )315 # setup nested vm on client in NAT configuration316 client_l2 = self._linux_setup_nat(317 node=client_l1,318 nested_vm_name="client_l2",319 guest_username=nested_image_username,320 guest_password=nested_image_password,321 guest_port=self._CLIENT_HOST_FWD_PORT,322 guest_image_url=nested_image_url,323 guest_internal_ip=self._CLIENT_IP_ADDR,324 guest_default_nic=self._NIC_NAME,325 bridge_name=self._BR_NAME,326 bridge_network=self._BR_NETWORK,327 bridge_cidr=self._BR_CIDR,328 bridge_gateway=self._BR_GATEWAY,329 )330 # run ntttcp test331 perf_ntttcp(332 result,333 server_l2,334 client_l2,335 server_nic_name=self._NIC_NAME,336 client_nic_name=self._NIC_NAME,337 test_case_name=inspect.stack()[1][3],338 )339 finally:340 self._linux_cleanup_nat(server_l1, self._BR_NAME, log)341 self._linux_cleanup_nat(client_l1, self._BR_NAME, log)342 @TestCaseMetadata(343 description="""344 This script runs ntttcp test on two nested VMs on different L1 guests345 connected with NAT346 """,347 priority=3,348 timeout=_TIME_OUT,349 requirement=simple_requirement(350 min_count=2,351 supported_os=[Windows],352 supported_platform_type=[AZURE, READY],353 ),354 )355 def perf_nested_hyperv_ntttcp_different_l1_nat(356 self,357 result: TestResult,358 variables: Dict[str, Any],359 log: Logger,360 ) -> None:361 environment = result.environment362 assert environment, "fail to get environment from testresult"363 server_l1 = cast(RemoteNode, environment.nodes[0])364 client_l1 = cast(RemoteNode, environment.nodes[1])365 # parse nested image variables366 (367 nested_image_username,368 nested_image_password,369 _,370 nested_image_url,371 ) = parse_nested_image_variables(variables)372 try:373 # setup nested vm on server in NAT configuration374 server_l2 = self._windows_setup_nat(375 node=server_l1,376 nested_vm_name="server_l2",377 guest_username=nested_image_username,378 guest_password=nested_image_password,379 guest_port=self._SERVER_HOST_FWD_PORT,380 guest_image_url=nested_image_url,381 )382 # setup nested vm on client in NAT configuration383 client_l2 = self._windows_setup_nat(384 node=client_l1,385 nested_vm_name="client_l2",386 guest_username=nested_image_username,387 guest_password=nested_image_password,388 guest_port=self._CLIENT_HOST_FWD_PORT,389 guest_image_url=nested_image_url,390 )391 # run ntttcp test392 perf_ntttcp(393 result,394 server_l2,395 client_l2,396 test_case_name=inspect.stack()[1][3],397 )398 finally:399 # cleanup server400 try:401 hyperv_remove_nested_vm(server_l1, "server_l2")402 except Exception as e:403 log.debug(f"Failed to clean up server vm: {e}")404 server_l1.mark_dirty()405 # cleanup client406 try:407 hyperv_remove_nested_vm(client_l1, "client_l2")408 except Exception as e:409 log.debug(f"Failed to clean up client vm: {e}")410 client_l1.mark_dirty()411 @TestCaseMetadata(412 description="""413 This script runs netperf test on two nested VMs on different L1 guests414 connected with NAT415 """,416 priority=3,417 timeout=_TIME_OUT,418 requirement=simple_requirement(419 min_count=2,420 network_interface=schema.NetworkInterfaceOptionSettings(421 nic_count=search_space.IntRange(min=2),422 ),423 disk=schema.DiskOptionSettings(424 data_disk_count=search_space.IntRange(min=1),425 data_disk_size=search_space.IntRange(min=12),426 ),427 ),428 )429 def perf_nested_kvm_netperf_pps_nat(430 self,431 result: TestResult,432 variables: Dict[str, Any],433 log: Logger,434 ) -> None:435 environment = result.environment436 assert environment, "fail to get environment from testresult"437 server_l1 = cast(RemoteNode, environment.nodes[0])438 client_l1 = cast(RemoteNode, environment.nodes[1])439 # parse nested image variables440 (441 nested_image_username,442 nested_image_password,443 _,444 nested_image_url,445 ) = parse_nested_image_variables(variables)446 try:447 # setup nested vm on server in NAT configuration448 server_l2 = self._linux_setup_nat(449 node=server_l1,450 nested_vm_name="server_l2",451 guest_username=nested_image_username,452 guest_password=nested_image_password,453 guest_port=self._SERVER_HOST_FWD_PORT,454 guest_image_url=nested_image_url,455 guest_internal_ip=self._SERVER_IP_ADDR,456 guest_default_nic=self._NIC_NAME,457 bridge_name=self._BR_NAME,458 bridge_network=self._BR_NETWORK,459 bridge_cidr=self._BR_CIDR,460 bridge_gateway=self._BR_GATEWAY,461 )462 # setup nested vm on client in NAT configuration463 client_l2 = self._linux_setup_nat(464 node=client_l1,465 nested_vm_name="client_l2",466 guest_username=nested_image_username,467 guest_password=nested_image_password,468 guest_port=self._CLIENT_HOST_FWD_PORT,469 guest_image_url=nested_image_url,470 guest_internal_ip=self._CLIENT_IP_ADDR,471 guest_default_nic=self._NIC_NAME,472 bridge_name=self._BR_NAME,473 bridge_network=self._BR_NETWORK,474 bridge_cidr=self._BR_CIDR,475 bridge_gateway=self._BR_GATEWAY,476 )477 # run netperf test478 perf_tcp_pps(result, "singlepps", server_l2, client_l2)479 finally:480 self._linux_cleanup_nat(server_l1, self._BR_NAME, log)481 self._linux_cleanup_nat(client_l1, self._BR_NAME, log)482 def _linux_setup_nat(483 self,484 node: RemoteNode,485 nested_vm_name: str,486 guest_username: str,487 guest_password: str,488 guest_port: int,489 guest_image_url: str,490 guest_internal_ip: str,491 guest_default_nic: str,492 bridge_name: str,493 bridge_network: str,494 bridge_cidr: str,495 bridge_gateway: str,496 ) -> RemoteNode:...

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