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