Search in sources :

Example 6 with ISchedulerClient

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);
    }
}
Also used : 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 7 with ISchedulerClient

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
}
Also used : ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) File(java.io.File) Test(org.junit.Test)

Example 8 with ISchedulerClient

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);
}
Also used : ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient)

Example 9 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("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();
}
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 10 with ISchedulerClient

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);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) 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) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) JobId(org.ow2.proactive.scheduler.common.job.JobId) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) Test(org.junit.Test)

Aggregations

ISchedulerClient (org.ow2.proactive.scheduler.rest.ISchedulerClient)16 Test (org.junit.Test)14 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)9 SimpleJob (functionaltests.jobs.SimpleJob)9 Job (org.ow2.proactive.scheduler.common.job.Job)9 JobId (org.ow2.proactive.scheduler.common.job.JobId)9 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)9 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)5 ConnectionInfo (org.ow2.proactive.authentication.ConnectionInfo)3 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)3 File (java.io.File)2 JobState (org.ow2.proactive.scheduler.common.job.JobState)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 Serializable (java.io.Serializable)1 ApacheHttpClient4Engine (org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine)1 StringWrapper (org.objectweb.proactive.core.util.wrapper.StringWrapper)1