Search in sources :

Example 41 with TaskFlowJob

use of org.ow2.proactive.scheduler.common.job.TaskFlowJob 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 42 with TaskFlowJob

use of org.ow2.proactive.scheduler.common.job.TaskFlowJob 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 43 with TaskFlowJob

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

Example 44 with TaskFlowJob

use of org.ow2.proactive.scheduler.common.job.TaskFlowJob 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 45 with TaskFlowJob

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

Aggregations

TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)184 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)92 Test (org.junit.Test)81 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)49 JobId (org.ow2.proactive.scheduler.common.job.JobId)33 File (java.io.File)31 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)25 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)22 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)21 SimpleScript (org.ow2.proactive.scripting.SimpleScript)20 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)18 ScriptTask (org.ow2.proactive.scheduler.common.task.ScriptTask)16 Task (org.ow2.proactive.scheduler.common.task.Task)16 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)13 TaskScript (org.ow2.proactive.scripting.TaskScript)13 JobState (org.ow2.proactive.scheduler.common.job.JobState)12 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)12 ArrayList (java.util.ArrayList)11 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)11 HashMap (java.util.HashMap)10