use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class SchedulerFrontendStateTest method testLRUCache.
@Test
public void testLRUCache() throws Exception {
SchedulerJMXHelper mockJMX = mock(SchedulerJMXHelper.class);
when(mockJMX.getSchedulerRuntimeMBean()).thenReturn(new RuntimeDataMBeanImpl(null));
SchedulerStateImpl<ClientJobState> schedulerStateImpl = new SchedulerStateImpl<>();
final ClientJobState clientJobState0 = createClientJobState(10l);
final ClientJobState clientJobState01 = createClientJobState(11l);
final ClientJobState clientJobState1 = createClientJobState(1l);
final ClientJobState clientJobState2 = createClientJobState(2l);
schedulerStateImpl.setFinishedJobs(new Vector());
schedulerStateImpl.setRunningJobs(new Vector(Lists.newArrayList(clientJobState1)));
schedulerStateImpl.setPendingJobs(new Vector(Lists.newArrayList(clientJobState2)));
SCHEDULER_FINISHED_JOBS_LRU_CACHE_SIZE.updateProperty("1");
SchedulerDBManager dbManager = mock(SchedulerDBManager.class);
SchedulerFrontendState schedulerFrontendState = new SchedulerFrontendState(schedulerStateImpl, mockJMX, dbManager);
InternalJob internalJob = spy(new InternalTaskFlowJob());
JobInfoImpl jobInfo = mock(JobInfoImpl.class);
doReturn(jobInfo).when(internalJob).getJobInfo();
doReturn(clientJobState0.getId()).when(jobInfo).getJobId();
doReturn(clientJobState0.getId()).when(internalJob).getId();
doReturn(Collections.singletonList(internalJob)).when(dbManager).loadInternalJob(10l);
InternalJob internalJob1 = spy(new InternalTaskFlowJob());
JobInfoImpl jobInfo1 = mock(JobInfoImpl.class);
doReturn(jobInfo1).when(internalJob1).getJobInfo();
doReturn(clientJobState01.getId()).when(jobInfo1).getJobId();
doReturn(clientJobState01.getId()).when(internalJob1).getId();
doReturn(Collections.singletonList(internalJob1)).when(dbManager).loadInternalJob(11l);
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState0.getId()).getJobId(), clientJobState0.getId());
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState0.getId()).getJobId(), clientJobState0.getId());
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState01.getId()).getJobId(), clientJobState01.getId());
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState01.getId()).getJobId(), clientJobState01.getId());
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState01.getId()).getJobId(), clientJobState01.getId());
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState0.getId()).getJobId(), clientJobState0.getId());
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState0.getId()).getJobId(), clientJobState0.getId());
verify(dbManager, times(3)).loadInternalJob(anyLong());
}
use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class SchedulingServiceTest method createMockedInternalJob.
private InternalJob createMockedInternalJob(JobId jobId) {
JobInfo jobInfo = Mockito.mock(JobInfoImpl.class);
InternalJob internalJob = Mockito.mock(InternalJob.class);
Mockito.when(jobInfo.getJobId()).thenReturn(jobId);
Mockito.when(internalJob.getJobInfo()).thenReturn(jobInfo);
Mockito.when(internalJob.getOwner()).thenReturn("MOCKED OWNER");
return internalJob;
}
use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class SchedulerStateRestJobTest method testJobsInfoList.
@Test
public void testJobsInfoList() throws Throwable {
List<JobInfo> expectedJobs = new ArrayList<>();
JobInfo jobData1 = RestTestUtils.newMockedJobInfo("2", null, 10);
expectedJobs.add(jobData1);
JobInfo jobData2 = RestTestUtils.newMockedJobInfo("4", null, 2);
expectedJobs.add(jobData2);
JobInfo jobData3 = RestTestUtils.newMockedJobInfo("10", null, 8);
expectedJobs.add(jobData3);
List<String> jobIds = new ArrayList<>();
jobIds.add("2");
jobIds.add("4");
jobIds.add("10");
when(mockOfScheduler.getJobsInfoList(jobIds)).thenReturn(expectedJobs);
List<UserJobData> actualList = restInterface.jobsInfoList(sessionId, jobIds);
for (int i = 0; i < expectedJobs.size() && i < actualList.size(); i++) {
RestTestUtils.assertJobInfo(expectedJobs.get(i), actualList.get(i));
}
}
use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class SchedulerStateRestJobTaskResultTest method testValueOfJobResult.
@Test
public void testValueOfJobResult() throws Throwable {
TaskResultImpl taskResult = new TaskResultImpl(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("42"), "mytask", 1), ObjectToByteConverter.ObjectStream.convert("hello"), null, null, false);
JobResultImpl jobResultWithValue = new JobResultImpl();
JobInfoImpl jobInfo = new JobInfoImpl();
jobInfo.setJobId(new JobIdImpl(12, "myjob"));
jobResultWithValue.setJobInfo(jobInfo);
jobResultWithValue.addTaskResult("mytask", taskResult, false);
when(mockOfScheduler.getJobResult("42")).thenReturn(jobResultWithValue);
JobResultData jobResultData = restInterface.jobResult(sessionId, "42");
TaskResultData taskResultData = jobResultData.getAllResults().get("mytask");
assertNotNull(taskResultData);
assertNotNull(taskResultData.getValue());
assertEquals("hello", taskResultData.getValue());
Map<String, String> jobResult = restInterface.jobResultValue(sessionId, "42");
String result = jobResult.get("mytask");
assertNotNull(result);
assertEquals("hello", result);
}
use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class RestTestUtils method newMockedJob.
protected static JobState newMockedJob(final String jobIdStr, final String tag, final int nbTasks) {
JobState mockedJob = mock(JobState.class);
JobId mockedJobId = mock(JobId.class);
JobInfo mockedJobInfo = mock(JobInfo.class);
List<TaskState> dumbList = new ArrayList<TaskState>(nbTasks);
for (int i = 0; i < nbTasks; i++) {
dumbList.add(newTaskState(jobIdStr, null, i, nbTasks));
}
when(mockedJobId.value()).thenReturn(jobIdStr);
when(mockedJobInfo.getJobId()).thenReturn(mockedJobId);
when(mockedJobInfo.getStatus()).thenReturn(JobStatus.PENDING);
when(mockedJob.getId()).thenReturn(mockedJobId);
when(mockedJob.getTasksPaginated(0, 50)).thenReturn(new TaskStatesPage(dumbList, nbTasks));
when(mockedJob.getTaskByTagPaginated("", 0, 50)).thenReturn(new TaskStatesPage(dumbList, nbTasks));
when(mockedJob.getJobInfo()).thenReturn(mockedJobInfo);
return mockedJob;
}
Aggregations