use of org.ow2.proactive.scheduler.job.JobIdImpl in project scheduling by ow2-proactive.
the class LiveJobsTest method testRestartTaskOnNodeRunningDecreasingExecution.
@Test(timeout = 60000)
public void testRestartTaskOnNodeRunningDecreasingExecution() throws UnknownJobException, UnknownTaskException {
PASchedulerProperties.NUMBER_OF_EXECUTION_ON_FAILURE.updateProperty("5");
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId id = new JobIdImpl(666L, "test-name");
job.setId(id);
List<InternalTask> tasksList = new ArrayList<>();
InternalScriptTask internalTask = new InternalScriptTask(job);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
internalTask.setMaxNumberOfExecution(5);
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
tasksList.add(internalTask);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
liveJobs.lockJobsToSchedule();
liveJobs.taskStarted(job, job.getTask("task-name"), null);
assertThat(internalTask.getMaxNumberOfExecutionOnFailure(), is(5));
assertThat(internalTask.getTaskInfo().getNumberOfExecutionOnFailureLeft(), is(5));
liveJobs.restartTaskOnNodeFailure(internalTask);
internalTask.setStatus(TaskStatus.RUNNING);
assertThat(internalTask.getMaxNumberOfExecutionOnFailure(), is(5));
assertThat(internalTask.getTaskInfo().getNumberOfExecutionOnFailureLeft(), is(4));
Mockito.verify(dbManager, Mockito.times(1)).taskRestarted(job, internalTask, null);
}
use of org.ow2.proactive.scheduler.job.JobIdImpl in project scheduling by ow2-proactive.
the class LiveJobsTest method testRestartTaskOnNodeFailureRunningExceptionExpectedBecauseNotLockedTask.
@Test(expected = IllegalStateException.class, timeout = 60000)
public void testRestartTaskOnNodeFailureRunningExceptionExpectedBecauseNotLockedTask() throws UnknownJobException, UnknownTaskException {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId id = new JobIdImpl(666L, "test-name");
job.setId(id);
List<InternalTask> tasksList = new ArrayList<>();
InternalTask internalTask = new InternalScriptTask(job);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
tasksList.add(internalTask);
job.setTasks(tasksList);
liveJobs.jobSubmitted(job);
liveJobs.restartTaskOnNodeFailure(internalTask);
}
use of org.ow2.proactive.scheduler.job.JobIdImpl in project scheduling by ow2-proactive.
the class TestTaskIdImpl method testGetReplicationIndex.
@Test
public void testGetReplicationIndex() throws Exception {
TaskId taskNoReplicationIndex = TaskIdImpl.createTaskId(new JobIdImpl(1L, "job"), "task", 1);
TaskId taskReplicationIndexSmallerThan9 = TaskIdImpl.createTaskId(new JobIdImpl(1L, "job"), "task*1", 1);
TaskId taskReplicationIndexGreaterThan9 = TaskIdImpl.createTaskId(new JobIdImpl(1L, "job"), "task*10", 1);
TaskId taskReplicatedAndIterated = TaskIdImpl.createTaskId(new JobIdImpl(1L, "job"), "task#10*10", 1);
assertEquals(0, taskNoReplicationIndex.getReplicationIndex());
assertEquals(1, taskReplicationIndexSmallerThan9.getReplicationIndex());
assertEquals(10, taskReplicationIndexGreaterThan9.getReplicationIndex());
assertEquals(10, taskReplicatedAndIterated.getReplicationIndex());
}
use of org.ow2.proactive.scheduler.job.JobIdImpl in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsPreviousTaskResults.
@Test
public void testAddBindingsToScriptHandlerContainsPreviousTaskResults() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
// Create task result array
TaskResultImpl taskResult = new TaskResultImpl(TaskIdImpl.createTaskId(new JobIdImpl(jobIdValue, jobNameValue), taskNameValue, taskIdValue), new Exception("Exception"));
TaskResult[] taskResultArray = { taskResult };
// Create TaskContext with task result array
TaskContext taskContext = createTaskContext(taskResultArray);
// Expect taskResultArray to be inside the map
validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.RESULTS_VARIABLE, taskResultArray);
}
use of org.ow2.proactive.scheduler.job.JobIdImpl in project scheduling by ow2-proactive.
the class TaskLoggerTest method createFileAppenderTest.
@Test
public void createFileAppenderTest() throws Exception {
JobId jobid = new JobIdImpl(1000, "job");
TaskId taskId = TaskIdImpl.createTaskId(jobid, "task", 42L);
taskLogger = new TaskLogger(taskId, "myhost");
File logFolder = tempFolder.newFolder("logfolder");
File logAppender = taskLogger.createFileAppender(logFolder);
System.out.println(logAppender.getParentFile().getName());
assertEquals(logAppender.getParentFile().getName(), jobid.value());
assertEquals(logAppender.getName(), new TaskLoggerRelativePathGenerator(taskId).getFileName());
}
Aggregations