use of org.apache.oozie.workflow.WorkflowInstance in project oozie by apache.
the class ActionExecutorTestCase method createWorkflow.
private WorkflowJobBean createWorkflow(WorkflowApp app, Configuration conf, XConfiguration protoConf) throws Exception {
WorkflowLib workflowLib = Services.get().get(WorkflowStoreService.class).getWorkflowLibWithNoDB();
WorkflowInstance wfInstance;
wfInstance = workflowLib.createInstance(app, conf);
WorkflowJobBean workflow = new WorkflowJobBean();
workflow.setId(wfInstance.getId());
workflow.setAppName(app.getName());
workflow.setAppPath(conf.get(OozieClient.APP_PATH));
workflow.setConf(XmlUtils.prettyPrint(conf).toString());
workflow.setProtoActionConf(XmlUtils.prettyPrint(protoConf).toString());
workflow.setCreatedTime(new Date());
workflow.setLogToken(conf.get(OozieClient.LOG_TOKEN, ""));
workflow.setStatus(WorkflowJob.Status.PREP);
workflow.setRun(0);
workflow.setUser(conf.get(OozieClient.USER_NAME));
workflow.setGroup(conf.get(OozieClient.GROUP_NAME));
workflow.setWorkflowInstance(wfInstance);
return workflow;
}
use of org.apache.oozie.workflow.WorkflowInstance in project oozie by apache.
the class TestPurgeXCommand method testSucJobPurgeXCommand.
/**
* Test : purge succeeded wf job and action successfully. Creates and runs a
* new job to completion. Attempts to purge jobs older than a day. Verifies
* the presence of the job in the system. </p> Sets the end date for the
* same job to make it qualify for the purge criteria. Calls the purge
* command, and ensure the job does not exist in the system.
*
* @throws Exception
*/
public void testSucJobPurgeXCommand() throws Exception {
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.OK);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(job.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
job = jpaService.execute(wfJobGetCmd);
action = jpaService.execute(wfActionGetCmd);
assertEquals(job.getStatus(), WorkflowJob.Status.SUCCEEDED);
assertEquals(action.getStatus(), WorkflowAction.Status.OK);
WorkflowInstance wfInstance = job.getWorkflowInstance();
assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.SUCCEEDED);
new PurgeXCommand(7, 1, 1, 10).call();
try {
jpaService.execute(wfJobGetCmd);
fail("Workflow Job should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfActionGetCmd);
fail("Workflow Action should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
}
use of org.apache.oozie.workflow.WorkflowInstance in project oozie by apache.
the class TestPurgeXCommand method testFailJobPurgeXCommand.
/**
* Test : purge failed wf job and action successfully
*
* @throws Exception
*/
public void testFailJobPurgeXCommand() throws Exception {
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.FAILED, WorkflowInstance.Status.FAILED);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.FAILED);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(job.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
job = jpaService.execute(wfJobGetCmd);
action = jpaService.execute(wfActionGetCmd);
assertEquals(job.getStatus(), WorkflowJob.Status.FAILED);
assertEquals(action.getStatus(), WorkflowAction.Status.FAILED);
WorkflowInstance wfInstance = job.getWorkflowInstance();
assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.FAILED);
new PurgeXCommand(7, 1, 1, 10).call();
try {
jpaService.execute(wfJobGetCmd);
fail("Workflow Job should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfActionGetCmd);
fail("Workflow Action should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
}
use of org.apache.oozie.workflow.WorkflowInstance in project oozie by apache.
the class TestWorkflowKillXCommand method testWfKillSuccess2.
/**
* Test : kill RUNNING job and RUNNING action successfully.
*
* @throws Exception
*/
public void testWfKillSuccess2() throws Exception {
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.RUNNING);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(job.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
job = jpaService.execute(wfJobGetCmd);
action = jpaService.execute(wfActionGetCmd);
assertEquals(job.getStatus(), WorkflowJob.Status.RUNNING);
assertEquals(action.getStatus(), WorkflowAction.Status.RUNNING);
WorkflowInstance wfInstance = job.getWorkflowInstance();
assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.RUNNING);
new KillXCommand(job.getId()).call();
job = jpaService.execute(wfJobGetCmd);
action = jpaService.execute(wfActionGetCmd);
assertEquals(job.getStatus(), WorkflowJob.Status.KILLED);
assertEquals(action.getStatus(), WorkflowAction.Status.KILLED);
wfInstance = job.getWorkflowInstance();
assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.KILLED);
}
use of org.apache.oozie.workflow.WorkflowInstance in project oozie by apache.
the class TestWorkflowKillXCommand method testWfKillFailedToLoadJob.
/**
* Test : kill job failed to load the job.
*
* @throws Exception
*/
public void testWfKillFailedToLoadJob() throws Exception {
final String testWfId = "0000001-" + new Date().getTime() + "-testWfKill-W";
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.OK);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(job.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
job = jpaService.execute(wfJobGetCmd);
action = jpaService.execute(wfActionGetCmd);
assertEquals(job.getStatus(), WorkflowJob.Status.RUNNING);
assertEquals(action.getStatus(), WorkflowAction.Status.OK);
WorkflowInstance wfInstance = job.getWorkflowInstance();
assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.RUNNING);
try {
new KillXCommand(testWfId).call();
fail("Job doesn't exist. Should fail.");
} catch (CommandException ce) {
}
}
Aggregations