use of org.apache.oozie.service.Services in project oozie by apache.
the class TestAuthFilterAuthOozieClient method runTest.
protected void runTest(Callable<Void> assertions, Configuration additionalConf) throws Exception {
Services services = new Services();
try {
services.init();
if (additionalConf != null) {
for (Map.Entry<String, String> prop : additionalConf) {
Services.get().getConf().set(prop.getKey(), prop.getValue());
}
}
Services.get().setService(ForTestAuthorizationService.class);
Services.get().setService(ForTestWorkflowStoreService.class);
Services.get().setService(MockDagEngineService.class);
Services.get().setService(MockCoordinatorEngineService.class);
container = new EmbeddedServletContainer("oozie");
container.addServletEndpoint("/versions", HeaderTestingVersionServlet.class);
String version = "/v" + XOozieClient.WS_PROTOCOL_VERSION;
container.addServletEndpoint(version + "/admin/*", V1AdminServlet.class);
container.addFilter("*", HostnameFilter.class);
container.addFilter("/*", AuthFilter.class);
container.start();
assertions.call();
} finally {
if (container != null) {
container.stop();
}
services.destroy();
container = null;
}
}
use of org.apache.oozie.service.Services in project oozie by apache.
the class TestBulkMonitorWebServiceAPI method runTest.
private void runTest(String[] servletPath, Class[] servletClass, boolean securityEnabled, Callable<Void> assertions) throws Exception {
Services services = new Services();
this.servletPath = servletPath[0];
try {
String proxyUser = getTestUser();
services.getConf().set(ProxyUserService.CONF_PREFIX + proxyUser + ProxyUserService.HOSTS, "*");
services.getConf().set(ProxyUserService.CONF_PREFIX + proxyUser + ProxyUserService.GROUPS, "*");
services.init();
services.getConf().setBoolean(AuthorizationService.CONF_SECURITY_ENABLED, securityEnabled);
Services.get().setService(ForTestAuthorizationService.class);
Services.get().setService(BundleEngineService.class);
container = new EmbeddedServletContainer("oozie");
for (int i = 0; i < servletPath.length; i++) {
container.addServletEndpoint(servletPath[i], servletClass[i]);
}
container.addFilter("*", HostnameFilter.class);
container.addFilter("*", AuthFilter.class);
setSystemProperty("user.name", getTestUser());
container.start();
assertions.call();
} finally {
this.servletPath = null;
if (container != null) {
container.stop();
}
services.destroy();
container = null;
}
}
use of org.apache.oozie.service.Services in project oozie by apache.
the class TestBulkMonitorWebServiceAPI method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
services = new Services();
services.init();
LocalOozie.start();
jpaService = Services.get().get(JPAService.class);
addRecordsForBulkMonitor();
}
use of org.apache.oozie.service.Services in project oozie by apache.
the class TestCallbackService method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
new Services().init();
}
use of org.apache.oozie.service.Services in project oozie by apache.
the class TestPauseTransitService method testPauseCoordinatorForBackwardSupport.
/**
* Test : Pause a RUNNING coordinator, but set oozie.service.StatusTransitService.backward.support.for.coord.status=true
* and use uri:oozie:coordinator:0.1 namespace, the status should not be changed to PAUSED
*
* @throws Exception
*/
public void testPauseCoordinatorForBackwardSupport() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, "true");
services = new Services();
setClassesToBeExcluded(services.getConf(), excludedServices);
services.init();
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Date pauseTime = new Date(new Date().getTime() - 30 * 1000);
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean coordJob1 = addRecordToCoordJobTable("action1", CoordinatorJob.Status.RUNNING, start, end, false);
CoordinatorJobBean coordJob2 = addRecordToCoordJobTable("action2", CoordinatorJob.Status.RUNNING, start, end, false);
coordJob1.setAppNamespace(SchemaService.COORDINATOR_NAMESPACE_URI_1);
coordJob1.setPauseTime(pauseTime);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_BUNDLEID_APPNAMESPACE_PAUSETIME, coordJob1);
coordJob2.setAppNamespace(SchemaService.COORDINATOR_NAMESPACE_URI_1);
coordJob2.setPauseTime(pauseTime);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_BUNDLEID_APPNAMESPACE_PAUSETIME, coordJob2);
Runnable pauseStartRunnable = new PauseTransitRunnable();
pauseStartRunnable.run();
final String coordJobId1 = coordJob1.getId();
final String coordJobId2 = coordJob2.getId();
waitFor(10 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean cJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId1));
return cJob1.getStatus() == Job.Status.RUNNING;
}
});
coordJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId1));
assertEquals(Job.Status.RUNNING, coordJob1.getStatus());
coordJob2 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId2));
assertEquals(Job.Status.RUNNING, coordJob2.getStatus());
}
Aggregations