Best Python code snippet using tempest_python
test_migrations.py
Source:test_migrations.py
...44 server_id, 'ACTIVE')45 body = self.client.list_migrations()['migrations']46 instance_uuids = [x['instance_uuid'] for x in body]47 self.assertIn(server_id, instance_uuids)48 def _flavor_clean_up(self, flavor_id):49 try:50 self.flavors_admin_client.delete_flavor(flavor_id)51 self.flavors_admin_client.wait_for_resource_deletion(flavor_id)52 except exceptions.NotFound:53 pass54 @test.idempotent_id('33f1fec3-ba18-4470-8e4e-1d888e7c3593')55 @testtools.skipUnless(CONF.compute_feature_enabled.resize,56 'Resize not available.')57 def test_resize_server_revert_deleted_flavor(self):58 # Tests that we can revert the resize on an instance whose original59 # flavor has been deleted.60 # First we have to create a flavor that we can delete so make a copy61 # of the normal flavor from which we'd create a server.62 flavor = self.flavors_admin_client.show_flavor(63 self.flavor_ref)['flavor']64 flavor = self.flavors_admin_client.create_flavor(65 name=data_utils.rand_name('test_resize_flavor_'),66 ram=flavor['ram'],67 disk=flavor['disk'],68 vcpus=flavor['vcpus']69 )['flavor']70 self.addCleanup(self._flavor_clean_up, flavor['id'])71 # Now boot a server with the copied flavor.72 server = self.create_test_server(73 wait_until='ACTIVE', flavor=flavor['id'])74 # Delete the flavor we used to boot the instance.75 self._flavor_clean_up(flavor['id'])76 # Now resize the server and wait for it to go into verify state.77 self.servers_client.resize_server(server['id'], self.flavor_ref_alt)78 waiters.wait_for_server_status(self.servers_client, server['id'],79 'VERIFY_RESIZE')80 # Now revert the resize, it should be OK even though the original81 # flavor used to boot the server was deleted.82 self.servers_client.revert_resize_server(server['id'])83 waiters.wait_for_server_status(self.servers_client, server['id'],84 'ACTIVE')85 server = self.servers_client.show_server(server['id'])['server']...
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!!