Search in sources :

Example 91 with InternalJob

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

the class TaskResultCreatorTest method testThatJobVariablesAreUsedIfTaskHasNoParents.

@Test
public void testThatJobVariablesAreUsedIfTaskHasNoParents() throws UnknownTaskException {
    TaskResultCreator taskResultCreator = new TaskResultCreator();
    SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
    when(mockedschedulerDbManager.loadTasksResults(any(JobId.class), any(List.class))).thenThrow(new DatabaseManagerException());
    InternalJob mockedInternalJob = this.getMockedInternalJobTaskFlowType(this.getMockedJobDescriptorWithPausedTaskWithoutParent());
    Map<String, JobVariable> fakeVariableMap = new HashMap<>();
    fakeVariableMap.put("TestVar", new JobVariable("TestVar", "h234"));
    when(mockedInternalJob.getVariables()).thenReturn(fakeVariableMap);
    Map<String, String> fakeReplacementVariableMap = new HashMap<>();
    fakeReplacementVariableMap.put("TestVar", "h234");
    when(mockedInternalJob.getVariablesAsReplacementMap()).thenReturn(fakeReplacementVariableMap);
    TaskResult taskResult = taskResultCreator.getTaskResult(mockedschedulerDbManager, mockedInternalJob, this.getMockedInternalTask());
    verify(mockedInternalJob, atLeastOnce()).getVariablesAsReplacementMap();
    assertThat(new String(taskResult.getPropagatedVariables().get("TestVar")), is("h234"));
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) List(java.util.List) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) JobId(org.ow2.proactive.scheduler.common.job.JobId) DatabaseManagerException(org.ow2.proactive.db.DatabaseManagerException) Test(org.junit.Test)

Example 92 with InternalJob

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

the class TaskResultCreatorTest method testThatTaskVariablesAreUsedIfTaskisInDB.

@Test
public void testThatTaskVariablesAreUsedIfTaskisInDB() throws UnknownTaskException {
    TaskResultCreator taskResultCreator = new TaskResultCreator();
    TaskResultImpl mockedTaskResultImpl = mock(TaskResultImpl.class);
    Map<String, byte[]> fakeVariableMap = new HashMap<>();
    fakeVariableMap.put("TestVar", new String("h234").getBytes());
    when(mockedTaskResultImpl.getPropagatedVariables()).thenReturn(fakeVariableMap);
    SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
    when(mockedschedulerDbManager.loadLastTaskResult(any(TaskId.class))).thenReturn(mockedTaskResultImpl);
    InternalJob mockedInternalJob = this.getMockedInternalJobTaskFlowType(this.getMockedJobDescriptorWithPausedTaskWithoutParent());
    TaskResult taskResult = taskResultCreator.getTaskResult(mockedschedulerDbManager, mockedInternalJob, this.getMockedInternalTask());
    verify(mockedTaskResultImpl, atLeastOnce()).getPropagatedVariables();
    assertThat(new String(taskResult.getPropagatedVariables().get("TestVar")), is("h234"));
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) Test(org.junit.Test)

Example 93 with InternalJob

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

the class TerminateReplicateTaskHandlerTest method generateInternalTask.

private InternalTask generateInternalTask(long id) {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
    InternalTask internalTask = new InternalScriptTask(job);
    internalTask.setId(TaskIdImpl.createTaskId(new JobIdImpl(666L, "JobName"), "readableName", id));
    internalTask.setStatus(TaskStatus.PENDING);
    return internalTask;
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob)

Example 94 with InternalJob

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

the class TerminateReplicateTaskHandlerTest method init.

@Before
public void init() {
    action = new FlowAction(FlowActionType.REPLICATE);
    action.setDupNumber(0);
    MockitoAnnotations.initMocks(this);
    when(internalJob.getJobInfo()).thenReturn(jobInfoImpl);
    when(internalJob.getJobDescriptor()).thenReturn(jobDescriptorImpl);
    terminateReplicateTaskHandler = new TerminateReplicateTaskHandler(internalJob);
}
Also used : FlowAction(org.ow2.proactive.scheduler.common.task.flow.FlowAction) Before(org.junit.Before)

Example 95 with InternalJob

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

the class ExtendedSchedulerPolicyTest method createTask.

private InternalScriptTask createTask(String taskStartAt) {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
    InternalScriptTask task1 = new InternalScriptTask(job);
    if (taskStartAt != null) {
        task1.addGenericInformation("START_AT", taskStartAt);
    }
    return task1;
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob)

Aggregations

InternalJob (org.ow2.proactive.scheduler.job.InternalJob)166 Test (org.junit.Test)115 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)90 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)53 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)36 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)34 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)33 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)32 JobId (org.ow2.proactive.scheduler.common.job.JobId)28 ArrayList (java.util.ArrayList)27 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)26 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)19 RecoveredSchedulerState (org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState)19 Matchers.containsString (org.hamcrest.Matchers.containsString)16 Matchers.anyString (org.mockito.Matchers.anyString)16 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)15 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)13 SchedulerStateRecoverHelper (org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper)12 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)12 HashMap (java.util.HashMap)10