Search in sources :

Example 21 with ISchedulerClient

use of org.ow2.proactive.scheduler.rest.ISchedulerClient in project scheduling by ow2-proactive.

the class SchedulerClientTest method testSchedulerNodeClientCleanScript.

@Test(timeout = MAX_WAIT_TIME)
public void testSchedulerNodeClientCleanScript() throws Throwable {
    ISchedulerClient client = clientInstance();
    client.putThirdPartyCredential("TEST_CREDS", "mypassword_${PA_JOB_ID}");
    Job job = nodeClientJob("/functionaltests/descriptors/scheduler_client_node.groovy", "/functionaltests/descriptors/scheduler_client_node_fork.groovy", "/functionaltests/descriptors/scheduler_client_node_cleaning.groovy");
    JobId jobId = submitJob(job, client);
    JobResult jres = client.waitForJob(jobId, TimeUnit.MINUTES.toMillis(5));
    Assert.assertNotNull(jres);
    // wait 10 seconds because it is possible clean script executes after job
    Thread.sleep(10000);
    String jobLog = client.getJobServerLogs("" + jobId);
    // assert schedulerapi.connect() worked
    Assert.assertThat(jobLog, CoreMatchers.containsString("SCHEDULERAPI_URI_LIST_NOT_NULL=true"));
    // assert userspaceapi.connect() worked
    Assert.assertThat(jobLog, CoreMatchers.containsString("USERSPACE_FILE_LIST_NOT_NULL=true"));
    // assert globalspaceapi.connect() worked
    Assert.assertThat(jobLog, CoreMatchers.containsString("GLOBALSPACE_FILE_LIST_NOT_NULL=true"));
    // assert globalspaceapi.connect() worked
    Assert.assertThat(jobLog, CoreMatchers.containsString("TEST_CREDS=mypassword_" + jobId.toString()));
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleJob(functionaltests.jobs.SimpleJob) Job(org.ow2.proactive.scheduler.common.job.Job) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 22 with ISchedulerClient

use of org.ow2.proactive.scheduler.rest.ISchedulerClient in project scheduling by ow2-proactive.

the class SchedulerClientTest method testJobSubmissionWithGenericInfoResolvedWithVariable.

@Test(timeout = MAX_WAIT_TIME * 2)
public void testJobSubmissionWithGenericInfoResolvedWithVariable() throws Throwable {
    ISchedulerClient client = clientInstance();
    // The job submission generic info must be replaced by the job submission variable
    String jobSubmissionGenericInfoKey = "job_generic_info";
    String jobSubmissionGenericInfoValue = "${updated_with_job_variable}";
    Map<String, String> genericInfosMap = Collections.singletonMap(jobSubmissionGenericInfoKey, jobSubmissionGenericInfoValue);
    // Create a variables map
    String jobVariableKey = "updated_with_job_variable";
    String jobVariableValue = "!*variable value*!";
    Map<String, String> variablesMap = Collections.singletonMap(jobVariableKey, jobVariableValue);
    // Submit a job with the generic informations map and the variables map
    JobId jobId = client.submit(jobDescriptor, variablesMap, genericInfosMap, anyMap());
    client.waitForJob(jobId, TimeUnit.SECONDS.toMillis(120));
    // The job generic info must be returned by the task
    TaskResult taskResult = client.getJobResult(jobId).getResult("task1");
    Assert.assertEquals(jobVariableValue, taskResult.value());
}
Also used : ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 23 with ISchedulerClient

use of org.ow2.proactive.scheduler.rest.ISchedulerClient in project scheduling by ow2-proactive.

the class SchedulerClientTest method testGetGroups.

@Test(timeout = MAX_WAIT_TIME)
public void testGetGroups() throws Exception {
    ISchedulerClient client = SchedulerClient.createInstance();
    client.init(new ConnectionInfo(getRestServerUrl(), getLogin(), getPassword(), null, true));
    UserData userData = client.getCurrentUserData();
    Assert.assertNotNull(userData);
    Assert.assertNotNull(userData.getGroups());
    Assert.assertTrue(userData.getGroups().contains("scheduleradmins"));
    client.disconnect();
    client.init(new ConnectionInfo(getRestServerUrl(), getNonAdminLogin(), getNonAdminLoginPassword(), null, true));
    userData = client.getCurrentUserData();
    Assert.assertNotNull(userData);
    Assert.assertNotNull(userData.getGroups());
    Assert.assertTrue(userData.getGroups().contains("user"));
    client.disconnect();
}
Also used : UserData(org.ow2.proactive.authentication.UserData) ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) ConnectionInfo(org.ow2.proactive.authentication.ConnectionInfo) Test(org.junit.Test)

