Best Python code snippet using tempest_python
test_volume_delete_cascade.py
Source:test_volume_delete_cascade.py
...29 def skip_checks(cls):30 super(VolumesDeleteCascade, cls).skip_checks()31 if not CONF.volume_feature_enabled.snapshot:32 raise cls.skipException("Cinder snapshot feature disabled")33 def _assert_cascade_delete(self, volume_id):34 # Fetch volume ids35 volume_list = [36 vol['id'] for vol in37 self.volumes_client.list_volumes()['volumes']38 ]39 # Verify the parent volume was deleted40 self.assertNotIn(volume_id, volume_list)41 # List snapshots42 snapshot_list = self.snapshots_client.list_snapshots()['snapshots']43 # Verify snapshots were deleted44 self.assertNotIn(volume_id, map(operator.itemgetter('volume_id'),45 snapshot_list))46 @decorators.idempotent_id('994e2d40-de37-46e8-b328-a58fba7e4a95')47 def test_volume_delete_cascade(self):48 # The case validates the ability to delete a volume49 # with associated snapshots.50 # Create a volume51 volume = self.create_volume()52 for _ in range(2):53 self.create_snapshot(volume['id'])54 # Delete the parent volume with associated snapshots55 self.volumes_client.delete_volume(volume['id'], cascade=True)56 self.volumes_client.wait_for_resource_deletion(volume['id'])57 # Verify volume parent was deleted with its associated snapshots58 self._assert_cascade_delete(volume['id'])59 @decorators.idempotent_id('59a77ede-609b-4ee8-9f68-fc3c6ffe97b5')60 @testtools.skipIf(CONF.volume.storage_protocol == 'ceph',61 'Skip because of Bug#1677525')62 def test_volume_from_snapshot_cascade_delete(self):63 # The case validates the ability to delete a volume with64 # associated snapshot while there is another volume created65 # from that snapshot.66 # Create a volume67 volume = self.create_volume()68 snapshot = self.create_snapshot(volume['id'])69 # Create volume from snapshot70 volume_snap = self.create_volume(snapshot_id=snapshot['id'])71 volume_details = self.volumes_client.show_volume(72 volume_snap['id'])['volume']73 self.assertEqual(snapshot['id'], volume_details['snapshot_id'])74 # Delete the parent volume with associated snapshot75 self.volumes_client.delete_volume(volume['id'], cascade=True)76 self.volumes_client.wait_for_resource_deletion(volume['id'])77 # Verify volume parent was deleted with its associated snapshot...
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!!