def test_offline_migration_xfs_disk_decrease(self): # Decreasing disk size back during migration disk_size_gib = self.vm_obj['disk_size_gib'] disk_set(VM_HOSTNAME, '+1') self.check_vm_present() self._xfs_migrate_wrapper( VM_HOSTNAME, offline=True, offline_transport='xfs', disk_size=disk_size_gib, ) self.check_vm_present()
def test_disk_set(self): def _get_disk_hv(): return (self.vm.hypervisor.vm_sync_from_hypervisor( self.vm)['disk_size_gib']) def _get_disk_vm(): return parse_size( self.vm.run( "df -h / | tail -n+2 | awk '{ print $2 }'").strip(), 'G') # Initial size same as built obj = Query({'hostname': VM_HOSTNAME}, ['disk_size_gib']).get() size = obj['disk_size_gib'] self.assertEqual(_get_disk_hv(), size) self.assertEqual(_get_disk_vm(), size) size = size + 1 disk_set(VM_HOSTNAME, '+1') obj = Query({'hostname': VM_HOSTNAME}, ['disk_size_gib']).get() self.assertEqual(obj['disk_size_gib'], size) self.assertEqual(_get_disk_hv(), size) self.assertEqual(_get_disk_vm(), size) size = 8 disk_set(VM_HOSTNAME, '{}GB'.format(size)) obj = Query({'hostname': VM_HOSTNAME}, ['disk_size_gib']).get() self.assertEqual(obj['disk_size_gib'], size) self.assertEqual(_get_disk_hv(), size) self.assertEqual(_get_disk_vm(), size) with self.assertRaises(Warning): disk_set(VM_HOSTNAME, '{}GB'.format(size)) with self.assertRaises(NotImplementedError): disk_set(VM_HOSTNAME, '{}GB'.format(size - 1)) with self.assertRaises(NotImplementedError): disk_set(VM_HOSTNAME, '-1')
def test_disk_set(self): if self.datacenter_type == 'kvm.dct': def _get_disk_hv(): return (self.vm.hypervisor.vm_sync_from_hypervisor( self.vm)['disk_size_gib']) def _get_disk_vm(): return parse_size( self.vm.run( "df -h / | tail -n+2 | awk '{ print $2 }'").strip(), 'G') elif self.datacenter_type == 'aws.dct': def _get_disk_vm(): partition = self.vm.run('findmnt -nro SOURCE /') disk = self.vm.run('lsblk -nro PKNAME {}'.format(partition)) disk_size = self.vm.run( 'lsblk -bdnro size /dev/{}'.format(disk)) disk_size_gib = int(disk_size) / 1024**3 return disk_size_gib # Initial size same as built obj = Query({'hostname': VM_HOSTNAME}, ['disk_size_gib']).get() size = obj['disk_size_gib'] if self.datacenter_type == 'kvm.dct': self.assertEqual(_get_disk_hv(), size) self.assertEqual(_get_disk_vm(), size) size = size + 1 disk_set(VM_HOSTNAME, '+1') obj = Query({'hostname': VM_HOSTNAME}, ['disk_size_gib']).get() self.assertEqual(obj['disk_size_gib'], size) if self.datacenter_type == 'kvm.dct': self.assertEqual(_get_disk_hv(), size) self.assertEqual(_get_disk_vm(), size) size = obj['disk_size_gib'] + 1 if self.datacenter_type == 'kvm.dct': disk_set(VM_HOSTNAME, '{}GB'.format(size)) obj = Query({'hostname': VM_HOSTNAME}, ['disk_size_gib']).get() self.assertEqual(obj['disk_size_gib'], size) self.assertEqual(_get_disk_hv(), size) self.assertEqual(_get_disk_vm(), size) elif self.datacenter_type == 'aws.dct': with self.assertRaises(VMError): disk_set(VM_HOSTNAME, '{}GB'.format(size)) if self.datacenter_type == 'kvm.dct': with self.assertRaises(Warning): disk_set(VM_HOSTNAME, '{}GB'.format(size)) obj = Query({'hostname': VM_HOSTNAME}, ['disk_size_gib']).get() size = obj['disk_size_gib'] with self.assertRaises(NotImplementedError): disk_set(VM_HOSTNAME, '{}GB'.format(size - 1)) with self.assertRaises(NotImplementedError): disk_set(VM_HOSTNAME, '-1')