Best Python code snippet using tempest_python
test_network_advanced_server_ops.py
Source:test_network_advanced_server_ops.py
...63 self.floating_ip = self._create_floating_ip(self.server,64 public_network_id)65 # Verify that we can indeed connect to the server before we mess with66 # it's state67 self._wait_server_status_and_check_network_connectivity()68 def _check_network_connectivity(self, should_connect=True):69 username = CONF.compute.image_ssh_user70 private_key = self.keypair['private_key']71 self._check_tenant_network_connectivity(72 self.server, username, private_key,73 should_connect=should_connect,74 servers_for_debug=[self.server])75 floating_ip = self.floating_ip.floating_ip_address76 self._check_public_network_connectivity(floating_ip, username,77 private_key, should_connect,78 servers=[self.server])79 self.check_floating_ip_status(self.floating_ip, 'ACTIVE')80 def _wait_server_status_and_check_network_connectivity(self):81 self.servers_client.wait_for_server_status(self.server['id'], 'ACTIVE')82 self._check_network_connectivity()83 @test.skip_because(bug="1323658")84 @test.services('compute', 'network')85 def test_server_connectivity_stop_start(self):86 self._setup_network_and_servers()87 self.servers_client.stop(self.server['id'])88 self.servers_client.wait_for_server_status(self.server['id'],89 'SHUTOFF')90 self._check_network_connectivity(should_connect=False)91 self.servers_client.start(self.server['id'])92 self._wait_server_status_and_check_network_connectivity()93 @test.services('compute', 'network')94 def test_server_connectivity_reboot(self):95 self._setup_network_and_servers()96 self.servers_client.reboot(self.server['id'], reboot_type='SOFT')97 self._wait_server_status_and_check_network_connectivity()98 @test.services('compute', 'network')99 def test_server_connectivity_rebuild(self):100 self._setup_network_and_servers()101 image_ref_alt = CONF.compute.image_ref_alt102 self.servers_client.rebuild(self.server['id'],103 image_ref=image_ref_alt)104 self._wait_server_status_and_check_network_connectivity()105 @testtools.skipUnless(CONF.compute_feature_enabled.pause,106 'Pause is not available.')107 @test.services('compute', 'network')108 def test_server_connectivity_pause_unpause(self):109 self._setup_network_and_servers()110 self.servers_client.pause_server(self.server['id'])111 self.servers_client.wait_for_server_status(self.server['id'], 'PAUSED')112 self._check_network_connectivity(should_connect=False)113 self.servers_client.unpause_server(self.server['id'])114 self._wait_server_status_and_check_network_connectivity()115 @testtools.skipUnless(CONF.compute_feature_enabled.suspend,116 'Suspend is not available.')117 @test.services('compute', 'network')118 def test_server_connectivity_suspend_resume(self):119 self._setup_network_and_servers()120 self.servers_client.suspend_server(self.server['id'])121 self.servers_client.wait_for_server_status(self.server['id'],122 'SUSPENDED')123 self._check_network_connectivity(should_connect=False)124 self.servers_client.resume_server(self.server['id'])125 self._wait_server_status_and_check_network_connectivity()126 @test.skip_because(bug="1323658")127 @testtools.skipUnless(CONF.compute_feature_enabled.resize,128 'Resize is not available.')129 @test.services('compute', 'network')130 def test_server_connectivity_resize(self):131 resize_flavor = CONF.compute.flavor_ref_alt132 if resize_flavor == CONF.compute.flavor_ref:133 msg = "Skipping test - flavor_ref and flavor_ref_alt are identical"134 raise self.skipException(msg)135 self._setup_network_and_servers()136 self.servers_client.resize(self.server['id'], flavor_ref=resize_flavor)137 self.servers_client.wait_for_server_status(self.server['id'],138 'VERIFY_RESIZE')139 self.servers_client.confirm_resize(self.server['id'])...
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!!