Search in sources :

Example 1 with ProcessStreamReader

use of functionaltests.utils.ProcessStreamReader in project scheduling by ow2-proactive.

the class RestFuncTHelper method startRestfulSchedulerWebapp.

public static void startRestfulSchedulerWebapp(int nbNodes) throws Exception {
    // Kill all children processes on exit
    org.apache.log4j.BasicConfigurator.configure(new org.apache.log4j.varia.NullAppender());
    CookieBasedProcessTreeKiller.registerKillChildProcessesOnShutdown("rest_tests");
    List<String> cmd = new ArrayList<>();
    String javaPath = RestFuncTUtils.getJavaPathFromSystemProperties();
    cmd.add(javaPath);
    cmd.add("-Djava.security.manager");
    cmd.add("-Dresteasy.allowGzip=true");
    cmd.add("-Dfile.encoding=UTF-8");
    cmd.add(CentralPAPropertyRepository.JAVA_SECURITY_POLICY.getCmdLine() + toPath(serverJavaPolicy));
    cmd.add(CentralPAPropertyRepository.PA_HOME.getCmdLine() + getSchedHome());
    cmd.add(PASchedulerProperties.SCHEDULER_HOME.getCmdLine() + getSchedHome());
    cmd.add(PAResourceManagerProperties.RM_HOME.getCmdLine() + getRmHome());
    cmd.add(PAResourceManagerProperties.RM_DB_HIBERNATE_DROPDB.getCmdLine() + System.getProperty("rm.deploy.dropDB", "true"));
    cmd.add(PAResourceManagerProperties.RM_DB_HIBERNATE_CONFIG.getCmdLine() + toPath(rmHibernateConfig));
    cmd.add(PASchedulerProperties.SCHEDULER_DB_HIBERNATE_DROPDB.getCmdLine() + System.getProperty("scheduler.deploy.dropDB", "true"));
    cmd.add(PASchedulerProperties.SCHEDULER_DB_HIBERNATE_CONFIG.getCmdLine() + toPath(schedHibernateConfig));
    cmd.add(WebProperties.WEB_HTTPS.getCmdLine() + "true");
    cmd.add(CentralPAPropertyRepository.PA_COMMUNICATION_PROTOCOL.getCmdLine() + "pnp");
    cmd.add(PNPConfig.PA_PNP_PORT.getCmdLine() + "1200");
    cmd.add("-cp");
    cmd.add(getClassPath());
    cmd.add(SchedulerStarter.class.getName());
    cmd.add("-ln");
    cmd.add("" + nbNodes);
    ProcessBuilder processBuilder = new ProcessBuilder(cmd);
    processBuilder.redirectErrorStream(true);
    schedProcess = processBuilder.start();
    ProcessStreamReader out = new ProcessStreamReader("scheduler-output: ", schedProcess.getInputStream());
    out.start();
    // RM and scheduler are on the same url
    String port = "1200";
    String url = "pnp://localhost:" + port + "/";
    // Connect a scheduler client
    SchedulerAuthenticationInterface schedAuth = SchedulerConnection.waitAndJoin(url, TimeUnit.SECONDS.toMillis(120));
    schedulerPublicKey = schedAuth.getPublicKey();
    Credentials schedCred = RestFuncTUtils.createCredentials("admin", "admin", schedulerPublicKey);
    scheduler = schedAuth.login(schedCred);
    // Connect a rm client
    RMAuthentication rmAuth = RMConnection.waitAndJoin(url, TimeUnit.SECONDS.toMillis(120));
    Credentials rmCredentials = getRmCredentials();
    rm = rmAuth.login(rmCredentials);
    restServerUrl = "https://localhost:8443/rest/";
    restfulSchedulerUrl = restServerUrl + "scheduler";
    restfulRmUrl = restServerUrl + "rm";
    await().atMost(new Duration(900, TimeUnit.SECONDS)).until(restIsStarted());
}
Also used : SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface) Duration(com.jayway.awaitility.Duration) SchedulerStarter(org.ow2.proactive.scheduler.util.SchedulerStarter) RMAuthentication(org.ow2.proactive.resourcemanager.authentication.RMAuthentication) ProcessStreamReader(functionaltests.utils.ProcessStreamReader) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

Aggregations

Duration (com.jayway.awaitility.Duration)1 ProcessStreamReader (functionaltests.utils.ProcessStreamReader)1 Credentials (org.ow2.proactive.authentication.crypto.Credentials)1 RMAuthentication (org.ow2.proactive.resourcemanager.authentication.RMAuthentication)1 SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)1 SchedulerStarter (org.ow2.proactive.scheduler.util.SchedulerStarter)1