Best Python code snippet using tempest_python
test_volume_retype.py
Source:test_volume_retype.py
...50 # Delete the snapshot51 self.snapshots_client.delete_snapshot(snapshot['id'])52 self.snapshots_client.wait_for_resource_deletion(snapshot['id'])53 return src_vol54 def _retype_volume(self, volume, migration_policy):55 volume_source = self.admin_volume_client.show_volume(56 volume['id'])['volume']57 self.volumes_client.retype_volume(58 volume['id'],59 new_type=self.dst_vol_type['name'],60 migration_policy=migration_policy)61 self.addCleanup(self._wait_for_internal_volume_cleanup, volume)62 waiters.wait_for_volume_retype(self.volumes_client, volume['id'],63 self.dst_vol_type['name'])64 volume_dest = self.admin_volume_client.show_volume(65 volume['id'])['volume']66 self._verify_migration(volume_source, volume_dest)67class VolumeRetypeWithMigrationTest(VolumeRetypeTest):68 @classmethod69 def skip_checks(cls):70 super(VolumeRetypeTest, cls).skip_checks()71 if not CONF.volume_feature_enabled.multi_backend:72 raise cls.skipException("Cinder multi-backend feature disabled")73 if len(set(CONF.volume.backend_names)) < 2:74 raise cls.skipException("Requires at least two different "75 "backend names")76 @classmethod77 def resource_setup(cls):78 super(VolumeRetypeWithMigrationTest, cls).resource_setup()79 # read backend name from a list.80 backend_src = CONF.volume.backend_names[0]81 backend_dst = CONF.volume.backend_names[1]82 extra_specs_src = {"volume_backend_name": backend_src}83 extra_specs_dst = {"volume_backend_name": backend_dst}84 cls.src_vol_type = cls.create_volume_type(extra_specs=extra_specs_src)85 cls.dst_vol_type = cls.create_volume_type(extra_specs=extra_specs_dst)86 def _verify_migration(self, volume_source, volume_dest):87 keys_with_no_change = ('id', 'size', 'description', 'name',88 'user_id', 'os-vol-tenant-attr:tenant_id')89 keys_with_change = ('volume_type', 'os-vol-host-attr:host')90 # Check the volume information after the migration.91 self.assertEqual('success',92 volume_dest['os-vol-mig-status-attr:migstat'])93 self.assertEqual('success', volume_dest['migration_status'])94 for key in keys_with_no_change:95 self.assertEqual(volume_source[key], volume_dest[key])96 for key in keys_with_change:97 self.assertNotEqual(volume_source[key], volume_dest[key])98 self.assertEqual(volume_dest['volume_type'], self.dst_vol_type['name'])99 @decorators.idempotent_id('a1a41f3f-9dad-493e-9f09-3ff197d477cd')100 def test_available_volume_retype_with_migration(self):101 src_vol = self.create_volume(volume_type=self.src_vol_type['name'])102 self._retype_volume(src_vol, migration_policy='on-demand')103 @decorators.idempotent_id('d0d9554f-e7a5-4104-8973-f35b27ccb60d')104 def test_volume_from_snapshot_retype_with_migration(self):105 src_vol = self._create_volume_from_snapshot()106 # Migrate the volume from snapshot to the second backend107 self._retype_volume(src_vol, migration_policy='on-demand')108class VolumeRetypeWithoutMigrationTest(VolumeRetypeTest):109 @classmethod110 def resource_setup(cls):111 super(VolumeRetypeWithoutMigrationTest, cls).resource_setup()112 cls.src_vol_type = cls.create_volume_type('volume-type-1')113 cls.dst_vol_type = cls.create_volume_type('volume-type-2')114 def _verify_migration(self, volume_source, volume_dest):115 keys_with_no_change = ('id', 'size', 'description', 'name',116 'user_id', 'os-vol-tenant-attr:tenant_id',117 'os-vol-host-attr:host')118 keys_with_change = ('volume_type',)119 # Check the volume information after the retype120 self.assertIsNone(volume_dest['os-vol-mig-status-attr:migstat'])121 self.assertIsNone(volume_dest['migration_status'])122 for key in keys_with_no_change:123 self.assertEqual(volume_source[key], volume_dest[key])124 for key in keys_with_change:125 self.assertNotEqual(volume_source[key], volume_dest[key])126 self.assertEqual(volume_dest['volume_type'], self.dst_vol_type['name'])127 @decorators.idempotent_id('b90412ee-465d-46e9-b249-ec84a47d5f25')128 def test_available_volume_retype(self):129 src_vol = self.create_volume(volume_type=self.src_vol_type['name'])130 # Retype the volume from 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!!