Search in sources :

Example 6 with SchedulerTHelper

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();
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) LogForwardingService(org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingService) File(java.io.File) Before(org.junit.Before)

Example 7 with SchedulerTHelper

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));
    }
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) TestListenJobLogs(functionaltests.job.log.TestListenJobLogs) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TestScheduler(functionaltests.utils.TestScheduler) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) 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 8 with SchedulerTHelper

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);
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) ArrayList(java.util.ArrayList) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 9 with SchedulerTHelper

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());
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 10 with SchedulerTHelper

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);
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Aggregations

SchedulerTHelper (functionaltests.utils.SchedulerTHelper)27 File (java.io.File)14 BeforeClass (org.junit.BeforeClass)14 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)5 JobState (org.ow2.proactive.scheduler.common.job.JobState)5 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)5 JobId (org.ow2.proactive.scheduler.common.job.JobId)4 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)3 SchedulerFunctionalTest (functionaltests.utils.SchedulerFunctionalTest)2 Before (org.junit.Before)2 TestListenJobLogs (functionaltests.job.log.TestListenJobLogs)1 SchedulerStartForFunctionalTest (functionaltests.utils.SchedulerStartForFunctionalTest)1 TestScheduler (functionaltests.utils.TestScheduler)1 FileSystemServerDeployer (org.objectweb.proactive.extensions.vfsprovider.FileSystemServerDeployer)1 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)1 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)1 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)1 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)1 LogForwardingService (org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingService)1