Search in sources :

Example 1 with AsyncTask

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

the class AsyncTaskDaoTest method testUpdate.

/**
 * Ensures that updating a ad_group works as expected.
 */
@Test
public void testUpdate() {
    existingAsyncTask.setstatus(AsyncTaskStatusEnum.aborting);
    existingAsyncTask.setresult(AsyncTaskResultEnum.failure);
    existingAsyncTask.setActionType(ActionType.AddDisk);
    dao.update(existingAsyncTask);
    AsyncTask result = dao.get(existingAsyncTask.getTaskId());
    assertEquals(existingAsyncTask, result);
}
Also used : AsyncTask(org.ovirt.engine.core.common.businessentities.AsyncTask) Test(org.junit.Test)

Example 2 with AsyncTask

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

the class AsyncTaskDaoTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    dao = dbFacade.getAsyncTaskDao();
    ActionParametersBase params = new ActionParametersBase();
    params.setSessionId("ASESSIONID");
    params.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
    ActionParametersBase taskParams = new ActionParametersBase();
    taskParams.setSessionId("ASESSIONID");
    taskParams.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
    taskParams.setParentParameters(params);
    // create some test data
    newAsyncTask = new AsyncTask();
    newAsyncTask.setTaskId(Guid.newGuid());
    newAsyncTask.setVdsmTaskId(Guid.newGuid());
    newAsyncTask.setStartTime(new Date());
    newAsyncTask.setActionType(ActionType.AddDisk);
    newAsyncTask.setstatus(AsyncTaskStatusEnum.running);
    newAsyncTask.setresult(AsyncTaskResultEnum.success);
    newAsyncTask.setActionParameters(params);
    newAsyncTask.setTaskParameters(taskParams);
    newAsyncTask.setCommandId(Guid.newGuid());
    newAsyncTask.setRootCommandId(Guid.newGuid());
    newAsyncTask.setTaskType(AsyncTaskType.copyImage);
    newAsyncTask.setStoragePoolId(Guid.newGuid());
    existingAsyncTask = dao.get(FixturesTool.EXISTING_TASK_ID);
}
Also used : AsyncTask(org.ovirt.engine.core.common.businessentities.AsyncTask) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Date(java.util.Date) Before(org.junit.Before)

Example 3 with AsyncTask

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

the class AsyncTaskDaoTest method testGetWithInvalidId.

/**
 * Ensures that if the id is invalid then no AsyncTask is returned.
 */
@Test
public void testGetWithInvalidId() {
    AsyncTask result = dao.get(Guid.newGuid());
    assertNull(result);
}
Also used : AsyncTask(org.ovirt.engine.core.common.businessentities.AsyncTask) Test(org.junit.Test)

Example 4 with AsyncTask

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

the class AsyncTaskDaoTest method testGetTaskByVdsmTaskId.

@Test
public void testGetTaskByVdsmTaskId() {
    AsyncTask result = dao.getByVdsmTaskId(FixturesTool.EXISTING_VDSM_TASK_ID);
    assertNotNull(result);
    assertEquals(existingAsyncTask, result);
}
Also used : AsyncTask(org.ovirt.engine.core.common.businessentities.AsyncTask) Test(org.junit.Test)

Example 5 with AsyncTask

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

the class AsyncTaskDaoTest method testRemoveByVdsmTaskId.

@Test
public void testRemoveByVdsmTaskId() {
    AsyncTask result = dao.getByVdsmTaskId(FixturesTool.EXISTING_VDSM_TASK_ID);
    assertNotNull(result);
    assertEquals(1, dao.removeByVdsmTaskId(existingAsyncTask.getVdsmTaskId()));
    result = dao.getByVdsmTaskId(existingAsyncTask.getVdsmTaskId());
    assertNull(result);
    assertEquals(0, dao.removeByVdsmTaskId(existingAsyncTask.getVdsmTaskId()));
    // The removed task is associated with an entity, try to fetch
    // tasks for the entity, and see no task is returned
    List<Guid> taskIds = dao.getAsyncTaskIdsByEntity(FixturesTool.ENTITY_WITH_TASKS_ID);
    assertNotNull(taskIds);
    assertTrue(taskIds.isEmpty());
}
Also used : AsyncTask(org.ovirt.engine.core.common.businessentities.AsyncTask) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Aggregations

AsyncTask (org.ovirt.engine.core.common.businessentities.AsyncTask)24 Test (org.junit.Test)8 Guid (org.ovirt.engine.core.compat.Guid)7 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)5 ArrayList (java.util.ArrayList)4 AsyncTaskCreationInfo (org.ovirt.engine.core.common.asynctasks.AsyncTaskCreationInfo)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Before (org.junit.Before)1 CommandMultiAsyncTasks (org.ovirt.engine.core.bll.CommandMultiAsyncTasks)1 ExecutionContext (org.ovirt.engine.core.bll.job.ExecutionContext)1 CommandCoordinator (org.ovirt.engine.core.bll.tasks.interfaces.CommandCoordinator)1 SPMTask (org.ovirt.engine.core.bll.tasks.interfaces.SPMTask)1 MultipleVmsValidator (org.ovirt.engine.core.bll.validator.MultipleVmsValidator)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1