use of functionaltests.utils.SchedulerTHelper in project scheduling by ow2-proactive.
the class RunningTaskRecoveryWithRecoveredNodeTestBase method startDedicatedScheduler.
@Before
public void startDedicatedScheduler() throws Exception {
RMFactory.setOsJavaProperty();
schedulerHelper = new SchedulerTHelper(false, new File(getSchedulerStartConfigurationURL().toURI()).getAbsolutePath(), new File(RM_CONFIGURATION_START.toURI()).getAbsolutePath(), null);
logForwardingService = new LogForwardingService(SocketBasedForwardingProvider.class.getName());
logForwardingService.initialize();
}
use of functionaltests.utils.SchedulerTHelper in project scheduling by ow2-proactive.
the class RunningTaskRecoveryWithRecoveredNodeTestBase method action.
@Test
public void action() throws Throwable {
nodes = schedulerHelper.createRMNodeStarterNodes(RunningTaskRecoveryWithForkedTaskExecutorTest.class.getSimpleName(), NB_NODES);
JobId jobid = schedulerHelper.submitJob(new File(JOB_DESCRIPTOR.toURI()).getAbsolutePath());
schedulerHelper.waitForEventJobRunning(jobid);
TaskState taskState = schedulerHelper.getSchedulerInterface().getJobState(jobid).getTasks().get(0);
schedulerHelper.waitForEventTaskRunning(taskState.getJobId(), taskState.getName());
taskState = schedulerHelper.getSchedulerInterface().getJobState(jobid).getTasks().get(0);
String firstExecutionHostInfo = taskState.getTaskInfo().getExecutionHostName();
// wait and restart scheduler
Thread.sleep(RESTART_SCHEDULER_INTER_TIME_IN_MILLISECONDS);
TestScheduler.kill();
Thread.sleep(RESTART_SCHEDULER_INTER_TIME_IN_MILLISECONDS);
schedulerHelper = new SchedulerTHelper(false, new File(getSchedulerReStartConfigurationURL().toURI()).getAbsolutePath(), new File(RM_CONFIGURATION_RESTART.toURI()).getAbsolutePath(), null, false);
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
TestListenJobLogs.TestAppender appender = new TestListenJobLogs.TestAppender(LOGGER_NAME);
String loggerName = Log4JTaskLogs.JOB_LOGGER_PREFIX + jobid;
logForwardingService.removeAllAppenders(LOGGER_NAME);
logForwardingService.addAppender(loggerName, appender);
scheduler.listenJobLogs(jobid, logForwardingService.getAppenderProvider());
System.out.println("Number of nodes: " + schedulerHelper.getResourceManager().getState().getAllNodes().size());
for (String freeNodeUrl : schedulerHelper.getResourceManager().getState().getFreeNodes()) {
// previous executing node should not be free when the nodes are added back to the rm
Assert.assertFalse(firstExecutionHostInfo.contains(freeNodeUrl));
}
// we should have just one running task
JobState jobState = scheduler.getJobState(jobid);
Assert.assertEquals(0, jobState.getNumberOfPendingTasks());
Assert.assertEquals(1, jobState.getNumberOfRunningTasks());
taskState = jobState.getTasks().get(0);
Assert.assertEquals(firstExecutionHostInfo, taskState.getTaskInfo().getExecutionHostName());
appender.waitForLoggingEvent(LOG_EVENT_TIMEOUT, TASK_LOG_OUTPUT_STARTING_STRING + MAXIMUM_STEP_IN_TASK_LOOP);
schedulerHelper.waitForEventJobFinished(jobid);
TaskResult taskResult = scheduler.getJobResult(jobid).getResult(TASK_NAME);
Assert.assertFalse(taskResult.hadException());
Assert.assertEquals(OK_TASK_RESULT_VALUE, taskResult.value());
String logs = taskResult.getOutput().getStdoutLogs();
for (int i = 0; i < MAXIMUM_STEP_IN_TASK_LOOP; i++) {
Assert.assertTrue(logs.contains(TASK_LOG_OUTPUT_STARTING_STRING + i));
}
}
use of functionaltests.utils.SchedulerTHelper in project scheduling by ow2-proactive.
the class TestRunAsMeLinuxKey method startDedicatedScheduler.
@BeforeClass
public static void startDedicatedScheduler() throws Exception {
assumeTrue(OperatingSystem.getOperatingSystem() == OperatingSystem.unix);
setupUser();
String keyPath = System.getProperty(RUNASME_KEY_PATH_PROPNAME);
assumeNotNull(keyPath);
key = IOUtils.toByteArray(new File(keyPath).toURI());
RMFactory.setOsJavaProperty();
// start an empty scheduler and add a node source with modified properties
schedulerHelper = new SchedulerTHelper(true, true);
List<String> arguments = new ArrayList<>();
arguments.addAll(RMTHelper.setup.getJvmParametersAsList());
arguments.add("-D" + ForkerUtils.FORK_METHOD_KEY + "=" + ForkerUtils.ForkMethod.KEY.toString());
schedulerHelper.createNodeSource("RunAsMeNSKey", 5, arguments);
}
use of functionaltests.utils.SchedulerTHelper in project scheduling by ow2-proactive.
the class TestJobScriptVariables method before.
@BeforeClass
public static void before() throws Throwable {
File propertiesfile = new File(configFile.toURI());
schedulerHelper = new SchedulerTHelper(true, propertiesfile.getAbsolutePath());
}
use of functionaltests.utils.SchedulerTHelper in project scheduling by ow2-proactive.
the class TestUnauthorizedScripts method before.
@BeforeClass
public static void before() throws Throwable {
// initialize the scheduler & rm with a custom authorized script folder
scriptsFolder = folder.newFolder("scripts");
File schedulerConfigFile = generateConfigFile(originalSchedulerConfigFile.toURI(), "schedulerConfig");
File rmConfigFile = generateConfigFile(originalRMConfigFile.toURI(), "rmConfig");
// create authorized and unauthorized scripts
String tempFolderPathEscaped = folder.getRoot().getAbsolutePath().replace("\\", "\\\\");
authorizedForkScriptContent = "new File('" + tempFolderPathEscaped + "','fork_auth.out').write('ok')";
authorizedCleanScriptContent = "new File('" + tempFolderPathEscaped + "','clean_auth.out').write('ok')";
authorizedSelectionScriptContent = "new File('" + tempFolderPathEscaped + "','selection_auth.out').write('ok'); selected=true";
File forkScript = new File(scriptsFolder, "forkScript");
FileUtils.write(forkScript, authorizedForkScriptContent, Charset.defaultCharset(), false);
File cleanScript = new File(scriptsFolder, "cleanScript");
FileUtils.write(cleanScript, authorizedCleanScriptContent, Charset.defaultCharset(), false);
File selectionScript = new File(scriptsFolder, "selectionScript");
FileUtils.write(selectionScript, authorizedSelectionScriptContent, Charset.defaultCharset(), false);
unauthorizedForkScriptContent = "new File('" + tempFolderPathEscaped + "','fork.out').write('ko')";
unauthorizedCleanScriptContent = "new File('" + tempFolderPathEscaped + "','clean.out').write('ko')";
unauthorizedSelectionScriptContent = "new File('" + tempFolderPathEscaped + "','selection.out').write('ko'); selected=true";
// start the configured scheduler
schedulerHelper = new SchedulerTHelper(true, schedulerConfigFile.getAbsolutePath(), rmConfigFile.getAbsolutePath(), null);
}
Aggregations