Search in sources :

Example 61 with JobState

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

the class DozerMappingTest method jobStateTasks_Key_AreMappedToString.

@Test
public void jobStateTasks_Key_AreMappedToString() throws Exception {
    JobState jobState = createJobState();
    JobStateData jobStateData = mapper.map(jobState, JobStateData.class);
    assertFalse(jobStateData.getTasks().isEmpty());
    for (String s : jobStateData.getTasks().keySet()) {
        assertEquals("1", s);
    }
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobStateData) Test(org.junit.Test)

Example 62 with JobState

use of org.ow2.proactive.scheduler.common.job.JobState 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;
}
Also used : JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ArrayList(java.util.ArrayList) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 63 with JobState

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

the class SchedulerStateRestJobLogsTest method job_full_logs_not_finished.

@Test
public void job_full_logs_not_finished() throws Exception {
    InternalTaskFlowJob jobState = new InternalTaskFlowJob();
    jobState.addTask(new InternalScriptTask(jobState));
    when(mockScheduler.getJobState("123")).thenReturn(jobState);
    InputStream fullLogs = restScheduler.jobFullLogs(validSessionId, "123", validSessionId);
    assertNull(fullLogs);
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InputStream(java.io.InputStream) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) Test(org.junit.Test)

Example 64 with JobState

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

the class SchedulerStateRestPaginationTest method newMockedJob.

private JobState newMockedJob(final String jobIdStr, final int nbTasks) {
    JobState mockedJob = mock(JobState.class);
    JobId mockedJobId = mock(JobId.class);
    List<TaskState> dumbList = new ArrayList<TaskState>(nbTasks);
    for (int i = 0; i < nbTasks; i++) {
        TaskState mockedTask = mock(TaskState.class);
        TaskId mockedTaskId = mock(TaskId.class);
        when(mockedTaskId.getReadableName()).thenReturn(generateReadableName(jobIdStr, i, nbTasks));
        when(mockedTask.getId()).thenReturn(mockedTaskId);
        dumbList.add(mockedTask);
    }
    when(mockedJobId.value()).thenReturn(jobIdStr);
    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));
    return mockedJob;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ArrayList(java.util.ArrayList) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 65 with JobState

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

the class SchedulerStateRestPaginationTest method testGetJobTasksIdsByTagPaginated.

@Test
public void testGetJobTasksIdsByTagPaginated() throws Throwable {
    JobState job = newMockedJob(jobIdStr, nbTasks);
    when(mockOfScheduler.getJobState(jobIdStr)).thenReturn(job);
    RestPage<String> page = restInterface.getTasksNamesPaginated(sessionId, jobIdStr, 0, nbTasks);
    assertTasks(nbTasks, jobIdStr, page);
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState) Test(org.junit.Test)

Aggregations

JobState (org.ow2.proactive.scheduler.common.job.JobState)67 Test (org.junit.Test)34 JobId (org.ow2.proactive.scheduler.common.job.JobId)28 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)25 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)23 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)19 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)17 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)17 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)15 ArrayList (java.util.ArrayList)14 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)14 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)14 GET (javax.ws.rs.GET)13 Path (javax.ws.rs.Path)13 Produces (javax.ws.rs.Produces)13 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)13 File (java.io.File)12 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)9 ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)9 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)8