Search in sources :

Example 11 with ValidationResult

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

the class IscsiBondValidatorTest method iscsiBondDoesNotExist.

@Test
public void iscsiBondDoesNotExist() {
    ValidationResult res = validator.isIscsiBondExist(null);
    assertThat(res, failsWith(EngineMessage.ISCSI_BOND_NOT_EXIST));
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 12 with ValidationResult

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

the class IscsiBondValidatorTest method addedLogicalNetworkBelongToAnotherDatacenter2.

@Test
public void addedLogicalNetworkBelongToAnotherDatacenter2() {
    Guid dataCenterId = Guid.newGuid();
    IscsiBond before = createIscsiBond("Before", dataCenterId);
    IscsiBond after = createIscsiBond("After", dataCenterId);
    List<Network> networks = new ArrayList<>();
    networks.add(createNetwork(dataCenterId));
    doReturn(networks).when(networkDao).getAllForDataCenter(dataCenterId);
    before.getNetworkIds().add(networks.get(0).getId());
    after.getNetworkIds().add(networks.get(0).getId());
    after.getNetworkIds().add(Guid.newGuid());
    ValidationResult res = validator.validateAddedLogicalNetworks(after, before);
    assertThat(res, failsWith(EngineMessage.NETWORKS_DONT_EXIST_IN_DATA_CENTER));
    assertEquals(2, res.getVariableReplacements().size());
    assertEquals("$networkIds " + after.getNetworkIds().get(1).toString(), res.getVariableReplacements().get(0));
    assertEquals("$dataCenterId " + after.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) Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 13 with ValidationResult

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

the class NetworkAttachmentValidatorTest method testNotRemovingManagementNetwork.

@Test
public void testNotRemovingManagementNetwork() {
    NetworkAttachmentValidator networkAttachmentValidatorSpy = spy(createNetworkAttachmentValidator(new NetworkAttachment()));
    doReturn(networkValidatorMock).when(networkAttachmentValidatorSpy).getNetworkValidator();
    ValidationResult propagatedResult = new ValidationResult(EngineMessage.NETWORK_CANNOT_REMOVE_MANAGEMENT_NETWORK, "a");
    when(networkValidatorMock.notRemovingManagementNetwork()).thenReturn(propagatedResult);
    assertThat("ValidationResult is not propagated correctly", networkAttachmentValidatorSpy.notRemovingManagementNetwork(), is(propagatedResult));
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 14 with ValidationResult

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

the class GlusterBrickValidatorTest method canRebalanceOnDistributeReplicateVolumeWithFewBrickDown.

@Test
public void canRebalanceOnDistributeReplicateVolumeWithFewBrickDown() {
    GlusterVolumeEntity volumeEntity = getDistributedReplicatedVolume(volumeId1, 12, 4);
    volumeEntity.getBricks().get(0).setStatus(GlusterStatus.DOWN);
    volumeEntity.getBricks().get(1).setStatus(GlusterStatus.DOWN);
    volumeEntity.getBricks().get(2).setStatus(GlusterStatus.DOWN);
    ValidationResult validationResult = brickValidator.canRebalance(volumeEntity);
    assertThat(validationResult, isValid());
    volumeEntity.getBricks().get(4).setStatus(GlusterStatus.DOWN);
    volumeEntity.getBricks().get(5).setStatus(GlusterStatus.DOWN);
    volumeEntity.getBricks().get(6).setStatus(GlusterStatus.DOWN);
    validationResult = brickValidator.canRebalance(volumeEntity);
    assertThat(validationResult, isValid());
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 15 with ValidationResult

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

the class GlusterBrickValidatorTest method canRemoveBrickReduceReplicaMoreThanOne.

@Test
public void canRemoveBrickReduceReplicaMoreThanOne() {
    GlusterVolumeEntity volumeEntity = getDistributedReplicatedVolume(volumeId1, 12, 4);
    List<GlusterBrickEntity> bricksToRemove = new ArrayList<>();
    bricksToRemove.add(volumeEntity.getBricks().get(0));
    bricksToRemove.add(volumeEntity.getBricks().get(4));
    bricksToRemove.add(volumeEntity.getBricks().get(8));
    bricksToRemove.add(volumeEntity.getBricks().get(1));
    bricksToRemove.add(volumeEntity.getBricks().get(5));
    bricksToRemove.add(volumeEntity.getBricks().get(9));
    ValidationResult validationResult = brickValidator.canRemoveBrick(bricksToRemove, volumeEntity, 2, false);
    assertThat(validationResult, failsWith(EngineMessage.ACTION_TYPE_FAILED_CAN_NOT_REDUCE_REPLICA_COUNT_MORE_THAN_ONE));
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) 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