def test_migrate_network_to_block(self): conf = drive_config(diskType=DISK_TYPE.NETWORK, path='pool/volume') drive = Drive({}, self.log, **conf) self.assertTrue(drive.networkDev) # Migrate drive to block domain... drive.path = '/blockdomain/volume' drive.diskType = None self.assertTrue(drive.blockDev)
def test_migrate_from_block_to_network(self): conf = drive_config(path='/blockdomain/volume') drive = Drive({}, self.log, **conf) self.assertTrue(drive.blockDev) # Migrate drive to network disk... drive.path = "pool/volume" drive.diskType = DISK_TYPE.NETWORK self.assertFalse(drive.blockDev)
def test_migrate_from_block_to_file(self): conf = drive_config(path='/blockdomain/volume') drive = Drive({}, self.log, **conf) self.assertTrue(drive.blockDev) # Migrate drive to file domain... utils.isBlockDevice = lambda path: False drive.path = "/filedomain/volume" self.assertFalse(drive.blockDev)
def test_migrate_from_block_to_network(self): conf = drive_config(path='/blockdomain/volume') drive = Drive({}, self.log, **conf) self.assertTrue(drive.blockDev) # Migrate drive to netowrk (not sure we will support this)... drive.path = "rbd:pool/volume" drive.volumeInfo = {'volType': 'network'} self.assertFalse(drive.blockDev)
def check_leases(self, conf): drive = Drive({}, self.log, **conf) leases = list(drive.getLeasesXML()) self.assertEqual(1, len(leases)) xml = """ <lease> <key>vol_id</key> <lockspace>dom_id</lockspace> <target offset="0" path="path" /> </lease> """ self.assertXMLEqual(vmxml.format_xml(leases[0]), xml)
def test_ide_drive(self, interface, index, expected_name): conf = drive_config( device='disk', iface=interface, index=index, ) drive = Drive({}, self.log, **conf) self.assertEqual(drive.name, expected_name)
def check(self, vm_conf, device_conf, xml, is_block_device=False): drive = Drive(vm_conf, self.log, **device_conf) # Patch to skip the block device checking. if is_block_device is not None: drive._blockDev = is_block_device self.assertXMLEqual(vmxml.format_xml(drive.getXML()), xml)
def check_no_leases(self, conf): drive = Drive({}, self.log, **conf) leases = list(drive.getLeasesXML()) self.assertEqual([], leases)
def test_no_replica(self): conf = drive_config() drive = Drive({}, self.log, **conf) self.assertEqual(drive.replicaChunked, False)
def test_replica(self, diskType, format, chunked): conf = drive_config(diskReplicate=replica(diskType, format=format)) drive = Drive({}, self.log, **conf) self.assertEqual(drive.replicaChunked, chunked)
def test_chunked(self, device, blockDev, format, chunked): conf = drive_config(device=device, format=format) drive = Drive({}, self.log, **conf) drive._blockDev = blockDev self.assertEqual(drive.chunked, chunked)
def check(self, vm_conf, device_conf, xml, is_block_device=False): drive = Drive(vm_conf, self.log, **device_conf) # Patch to skip the block device checking. drive._blockDev = is_block_device self.assertXMLEqual(drive.getReplicaXML().toxml(), xml)
def test_network_disk(self): # This is undocumented interface used by glusterfs conf = drive_config(volumeInfo={'volType': 'network'}) drive = Drive({}, self.log, **conf) self.assertTrue(drive.networkDev) self.assertFalse(drive.blockDev)
def check(self, shared, expected): conf = drive_config() if shared: conf['shared'] = shared drive = Drive({}, self.log, **conf) self.assertEqual(drive.extSharedState, expected)
def test_max_size(self): conf = drive_config(format='cow') drive = Drive({}, self.log, **conf) size = utils.round(self.CAPACITY * drive.VOLWM_COW_OVERHEAD, constants.MEGAB) self.assertEqual(drive.getMaxVolumeSize(self.CAPACITY), size)
def test_next_size_limit(self, cursize): conf = drive_config(format='cow') drive = Drive({}, self.log, **conf) self.assertEqual(drive.getNextVolumeSize(cursize, self.CAPACITY), drive.getMaxVolumeSize(self.CAPACITY))
def test_next_size(self, cursize): conf = drive_config(format='cow') drive = Drive({}, self.log, **conf) self.assertEqual(drive.getNextVolumeSize(cursize, self.CAPACITY), cursize + drive.volExtensionChunk)
def check(self, vm_conf, device_conf, xml, is_block_device=False): drive = Drive(vm_conf, self.log, **device_conf) # Patch to skip the block device checking. drive._blockDev = is_block_device self.assertXMLEqual(drive.getXML().toxml(), xml)
def check(self, **kw): conf = drive_config(**kw) drive = Drive({}, self.log, **conf) self.assertRaises(ValueError, drive.getXML)
def test_floppy(self): conf = drive_config(device='floppy') drive = Drive({}, self.log, **conf) self.assertFalse(drive.networkDev) self.assertFalse(drive.blockDev)
def test_network_disk(self): conf = drive_config(diskType=DISK_TYPE.NETWORK) drive = Drive({}, self.log, **conf) self.assertTrue(drive.networkDev) self.assertFalse(drive.blockDev)
def test_file_disk(self): conf = drive_config(device='disk') drive = Drive({}, self.log, **conf) self.assertFalse(drive.networkDev) self.assertFalse(drive.blockDev)
def test_replica(self, diskType, format): conf = drive_config(diskReplicate=replica(diskType, format=format)) drive = Drive({}, self.log, **conf) drive._blockDev = False self.assertEqual(drive.chunked, False)
def test_capacity_limit(self, cursize): conf = drive_config(format='cow') drive = Drive({}, self.log, **conf) self.assertEqual(drive.getNextVolumeSize(cursize, self.CAPACITY), self.CAPACITY / constants.MEGAB)