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