Search in sources :

Example 91 with TaskFlowJob

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

the class TaskSchedulingTimeTest method test.

@Test(timeout = 3600000)
public void test() throws Exception {
    ProActiveConfiguration.load();
    RMFactory.setOsJavaProperty();
    schedulerHelper = new SchedulerTHelper(false, SCHEDULER_CONFIGURATION_START.getPath(), RM_CONFIGURATION_START.getPath(), null);
    schedulerHelper.createNodeSourceWithInfiniteTimeout("local", numberOfExperiments);
    final TaskFlowJob job = SchedulerEfficiencyMetricsTest.createJob(1, 10);
    long totalTime = 0;
    for (int i = 0; i < numberOfExperiments; ++i) {
        JobId jobId = schedulerHelper.submitJob(job);
        jobIds.add(jobId);
        schedulerHelper.waitForEventJobFinished(jobId);
        final JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobId);
        final long submittedTime = jobState.getSubmittedTime();
        final long taskStartTime = jobState.getTasks().get(0).getStartTime();
        final long timeToScheduleTask = taskStartTime - submittedTime;
        totalTime += timeToScheduleTask;
    }
    long averageTime = totalTime / numberOfExperiments;
    LOGGER.info(makeCSVString("AverageTaskSchedulingTime", numberOfExperiments, timeLimit, averageTime, ((averageTime < timeLimit) ? SUCCESS : FAILURE)));
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 92 with TaskFlowJob

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

the class SchedulingServiceTest7 method createTestJob.

private TaskFlowJob createTestJob() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    JavaTask mainTask = new JavaTask();
    mainTask.setName("Main task");
    mainTask.setExecutableClassName("ReplicateMainTask");
    mainTask.setFlowBlock(FlowBlock.START);
    String replicateScript = String.format("runs = %d", 3);
    mainTask.setFlowScript(FlowScript.createReplicateFlowScript(replicateScript));
    job.addTask(mainTask);
    JavaTask replicatedTask = new JavaTask();
    replicatedTask.setExecutableClassName("ReplicatedTask");
    replicatedTask.setName("Replicated task");
    replicatedTask.addDependence(mainTask);
    replicatedTask.addArgument("taskParameter", "test");
    job.addTask(replicatedTask);
    JavaTask lastTask = new JavaTask();
    lastTask.setExecutableClassName("LastTask");
    lastTask.setName("Replication last task");
    lastTask.setFlowBlock(FlowBlock.END);
    lastTask.addDependence(replicatedTask);
    job.addTask(lastTask);
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 93 with TaskFlowJob

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

the class SchedulingServiceTest9 method createTestJob.

private TaskFlowJob createTestJob() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName());
    JavaTask task1 = new JavaTask();
    task1.setName("javaTask1");
    task1.setExecutableClassName("class");
    job.addTask(task1);
    JavaTask task2 = new JavaTask();
    task2.setName("javaTask2");
    task2.setExecutableClassName("class");
    job.addTask(task2);
    return job;
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 94 with TaskFlowJob

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

the class TestTaskIdOrderSameAsDeclarationOrder method task_ids_should_be_ordered_as_task_declaration_order.

@Test
public void task_ids_should_be_ordered_as_task_declaration_order() throws Throwable {
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    JobId id = schedulerHelper.submitJob(job);
    JobState jobState = schedulerHelper.waitForEventJobSubmitted(id);
    List<TaskState> sortedTasksById = sortTasksById(jobState);
    assertEquals("premiere", sortedTasksById.get(0).getName());
    assertEquals("deuxieme", sortedTasksById.get(1).getName());
    assertEquals("troisieme", sortedTasksById.get(2).getName());
    // remove job
    schedulerHelper.waitForEventJobFinished(id);
    schedulerHelper.removeJob(id);
    schedulerHelper.waitForEventJobRemoved(id);
}
Also used : TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JobState(org.ow2.proactive.scheduler.common.job.JobState) File(java.io.File) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 95 with TaskFlowJob

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

the class TestJobNativeSubmission method testJobNativeSubmission.

@Test
public void testJobNativeSubmission() throws Throwable {
    // test submission and event reception
    TaskFlowJob job = new TaskFlowJob();
    NativeTask successfulTask = new NativeTask();
    successfulTask.setName("successfulTask");
    if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
        successfulTask.setCommandLine("cmd", "/C", "ping 127.0.0.1 -n 10", ">", "NUL");
    } else {
        successfulTask.setCommandLine("ping", "-c", "5", "127.0.0.1");
    }
    job.addTask(successfulTask);
    NativeTask invalidCommandTask = new NativeTask();
    invalidCommandTask.setName("invalidCommandTask");
    invalidCommandTask.addDependence(successfulTask);
    invalidCommandTask.setCommandLine("invalid_command");
    job.addTask(invalidCommandTask);
    // SCHEDULING-1987
    NativeTask taskReadingInput = new NativeTask();
    taskReadingInput.setName("taskReadingInput");
    if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
        // wait for y/n
        taskReadingInput.setCommandLine("choice");
    } else {
        // cat hangs for user's input
        taskReadingInput.setCommandLine("cat");
    }
    job.addTask(taskReadingInput);
    JobId id = schedulerHelper.submitJob(job);
    log("Job submitted, id " + id.toString());
    log("Waiting for jobSubmitted Event");
    JobState receivedState = schedulerHelper.waitForEventJobSubmitted(id);
    assertEquals(receivedState.getId(), id);
    log("Waiting for job running");
    JobInfo jInfo = schedulerHelper.waitForEventJobRunning(id);
    assertEquals(jInfo.getJobId(), id);
    assertEquals(JobStatus.RUNNING, jInfo.getStatus());
    schedulerHelper.waitForEventTaskRunning(id, successfulTask.getName());
    TaskInfo tInfo = schedulerHelper.waitForEventTaskFinished(id, successfulTask.getName());
    assertEquals(TaskStatus.FINISHED, tInfo.getStatus());
    schedulerHelper.waitForEventTaskRunning(id, invalidCommandTask.getName());
    tInfo = schedulerHelper.waitForEventTaskFinished(id, invalidCommandTask.getName());
    assertEquals(TaskStatus.FAULTY, tInfo.getStatus());
    TaskInfo taskReadingInputInfo = schedulerHelper.waitForEventTaskFinished(id, taskReadingInput.getName());
    if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
        // choice fails when input is closed
        assertEquals(TaskStatus.FAULTY, taskReadingInputInfo.getStatus());
    } else {
        assertEquals(TaskStatus.FINISHED, taskReadingInputInfo.getStatus());
    }
    schedulerHelper.waitForEventJobFinished(id);
    // remove job
    schedulerHelper.removeJob(id);
    schedulerHelper.waitForEventJobRemoved(id);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) 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