Search in sources :

Example 46 with InternalJob

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

the class TestJobAttributes method testGenericInformation.

@Test
public void testGenericInformation() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    Map<String, String> genericInfo;
    InternalJob jobData;
    genericInfo = new HashMap<>();
    job.setGenericInformation(genericInfo);
    jobData = defaultSubmitJobAndLoadInternal(false, job);
    Assert.assertNotNull(jobData.getGenericInformation());
    Assert.assertTrue(jobData.getGenericInformation().isEmpty());
    genericInfo = new HashMap<>();
    genericInfo.put("p1", "v1");
    genericInfo.put("p2", "v2");
    job.setGenericInformation(genericInfo);
    jobData = defaultSubmitJobAndLoadInternal(false, job);
    Assert.assertEquals(2, jobData.getGenericInformation().size());
    Assert.assertEquals("v1", jobData.getGenericInformation().get("p1"));
    Assert.assertEquals("v2", jobData.getGenericInformation().get("p2"));
    StringBuilder longString = new StringBuilder();
    for (int i = 0; i < 100; i++) {
        longString.append("0123456789abcdefghijklmnopqrstuvwxyz");
    }
    genericInfo = new HashMap<>();
    genericInfo.put("longProperty", longString.toString());
    job.setGenericInformation(genericInfo);
    jobData = defaultSubmitJobAndLoadInternal(false, job);
    Assert.assertEquals(1, jobData.getGenericInformation().size());
    Assert.assertEquals(longString.toString(), jobData.getGenericInformation().get("longProperty"));
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Example 47 with InternalJob

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

the class TestJobAttributes method testJobAttribute.

@Test
public void testJobAttribute() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setMaxNumberOfExecution(10);
    job.setOnTaskError(OnTaskError.CANCEL_JOB);
    job.setDescription("desc");
    job.setProjectName("project");
    job.setName("name");
    job.setInputSpace("input");
    job.setOutputSpace("output");
    job.setGenericInformation(null);
    job.setPriority(JobPriority.HIGHEST);
    InternalJob jobData = defaultSubmitJob(job, DEFAULT_USER_NAME);
    Assert.assertNotNull(jobData.getId());
    Assert.assertEquals("name", jobData.getId().getReadableName());
    jobData = loadInternalJob(true, jobData.getId());
    Assert.assertNotNull(jobData.getId());
    Assert.assertEquals("name", jobData.getId().getReadableName());
    Assert.assertEquals(10, jobData.getMaxNumberOfExecution());
    Assert.assertEquals(OnTaskError.CANCEL_JOB, jobData.getOnTaskErrorProperty().getValue());
    Assert.assertEquals("name", jobData.getName());
    Assert.assertEquals("desc", jobData.getDescription());
    Assert.assertEquals("project", jobData.getProjectName());
    Assert.assertEquals("input", jobData.getInputSpace());
    Assert.assertEquals("output", jobData.getOutputSpace());
    Assert.assertEquals(JobPriority.HIGHEST, jobData.getPriority());
    Assert.assertNotNull(jobData.getGenericInformation());
    Assert.assertTrue(jobData.getGenericInformation().isEmpty());
    Map<String, JobVariable> jobDataVariables = jobData.getVariables();
    Assert.assertNotNull(jobDataVariables);
    Assert.assertTrue(jobDataVariables.isEmpty());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) Test(org.junit.Test)

Example 48 with InternalJob

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

the class TestJobAttributes method testJobIdGeneration.

@Test
public void testJobIdGeneration() throws Exception {
    // test job ids are sequential
    for (int i = 0; i < 5; i++) {
        TaskFlowJob jobDef = new TaskFlowJob();
        for (int j = 0; j < 10; j++) {
            jobDef.addTask(createDefaultTask("task" + j));
        }
        InternalJob job = defaultSubmitJob(jobDef);
        Assert.assertEquals(String.valueOf(i + 1), job.getId().value());
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Example 49 with InternalJob

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

the class TestJobOperations method testSetToBeRemoved.

@Test
public void testSetToBeRemoved() throws Exception {
    InternalJob job = defaultSubmitJobAndLoadInternal(false, new TaskFlowJob());
    Assert.assertFalse(job.isToBeRemoved());
    job.setToBeRemoved();
    System.out.println("Set job to be removed");
    dbManager.jobSetToBeRemoved(job.getId());
    job = recoverJob();
    Assert.assertTrue(job.isToBeRemoved());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Example 50 with InternalJob

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

the class TestJobOperations method recoverJob.

private InternalJob recoverJob() {
    SchedulerStateRecoverHelper recoverHelper = new SchedulerStateRecoverHelper(dbManager);
    Collection<InternalJob> jobs = recoverHelper.recover(-1).getPendingJobs();
    Assert.assertEquals(1, jobs.size());
    return jobs.iterator().next();
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SchedulerStateRecoverHelper(org.ow2.proactive.scheduler.core.db.SchedulerStateRecoverHelper)

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