Search in sources :

Example 31 with Job

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

the class SchedulerStateRestTaskCentricTest method testGetJobTasksIdsByTagPaginated.

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

Example 32 with Job

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

the class SchedulerStateRestTaskCentricTest method testGetJobTasksIdsPaginated.

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

Example 33 with Job

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

the class SchedulerStateRestTaskCentricTest method testGetJobTaskStatesPaginated.

@Test
public void testGetJobTaskStatesPaginated() throws Throwable {
    int nbTasks = 50;
    String jobIdStr = "1";
    JobState job = RestTestUtils.newMockedJob(jobIdStr, null, nbTasks);
    when(mockOfScheduler.getJobState(jobIdStr)).thenReturn(job);
    List<TaskStateData> res = restInterface.getJobTaskStatesPaginated(sessionId, jobIdStr, 0, nbTasks).getList();
    assertEquals("Number of tasks is incorrect", nbTasks, res.size());
}
Also used : TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) JobState(org.ow2.proactive.scheduler.common.job.JobState) Test(org.junit.Test)

Example 34 with Job

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

the class SchedulerStateRestTaskCentricTest method testGetTaskStatesByTagSortByTaskIdDesc.

@Test
public void testGetTaskStatesByTagSortByTaskIdDesc() 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(".id.taskId,descending"));
    RestTestUtils.assertTaskStates(expectedPage, page);
    // let's check only the first two as the string comparison is not valid
    // after that case : "JOB-1-TASK-1/50".compareTo("JOB-1-TASK-10/50")
    List<TaskStateData> tasks = page.getList();
    TaskStateData previousTask = tasks.get(0);
    TaskStateData currentTask = tasks.get(1);
    assertTrue(previousTask.getName().compareTo(currentTask.getName()) < 0);
}
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 35 with Job

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

the class NoVncSecuredTargetResolverTest method testMagicStringFoundInLogs_MagicStringOnSeveralLines.

@Test
public void testMagicStringFoundInLogs_MagicStringOnSeveralLines() throws Exception {
    String sessionId = SharedSessionStoreTestUtils.createValidSession(schedulerMock);
    when(schedulerMock.getTaskResult("42", "remoteVisuTask")).thenReturn(new TaskResultImpl(TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 1), new byte[0], new byte[0], new SimpleTaskLogs("PA_REMOTE_CONNECTION\nPA_REMOTE_CONNECTION;42;1;vnc;node.grid.com:5900", ""), true));
    InetSocketAddress targetVncHost = new NoVncSecuredTargetResolver().doResolve(sessionId, "42", "remoteVisuTask");
    assertEquals(5900, targetVncHost.getPort());
    assertEquals("node.grid.com", targetVncHost.getHostName());
}
Also used : SimpleTaskLogs(org.ow2.proactive.scheduler.common.task.SimpleTaskLogs) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InetSocketAddress(java.net.InetSocketAddress) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)260 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)198 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)145 JobId (org.ow2.proactive.scheduler.common.job.JobId)122 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)91 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)87 File (java.io.File)76 SimpleScript (org.ow2.proactive.scripting.SimpleScript)70 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)68 TaskScript (org.ow2.proactive.scripting.TaskScript)65 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)64 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)58 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)52 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)48 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)48 ArrayList (java.util.ArrayList)46 JobState (org.ow2.proactive.scheduler.common.job.JobState)45 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)45 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)41 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)39