use of org.ow2.proactive.scheduler.rest.ISchedulerClient in project scheduling by ow2-proactive.
the class SchedulerClientTest method testWaitForNonTerminatingJob.
@Test(timeout = MAX_WAIT_TIME, expected = TimeoutException.class)
public void testWaitForNonTerminatingJob() throws Exception {
ISchedulerClient client = clientInstance();
Job job = pendingJob();
JobId jobId = submitJob(job, client);
try {
client.waitForJob(jobId, TimeUnit.SECONDS.toMillis(10));
} finally {
// Once the TimeoutException has been thrown
// kill the job to free the node
client.killJob(jobId);
}
}
use of org.ow2.proactive.scheduler.rest.ISchedulerClient in project scheduling by ow2-proactive.
the class SchedulerClientTest method testPushPullDeleteEmptyFile.
@Test(timeout = MAX_WAIT_TIME)
public void testPushPullDeleteEmptyFile() throws Exception {
File emptyFile = File.createTempFile("emptyFile", ".tmp");
ISchedulerClient client = clientInstance();
// Push the empty file into the userspace
client.pushFile("USERSPACE", "", emptyFile.getName(), emptyFile.getCanonicalPath());
// Delete the local file
Assert.assertTrue("Unable to delete the local file after push, maybe there are still some open streams?", emptyFile.delete());
// Pull it from the userspace to be sure that it was pushed
client.pullFile("USERSPACE", "", emptyFile.getCanonicalPath());
// Check the file was pulled
Assert.assertTrue("Unable to pull the empty file, maybe the pull mechanism is broken?", emptyFile.exists());
// Delete the local file
Assert.assertTrue("Unable to delete the local file after pull, maybe there are still some open streams?", emptyFile.delete());
// Delete the file in the user space
// TODO: TEST THIS
client.deleteFile("USERSPACE", "/" + emptyFile.getName());
// LATER
}
use of org.ow2.proactive.scheduler.rest.ISchedulerClient in project scheduling by ow2-proactive.
the class DataSpaceClient method init.
public void init(ConnectionInfo connectionInfo) throws Exception {
ISchedulerClient client = SchedulerClient.createInstance();
client.init(connectionInfo);
init(connectionInfo.getUrl(), client);
}
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("admin"));
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 testKillTask.
@Test(timeout = MAX_WAIT_TIME)
public void testKillTask() throws Exception {
ISchedulerClient client = clientInstance();
Job job = createJob(NonTerminatingJob.class);
SchedulerEventListenerImpl listener = new SchedulerEventListenerImpl();
client.addEventListener(listener, true, SchedulerEvent.TASK_PENDING_TO_RUNNING);
JobId jobId = submitJob(job, client);
TaskInfo startedTask = listener.getStartedTask();
while (!startedTask.getJobId().value().equals(jobId.value())) {
startedTask = listener.getStartedTask();
}
client.killTask(jobId, getTaskNameForClass(NonTerminatingJob.class));
client.removeEventListener();
// should return immediately
JobResult result = client.waitForJob(jobId, TimeUnit.MINUTES.toMillis(3));
TaskResult tresult = result.getResult(getTaskName(NonTerminatingJob.class));
Assert.assertTrue(tresult.hadException());
Assert.assertTrue(tresult.getException() instanceof TaskAbortedException);
}
Aggregations