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);
}
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));
}
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));
}
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));
}
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;
}
Aggregations