Search in sources :

Example 66 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity 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);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) Test(org.junit.Test)

Example 67 with GlusterBrickEntity

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

the class GlusterBrickDaoTest method testUpdateBrickStatuses.

@Test
public void testUpdateBrickStatuses() {
    GlusterBrickEntity existingBrick = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
    GlusterBrickEntity existingBrick1 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID2);
    assertNotNull(existingBrick);
    assertNotNull(existingBrick1);
    assertEquals(GlusterStatus.UP, existingBrick.getStatus());
    assertEquals(GlusterStatus.UP, existingBrick1.getStatus());
    List<GlusterBrickEntity> bricks = new ArrayList<>();
    bricks.add(existingBrick);
    bricks.add(existingBrick1);
    dao.updateBrickStatuses(bricks);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 68 with GlusterBrickEntity

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

the class GlusterBrickDaoTest method testRemoveBricksInBatch.

@Test
public void testRemoveBricksInBatch() {
    GlusterBrickEntity existingBrick1 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
    GlusterBrickEntity existingBrick2 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID2);
    List<GlusterBrickEntity> bricks = new ArrayList<>();
    bricks.add(existingBrick1);
    bricks.add(existingBrick2);
    dao.removeAllInBatch(bricks);
    GlusterBrickEntity newEnity1 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
    GlusterBrickEntity newEnity2 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID2);
    assertNull(newEnity1);
    assertNull(newEnity2);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 69 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity 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());
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 70 with GlusterBrickEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity 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());
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) ArrayList(java.util.ArrayList) Test(org.junit.Test)

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