Search in sources :

Example 6 with SortSpecifierContainer

use of org.ow2.proactive.scheduler.common.SortSpecifierContainer in project scheduling by ow2-proactive.

the class SchedulerDBManagerTest method testGetTaskStates.

@Test
public void testGetTaskStates() throws Throwable {
    initExpectedResults("testGetTaskStates-Job", "TEST-TAG");
    // no given statuses, no pagination, nothing should come up
    crit = TaskFilterCriteria.TFCBuilder.newInstance().running(false).pending(false).finished(false).criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
    // all statuses, no pagination, everything should come up
    crit = TaskFilterCriteria.TFCBuilder.newInstance().criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
    // all statuses, pagination [0,5[
    crit = TaskFilterCriteria.TFCBuilder.newInstance().limit(5).criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
    // pending tasks only, no pagination
    crit = TaskFilterCriteria.TFCBuilder.newInstance().running(false).finished(false).criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
    // running tasks only, no pagination
    startJob(0);
    crit = TaskFilterCriteria.TFCBuilder.newInstance().pending(false).finished(false).criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
    // running tasks only, pagination [0,5[
    crit = TaskFilterCriteria.TFCBuilder.newInstance().limit(5).pending(false).finished(false).criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
    // finished tasks only, no pagination
    terminateJob(1, 100L);
    crit = TaskFilterCriteria.TFCBuilder.newInstance().pending(false).running(false).criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
    // finished tasks only, pagination [0,5[
    crit = TaskFilterCriteria.TFCBuilder.newInstance().limit(5).pending(false).running(false).criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
    // finished tasks only, dates [0,100], no pagination
    crit = TaskFilterCriteria.TFCBuilder.newInstance().from(0).to(100L).pending(false).running(false).criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
    // finished tasks only, dates [0,100], pagination [0,5[
    crit = TaskFilterCriteria.TFCBuilder.newInstance().from(0).to(100L).offset(0).limit(5).pending(false).running(false).criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
    // default parameters, with tag "TEST-TAG"
    crit = TaskFilterCriteria.TFCBuilder.newInstance().tag("TEST-TAG").criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
    // default parameters, with tag "NON-EXISTENT-TAG"
    crit = TaskFilterCriteria.TFCBuilder.newInstance().tag("NON-EXISTENT-TAG").criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
    // all statuses, no pagination, everything should come up sorted by taskId
    sortParameters = new ArrayList<>();
    sortParameters.add(new SortSpecifierContainer("id.taskId,descending"));
    crit = TaskFilterCriteria.TFCBuilder.newInstance().sortParameters(sortParameters).criterias();
    actualPageState = getTaskStates(crit);
    assertTaskStatePage(actualPageState, crit);
}
Also used : SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) Test(org.junit.Test)

Example 7 with SortSpecifierContainer

use of org.ow2.proactive.scheduler.common.SortSpecifierContainer in project scheduling by ow2-proactive.

the class SchedulerStateRestTaskCentricTest method testGetTaskStatesByTagNoSorting.

@Test
public void testGetTaskStatesByTagNoSorting() throws Throwable {
    int nbTasksInPage = 50;
    int nbTotalTasks = 100;
    String jobIdStr = "1";
    String tag = "TAG-TEST";
    Page<TaskState> expectedPage = RestTestUtils.newMockedTaskStatePage(jobIdStr, tag, nbTasksInPage, nbTotalTasks);
    when(mockOfScheduler.getTaskStates(anyString(), anyLong(), anyLong(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyInt(), anyInt(), any(SortSpecifierContainer.class))).thenReturn(expectedPage);
    RestPage<TaskStateData> page = restInterface.getTaskStatesByTag(sessionId, tag, 0, 0, false, true, true, true, 0, nbTasksInPage, new SortSpecifierContainer());
    RestTestUtils.assertTaskStates(expectedPage, page);
}
Also used : SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Example 8 with SortSpecifierContainer

use of org.ow2.proactive.scheduler.common.SortSpecifierContainer in project scheduling by ow2-proactive.

the class SchedulerDBManagerTest method testUpdateJobAndTasksState.

@Test
public void testUpdateJobAndTasksState() throws Exception {
    InternalJob job = createTestJob("test", "tag", 1);
    service.submitJob(job);
    job.setStatus(JobStatus.KILLED);
    job.setNumberOfFailedTasks(2);
    job.setNumberOfFaultyTasks(3);
    job.setNumberOfInErrorTasks(5);
    job.setInErrorTime(7);
    InternalTask internalTask = job.getITasks().get(0);
    internalTask.setStatus(TaskStatus.IN_ERROR);
    internalTask.setInErrorTime(11);
    dbManager.updateJobAndTasksState(job);
    Page<JobInfo> jobs = dbManager.getJobs(0, 10, null, true, true, true, null);
    assertThat(jobs.getSize()).isEqualTo(1);
    JobInfo jobInfo = jobs.getList().get(0);
    assertThat(jobInfo.getStatus()).isEqualTo(JobStatus.KILLED);
    assertThat(jobInfo.getNumberOfFailedTasks()).isEqualTo(2);
    assertThat(jobInfo.getNumberOfFaultyTasks()).isEqualTo(3);
    assertThat(jobInfo.getNumberOfInErrorTasks()).isEqualTo(5);
    assertThat(jobInfo.getInErrorTime()).isEqualTo(7);
    Page<TaskState> tasks = dbManager.getTaskStates(0, 10, null, 0, 10, null, true, true, true, new SortSpecifierContainer());
    assertThat(tasks.getSize()).isEqualTo(1);
    TaskState taskState = tasks.getList().get(0);
    assertThat(taskState.getStatus()).isEqualTo(TaskStatus.IN_ERROR);
    assertThat(taskState.getTaskInfo().getInErrorTime()).isEqualTo(11);
}
Also used : SortSpecifierContainer(org.ow2.proactive.scheduler.common.SortSpecifierContainer) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Test(org.junit.Test)

Aggregations

SortSpecifierContainer (org.ow2.proactive.scheduler.common.SortSpecifierContainer)8 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)7 Test (org.junit.Test)6 TaskStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData)5 ArrayList (java.util.ArrayList)2 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)2 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)2 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)2 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)2 RestPage (org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage)2 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)2 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)2 Page (org.ow2.proactive.scheduler.common.Page)1 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)1 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)1 PageBoundaries (org.ow2.proactive.scheduler.common.util.PageBoundaries)1 TaskStateImpl (org.ow2.proactive.scheduler.rest.data.TaskStateImpl)1