Search in sources :

Example 1 with JobIdImpl

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

the class DozerMappingTest method createJobState.

private JobState createJobState() {
    return new ClientJobState(new JobState() {

        @Override
        public void update(TaskInfo taskInfo) {
        }

        @Override
        public void update(JobInfo jobInfo) {
        }

        @Override
        public JobInfo getJobInfo() {
            return new JobInfoImpl();
        }

        @Override
        public ArrayList<TaskState> getTasks() {
            return new ArrayList<>(getHMTasks().values());
        }

        @Override
        public Map<TaskId, TaskState> getHMTasks() {
            TaskId taskId = TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 1);
            TaskState value = new ClientTaskState(new TaskState() {

                @Override
                public void update(TaskInfo taskInfo) {
                }

                @Override
                public List<TaskState> getDependences() {
                    return null;
                }

                @Override
                public TaskInfo getTaskInfo() {
                    TaskInfoImpl taskInfo = new TaskInfoImpl();
                    taskInfo.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 1));
                    return taskInfo;
                }

                @Override
                public int getMaxNumberOfExecutionOnFailure() {
                    return 0;
                }

                @Override
                public TaskState replicate() throws Exception {
                    return null;
                }

                @Override
                public int getIterationIndex() {
                    return 0;
                }

                @Override
                public int getReplicationIndex() {
                    return 0;
                }
            });
            return Collections.singletonMap(taskId, value);
        }

        @Override
        public String getOwner() {
            return null;
        }

        @Override
        public JobType getType() {
            return null;
        }
    });
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ArrayList(java.util.ArrayList) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) ClientTaskState(org.ow2.proactive.scheduler.task.ClientTaskState) TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) JobType(org.ow2.proactive.scheduler.common.job.JobType) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobState(org.ow2.proactive.scheduler.common.job.JobState) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) Map(java.util.Map) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) ClientTaskState(org.ow2.proactive.scheduler.task.ClientTaskState)

Example 2 with JobIdImpl

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

the class SchedulerRestWorkflowFromCatalogExecutionTest method testWhenSubmittingAValidTemplateWithVariablesThenTheProvidedJobVariableIsUsed.

@Test
public void testWhenSubmittingAValidTemplateWithVariablesThenTheProvidedJobVariableIsUsed() throws Exception {
    when(scheduler.submit(Matchers.<Job>any())).thenReturn(new JobIdImpl(99L, "job"));
    ArgumentCaptor<Job> argumentCaptor = ArgumentCaptor.forClass(Job.class);
    String workflowUrl = getBaseUriTestWorkflowsServer() + "/workflow";
    JobIdData response = schedulerRest.submitFromUrl(sessionId, workflowUrl, getOneVariablePathSegment("var1", "value1"));
    verify(scheduler).submit(argumentCaptor.capture());
    Job interceptedJob = argumentCaptor.getValue();
    Assert.assertEquals(1, interceptedJob.getVariables().size());
    Assert.assertEquals("value1", interceptedJob.getVariables().get("var1").getValue());
    Assert.assertEquals(99L, response.getId());
    Assert.assertEquals("job", response.getReadableName());
}
Also used : JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Job(org.ow2.proactive.scheduler.common.job.Job) Test(org.junit.Test)

Example 3 with JobIdImpl

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

the class SchedulerRestWorkflowFromCatalogExecutionTest method testWhenSubmittingAValidTemplateWithoutVariablesThenTheDefaultJobVariableIsUsed.

@Test
public void testWhenSubmittingAValidTemplateWithoutVariablesThenTheDefaultJobVariableIsUsed() throws Exception {
    when(scheduler.submit(Matchers.<Job>any())).thenReturn(new JobIdImpl(88L, "job"));
    ArgumentCaptor<Job> argumentCaptor = ArgumentCaptor.forClass(Job.class);
    String workflowUrl = getBaseUriTestWorkflowsServer() + "/workflow";
    JobIdData response = schedulerRest.submitFromUrl(sessionId, workflowUrl, getEmptyPathSegment());
    verify(scheduler).submit(argumentCaptor.capture());
    Job interceptedJob = argumentCaptor.getValue();
    Assert.assertEquals(1, interceptedJob.getVariables().size());
    Assert.assertEquals("defaultvalue", interceptedJob.getVariables().get("var1").getValue());
    Assert.assertEquals(88L, response.getId());
    Assert.assertEquals("job", response.getReadableName());
}
Also used : JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Job(org.ow2.proactive.scheduler.common.job.Job) Test(org.junit.Test)

Example 4 with JobIdImpl

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

the class SchedulerStateRestJobLogsTest method addTask.

private static void addTask(InternalTaskFlowJob jobState, long finishedTime, long id) {
    InternalScriptTask task = new InternalScriptTask(jobState);
    task.setPreciousLogs(true);
    task.setFinishedTime(finishedTime);
    jobState.addTask(task);
    task.setId(TaskIdImpl.createTaskId(new JobIdImpl(123, "job"), "task", id));
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl)

Example 5 with JobIdImpl

use of org.ow2.proactive.scheduler.job.JobIdImpl 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

JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)85 Test (org.junit.Test)70 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)36 JobId (org.ow2.proactive.scheduler.common.job.JobId)34 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)26 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)24 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)24 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)24 ArrayList (java.util.ArrayList)20 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)13 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)12 Matchers.containsString (org.hamcrest.Matchers.containsString)10 Matchers.anyString (org.mockito.Matchers.anyString)10 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)9 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)9 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)8 SimpleScript (org.ow2.proactive.scripting.SimpleScript)8 TaskScript (org.ow2.proactive.scripting.TaskScript)8 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)7 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)6