How to use _verify_migration method in tempest

Best Python code snippet using tempest_python

test_volume_retype.py

Source:test_volume_retype.py Github

copy

Full Screen

...36 self.admin_volume_client.wait_for_resource_deletion(37 fetched_vol['id'])38 break39 @abc.abstractmethod40 def _verify_migration(self, source_vol, dest_vol):41 pass42 def _create_volume_from_snapshot(self):43 # Create a volume in the first backend44 src_vol = self.create_volume(volume_type=self.src_vol_type['name'])45 # Create a volume snapshot46 snapshot = self.create_snapshot(src_vol['id'])47 # Create a volume from the snapshot48 src_vol = self.create_volume(volume_type=self.src_vol_type['name'],49 snapshot_id=snapshot['id'])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):...

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