Search in sources :

Example 16 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class RestClientExceptionHandlerTest method client_handles_jetty_errors_500.

@Test
public void client_handles_jetty_errors_500() throws Exception {
    try {
        SchedulerRMProxyFactory schedulerFactory = mock(SchedulerRMProxyFactory.class);
        when(schedulerFactory.connectToScheduler(Matchers.<CredData>any())).thenThrow(new LoginException());
        SharedSessionStore.getInstance().setSchedulerRMProxyFactory(schedulerFactory);
        SchedulerRestClient client = new SchedulerRestClient("http://localhost:" + port + "/");
        client.getScheduler().login("demo", "demo");
        fail("Should have throw an exception");
    } catch (WebApplicationException e) {
        assertTrue(e instanceof InternalServerErrorException);
        assertEquals(500, e.getResponse().getStatus());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) LoginException(javax.security.auth.login.LoginException) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) SchedulerRMProxyFactory(org.ow2.proactive_grid_cloud_portal.common.SchedulerRMProxyFactory) Test(org.junit.Test)

Example 17 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class TestJobInstantGetTaskResult method testJobInstantGetTaskResult.

@Test
public void testJobInstantGetTaskResult() throws Throwable {
    // create Scheduler client as an active object
    client = (SubmitJob) PAActiveObject.newActive(SubmitJob.class.getName(), new Object[] {});
    // begin to use the client : must be a futur result in order to start the scheduler at next step
    client.begin();
    // create job
    TaskFlowJob job = new TaskFlowJob();
    job.setProjectName("My project");
    for (int i = 0; i < 50; i++) {
        JavaTask t = new JavaTask();
        t.setExecutableClassName(ResultAsArray.class.getName());
        t.setName("task" + i);
        job.addTask(t);
    }
    JobId id = schedulerHelper.submitJob(job);
    client.setJobId(id);
    schedulerHelper.waitForEventJobRemoved(id);
    String projectName = client.getProjectName();
    Assert.assertEquals("My project", projectName);
}
Also used : ResultAsArray(functionaltests.executables.ResultAsArray) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 18 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class SchedulerClientTest method testAttachService.

@Test(timeout = MAX_WAIT_TIME)
public void testAttachService() throws Throwable {
    ISchedulerClient client = clientInstance();
    Job job = nodeClientJob("/functionaltests/descriptors/register_service.groovy", null, null);
    JobId jobId = submitJob(job, client);
    client.waitForJob(jobId.toString(), TimeUnit.MINUTES.toMillis(5));
    JobInfo jobInfo = client.getJobInfo(jobId.toString());
    Assert.assertNotNull(jobInfo);
    Assert.assertNotNull(jobInfo.getAttachedServices());
    Assert.assertEquals(1, jobInfo.getAttachedServices().size());
    Assert.assertTrue(jobInfo.getAttachedServices().containsKey(12));
}
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) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 19 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class SchedulerClientTest method createThirdPartyCredentials.

@Test(timeout = MAX_WAIT_TIME)
public void createThirdPartyCredentials() throws Throwable {
    ISchedulerClient client = clientInstance();
    client.putThirdPartyCredential("key/slash", "value/slash");
    Set<String> keySet1 = client.thirdPartyCredentialsKeySet();
    System.out.println("Server Third-Party Credentials : " + keySet1);
    Job job1 = createJob(JobResultTask.class);
    Assert.assertTrue("credentials should contain the key", keySet1.contains("key/slash"));
    client.removeThirdPartyCredential("key/slash");
    Set<String> keySet2 = client.thirdPartyCredentialsKeySet();
    System.out.println("Server Third-Party Credentials : " + keySet2);
    Job job2 = createJob(JobResultTask.class);
    Assert.assertFalse("credentials should not contain the key", keySet2.contains("key/slash"));
}
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) Test(org.junit.Test)

Example 20 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class SchedulerClientTest method testAddAndRemoveExternalEndpointUrl.

@Test(timeout = MAX_WAIT_TIME)
public void testAddAndRemoveExternalEndpointUrl() throws Throwable {
    ISchedulerClient client = clientInstance();
    Job job = nodeClientJob("/functionaltests/descriptors/add_and_remove_external_endpoint_urls.groovy", null, null);
    JobId jobId = submitJob(job, client);
    client.waitForJob(jobId.toString(), TimeUnit.MINUTES.toMillis(5));
    JobInfo jobInfo = client.getJobInfo(jobId.toString());
    Assert.assertNotNull(jobInfo);
    Assert.assertNotNull(jobInfo.getExternalEndpointUrls());
    Assert.assertEquals(3, jobInfo.getExternalEndpointUrls().size());
    Assert.assertEquals(new ExternalEndpoint("ccc", "http://ccc.fr", "icon/ccc"), jobInfo.getExternalEndpointUrls().get("ccc"));
    Assert.assertEquals(new ExternalEndpoint("bbb", "http://bbb.fr", "icon/bbb"), jobInfo.getExternalEndpointUrls().get("bbb"));
    // the last endpoint has null icon on purpose (to check that it does not cause issues)
    Assert.assertEquals(new ExternalEndpoint("eee", "http://eee.fr", null), jobInfo.getExternalEndpointUrls().get("eee"));
}
Also used : ExternalEndpoint(org.ow2.proactive.scheduler.job.ExternalEndpoint) 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) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)69 ISchedulerClient (org.ow2.proactive.scheduler.rest.ISchedulerClient)36 Client (org.ow2.proactive.resourcemanager.authentication.Client)31 JobId (org.ow2.proactive.scheduler.common.job.JobId)30 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)28 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)25 SimpleJob (functionaltests.jobs.SimpleJob)25 Job (org.ow2.proactive.scheduler.common.job.Job)25 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)18 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)18 ListFile (org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile)18 File (java.io.File)17 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)13 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)13 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)11 Node (org.objectweb.proactive.core.node.Node)9 IOException (java.io.IOException)8 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)8 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)8 NodeSet (org.ow2.proactive.utils.NodeSet)7