Search in sources :

Example 6 with Services

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;
    }
}
Also used : Services(org.apache.oozie.service.Services) EmbeddedServletContainer(org.apache.oozie.test.EmbeddedServletContainer) Map(java.util.Map)

Example 7 with Services

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;
    }
}
Also used : Services(org.apache.oozie.service.Services) EmbeddedServletContainer(org.apache.oozie.test.EmbeddedServletContainer)

Example 8 with Services

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();
}
Also used : Services(org.apache.oozie.service.Services) JPAService(org.apache.oozie.service.JPAService)

Example 9 with Services

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();
}
Also used : Services(org.apache.oozie.service.Services)

Example 10 with Services

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());
}
Also used : Services(org.apache.oozie.service.Services) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) PauseTransitRunnable(org.apache.oozie.service.PauseTransitService.PauseTransitRunnable) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) PauseTransitRunnable(org.apache.oozie.service.PauseTransitService.PauseTransitRunnable) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Aggregations

Services (org.apache.oozie.service.Services)247 JPAService (org.apache.oozie.service.JPAService)32 Configuration (org.apache.hadoop.conf.Configuration)21 Date (java.util.Date)17 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)16 File (java.io.File)14 Before (org.junit.Before)14 XConfiguration (org.apache.oozie.util.XConfiguration)11 Path (org.apache.hadoop.fs.Path)10 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)10 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)8 EmbeddedServletContainer (org.apache.oozie.test.EmbeddedServletContainer)8 FileOutputStream (java.io.FileOutputStream)7 InputStream (java.io.InputStream)7 HashMap (java.util.HashMap)7 IOException (java.io.IOException)6 Properties (java.util.Properties)6 ActionService (org.apache.oozie.service.ActionService)6 StringWriter (java.io.StringWriter)5 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)5