Search in sources :

Example 36 with WorkflowException

use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.

the class TestLiteWorkflowAppParser method testParserGlobalExtensionActionsNoGlobal.

public void testParserGlobalExtensionActionsNoGlobal() throws Exception {
    LiteWorkflowAppParser parser = newLiteWorkflowAppParser();
    // If no global section is defined, some extension actions (e.g. hive) must still have name-node and job-tracker elements
    // or the handleGlobal() method will throw an exception
    parser.validateAndParse(IOUtils.getResourceAsReader("wf-schema-valid-global-ext-no-global.xml", -1), new Configuration());
    try {
        parser.validateAndParse(IOUtils.getResourceAsReader("wf-schema-invalid-global-ext-no-global.xml", -1), new Configuration());
        fail();
    } catch (WorkflowException ex) {
        assertEquals(ErrorCode.E0701, ex.getErrorCode());
    } catch (Exception ex) {
        fail();
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) WorkflowException(org.apache.oozie.workflow.WorkflowException) IOException(java.io.IOException) WorkflowException(org.apache.oozie.workflow.WorkflowException)

Example 37 with WorkflowException

use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.

the class TestLiteWorkflowAppParser method testParser.

public void testParser() throws Exception {
    LiteWorkflowAppParser parser = newLiteWorkflowAppParser();
    parser.validateAndParse(IOUtils.getResourceAsReader("wf-schema-valid.xml", -1), new Configuration());
    try {
        // Check TestLiteWorkflowAppService.TestActionExecutor is registered.
        parser.validateAndParse(IOUtils.getResourceAsReader("wf-unsupported-action.xml", -1), new Configuration());
        fail();
    } catch (WorkflowException ex) {
        assertEquals(ErrorCode.E0723, ex.getErrorCode());
    } catch (Exception ex) {
        fail();
    }
    try {
        parser.validateAndParse(IOUtils.getResourceAsReader("wf-loop2-invalid.xml", -1), new Configuration());
        fail();
    } catch (WorkflowException ex) {
        assertEquals(ErrorCode.E0706, ex.getErrorCode());
    } catch (Exception ex) {
        fail();
    }
    try {
        parser.validateAndParse(IOUtils.getResourceAsReader("wf-transition-invalid.xml", -1), new Configuration());
        fail();
    } catch (WorkflowException ex) {
        assertEquals(ErrorCode.E0708, ex.getErrorCode());
    } catch (Exception ex) {
        fail();
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) WorkflowException(org.apache.oozie.workflow.WorkflowException) IOException(java.io.IOException) WorkflowException(org.apache.oozie.workflow.WorkflowException)

Example 38 with WorkflowException

use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.

the class TestLiteWorkflowAppParser method testDisableWFValidateForkJoin.

public void testDisableWFValidateForkJoin() throws Exception {
    LiteWorkflowAppParser parser = newLiteWorkflowAppParser();
    // oozie level default, wf level default
    try {
        parser.validateAndParse(IOUtils.getResourceAsReader("wf-invalid-fork.xml", -1), new Configuration());
    } catch (WorkflowException wfe) {
        assertEquals(ErrorCode.E0730, wfe.getErrorCode());
        assertEquals("E0730: Fork/Join not in pair", wfe.getMessage());
    }
    // oozie level default, wf level disabled
    Configuration conf = new Configuration();
    conf.set("oozie.wf.validate.ForkJoin", "false");
    parser.validateAndParse(IOUtils.getResourceAsReader("wf-invalid-fork.xml", -1), conf);
    // oozie level default, wf level enabled
    conf.set("oozie.wf.validate.ForkJoin", "true");
    try {
        parser.validateAndParse(IOUtils.getResourceAsReader("wf-invalid-fork.xml", -1), conf);
    } catch (WorkflowException wfe) {
        assertEquals(ErrorCode.E0730, wfe.getErrorCode());
        assertEquals("E0730: Fork/Join not in pair", wfe.getMessage());
    }
    // oozie level disabled, wf level default
    Services.get().destroy();
    setSystemProperty("oozie.validate.ForkJoin", "false");
    new Services().init();
    parser.validateAndParse(IOUtils.getResourceAsReader("wf-invalid-fork.xml", -1), new Configuration());
    // oozie level disabled, wf level disabled
    conf.set("oozie.wf.validate.ForkJoin", "false");
    parser.validateAndParse(IOUtils.getResourceAsReader("wf-invalid-fork.xml", -1), conf);
    // oozie level disabled, wf level enabled
    conf.set("oozie.wf.validate.ForkJoin", "true");
    parser.validateAndParse(IOUtils.getResourceAsReader("wf-invalid-fork.xml", -1), conf);
    // oozie level enabled, wf level default
    Services.get().destroy();
    setSystemProperty("oozie.validate.ForkJoin", "true");
    new Services().init();
    try {
        parser.validateAndParse(IOUtils.getResourceAsReader("wf-invalid-fork.xml", -1), new Configuration());
    } catch (WorkflowException wfe) {
        assertEquals(ErrorCode.E0730, wfe.getErrorCode());
        assertEquals("E0730: Fork/Join not in pair", wfe.getMessage());
    }
    // oozie level enabled, wf level disabled
    conf.set("oozie.wf.validate.ForkJoin", "false");
    parser.validateAndParse(IOUtils.getResourceAsReader("wf-invalid-fork.xml", -1), conf);
    // oozie level enabled, wf level enabled
    conf.set("oozie.wf.validate.ForkJoin", "true");
    try {
        parser.validateAndParse(IOUtils.getResourceAsReader("wf-invalid-fork.xml", -1), new Configuration());
    } catch (WorkflowException wfe) {
        assertEquals(ErrorCode.E0730, wfe.getErrorCode());
        assertEquals("E0730: Fork/Join not in pair", wfe.getMessage());
    }
}
Also used : Services(org.apache.oozie.service.Services) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) WorkflowException(org.apache.oozie.workflow.WorkflowException)

Example 39 with WorkflowException

use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.

the class TestLiteWorkflowLib method testLoopSimple.

public void testLoopSimple() throws WorkflowException {
    LiteWorkflowApp def = new LiteWorkflowApp("wf", "<worklfow-app/>", new StartNodeDef(TestControlNodeHandler.class, "one")).addNode(new NodeDef("one", null, SynchNodeHandler.class, Arrays.asList(new String[] { "two" }))).addNode(new NodeDef("two", null, SynchNodeHandler.class, Arrays.asList(new String[] { "one" }))).addNode(new EndNodeDef("end", TestControlNodeHandler.class));
    LiteWorkflowInstance job = new LiteWorkflowInstance(def, new XConfiguration(), "1");
    try {
        job.start();
        fail();
    } catch (WorkflowException ex) {
        assertEquals(ErrorCode.E0709, ex.getErrorCode());
    }
    assertEquals(WorkflowInstance.Status.FAILED, job.getStatus());
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) WorkflowException(org.apache.oozie.workflow.WorkflowException)

Example 40 with WorkflowException

use of org.apache.oozie.workflow.WorkflowException in project oozie by apache.

the class TestLiteWorkflowLib method testWorkflowStates.

public void testWorkflowStates() throws WorkflowException {
    LiteWorkflowApp def = new LiteWorkflowApp("wf", "<worklfow-app/>", new StartNodeDef(TestControlNodeHandler.class, "one")).addNode(new NodeDef("one", null, AsynchNodeHandler.class, Arrays.asList(new String[] { "end" }))).addNode(new EndNodeDef("end", TestControlNodeHandler.class));
    LiteWorkflowInstance job = new LiteWorkflowInstance(def, new XConfiguration(), "1");
    assertEquals(WorkflowInstance.Status.PREP, job.getStatus());
    job.kill();
    assertEquals(WorkflowInstance.Status.KILLED, job.getStatus());
    job = new LiteWorkflowInstance(def, new XConfiguration(), "1");
    job.fail("one");
    assertEquals(WorkflowInstance.Status.FAILED, job.getStatus());
    job = new LiteWorkflowInstance(def, new XConfiguration(), "1");
    try {
        job.suspend();
        fail();
    } catch (WorkflowException ex) {
    // nop
    }
    try {
        job.resume();
        fail();
    } catch (WorkflowException ex) {
    // nop
    }
    job.start();
    assertEquals(WorkflowInstance.Status.RUNNING, job.getStatus());
    try {
        job.resume();
        fail();
    } catch (WorkflowException ex) {
    // nop
    }
    try {
        job.start();
        fail();
    } catch (WorkflowException ex) {
    // nop
    }
    job.suspend();
    assertEquals(WorkflowInstance.Status.SUSPENDED, job.getStatus());
    try {
        job.suspend();
        fail();
    } catch (WorkflowException ex) {
    // nop
    }
    try {
        job.start();
        fail();
    } catch (WorkflowException ex) {
    // nop
    }
    job.resume();
    assertEquals(WorkflowInstance.Status.RUNNING, job.getStatus());
    try {
        job.resume();
        fail();
    } catch (WorkflowException ex) {
    // nop
    }
    try {
        job.start();
        fail();
    } catch (WorkflowException ex) {
    // nop
    }
    job.kill();
    assertEquals(WorkflowInstance.Status.KILLED, job.getStatus());
    try {
        job.kill();
        fail();
    } catch (WorkflowException ex) {
    // nop
    }
    try {
        job.suspend();
        fail();
    } catch (WorkflowException ex) {
    // nop
    }
    try {
        job.resume();
        fail();
    } catch (WorkflowException ex) {
    // nop
    }
    try {
        job.start();
        fail();
    } catch (WorkflowException ex) {
    // nop
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) WorkflowException(org.apache.oozie.workflow.WorkflowException)

Aggregations

WorkflowException (org.apache.oozie.workflow.WorkflowException)41 XConfiguration (org.apache.oozie.util.XConfiguration)23 IOException (java.io.IOException)15 Configuration (org.apache.hadoop.conf.Configuration)15 CommandException (org.apache.oozie.command.CommandException)8 Date (java.util.Date)7 WorkflowInstance (org.apache.oozie.workflow.WorkflowInstance)7 Element (org.jdom.Element)7 ArrayList (java.util.ArrayList)6 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)6 JDOMException (org.jdom.JDOMException)6 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)5 WorkflowJobQuery (org.apache.oozie.executor.jpa.WorkflowJobQueryExecutor.WorkflowJobQuery)5 File (java.io.File)4 Reader (java.io.Reader)4 URI (java.net.URI)4 FileSystem (org.apache.hadoop.fs.FileSystem)4 Path (org.apache.hadoop.fs.Path)4 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)4 WorkflowApp (org.apache.oozie.workflow.WorkflowApp)4