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