Search in sources :

Example 41 with InternalJob

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

the class TestInMemorySchedulerDB method sanityLastUpdatedTimeTest.

@Test
public void sanityLastUpdatedTimeTest() throws Exception {
    SchedulerDBManager dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task1"));
    InternalJob job = InternalJobFactory.createJob(jobDef, BaseSchedulerDBTest.getDefaultCredentials());
    job.setOwner("test");
    dbManager.newJobSubmitted(job);
    List<InternalJob> jobs = dbManager.loadJobs(false, job.getId());
    // when job is submitted, the last updated time is initialized as submitted time
    Assert.assertThat(jobs.size(), is(1));
    Assert.assertThat(jobs.get(0).getJobInfo().getLastUpdatedTime(), is(jobs.get(0).getJobInfo().getSubmittedTime()));
    dbManager.changeJobPriority(job.getId(), JobPriority.HIGH);
    jobs = dbManager.loadJobs(false, job.getId());
    // job's priority was changed, the last update time must be greater than submitted time
    long priorityChangedTime = jobs.get(0).getJobInfo().getLastUpdatedTime();
    Assert.assertThat(priorityChangedTime - jobs.get(0).getJobInfo().getSubmittedTime() > 0, is(true));
    dbManager.jobSetToBeRemoved(job.getId());
    jobs = dbManager.loadJobs(false, job.getId());
    // job's state was changed, the last update time must be greater than submitted time
    Assert.assertThat(jobs.get(0).getJobInfo().getLastUpdatedTime() - priorityChangedTime > 0, is(true));
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test) ProActiveTest(org.ow2.tests.ProActiveTest)

Example 42 with InternalJob

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

the class TestInMemorySchedulerDB method sanityTest.

@Test
public void sanityTest() throws Exception {
    SchedulerDBManager dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task1"));
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task2"));
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task3"));
    InternalJob job = InternalJobFactory.createJob(jobDef, BaseSchedulerDBTest.getDefaultCredentials());
    job.setOwner("test");
    dbManager.newJobSubmitted(job);
    dbManager.readAccount("test");
    dbManager.changeJobPriority(job.getId(), JobPriority.HIGH);
    Assert.assertEquals(1, dbManager.loadNotFinishedJobs(true).size());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test) ProActiveTest(org.ow2.tests.ProActiveTest)

Example 43 with InternalJob

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

the class TestInMemorySchedulerDB method sanityTestJobContent.

@Test
public void sanityTestJobContent() throws Exception {
    SchedulerDBManager dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task1"));
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task2"));
    jobDef.addTask(BaseSchedulerDBTest.createDefaultTask("task3"));
    InternalJob job = InternalJobFactory.createJob(jobDef, BaseSchedulerDBTest.getDefaultCredentials());
    job.setOwner("test");
    dbManager.newJobSubmitted(job);
    Job content = dbManager.loadInitalJobContent(job.getId());
    Assert.assertTrue(content instanceof TaskFlowJob);
    Assert.assertThat(((TaskFlowJob) content).getTasks().size(), is(3));
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Job(org.ow2.proactive.scheduler.common.job.Job) Test(org.junit.Test) ProActiveTest(org.ow2.tests.ProActiveTest)

Example 44 with InternalJob

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

the class TestJobAttributes method testJobVariables.

@Test
public void testJobVariables() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    InternalJob jobData;
    HashMap<String, JobVariable> jobVariables = new HashMap<>();
    job.setVariables(jobVariables);
    jobData = defaultSubmitJobAndLoadInternal(false, job);
    Assert.assertNotNull(jobData.getVariables());
    Assert.assertTrue(jobData.getVariables().isEmpty());
    jobVariables.put("var1", new JobVariable("var1", "value1", null));
    jobVariables.put("var2", new JobVariable("var2", "value2", null));
    job.setVariables(jobVariables);
    jobVariables = new HashMap<>();
    jobVariables.put("var1", new JobVariable("var1", "value1", null));
    jobVariables.put("var2", new JobVariable("var2", "value2", null));
    job.setVariables(jobVariables);
    jobData = defaultSubmitJobAndLoadInternal(false, job);
    Assert.assertEquals(2, jobData.getVariables().size());
    Assert.assertEquals("value1", jobData.getVariables().get("var1").getValue());
    Assert.assertEquals("value2", jobData.getVariables().get("var2").getValue());
    StringBuilder longString = new StringBuilder();
    for (int i = 0; i < 100; i++) {
        longString.append("0123456789abcdefghijklmnopqrstuvwxyz");
    }
    jobVariables = new HashMap<>();
    jobVariables.put("longProperty", new JobVariable("longProperty", longString.toString()));
    job.setVariables(jobVariables);
    jobData = defaultSubmitJobAndLoadInternal(false, job);
    Assert.assertEquals(1, jobData.getVariables().size());
    Assert.assertEquals(longString.toString(), jobData.getVariables().get("longProperty").getValue());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) HashMap(java.util.HashMap) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) Test(org.junit.Test)

Example 45 with InternalJob

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

the class TestJobAttributes method testLargeStringValues.

@Test
public void testLargeStringValues() throws Exception {
    String description = createString(500);
    TaskFlowJob jobDef = new TaskFlowJob();
    jobDef.setDescription(description);
    InternalJob job = defaultSubmitJobAndLoadInternal(false, jobDef);
    Assert.assertEquals(description, job.getDescription());
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

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