Search in sources :

Example 51 with JobIdImpl

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

the class TaskLoggerTest method multipleRemoveLoggers.

@Test
public void multipleRemoveLoggers() throws Exception {
    List<TaskLogger> loggers = new ArrayList<>(1000);
    for (int i = 0; i < 1000; i++) {
        loggers.add(new TaskLogger(TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", i), "myhost"));
    }
    for (int i = 0; i < 1000; i++) {
        loggers.get(i).close();
        assertNull(LogManager.exists(loggers.get(i).getName()));
    }
    assertNull(LogManager.exists(Log4JTaskLogs.getLoggerName("" + 1000)));
}
Also used : ArrayList(java.util.ArrayList) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Test(org.junit.Test)

Example 52 with JobIdImpl

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

the class TaskLoggerTest method printAndGetLogs.

@Test
public void printAndGetLogs() throws Exception {
    taskLogger = new TaskLogger(TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", 42L), "myhost");
    assertEquals("", taskLogger.getLogs().getAllLogs(false));
    taskLogger.getOutputSink().println("hello");
    assertEquals(String.format("hello%n"), taskLogger.getLogs().getAllLogs(false));
    assertEquals(String.format("hello%n"), taskLogger.getLogs().getStdoutLogs(false));
    taskLogger.getErrorSink().println("error");
    assertEquals(String.format("hello%nerror%n"), taskLogger.getLogs().getAllLogs(false));
    assertEquals(String.format("error%n"), taskLogger.getLogs().getStderrLogs(false));
}
Also used : JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Test(org.junit.Test)

Example 53 with JobIdImpl

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

the class InProcessTaskExecutorTest method result_from_parent_task.

@Test
public void result_from_parent_task() throws Throwable {
    TestTaskOutput taskOutput = new TestTaskOutput();
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(1000, "job"), "task", 42L));
    TaskResult[] previousTasksResults = { new TaskResultImpl(null, "aresult", null, 0) };
    new InProcessTaskExecutor().execute(new TaskContext(new ScriptExecutableContainer(new TaskScript(new SimpleScript("print(results[0]);", "groovy"))), initializer, previousTasksResults, new NodeDataSpacesURIs("", "", "", "", "", ""), "", ""), taskOutput.outputStream, taskOutput.error);
    assertEquals("aresult", taskOutput.output());
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskScript(org.ow2.proactive.scripting.TaskScript) InProcessTaskExecutor(org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor) SimpleScript(org.ow2.proactive.scripting.SimpleScript) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) NodeDataSpacesURIs(org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs) Test(org.junit.Test)

Example 54 with JobIdImpl

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

the class SchedulerRestWorkflowFromCatalogExecutionTest method testWhenSubmittingConcurrentlyUsingAValidWfContentUrlAllValidJobIdsMustBeRetrieved.

@Test
public void testWhenSubmittingConcurrentlyUsingAValidWfContentUrlAllValidJobIdsMustBeRetrieved() throws Exception {
    Integer NRO_THREADS = 100;
    when(scheduler.submit(Matchers.<Job>any())).thenReturn(new JobIdImpl(55L, "job"));
    final AtomicInteger successfullyFinished = new AtomicInteger(0);
    Runnable runnable = new Runnable() {

        public void run() {
            try {
                String workflowUrl = getBaseUriTestWorkflowsServer() + "/workflow";
                JobIdData jobId = schedulerRest.submitFromUrl(sessionId, workflowUrl, getEmptyPathSegment());
                if (jobId.getId() == 55L) {
                    successfullyFinished.incrementAndGet();
                }
            } catch (Exception e) {
                fail(e.getMessage());
            }
        }
    };
    List<Thread> threads = new ArrayList<>(NRO_THREADS);
    for (int i = 0; i < NRO_THREADS; i++) {
        Thread t = new Thread(runnable, "submitter-" + i);
        t.start();
        threads.add(t);
    }
    for (Thread t : threads) {
        t.join();
    }
    Assert.assertEquals(NRO_THREADS, (Integer) successfullyFinished.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobCreationRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobCreationRestException) IOException(java.io.IOException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) Test(org.junit.Test)

Example 55 with JobIdImpl

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

the class SchedulerRestWorkflowFromCatalogExecutionTest method testWhenSubmittingUsingAValidWfContentUrlThenAJobIdMustBeRetrieved.

@Test
public void testWhenSubmittingUsingAValidWfContentUrlThenAJobIdMustBeRetrieved() throws Exception {
    when(scheduler.submit(Matchers.<Job>any())).thenReturn(new JobIdImpl(77L, "job"));
    String workflowUrl = getBaseUriTestWorkflowsServer() + "/workflow";
    JobIdData jobId = schedulerRest.submitFromUrl(sessionId, workflowUrl, getEmptyPathSegment());
    Assert.assertNotNull(jobId);
    Assert.assertEquals(77L, jobId.getId());
    Assert.assertEquals("job", jobId.getReadableName());
}
Also used : JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Test(org.junit.Test)

Aggregations

JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)85 Test (org.junit.Test)70 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)36 JobId (org.ow2.proactive.scheduler.common.job.JobId)34 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)26 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)24 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)24 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)24 ArrayList (java.util.ArrayList)20 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)13 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)12 Matchers.containsString (org.hamcrest.Matchers.containsString)10 Matchers.anyString (org.mockito.Matchers.anyString)10 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)9 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)9 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)8 SimpleScript (org.ow2.proactive.scripting.SimpleScript)8 TaskScript (org.ow2.proactive.scripting.TaskScript)8 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)7 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)6