Example 24 with ISchedulerClient

use of org.ow2.proactive.scheduler.rest.ISchedulerClient in project scheduling by ow2-proactive.

the class SchedulerClientTest method testSchedulerNodeClientDisconnect.

@Test(timeout = MAX_WAIT_TIME)
public void testSchedulerNodeClientDisconnect() throws Throwable {
    ISchedulerClient client = clientInstance();
    Job job = nodeClientJob("/functionaltests/descriptors/scheduler_client_node_disconnect.groovy", null, null);
    JobId jobId = submitJob(job, client);
    TaskResult tres = client.waitForTask(jobId.toString(), "NodeClientTask", TimeUnit.MINUTES.toMillis(5));
    System.out.println(tres.getOutput().getAllLogs(false));
    Assert.assertFalse(tres.hadException());
}
Also used : ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleJob(functionaltests.jobs.SimpleJob) Job(org.ow2.proactive.scheduler.common.job.Job) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 25 with ISchedulerClient

use of org.ow2.proactive.scheduler.rest.ISchedulerClient in project scheduling by ow2-proactive.

the class SchedulerClientTest method testSignals.

@Test(timeout = MAX_WAIT_TIME)
public void testSignals() throws Throwable {
    ISchedulerClient client = clientInstance();
    Job job = nodeClientJob("/functionaltests/descriptors/register_service_with_signals.groovy", null, null);
    // submit job with 'ready signal' and add variables
    JobId jobId = submitJob(job, client);
    JobInfo jobInfo;
    // wait until 'ready_my_signal' signal is sent
    do {
        jobInfo = client.getJobInfo(jobId.toString());
        Assert.assertNotNull(jobInfo);
        Thread.sleep(1000);
    } while (!jobInfo.getSignals().contains("ready_my_signal"));
    Map<String, String> outpuVariables = new HashMap<>();
    outpuVariables.put("name", "15");
    // validate the job variables
    List<JobVariable> jobVariables = client.validateJobSignal(jobId.value(), "my_signal", outpuVariables);
    // add 'my_signal' signal
    Set<String> signals = client.addJobSignal(jobId.value(), "my_signal", outpuVariables);
    // wait until the job is finished
    client.waitForJob(jobId.toString(), TimeUnit.MINUTES.toMillis(5));
    Assert.assertFalse(signals.contains("ready_my_signal"));
    Assert.assertTrue(signals.contains("my_signal"));
    JobVariable nameJobVariable = jobVariables.stream().filter(jobVariable -> jobVariable.getName().equals("name")).findFirst().get();
    Assert.assertNotNull(nameJobVariable);
    Assert.assertEquals("15", nameJobVariable.getValue());
    Assert.assertEquals("PA:Integer", nameJobVariable.getModel());
    JobVariable secondJobVariable = jobVariables.stream().filter(jobVariable -> jobVariable.getName().equals("second")).findFirst().get();
    Assert.assertNotNull(secondJobVariable);
    Assert.assertEquals("15", secondJobVariable.getValue());
    Assert.assertEquals("PA:Integer", secondJobVariable.getModel());
}
Also used : JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleJob(functionaltests.jobs.SimpleJob) Job(org.ow2.proactive.scheduler.common.job.Job) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Aggregations

ISchedulerClient (org.ow2.proactive.scheduler.rest.ISchedulerClient)36 Test (org.junit.Test)34 JobId (org.ow2.proactive.scheduler.common.job.JobId)28 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)25 SimpleJob (functionaltests.jobs.SimpleJob)25 Job (org.ow2.proactive.scheduler.common.job.Job)25 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)25 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)11 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)6 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)5 JobVariable (org.ow2.proactive.scheduler.common.job.JobVariable)4 ConnectionInfo (org.ow2.proactive.authentication.ConnectionInfo)3 File (java.io.File)2 JobState (org.ow2.proactive.scheduler.common.job.JobState)2 ExternalEndpoint (org.ow2.proactive.scheduler.job.ExternalEndpoint)2 ErrorTask (functionaltests.jobs.ErrorTask)1 LogTask (functionaltests.jobs.LogTask)1 MetadataTask (functionaltests.jobs.MetadataTask)1 RawTask (functionaltests.jobs.RawTask)1 VariableTask (functionaltests.jobs.VariableTask)1