Search in sources :

Example 31 with Scheduler

use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.

the class RestfulSchedulerFreezeTest method testFreezeScheduler.

@Test
public void testFreezeScheduler() throws Exception {
    String resourceUrl = getResourceUrl("freeze");
    HttpPut httpPut = new HttpPut(resourceUrl);
    setSessionHeader(httpPut);
    HttpResponse response = executeUriRequest(httpPut);
    assertHttpStatusOK(response);
    assertTrue(Boolean.valueOf(getContent(response)));
    Scheduler scheduler = RestFuncTHelper.getScheduler();
    assertEquals(SchedulerStatus.FROZEN, scheduler.getStatus());
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) HttpResponse(org.apache.http.HttpResponse) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Example 32 with Scheduler

use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.

the class SessionTest method testRenewSession.

/**
 * Check that session id does not change if {@link Session#renewSession} is called on an existing session instance.
 * The test also checks that {@link SchedulerProxyUserInterface#renewSession} is invoked on embedded scheduler
 * instance if available.
 *
 * @throws NotConnectedException
 */
@Test
public void testRenewSession() throws NotConnectedException {
    SchedulerRMProxyFactory schedulerProxyFactory = mock(SchedulerRMProxyFactory.class);
    SchedulerProxyUserInterface scheduler = mock(SchedulerProxyUserInterface.class);
    Session session = new Session("sessionId", schedulerProxyFactory, new Clock());
    session.setScheduler(scheduler);
    session.renewSession();
    Assert.assertEquals("sessionId", session.getSessionId());
    verify(scheduler).renewSession();
}
Also used : SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) Test(org.junit.Test)

Example 33 with Scheduler

use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.

the class SchedulerRestWorkflowFromCatalogExecutionTest method testWhenSubmittingAValidTemplateWithVariablesThenTheProvidedJobVariableIsUsed.

@Test
public void testWhenSubmittingAValidTemplateWithVariablesThenTheProvidedJobVariableIsUsed() throws Exception {
    when(scheduler.submit(Matchers.<Job>any())).thenReturn(new JobIdImpl(99L, "job"));
    ArgumentCaptor<Job> argumentCaptor = ArgumentCaptor.forClass(Job.class);
    String workflowUrl = getBaseUriTestWorkflowsServer() + "/workflow";
    JobIdData response = schedulerRest.submitFromUrl(sessionId, workflowUrl, getOneVariablePathSegment("var1", "value1"));
    verify(scheduler).submit(argumentCaptor.capture());
    Job interceptedJob = argumentCaptor.getValue();
    Assert.assertEquals(1, interceptedJob.getVariables().size());
    Assert.assertEquals("value1", interceptedJob.getVariables().get("var1").getValue());
    Assert.assertEquals(99L, response.getId());
    Assert.assertEquals("job", response.getReadableName());
}
Also used : JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Job(org.ow2.proactive.scheduler.common.job.Job) Test(org.junit.Test)

Example 34 with Scheduler

use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.

the class SchedulerRestWorkflowFromCatalogExecutionTest method testWhenSubmittingAValidTemplateWithoutVariablesThenTheDefaultJobVariableIsUsed.

@Test
public void testWhenSubmittingAValidTemplateWithoutVariablesThenTheDefaultJobVariableIsUsed() throws Exception {
    when(scheduler.submit(Matchers.<Job>any())).thenReturn(new JobIdImpl(88L, "job"));
    ArgumentCaptor<Job> argumentCaptor = ArgumentCaptor.forClass(Job.class);
    String workflowUrl = getBaseUriTestWorkflowsServer() + "/workflow";
    JobIdData response = schedulerRest.submitFromUrl(sessionId, workflowUrl, getEmptyPathSegment());
    verify(scheduler).submit(argumentCaptor.capture());
    Job interceptedJob = argumentCaptor.getValue();
    Assert.assertEquals(1, interceptedJob.getVariables().size());
    Assert.assertEquals("defaultvalue", interceptedJob.getVariables().get("var1").getValue());
    Assert.assertEquals(88L, response.getId());
    Assert.assertEquals("job", response.getReadableName());
}
Also used : JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) Job(org.ow2.proactive.scheduler.common.job.Job) Test(org.junit.Test)

Example 35 with Scheduler

use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.

the class SchedulerStateRestLiveLogsTest method verifyListenAndGetAppender.

private Appender verifyListenAndGetAppender(String jobId) throws NotConnectedException, UnknownJobException, PermissionException, LogForwardingException {
    ArgumentCaptor<AppenderProvider> appenderProviderArgumentCaptor = ArgumentCaptor.forClass(AppenderProvider.class);
    verify(scheduler).listenJobLogs(eq(jobId), appenderProviderArgumentCaptor.capture());
    AppenderProvider appenderProvider = appenderProviderArgumentCaptor.getValue();
    return appenderProvider.getAppender();
}
Also used : AppenderProvider(org.ow2.proactive.scheduler.common.util.logforwarder.AppenderProvider)

Aggregations

Scheduler (org.ow2.proactive.scheduler.common.Scheduler)97 JobId (org.ow2.proactive.scheduler.common.job.JobId)51 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)49 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)46 Path (javax.ws.rs.Path)45 Produces (javax.ws.rs.Produces)43 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)42 Test (org.junit.Test)39 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)38 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)36 File (java.io.File)34 GET (javax.ws.rs.GET)34 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)31 SchedulerRestInterface (org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface)31 CLIException (org.ow2.proactive_grid_cloud_portal.cli.CLIException)30 JobState (org.ow2.proactive.scheduler.common.job.JobState)29 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)28 GZIP (org.jboss.resteasy.annotations.GZIP)23 KeyException (java.security.KeyException)20 CredData (org.ow2.proactive.authentication.crypto.CredData)19