use of org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor in project oozie by apache.
the class TestActionStartXCommand method testActionWithEscapedStringAndCDATA.
/**
* Test workflow action with CDATA section and string configuration that needs to be escaped can be submitted without
* throwing exceptions.
* <p/>
* Escaped string needs to be 'escaped' before converting to XML Document, otherwise,
* exception will be thrown.
* @see org.apache.oozie.DagELFunctions#configureEvaluator(org.apache.oozie.util.ELEvaluator.ELEvaluator evaluator,
* org.apache.oozie.WorkflowJobBean, org.apache.oozie.WorkflowActionBean)
*
* @throws Exception thrown if failed to execute test case
*/
public void testActionWithEscapedStringAndCDATA() throws Exception {
// create workflow job and action beans with escaped parameters and CDATA value
JPAService jpaService = Services.get().get(JPAService.class);
WorkflowJobBean job = this.addRecordToWfJobTableWithEscapedStringAndCDATA(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = this.addRecordToWfActionTableWithEscapedStringAndCDATA(job.getId(), WorkflowAction.Status.PREP);
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
// start workflow action
new ActionStartXCommand(action.getId(), "map-reduce").call();
action = jpaService.execute(wfActionGetCmd);
assertNotNull(action.getExternalId());
ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(job, action, false, false);
MapReduceActionExecutor actionExecutor = new MapReduceActionExecutor();
Configuration conf = actionExecutor.createBaseHadoopConf(context, XmlUtils.parseXml(action.getConf()));
String user = conf.get("user.name");
String launcherId = action.getExternalId();
waitUntilYarnAppDoneAndAssertSuccess(launcherId);
Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
assertTrue(LauncherHelper.hasIdSwap(actionData));
}
use of org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor in project oozie by apache.
the class TestActionStartXCommand method testActionStart.
public void testActionStart() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
new ActionStartXCommand(action.getId(), "map-reduce").call();
action = jpaService.execute(wfActionGetCmd);
assertNotNull(action.getExternalId());
ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(job, action, false, false);
MapReduceActionExecutor actionExecutor = new MapReduceActionExecutor();
Configuration conf = actionExecutor.createBaseHadoopConf(context, XmlUtils.parseXml(action.getConf()));
String launcherId = action.getExternalId();
waitUntilYarnAppDoneAndAssertSuccess(launcherId);
Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
assertTrue(LauncherHelper.hasIdSwap(actionData));
}
use of org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor in project oozie by apache.
the class TestWorkflowActionKillXCommand method testWfActionKillFailed.
/**
* Test : kill a non-killed action. Will throw the exception from {@link
* WorkflowActionKillXCommand.verifyPrecondition()}
*
* @throws Exception
*/
public void testWfActionKillFailed() throws Exception {
String externalJobID = launchSleepJob(1000);
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), externalJobID, "1", WorkflowAction.Status.RUNNING, null);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
action = jpaService.execute(wfActionGetCmd);
assertEquals(action.getStatus(), WorkflowAction.Status.RUNNING);
assertEquals(action.getExternalStatus(), "RUNNING");
new ActionKillXCommand(action.getId()).call();
// action is not in KILLED, action status must not change
action = jpaService.execute(wfActionGetCmd);
assertEquals(action.getStatus(), WorkflowAction.Status.RUNNING);
assertEquals(action.getExternalStatus(), "RUNNING");
}
use of org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor 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.executor.jpa.WorkflowActionGetJPAExecutor 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