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