use of org.apache.oozie.workflow.WorkflowInstance in project oozie by apache.
the class TestWorkflowKillXCommand method testWfKillSuccess1.
/**
* Test : kill RUNNING job and PREP action successfully.
*
* @throws Exception
*/
public void testWfKillSuccess1() throws Exception {
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
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.PREP);
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 testWfKillSuccessAfterNodeDefUpgrade.
/**
* Test : kill RUNNING job after NodeDef upgrade.
*
* @throws Exception
*/
public void testWfKillSuccessAfterNodeDefUpgrade() throws Exception {
services.destroy();
setSystemProperty(LiteWorkflowStoreService.CONF_NODE_DEF_VERSION, LiteWorkflowStoreService.NODE_DEF_VERSION_0);
services = new Services();
services.init();
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
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.PREP);
WorkflowInstance wfInstance = job.getWorkflowInstance();
assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.RUNNING);
services.destroy();
sleep(5000);
setSystemProperty(LiteWorkflowStoreService.CONF_NODE_DEF_VERSION, LiteWorkflowStoreService.NODE_DEF_VERSION_1);
services = new Services();
services.init();
sleep(5000);
new KillXCommand(job.getId()).call();
jpaService = Services.get().get(JPAService.class);
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);
services.destroy();
sleep(5000);
setSystemProperty(LiteWorkflowStoreService.CONF_NODE_DEF_VERSION, LiteWorkflowStoreService.NODE_DEF_VERSION_2);
services = new Services();
services.init();
sleep(5000);
jpaService = Services.get().get(JPAService.class);
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 testWfKillFailed.
/**
* Test : kill job but failed to kill an already successful action.
*
* @throws Exception
*/
public void testWfKillFailed() throws Exception {
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);
new KillXCommand(job.getId()).call();
job = jpaService.execute(wfJobGetCmd);
action = jpaService.execute(wfActionGetCmd);
assertEquals(job.getStatus(), WorkflowJob.Status.KILLED);
assertEquals(action.getStatus(), WorkflowAction.Status.OK);
wfInstance = job.getWorkflowInstance();
assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.KILLED);
}
use of org.apache.oozie.workflow.WorkflowInstance in project oozie by apache.
the class TestDBWorkflowStore method createWorkflow.
private WorkflowJobBean createWorkflow(WorkflowApp app, Configuration conf, String authToken) throws Exception {
WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
Configuration protoActionConf = wps.createProtoActionConf(conf, true);
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(protoActionConf).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;
}
Aggregations