use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class GlusterBrickDaoTest method testReplaceBrick.
@Test
public void testReplaceBrick() {
GlusterBrickEntity firstBrick = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
assertNotNull(firstBrick);
GlusterBrickEntity newBrick = new GlusterBrickEntity();
newBrick.setVolumeId(FixturesTool.GLUSTER_VOLUME_UUID1);
newBrick.setServerId(FixturesTool.GLUSTER_SERVER_UUID3);
newBrick.setServerName(FixturesTool.GLUSTER_SERVER_NAME3);
newBrick.setBrickDirectory(BRICK_EXPORT_DIR);
GlusterAsyncTask asyncTask = new GlusterAsyncTask();
asyncTask.setTaskId(FixturesTool.GLUSTER_ASYNC_TASK_ID1);
newBrick.setAsyncTask(asyncTask);
newBrick.setStatus(GlusterStatus.UP);
newBrick.setBrickOrder(0);
assertNull(dao.getById(newBrick.getId()));
dao.replaceBrick(firstBrick, newBrick);
assertNull(dao.getById(FixturesTool.GLUSTER_BRICK_UUID1));
GlusterBrickEntity retrievedBrick = dao.getById(newBrick.getId());
assertNotNull(retrievedBrick);
assertEquals(newBrick, retrievedBrick);
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class GlusterBrickDaoTest method testUpdateAllBrickTasksByHostIdBrickDir.
@Test
public void testUpdateAllBrickTasksByHostIdBrickDir() {
GlusterBrickEntity existingBrick = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
GlusterBrickEntity existingBrick2 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID2);
GlusterAsyncTask asyncTask = new GlusterAsyncTask();
asyncTask.setTaskId(FixturesTool.GLUSTER_ASYNC_TASK_ID1);
GlusterBrickEntity updateBrick = new GlusterBrickEntity();
updateBrick.setBrickDirectory(existingBrick.getBrickDirectory());
updateBrick.setServerId(existingBrick.getServerId());
updateBrick.setAsyncTask(asyncTask);
GlusterBrickEntity updateBrick2 = new GlusterBrickEntity();
updateBrick2.setBrickDirectory(existingBrick2.getBrickDirectory());
updateBrick2.setServerId(existingBrick2.getServerId());
updateBrick2.setAsyncTask(asyncTask);
List<GlusterBrickEntity> bricks = new ArrayList<>();
bricks.add(updateBrick);
bricks.add(updateBrick2);
dao.updateAllBrickTasksByHostIdBrickDirInBatch(bricks);
GlusterBrickEntity newEntity1 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
GlusterBrickEntity newEntity2 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
assertEquals(FixturesTool.GLUSTER_ASYNC_TASK_ID1, newEntity1.getAsyncTask().getTaskId());
assertEquals(FixturesTool.GLUSTER_ASYNC_TASK_ID1, newEntity2.getAsyncTask().getTaskId());
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class GlusterBrickDaoTest method testUpdateBrickTasksInBatch.
@Test
public void testUpdateBrickTasksInBatch() {
GlusterBrickEntity existingBrick1 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
GlusterBrickEntity existingBrick2 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID2);
GlusterAsyncTask asyncTask = new GlusterAsyncTask();
asyncTask.setTaskId(FixturesTool.GLUSTER_ASYNC_TASK_ID1);
assertNotNull(existingBrick1);
assertNotNull(existingBrick2);
assertEquals(GlusterStatus.UP, existingBrick1.getStatus());
assertEquals(GlusterStatus.UP, existingBrick2.getStatus());
existingBrick1.setAsyncTask(asyncTask);
existingBrick2.setAsyncTask(asyncTask);
List<GlusterBrickEntity> bricks = new ArrayList<>();
bricks.add(existingBrick1);
bricks.add(existingBrick2);
dao.updateBrickTasksInBatch(bricks);
GlusterBrickEntity newEnity1 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
GlusterBrickEntity newEnity2 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID2);
assertEquals(FixturesTool.GLUSTER_ASYNC_TASK_ID1, newEnity1.getAsyncTask().getTaskId());
assertEquals(FixturesTool.GLUSTER_ASYNC_TASK_ID1, newEnity2.getAsyncTask().getTaskId());
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class GlusterTestHelper method getVolumeEntity.
protected GlusterVolumeEntity getVolumeEntity(int index) {
List<GlusterVolumeEntity> volumesList = new ArrayList<>();
GlusterVolumeEntity entity1 = mock(GlusterVolumeEntity.class);
when(entity1.getId()).thenReturn(volumeId);
when(entity1.getName()).thenReturn(volumeName);
when(entity1.getClusterId()).thenReturn(clusterId);
volumesList.add(entity1);
GlusterAsyncTask task = new GlusterAsyncTask();
task.setType(GlusterTaskType.REMOVE_BRICK);
task.setStatus(JobExecutionStatus.FINISHED);
task.setTaskId(GUIDS[2]);
GlusterVolumeEntity entity2 = mock(GlusterVolumeEntity.class);
when(entity2.getId()).thenReturn(volumeId);
when(entity2.getName()).thenReturn(volumeName);
when(entity2.getClusterId()).thenReturn(clusterId);
when(entity2.getAsyncTask()).thenReturn(task);
volumesList.add(entity2);
return volumesList.get(index);
}
use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.
the class GetGlusterVolumeRemoveBricksStatusQuery method fetchTaskStatusDetails.
@Override
protected GlusterVolumeTaskStatusEntity fetchTaskStatusDetails() {
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterVolumeRemoveBricksStatus, new GlusterVolumeRemoveBricksVDSParameters(getUpServerId(clusterId), volume.getName(), getParameters().getBricks(), volume.getReplicaCount()));
GlusterVolumeTaskStatusEntity entity = (GlusterVolumeTaskStatusEntity) returnValue.getReturnValue();
// Update the latest status details
GlusterAsyncTask asyncTask = volume.getAsyncTask();
if (asyncTask != null) {
// take a copy of the task status with engine for further use
JobExecutionStatus jobStatusWithEngine = volume.getAsyncTask().getStatus();
// update the status entity with required details
updateStatusEntity(entity);
// be set to aborted. This is required only in case of remove bricks
if (jobStatusWithEngine == JobExecutionStatus.ABORTED) {
entity.getStatusSummary().setStatus(JobExecutionStatus.ABORTED);
}
}
return entity;
}
Aggregations