How to use _wait_server_status_and_check_network_connectivity method in tempest

Best Python code snippet using tempest_python

test_network_advanced_server_ops.py

Source:test_network_advanced_server_ops.py Github

copy

Full Screen

...62 public_network_id = CONF.network.public_network_id63 floating_ip = self.create_floating_ip(server, public_network_id)64 # Verify that we can indeed connect to the server before we mess with65 # it's state66 self._wait_server_status_and_check_network_connectivity(67 server, keypair, floating_ip)68 return floating_ip69 def _check_network_connectivity(self, server, keypair, floating_ip,70 should_connect=True):71 username = CONF.validation.image_ssh_user72 private_key = keypair['private_key']73 self.check_tenant_network_connectivity(74 server, username, private_key,75 should_connect=should_connect,76 servers_for_debug=[server])77 floating_ip_addr = floating_ip['floating_ip_address']78 # Check FloatingIP status before checking the connectivity79 self.check_floating_ip_status(floating_ip, 'ACTIVE')80 self.check_vm_connectivity(floating_ip_addr, username,81 private_key, should_connect,82 'Public network connectivity check failed',83 server)84 def _wait_server_status_and_check_network_connectivity(self, server,85 keypair,86 floating_ip):87 waiters.wait_for_server_status(self.servers_client, server['id'],88 'ACTIVE')89 self._check_network_connectivity(server, keypair, floating_ip)90 @decorators.idempotent_id('61f1aa9a-1573-410e-9054-afa557cab021')91 @decorators.attr(type='slow')92 @utils.services('compute', 'network')93 def test_server_connectivity_stop_start(self):94 keypair = self.create_keypair()95 server = self._setup_server(keypair)96 floating_ip = self._setup_network(server, keypair)97 self.servers_client.stop_server(server['id'])98 waiters.wait_for_server_status(self.servers_client, server['id'],99 'SHUTOFF')100 self._check_network_connectivity(server, keypair, floating_ip,101 should_connect=False)102 self.servers_client.start_server(server['id'])103 self._wait_server_status_and_check_network_connectivity(104 server, keypair, floating_ip)105 @decorators.idempotent_id('7b6860c2-afa3-4846-9522-adeb38dfbe08')106 @decorators.attr(type='slow')107 @utils.services('compute', 'network')108 def test_server_connectivity_reboot(self):109 keypair = self.create_keypair()110 server = self._setup_server(keypair)111 floating_ip = self._setup_network(server, keypair)112 self.servers_client.reboot_server(server['id'], type='SOFT')113 self._wait_server_status_and_check_network_connectivity(114 server, keypair, floating_ip)115 @decorators.idempotent_id('88a529c2-1daa-4c85-9aec-d541ba3eb699')116 @decorators.attr(type='slow')117 @utils.services('compute', 'network')118 def test_server_connectivity_rebuild(self):119 keypair = self.create_keypair()120 server = self._setup_server(keypair)121 floating_ip = self._setup_network(server, keypair)122 image_ref_alt = CONF.compute.image_ref_alt123 self.servers_client.rebuild_server(server['id'],124 image_ref=image_ref_alt)125 self._wait_server_status_and_check_network_connectivity(126 server, keypair, floating_ip)127 @decorators.idempotent_id('2b2642db-6568-4b35-b812-eceed3fa20ce')128 @testtools.skipUnless(CONF.compute_feature_enabled.pause,129 'Pause is not available.')130 @decorators.attr(type='slow')131 @utils.services('compute', 'network')132 def test_server_connectivity_pause_unpause(self):133 keypair = self.create_keypair()134 server = self._setup_server(keypair)135 floating_ip = self._setup_network(server, keypair)136 self.servers_client.pause_server(server['id'])137 waiters.wait_for_server_status(self.servers_client, server['id'],138 'PAUSED')139 self._check_network_connectivity(server, keypair, floating_ip,140 should_connect=False)141 self.servers_client.unpause_server(server['id'])142 self._wait_server_status_and_check_network_connectivity(143 server, keypair, floating_ip)144 @decorators.idempotent_id('5cdf9499-541d-4923-804e-b9a60620a7f0')145 @testtools.skipUnless(CONF.compute_feature_enabled.suspend,146 'Suspend is not available.')147 @decorators.attr(type='slow')148 @utils.services('compute', 'network')149 def test_server_connectivity_suspend_resume(self):150 keypair = self.create_keypair()151 server = self._setup_server(keypair)152 floating_ip = self._setup_network(server, keypair)153 self.servers_client.suspend_server(server['id'])154 waiters.wait_for_server_status(self.servers_client, server['id'],155 'SUSPENDED')156 self._check_network_connectivity(server, keypair, floating_ip,157 should_connect=False)158 self.servers_client.resume_server(server['id'])159 self._wait_server_status_and_check_network_connectivity(160 server, keypair, floating_ip)161 @decorators.idempotent_id('719eb59d-2f42-4b66-b8b1-bb1254473967')162 @testtools.skipUnless(CONF.compute_feature_enabled.resize,163 'Resize is not available.')164 @decorators.attr(type='slow')165 @utils.services('compute', 'network')166 def test_server_connectivity_resize(self):167 resize_flavor = CONF.compute.flavor_ref_alt168 keypair = self.create_keypair()169 server = self._setup_server(keypair)170 floating_ip = self._setup_network(server, keypair)171 self.servers_client.resize_server(server['id'],172 flavor_ref=resize_flavor)173 waiters.wait_for_server_status(self.servers_client, server['id'],174 'VERIFY_RESIZE')175 self.servers_client.confirm_resize_server(server['id'])176 server = self.servers_client.show_server(server['id'])['server']177 # Nova API > 2.46 no longer includes flavor.id, and schema check178 # will cover whether 'id' should be in flavor179 if server['flavor'].get('id'):180 self.assertEqual(resize_flavor, server['flavor']['id'])181 else:182 flavor = self.flavors_client.show_flavor(resize_flavor)['flavor']183 self.assertEqual(flavor['name'], server['original_name'])184 for key in ['ram', 'vcpus', 'disk']:185 self.assertEqual(flavor[key], server['flavor'][key])186 self._wait_server_status_and_check_network_connectivity(187 server, keypair, floating_ip)188 @decorators.idempotent_id('a4858f6c-401e-4155-9a49-d5cd053d1a2f')189 @testtools.skipUnless(CONF.compute_feature_enabled.cold_migration,190 'Cold migration is not available.')191 @testtools.skipUnless(CONF.compute.min_compute_nodes > 1,192 'Less than 2 compute nodes, skipping multinode '193 'tests.')194 @decorators.attr(type='slow')195 @utils.services('compute', 'network')196 def test_server_connectivity_cold_migration(self):197 keypair = self.create_keypair()198 server = self._setup_server(keypair)199 floating_ip = self._setup_network(server, keypair)200 src_host = self.get_host_for_server(server['id'])201 self._wait_server_status_and_check_network_connectivity(202 server, keypair, floating_ip)203 self.admin_servers_client.migrate_server(server['id'])204 waiters.wait_for_server_status(self.servers_client, server['id'],205 'VERIFY_RESIZE')206 self.servers_client.confirm_resize_server(server['id'])207 self._wait_server_status_and_check_network_connectivity(208 server, keypair, floating_ip)209 dst_host = self.get_host_for_server(server['id'])210 self.assertNotEqual(src_host, dst_host)211 @decorators.idempotent_id('03fd1562-faad-11e7-9ea0-fa163e65f5ce')212 @testtools.skipUnless(CONF.compute_feature_enabled.live_migration,213 'Live migration is not available.')214 @testtools.skipUnless(CONF.compute.min_compute_nodes > 1,215 'Less than 2 compute nodes, skipping multinode '216 'tests.')217 @decorators.attr(type='slow')218 @utils.services('compute', 'network')219 def test_server_connectivity_live_migration(self):220 keypair = self.create_keypair()221 server = self._setup_server(keypair)222 floating_ip = self._setup_network(server, keypair)223 self._wait_server_status_and_check_network_connectivity(224 server, keypair, floating_ip)225 block_migration = (CONF.compute_feature_enabled.226 block_migration_for_live_migration)227 self.admin_servers_client.live_migrate_server(228 server['id'], host=None, block_migration=block_migration,229 disk_over_commit=False)230 waiters.wait_for_server_status(self.servers_client,231 server['id'], 'ACTIVE')232 self._wait_server_status_and_check_network_connectivity(233 server, keypair, floating_ip)234 @decorators.skip_because(bug='1836595')235 @decorators.idempotent_id('25b188d7-0183-4b1e-a11d-15840c8e2fd6')236 @testtools.skipUnless(CONF.compute_feature_enabled.cold_migration,237 'Cold migration is not available.')238 @testtools.skipUnless(CONF.compute.min_compute_nodes > 1,239 'Less than 2 compute nodes, skipping multinode '240 'tests.')241 @decorators.attr(type='slow')242 @utils.services('compute', 'network')243 def test_server_connectivity_cold_migration_revert(self):244 keypair = self.create_keypair()245 server = self._setup_server(keypair)246 floating_ip = self._setup_network(server, keypair)247 src_host = self.get_host_for_server(server['id'])248 self._wait_server_status_and_check_network_connectivity(249 server, keypair, floating_ip)250 self.admin_servers_client.migrate_server(server['id'])251 waiters.wait_for_server_status(self.servers_client, server['id'],252 'VERIFY_RESIZE')253 self.servers_client.revert_resize_server(server['id'])254 self._wait_server_status_and_check_network_connectivity(255 server, keypair, floating_ip)256 dst_host = self.get_host_for_server(server['id'])...

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 tempest 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