Search in sources :

Example 26 with ValidationResult

use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.

the class DiskVmElementDiscardSupportValidatorTest method data.

@Parameters
public static Object[][] data() {
    ValidationResult passDiscardNotSupportedByDiskInterface = new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_DISK_INTERFACE, getDiskAliasVarReplacement());
    ValidationResult passDiscardNotSupportedForDirectLunByUnderlyingStorage = new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_FOR_DIRECT_LUN_BY_UNDERLYING_STORAGE, getDiskAliasVarReplacement());
    ValidationResult passDiscardNotSupportedForDiskImageByUnderlyingStorage = new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_FOR_DISK_IMAGE_BY_UNDERLYING_STORAGE, getDiskAliasVarReplacement(), getStorageDomainNameVarReplacement());
    ValidationResult passDiscardNotSupportedByCinder = new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_DISK_STORAGE_TYPE, getDiskAliasVarReplacement(), String.format("$diskStorageType %s", DiskStorageType.CINDER));
    // sdSupportsDiscard, diskWipeAfterDelete, expectedResult.
    return new Object[][] { // isPassDiscard == false
    { new DiskImage(), false, null, null, null, null, null, ValidationResult.VALID }, // Unsupported interface
    { new DiskImage(), true, DiskInterface.VirtIO, null, null, null, null, passDiscardNotSupportedByDiskInterface }, { new DiskImage(), true, DiskInterface.SPAPR_VSCSI, null, null, null, null, passDiscardNotSupportedByDiskInterface }, // Direct lun without support from underlying storage (different interfaces)
    { new LunDisk(), true, DiskInterface.VirtIO_SCSI, 0L, null, null, null, passDiscardNotSupportedForDirectLunByUnderlyingStorage }, { new LunDisk(), true, DiskInterface.IDE, 0L, null, null, null, passDiscardNotSupportedForDirectLunByUnderlyingStorage }, // Direct lun with support from underlying storage (different interfaces)
    { new LunDisk(), true, DiskInterface.VirtIO_SCSI, 1024L, null, null, null, ValidationResult.VALID }, { new LunDisk(), true, DiskInterface.IDE, 1024L, null, null, null, ValidationResult.VALID }, /*
                Image on file storage domain:
                - with/without support from underlying storage
                - different interfaces
                - different file storage types
                 */
    { new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.NFS, true, null, ValidationResult.VALID }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.POSIXFS, false, null, ValidationResult.VALID }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.POSIXFS, null, null, ValidationResult.VALID }, /*
                Image on block storage domain without support from underlying storage:
                - different interfaces
                - different block storage types
                 */
    { new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.ISCSI, false, null, passDiscardNotSupportedForDiskImageByUnderlyingStorage }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.FCP, false, null, passDiscardNotSupportedForDiskImageByUnderlyingStorage }, /*
                Image on block storage domain with support from underlying storage:
                - different interfaces
                - different block storage types
                 */
    { new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.ISCSI, true, null, ValidationResult.VALID }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.FCP, true, null, ValidationResult.VALID }, /*
                Image on block storage domain with support from underlying storage and WAD enabled:
                - different interfaces
                - different block storage types
                 */
    { new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.ISCSI, true, true, new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_UNDERLYING_STORAGE_WHEN_WAD_IS_ENABLED, getStorageDomainNameVarReplacement(), getDiskAliasVarReplacement()) }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.FCP, true, true, new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_UNDERLYING_STORAGE_WHEN_WAD_IS_ENABLED, getStorageDomainNameVarReplacement(), getDiskAliasVarReplacement()) }, /*
                Image on non file or block storage domain:
                - different interfaces
                - different non file or block storage types
                 */
    { new DiskImage(), true, DiskInterface.VirtIO_SCSI, null, StorageType.UNKNOWN, null, null, createPassDiscardNotSupportedByStorageTypeValResult(StorageType.UNKNOWN) }, { new DiskImage(), true, DiskInterface.IDE, null, StorageType.CINDER, null, null, createPassDiscardNotSupportedByStorageTypeValResult(StorageType.CINDER) }, // Unsupported disk storage type (different interfaces)
    { new CinderDisk(), true, DiskInterface.VirtIO_SCSI, null, null, null, null, passDiscardNotSupportedByCinder }, { new CinderDisk(), true, DiskInterface.IDE, null, null, null, null, passDiscardNotSupportedByCinder } };
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Parameters(org.junit.runners.Parameterized.Parameters)

Example 27 with ValidationResult

use of org.ovirt.engine.core.bll.ValidationResult 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));
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Example 28 with ValidationResult

use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.

the class MultipleStorageDomainsValidatorTest method testAllDomainsExistAndActiveOneInactive.

@Test
public void testAllDomainsExistAndActiveOneInactive() {
    domain1.setStatus(StorageDomainStatus.Active);
    domain2.setStatus(StorageDomainStatus.Inactive);
    domain3.setStatus(StorageDomainStatus.Active);
    ValidationResult result = validator.allDomainsExistAndActive();
    assertThat("One domain should not be active", result, failsWith(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL2));
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 29 with ValidationResult

use of org.ovirt.engine.core.bll.ValidationResult 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));
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Example 30 with ValidationResult

use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.

the class MultipleStorageDomainsValidatorTest method testAllDomainsWithinThresholdsOneLacking.

@Test
public void testAllDomainsWithinThresholdsOneLacking() {
    domain1.getStorageDynamicData().setAvailableDiskSize(CRITICAL_SPACE_THRESHOLD + 1);
    domain2.getStorageDynamicData().setAvailableDiskSize(CRITICAL_SPACE_THRESHOLD - 1);
    domain1.setCriticalSpaceActionBlocker(CRITICAL_SPACE_THRESHOLD);
    domain2.setCriticalSpaceActionBlocker(CRITICAL_SPACE_THRESHOLD);
    ValidationResult result = validator.allDomainsWithinThresholds();
    assertThat("domain2 should not be within thresholds", result, failsWith(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN));
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Aggregations

ValidationResult (org.ovirt.engine.core.bll.ValidationResult)239 Test (org.junit.Test)132 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)49 Guid (org.ovirt.engine.core.compat.Guid)40 ArrayList (java.util.ArrayList)31 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)31 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)30 Network (org.ovirt.engine.core.common.businessentities.network.Network)21 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)19 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)16 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)15 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)13 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)12 List (java.util.List)11 VM (org.ovirt.engine.core.common.businessentities.VM)11 HashSet (java.util.HashSet)10 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)10 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)9 StorageDomainValidator (org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)7 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)7