use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class MultipleStorageDomainsValidatorTest method testAllDomainsHaveSpaceForClonedDisksFail.
@Test
public void testAllDomainsHaveSpaceForClonedDisksFail() {
List<Guid> sdIds = Arrays.asList(sdId1, sdId2);
List<DiskImage> disksList = generateDisksList(NUM_DISKS, sdIds);
StorageDomainValidator storageDomainValidator = mock(StorageDomainValidator.class);
doReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN)).when(storageDomainValidator).hasSpaceForClonedDisks(any());
doReturn(storageDomainValidator).when(validator).getStorageDomainValidator(any());
ValidationResult result = validator.allDomainsHaveSpaceForClonedDisks(disksList);
assertThat(result, failsWith(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN));
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class MultipleStorageDomainsValidatorTest method testAllDomainsHaveSpaceForAllDisksFail.
@Test
public void testAllDomainsHaveSpaceForAllDisksFail() {
List<Guid> sdIdsForNew = Arrays.asList(sdId1, sdId2);
List<Guid> sdIdsForCloned = Arrays.asList(sdId2, sdId3);
List<DiskImage> disksListForNew = generateDisksList(NUM_DISKS, sdIdsForNew);
List<DiskImage> disksListForCloned = generateDisksList(NUM_DISKS, sdIdsForCloned);
StorageDomainValidator storageDomainValidator = mock(StorageDomainValidator.class);
doReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN)).when(storageDomainValidator).hasSpaceForAllDisks(any(), any());
doReturn(storageDomainValidator).when(validator).getStorageDomainValidator(any());
ValidationResult result = validator.allDomainsHaveSpaceForAllDisks(disksListForNew, disksListForCloned);
assertThat(result, failsWith(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN));
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class StorageDomainValidatorFreeSpaceTest method createParams.
@Parameterized.Parameters
public static Collection<Object[]> createParams() {
List<Object[]> params = new ArrayList<>();
for (StorageType storageType : StorageType.values()) {
if (storageType.isConcreteStorageType() && !storageType.isCinderDomain()) {
List<VolumeType> volumeTypes = storageType.isFileDomain() ? Arrays.asList(VolumeType.Preallocated, VolumeType.Sparse) : Collections.singletonList(VolumeType.Preallocated);
for (VolumeType volumeType : volumeTypes) {
for (VolumeFormat volumeFormat : new VolumeFormat[] { VolumeFormat.COW, VolumeFormat.RAW }) {
DiskImage disk = new DiskImage();
disk.setVolumeFormat(volumeFormat);
disk.setVolumeType(volumeType);
disk.getSnapshots().add(disk);
disk.setSizeInGigabytes(200);
// GB
disk.setActualSize(100);
StorageDomain sd = new StorageDomain();
sd.setStorageType(storageType);
// GB
sd.setAvailableDiskSize(107);
params.add(new Object[] { disk, sd, volumeFormat == VolumeFormat.RAW && volumeType == VolumeType.Sparse, volumeFormat == VolumeFormat.COW || volumeType == VolumeType.Sparse, volumeFormat == VolumeFormat.RAW && volumeType == VolumeType.Sparse });
}
}
}
}
return params;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class StorageDomainValidatorTest method invalidRunningVmsAndVmLeasesForBackupDomain.
@Test
public void invalidRunningVmsAndVmLeasesForBackupDomain() {
QueryReturnValue ret = new QueryReturnValue();
List<VmBase> vmLeases = new ArrayList<>();
VM vmWithLease = new VM();
vmWithLease.setName("firstVM");
vmLeases.add(vmWithLease.getStaticData());
ret.setReturnValue(vmLeases);
ret.setSucceeded(true);
// VM1
VM vm1 = new VM();
vm1.setName("firstVM");
Map<Guid, Disk> attachedDisksForVm1 = new HashMap<>();
DiskImage diskVm1 = new DiskImage();
diskVm1.setStorageIds(new ArrayList<>(Collections.singletonList(domain.getId())));
diskVm1.setPlugged(true);
attachedDisksForVm1.put(Guid.newGuid(), diskVm1);
vm1.setDiskMap(attachedDisksForVm1);
// VM2
VM vm2 = new VM();
vm2.setName("secondVM");
Map<Guid, Disk> attachedDisksForVm2 = new HashMap<>();
DiskImage diskVm2 = new DiskImage();
diskVm2.setStorageIds(new ArrayList<>(Collections.singletonList(domain.getId())));
diskVm2.setPlugged(true);
attachedDisksForVm2.put(Guid.newGuid(), diskVm2);
vm2.setDiskMap(attachedDisksForVm2);
List<VM> runningVMs = new ArrayList<>();
runningVMs.add(vm1);
runningVMs.add(vm2);
when(vmDao.getAllActiveForStorageDomain(any())).thenReturn(runningVMs);
doReturn(ret).when(validator).getEntitiesWithLeaseIdForStorageDomain(any());
assertThat(validator.isRunningVmsOrVmLeasesForBackupDomain(vmHandler), failsWith(EngineMessage.ACTION_TYPE_FAILED_RUNNING_VM_OR_VM_LEASES_PRESENT_ON_STORAGE_DOMAIN));
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.
the class StorageDomainValidatorTest method validRunningVmsWithUnpluggedDisksForBackupDomain.
@Test
public void validRunningVmsWithUnpluggedDisksForBackupDomain() {
// VM1
VM vm1 = new VM();
vm1.setName("firstVM");
Map<Guid, Disk> attachedDisksForVm1 = new HashMap<>();
DiskImage diskVm1 = new DiskImage();
diskVm1.setStorageIds(new ArrayList<>(Collections.singletonList(domain.getId())));
diskVm1.setPlugged(false);
attachedDisksForVm1.put(Guid.newGuid(), diskVm1);
vm1.setDiskMap(attachedDisksForVm1);
List<VM> runningVMs = new ArrayList<>();
runningVMs.add(vm1);
when(vmDao.getAllActiveForStorageDomain(any())).thenReturn(runningVMs);
QueryReturnValue ret = new QueryReturnValue();
ret.setReturnValue(new ArrayList<VmBase>());
ret.setSucceeded(true);
doReturn(ret).when(validator).getEntitiesWithLeaseIdForStorageDomain(any());
assertThat(validator.isRunningVmsOrVmLeasesForBackupDomain(vmHandler), isValid());
}
Aggregations