use of org.apache.oozie.workflow.lite.EndNodeDef in project oozie by apache.
the class ActionExecutorTestCase method createBaseWorkflowWithCredentials.
/**
* Return a workflow job which contains one action with no configuration and workflow contains credentials information.
*
* @param protoConf
* @param actionName
* @return workflow job bean
* @throws Exception
*/
protected WorkflowJobBean createBaseWorkflowWithCredentials(XConfiguration protoConf, String actionName) throws Exception {
Path appUri = new Path(getAppPath(), "workflow.xml");
Reader reader = IOUtils.getResourceAsReader("wf-credentials.xml", -1);
String wfxml = IOUtils.getReaderAsString(reader, -1);
writeToFile(wfxml, getAppPath(), "workflow.xml");
WorkflowApp app = new LiteWorkflowApp("test-wf-cred", wfxml, new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "start")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
XConfiguration wfConf = new XConfiguration();
wfConf.set(OozieClient.USER_NAME, getTestUser());
wfConf.set(OozieClient.APP_PATH, appUri.toString());
WorkflowJobBean workflow = createWorkflow(app, wfConf, protoConf);
WorkflowActionBean action = new WorkflowActionBean();
action.setName(actionName);
action.setId(Services.get().get(UUIDService.class).generateChildId(workflow.getId(), actionName));
workflow.getActions().add(action);
return workflow;
}
use of org.apache.oozie.workflow.lite.EndNodeDef in project oozie by apache.
the class ActionExecutorTestCase method createBaseWorkflow.
/**
* Return a workflow job which contains one action with no configuration.
*
* @param protoConf
* @param actionName
* @return workflow job bean
* @throws Exception
*/
protected WorkflowJobBean createBaseWorkflow(XConfiguration protoConf, String actionName) throws Exception {
Path appUri = new Path(getAppPath(), "workflow.xml");
String content = "<workflow-app xmlns='uri:oozie:workflow:1.0' xmlns:sla='uri:oozie:sla:0.1' name='no-op-wf'>";
content += "<start to='end' />";
content += "<end name='end' /></workflow-app>";
writeToFile(content, getAppPath(), "workflow.xml");
WorkflowApp app = new LiteWorkflowApp("testApp", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
XConfiguration wfConf = new XConfiguration();
wfConf.set(OozieClient.USER_NAME, getTestUser());
wfConf.set(OozieClient.APP_PATH, appUri.toString());
WorkflowJobBean workflow = createWorkflow(app, wfConf, protoConf);
WorkflowActionBean action = new WorkflowActionBean();
action.setName(actionName);
action.setId(Services.get().get(UUIDService.class).generateChildId(workflow.getId(), actionName));
workflow.getActions().add(action);
return workflow;
}
use of org.apache.oozie.workflow.lite.EndNodeDef in project oozie by apache.
the class TestPurgeXCommand method addRecordToWfJobTableForNegCase.
protected WorkflowJobBean addRecordToWfJobTableForNegCase(WorkflowJob.Status jobStatus, WorkflowInstance.Status instanceStatus) throws Exception {
WorkflowApp app = new LiteWorkflowApp("testApp", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
Configuration conf = new Configuration();
Path appUri = new Path(getAppPath(), "workflow.xml");
conf.set(OozieClient.APP_PATH, appUri.toString());
conf.set(OozieClient.LOG_TOKEN, "testToken");
conf.set(OozieClient.USER_NAME, getTestUser());
WorkflowJobBean wfBean = createWorkflow(app, conf, jobStatus, instanceStatus);
// Set start time to 100 days from now
wfBean.setStartTime(new Date(System.currentTimeMillis() + (long) 100 * 24 * 60 * 60 * 1000));
// Set end time to 100 days + 2 hours from now
wfBean.setEndTime(new Date(System.currentTimeMillis() + (long) 100 * 24 * 60 * 60 * 1000 + (long) 2 * 60 * 60 * 1000));
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobInsertJPAExecutor wfInsertCmd = new WorkflowJobInsertJPAExecutor(wfBean);
jpaService.execute(wfInsertCmd);
} catch (JPAExecutorException ce) {
ce.printStackTrace();
fail("Unable to insert the test wf job record to table");
throw ce;
}
return wfBean;
}
use of org.apache.oozie.workflow.lite.EndNodeDef in project oozie by apache.
the class TestHCatELFunctions method testHCatPartitionExists.
@Test
public void testHCatPartitionExists() throws Exception {
dropTable("db1", "table1", true);
dropDatabase("db1", true);
createDatabase("db1");
createTable("db1", "table1", "year,month,dt,country");
addPartition("db1", "table1", "year=2012;month=12;dt=02;country=us");
Configuration protoConf = new Configuration();
protoConf.set(OozieClient.USER_NAME, getTestUser());
protoConf.set("hadoop.job.ugi", getTestUser() + "," + "group");
Configuration conf = new XConfiguration();
conf.set(OozieClient.APP_PATH, "appPath");
conf.set(OozieClient.USER_NAME, getTestUser());
conf.set("test.dir", getTestCaseDir());
conf.set("partition1", getHCatURI("db1", "table1", "dt=02").toString());
conf.set("partition2", getHCatURI("db1", "table1", "dt=05").toString());
LiteWorkflowApp def = new LiteWorkflowApp("name", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
LiteWorkflowInstance job = new LiteWorkflowInstance(def, conf, "wfId");
WorkflowJobBean wf = new WorkflowJobBean();
wf.setId(job.getId());
wf.setAppName("name");
wf.setAppPath("appPath");
wf.setUser(getTestUser());
wf.setGroup("group");
wf.setWorkflowInstance(job);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
protoConf.writeXml(baos);
wf.setProtoActionConf(baos.toString());
WorkflowActionBean action = new WorkflowActionBean();
action.setId("actionId");
action.setName("actionName");
ELEvaluator eval = Services.get().get(ELService.class).createEvaluator("workflow");
DagELFunctions.configureEvaluator(eval, wf, action);
assertEquals(true, (boolean) eval.evaluate("${hcat:exists(wf:conf('partition1'))}", Boolean.class));
assertEquals(false, (boolean) eval.evaluate("${hcat:exists(wf:conf('partition2'))}", Boolean.class));
dropTable("db1", "table1", true);
dropDatabase("db1", true);
}
use of org.apache.oozie.workflow.lite.EndNodeDef in project oozie by apache.
the class TestWorkflowIdGetForExternalIdJPAExecutor method addRecordToWfJobTable.
@Override
protected WorkflowJobBean addRecordToWfJobTable(WorkflowJob.Status jobStatus, WorkflowInstance.Status instanceStatus) throws Exception {
WorkflowApp app = new LiteWorkflowApp("testApp", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
Configuration conf = new Configuration();
conf.set(OozieClient.APP_PATH, "testPath");
conf.set(OozieClient.LOG_TOKEN, "testToken");
conf.set(OozieClient.USER_NAME, getTestUser());
WorkflowJobBean wfBean = createWorkflow(app, conf, jobStatus, instanceStatus);
wfBean.setExternalId("external-id");
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobInsertJPAExecutor wfInsertCmd = new WorkflowJobInsertJPAExecutor(wfBean);
jpaService.execute(wfInsertCmd);
} catch (JPAExecutorException je) {
je.printStackTrace();
fail("Unable to insert the test wf job record to table");
throw je;
}
return wfBean;
}
Aggregations