Best Python code snippet using tempest_python
test_volumes_actions.py
Source:test_volumes_actions.py
...22 def _create_reset_and_force_delete_temp_volume(self, status=None):23 # Create volume, reset volume status, and force delete temp volume24 temp_volume = self.create_volume()25 if status:26 self.admin_volume_client.reset_volume_status(27 temp_volume['id'], status=status)28 self.admin_volume_client.force_delete_volume(temp_volume['id'])29 self.volumes_client.wait_for_resource_deletion(temp_volume['id'])30 @decorators.idempotent_id('d063f96e-a2e0-4f34-8b8a-395c42de1845')31 def test_volume_reset_status(self):32 # test volume reset status : available->error->available33 volume = self.create_volume()34 self.addCleanup(self.admin_volume_client.reset_volume_status,35 volume['id'], status='available')36 for status in ['error', 'available', 'maintenance']:37 self.admin_volume_client.reset_volume_status(38 volume['id'], status=status)39 volume_get = self.admin_volume_client.show_volume(40 volume['id'])['volume']41 self.assertEqual(status, volume_get['status'])42 @decorators.idempotent_id('21737d5a-92f2-46d7-b009-a0cc0ee7a570')43 def test_volume_force_delete_when_volume_is_creating(self):44 # test force delete when status of volume is creating45 self._create_reset_and_force_delete_temp_volume('creating')46 @decorators.idempotent_id('db8d607a-aa2e-4beb-b51d-d4005c232011')47 def test_volume_force_delete_when_volume_is_attaching(self):48 # test force delete when status of volume is attaching49 self._create_reset_and_force_delete_temp_volume('attaching')50 @decorators.idempotent_id('3e33a8a8-afd4-4d64-a86b-c27a185c5a4a')51 def test_volume_force_delete_when_volume_is_error(self):52 # test force delete when status of volume is error53 self._create_reset_and_force_delete_temp_volume('error')54 @decorators.idempotent_id('b957cabd-1486-4e21-90cf-a9ed3c39dfb2')55 def test_volume_force_delete_when_volume_is_maintenance(self):56 # test force delete when status of volume is maintenance57 self._create_reset_and_force_delete_temp_volume('maintenance')58 @decorators.idempotent_id('d38285d9-929d-478f-96a5-00e66a115b81')59 @test.services('compute')60 def test_force_detach_volume(self):61 # Create a server and a volume62 server_id = self.create_server()['id']63 volume_id = self.create_volume()['id']64 # Attach volume65 self.volumes_client.attach_volume(66 volume_id,67 instance_uuid=server_id,68 mountpoint='/dev/%s' % CONF.compute.volume_device_name)69 waiters.wait_for_volume_resource_status(self.volumes_client,70 volume_id, 'in-use')71 self.addCleanup(waiters.wait_for_volume_resource_status,72 self.volumes_client, volume_id, 'available')73 self.addCleanup(self.volumes_client.detach_volume, volume_id)74 attachment = self.volumes_client.show_volume(75 volume_id)['volume']['attachments'][0]76 # Reset volume's status to error77 self.admin_volume_client.reset_volume_status(volume_id, status='error')78 # Force detach volume79 self.admin_volume_client.force_detach_volume(80 volume_id, connector=None,81 attachment_id=attachment['attachment_id'])82 waiters.wait_for_volume_resource_status(self.volumes_client,83 volume_id, 'available')84 vol_info = self.volumes_client.show_volume(volume_id)['volume']85 self.assertIn('attachments', vol_info)...
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!!