Search in sources :

Example 6 with ValidationResult

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

the class ImportValidatorTest method insufficientDiskSpaceWithCollapse.

@Test
public void insufficientDiskSpaceWithCollapse() {
    ImportValidator validator = setupDiskSpaceTest(createParameters());
    doReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN)).when(multipleSdValidator).allDomainsHaveSpaceForClonedDisks(any());
    assertThat(validator.validateSpaceRequirements(Collections.emptyList()), failsWith(EngineMessage.ACTION_TYPE_FAILED_DISK_SPACE_LOW_ON_STORAGE_DOMAIN));
    verify(multipleSdValidator).allDomainsHaveSpaceForClonedDisks(any());
    verify(multipleSdValidator, never()).allDomainsHaveSpaceForDisksWithSnapshots(any());
    verify(multipleSdValidator, never()).allDomainsHaveSpaceForNewDisks(any());
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 7 with ValidationResult

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

the class InClusterUpgradeValidatorTest method shouldCreateNiceValidationResult.

@Test
public void shouldCreateNiceValidationResult() throws IOException {
    invalidVM.setCpuPinning("i am pinned");
    invalidVM.setDedicatedVmForVdsList(Guid.newGuid());
    invalidVM.setMigrationSupport(PINNED_TO_HOST);
    invalidVM.setId(Guid.Empty);
    newHost1.setHostOs("invalid os");
    ValidationResult validationResult = validator.isUpgradePossible(Collections.singletonList(newHost1), Collections.singletonList(invalidVM));
    assertThat(validationResult.getVariableReplacements()).contains("CLUSTER_UPGRADE_DETAIL_HOST_INVALID_OS", "CLUSTER_UPGRADE_DETAIL_VM_CPUS_PINNED", "CLUSTER_UPGRADE_DETAIL_VM_NOT_MIGRATABLE");
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 8 with ValidationResult

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

the class IscsiBondValidatorTest method addedLogicalNetworkBelongToAnotherDatacenter.

@Test
public void addedLogicalNetworkBelongToAnotherDatacenter() {
    IscsiBond iscsiBond = createIscsiBond("First", Guid.newGuid());
    List<Network> networks = new ArrayList<>();
    networks.add(createNetwork(iscsiBond.getStoragePoolId()));
    doReturn(networks).when(networkDao).getAllForDataCenter(iscsiBond.getStoragePoolId());
    iscsiBond.getNetworkIds().add(networks.get(0).getId());
    iscsiBond.getNetworkIds().add(Guid.newGuid());
    ValidationResult res = validator.validateAddedLogicalNetworks(iscsiBond);
    assertThat(res, failsWith(EngineMessage.NETWORKS_DONT_EXIST_IN_DATA_CENTER));
    assertEquals(2, res.getVariableReplacements().size());
    assertEquals("$networkIds " + iscsiBond.getNetworkIds().get(1).toString(), res.getVariableReplacements().get(0));
    assertEquals("$dataCenterId " + iscsiBond.getStoragePoolId().toString(), res.getVariableReplacements().get(1));
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 9 with ValidationResult

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

the class IscsiBondValidatorTest method someAddedStorageConnectionsAreNotAnIscsi.

@Test
public void someAddedStorageConnectionsAreNotAnIscsi() {
    IscsiBond iscsiBond = createIscsiBond("First", Guid.newGuid());
    List<StorageServerConnections> conns = new ArrayList<>();
    conns.add(createStorageConnection());
    doReturn(conns).when(storageServerConnectionDao).getConnectableStorageConnectionsByStorageType(iscsiBond.getStoragePoolId(), StorageType.ISCSI);
    iscsiBond.getStorageConnectionIds().add(conns.get(0).getId());
    iscsiBond.getStorageConnectionIds().add(Guid.newGuid().toString());
    ValidationResult res = validator.validateAddedStorageConnections(iscsiBond);
    assertThat(res, failsWith(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTIONS_CANNOT_BE_ADDED_TO_ISCSI_BOND));
    assertEquals(1, res.getVariableReplacements().size());
    assertEquals("$connectionIds " + iscsiBond.getStorageConnectionIds().get(1).toString(), res.getVariableReplacements().get(0));
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 10 with ValidationResult

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

the class IscsiBondValidatorTest method addedRequiredLogicalNetworks.

@Test
public void addedRequiredLogicalNetworks() {
    IscsiBond iscsiBond = createIscsiBond("First", Guid.newGuid());
    List<Network> networks = new ArrayList<>();
    networks.add(createNetwork(iscsiBond.getStoragePoolId()));
    networks.add(createNetwork(iscsiBond.getStoragePoolId()));
    doReturn(networks).when(networkDao).getAllForDataCenter(iscsiBond.getStoragePoolId());
    for (Network network : networks) {
        iscsiBond.getNetworkIds().add(network.getId());
    }
    List<NetworkCluster> networkClusters = new ArrayList<>();
    networkClusters.add(createNetworkCluster(true));
    doReturn(networkClusters).when(networkClusterDao).getAllForNetwork(any());
    ValidationResult res = validator.validateAddedLogicalNetworks(iscsiBond);
    assertThat(res, failsWith(EngineMessage.ACTION_TYPE_FAILED_ISCSI_BOND_NETWORK_CANNOT_BE_REQUIRED));
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond) 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