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)));
}
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));
}
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());
}
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());
}
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());
}
Aggregations