Search in sources :

Example 11 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class RemoveVdsCommandTest method mockHasVolumeOnServer.

/**
 * Mock that whether the VDS configured with gluster volume. This will return the given volume count
 */
private void mockHasVolumeOnServer(boolean isBricksRequired) {
    List<GlusterBrickEntity> bricks = new ArrayList<>();
    if (isBricksRequired) {
        GlusterBrickEntity brick = new GlusterBrickEntity();
        brick.setVolumeId(Guid.newGuid());
        brick.setServerId(command.getVdsId());
        bricks.add(brick);
    }
    when(glusterBrickDao.getGlusterVolumeBricksByServerId(command.getVdsId())).thenReturn(bricks);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList)

Example 12 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity 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)

Example 13 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GlusterBrickValidatorTest method canRemoveBrickIfSomeBricksAreDown.

@Test
public void canRemoveBrickIfSomeBricksAreDown() {
    GlusterVolumeEntity volumeEntity = getDistributedVolume(volumeId1, 4);
    List<GlusterBrickEntity> bricksToRemove = new ArrayList<>();
    bricksToRemove.add(volumeEntity.getBricks().get(1));
    volumeEntity.getBricks().get(0).setStatus(GlusterStatus.DOWN);
    ValidationResult validationResult = brickValidator.canRemoveBrick(bricksToRemove, volumeEntity, 1, false);
    assertThat(validationResult, failsWith(EngineMessage.ACTION_TYPE_FAILED_ONE_OR_MORE_BRICKS_ARE_DOWN));
}
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)

Example 14 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GlusterBrickValidatorTest method canRemoveWithOutforceAndReduceReplicaCount.

@Test
public void canRemoveWithOutforceAndReduceReplicaCount() {
    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));
    ValidationResult validationResult = brickValidator.canRemoveBrick(bricksToRemove, volumeEntity, 3, false);
    assertThat(validationResult, failsWith(EngineMessage.ACTION_TYPE_FAILED_CAN_NOT_REDUCE_REPLICA_COUNT_WITH_DATA_MIGRATION));
}
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)

Example 15 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity in project ovirt-engine by oVirt.

the class GlusterBrickValidatorTest method getBricks.

private List<GlusterBrickEntity> getBricks(Guid volumeId, int max) {
    List<GlusterBrickEntity> bricks = new ArrayList<>();
    for (Integer i = 0; i < max; i++) {
        GlusterBrickEntity brick = new GlusterBrickEntity();
        brick.setVolumeId(volumeId);
        brick.setServerName("server1");
        brick.setStatus(GlusterStatus.UP);
        brick.setBrickDirectory("/tmp/s" + i.toString());
        bricks.add(brick);
        brick.setId(Guid.newGuid());
    }
    return bricks;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList)

Aggregations

GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)132 ArrayList (java.util.ArrayList)63 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)43 Test (org.junit.Test)28 Guid (org.ovirt.engine.core.compat.Guid)19 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)14 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)13 VDS (org.ovirt.engine.core.common.businessentities.VDS)11 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11 List (java.util.List)10 HashMap (java.util.HashMap)9 Map (java.util.Map)9 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)9 BrickProperties (org.ovirt.engine.core.common.businessentities.gluster.BrickProperties)9 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)7 BrickDetails (org.ovirt.engine.core.common.businessentities.gluster.BrickDetails)7 GlusterVolumeAdvancedDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails)7 GlusterVolumeType (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType)7 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)7 Iterator (java.util.Iterator)5