use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestActionStartXCommand method addRecordToWfActionTableWithAppPathConfig.
/**
* Create workflow action with custom action configuration
*
* @param wfId workflow id
* @param actionName action name
* @param status workflow action status
* @return workflow action bean
* @throws Exception thrown if failed to create workflow action
*/
protected WorkflowActionBean addRecordToWfActionTableWithAppPathConfig(String wfId, String actionName, WorkflowAction.Status status) throws Exception {
WorkflowActionBean action = createWorkflowActionWithAppPathConfig(wfId, status);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action);
jpaService.execute(actionInsertCmd);
} catch (JPAExecutorException ce) {
ce.printStackTrace();
fail("Unable to insert the test wf action record to table");
throw ce;
}
return action;
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestActionStartXCommand method addRecordToWfActionTableWithFS.
private WorkflowActionBean addRecordToWfActionTableWithFS(String wfId, String actionName, WorkflowAction.Status status) throws Exception {
WorkflowActionBean action = createWorkflowActionForFS(wfId, status);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action);
jpaService.execute(actionInsertCmd);
} catch (JPAExecutorException ce) {
ce.printStackTrace();
fail("Unable to insert the test wf action record to table");
throw ce;
}
return action;
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestActionStartXCommand method createWorkflowActionWithAppPathConfig.
/**
* Create workflow action with custom action configuration
*
* @param wfId workflow id
* @param status workflow action status
* @return workflow action bean
* @throws Exception thrown if failed to create workflow action
*/
protected WorkflowActionBean createWorkflowActionWithAppPathConfig(String wfId, WorkflowAction.Status status) throws Exception {
WorkflowActionBean action = new WorkflowActionBean();
String actionname = "testAction";
action.setName(actionname);
action.setId(Services.get().get(UUIDService.class).generateChildId(wfId, actionname));
action.setJobId(wfId);
action.setType("map-reduce");
action.setTransition("transition");
action.setStatus(status);
action.setStartTime(new Date());
action.setEndTime(new Date());
action.setLastCheckTime(new Date());
action.setPending();
Path inputDir = new Path(getFsTestCaseDir(), "input");
Path outputDir = new Path(getFsTestCaseDir(), "output");
FileSystem fs = getFileSystem();
Writer w = new OutputStreamWriter(fs.create(new Path(inputDir, "data.txt")));
w.write("dummy\n");
w.write("dummy\n");
w.close();
String actionXml = "<map-reduce>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "<property><name>mapred.mapper.class</name><value>" + MapperReducerForTest.class.getName() + "</value></property>" + "<property><name>mapred.reducer.class</name><value>" + MapperReducerForTest.class.getName() + "</value></property>" + "<property><name>work.dir</name><value>${wf:appPath()}/sub</value></property>" + "<property><name>mapred.input.dir</name><value>" + inputDir.toString() + "</value></property>" + "<property><name>mapred.output.dir</name><value>" + outputDir.toString() + "</value></property>" + "</configuration>" + "</map-reduce>";
action.setConf(actionXml);
return action;
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestActionStartXCommand method addRecordToWfActionTable.
/* (non-Javadoc)
* @see org.apache.oozie.test.XDataTestCase#addRecordToWfActionTable(
* java.lang.String, java.lang.String, org.apache.oozie.client.WorkflowAction.Status)
*/
@Override
protected WorkflowActionBean addRecordToWfActionTable(String wfId, String actionName, WorkflowAction.Status status) throws Exception {
WorkflowActionBean action = createWorkflowActionSetPending(wfId, status);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action);
jpaService.execute(actionInsertCmd);
} catch (JPAExecutorException ce) {
ce.printStackTrace();
fail("Unable to insert the test wf action record to table");
throw ce;
}
return action;
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestActionStartXCommand method testActionStartPreCondition3.
/**
* Test : verify the PreconditionException is thrown when pending = false
*
* @throws Exception
*/
public void testActionStartPreCondition3() throws Exception {
Instrumentation inst = Services.get().get(InstrumentationService.class).get();
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = super.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
assertFalse(action.isPending());
assertNull(inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP));
ActionStartXCommand startCmd = new ActionStartXCommand(action.getId(), "map-reduce");
startCmd.call();
// precondition failed because of pending = false
Long counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(startCmd.getName() + ".preconditionfailed").getValue();
assertEquals(new Long(1), new Long(counterVal));
}
Aggregations