use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestBulkWorkflowXCommand method testBulkSuspendNoOp.
public void testBulkSuspendNoOp() throws Exception {
WorkflowJobBean job1 = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action1 = this.addRecordToWfActionTable(job1.getId(), "1", WorkflowAction.Status.RUNNING);
WorkflowJobBean job2 = this.addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean action2 = this.addRecordToWfActionTable(job2.getId(), "1", WorkflowAction.Status.DONE);
Map<String, List<String>> map = new HashMap<String, List<String>>();
List<String> names = new ArrayList<String>();
names.add("testApp");
map.put("name", names);
new BulkWorkflowXCommand(map, 1, 50, OperationType.Suspend).call();
verifyJobStatus(job1.getId(), WorkflowJob.Status.SUSPENDED);
verifyActionStatus(action1.getId(), WorkflowAction.Status.RUNNING);
verifyJobStatus(job2.getId(), WorkflowJob.Status.SUCCEEDED);
verifyActionStatus(action2.getId(), WorkflowAction.Status.DONE);
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestBulkWorkflowXCommand method testBulkResumeNegative.
public void testBulkResumeNegative() throws Exception {
WorkflowJobBean job1 = this.addRecordToWfJobTable(WorkflowJob.Status.SUSPENDED, WorkflowInstance.Status.SUSPENDED);
WorkflowActionBean action1 = this.addRecordToWfActionTable(job1.getId(), "1", WorkflowAction.Status.RUNNING);
Map<String, List<String>> map = new HashMap<String, List<String>>();
List<String> names = new ArrayList<String>();
names.add("testApp-new");
map.put("name", names);
new BulkWorkflowXCommand(map, 1, 50, OperationType.Resume).call();
verifyJobStatus(job1.getId(), WorkflowJob.Status.SUSPENDED);
verifyActionStatus(action1.getId(), WorkflowAction.Status.RUNNING);
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestCompletedActionXCommand method testEarlyCallbackTimeout.
public void testEarlyCallbackTimeout() throws Exception {
final Instrumentation inst = Services.get().get(InstrumentationService.class).get();
WorkflowJobBean job = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
final CompletedActionXCommand cmd = new CompletedActionXCommand(action.getId(), "SUCCEEDED", null);
long xexceptionCount;
try {
xexceptionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".xexceptions").getValue();
} catch (NullPointerException npe) {
// counter might be null
xexceptionCount = 0L;
}
assertEquals(0L, xexceptionCount);
long executionsCount;
try {
executionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".executions").getValue();
} catch (NullPointerException npe) {
// counter might be null
executionsCount = 0L;
}
assertEquals(0L, executionsCount);
long executionCount;
try {
executionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".execution").getValue();
} catch (NullPointerException npe) {
// counter might be null
executionCount = 0L;
}
assertEquals(0L, executionCount);
cmd.call();
int timeout = 10000 * 5 * 2;
waitFor(timeout, new Predicate() {
@Override
public boolean evaluate() throws Exception {
long xexceptionCount;
try {
xexceptionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".xexceptions").getValue();
} catch (NullPointerException npe) {
// counter might be null
xexceptionCount = 0L;
}
return (xexceptionCount == 1L);
}
});
executionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".executions").getValue();
assertEquals(6L, executionsCount);
try {
executionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".execution").getValue();
} catch (NullPointerException npe) {
// counter might be null
executionCount = 0L;
}
assertEquals(0L, executionCount);
xexceptionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".xexceptions").getValue();
assertEquals(1L, xexceptionCount);
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestCompletedActionXCommand method testEarlyCallbackTransitionToRunning.
public void testEarlyCallbackTransitionToRunning() throws Exception {
final Instrumentation inst = Services.get().get(InstrumentationService.class).get();
WorkflowJobBean job = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
final WorkflowActionBean action = addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
final CompletedActionXCommand cmd = new CompletedActionXCommand(action.getId(), "SUCCEEDED", null);
long xexceptionCount;
try {
xexceptionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".xexceptions").getValue();
} catch (NullPointerException npe) {
// counter might be null
xexceptionCount = 0L;
}
assertEquals(0L, xexceptionCount);
long executionsCount;
try {
executionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".executions").getValue();
} catch (NullPointerException npe) {
// counter might be null
executionsCount = 0L;
}
assertEquals(0L, executionsCount);
long checkXCommandExecutionsCount;
try {
checkXCommandExecutionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get("action.check.executions").getValue();
} catch (NullPointerException npe) {
// counter might be null
checkXCommandExecutionsCount = 0L;
}
assertEquals(0L, checkXCommandExecutionsCount);
cmd.call();
int timeout = 100000 * 5 * 2;
waitFor(timeout, new Predicate() {
@Override
public boolean evaluate() throws Exception {
long executionsCount;
try {
executionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".executions").getValue();
} catch (NullPointerException npe) {
// counter might be null
executionsCount = 0L;
}
if (executionsCount == 3 && !action.getStatus().equals(WorkflowAction.Status.RUNNING)) {
// Transition the action to RUNNING
action.setStatus(WorkflowAction.Status.RUNNING);
WorkflowActionQueryExecutor.getInstance().executeUpdate(WorkflowActionQueryExecutor.WorkflowActionQuery.UPDATE_ACTION, action);
}
long checkXCommandExecutionsCount;
try {
checkXCommandExecutionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get("action.check.executions").getValue();
} catch (NullPointerException npe) {
// counter might be null
checkXCommandExecutionsCount = 0L;
}
return (checkXCommandExecutionsCount == 1L);
}
});
executionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".executions").getValue();
assertTrue("expected a value greater than 3L, but found " + executionsCount, executionsCount >= 3L);
checkXCommandExecutionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get("action.check.executions").getValue();
assertEquals(1L, checkXCommandExecutionsCount);
try {
xexceptionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".xexceptions").getValue();
} catch (NullPointerException npe) {
// counter might be null
xexceptionCount = 0L;
}
assertEquals(0L, xexceptionCount);
}
use of org.apache.oozie.WorkflowActionBean in project oozie by apache.
the class TestSubmitXCommand method testWFConfigDefaultVarResolve.
public void testWFConfigDefaultVarResolve() throws Exception {
final OozieClient wfClient = LocalOozie.getClient();
OutputStream os = new FileOutputStream(getTestCaseDir() + "/config-default.xml");
XConfiguration defaultConf = new XConfiguration();
defaultConf.set("outputDir", "default-output-dir");
defaultConf.set("foo.bar", "default-foo-bar");
defaultConf.set("foobarRef", "${foo.bar}");
defaultConf.set("key", "default_value");
defaultConf.set("should_resolve", "${should.resolve}");
defaultConf.set("mixed", "${nameNode}/${outputDir}");
defaultConf.writeXml(os);
os.close();
String workflowUri = getTestCaseFileUri("workflow.xml");
String actionXml = "<map-reduce>" + "<job-tracker>${jobTracker}</job-tracker>" + "<name-node>${nameNode}</name-node>" + " <prepare>" + " <delete path=\"${nameNode}/user/${wf:user()}/mr/${outputDir}\"/>" + " </prepare>" + " <configuration>" + " <property><name>bb</name><value>BB</value></property>" + " <property><name>cc</name><value>from_action</value></property>" + " </configuration>" + " </map-reduce>";
String wfXml = "<workflow-app xmlns=\"uri:oozie:workflow:0.5\" name=\"map-reduce-wf\">" + " <start to=\"mr-node\"/>" + " <action name=\"mr-node\">" + actionXml + " <ok to=\"end\"/>" + " <error to=\"fail\"/>" + "</action>" + "<kill name=\"fail\">" + " <message>Map/Reduce failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>" + "</kill>" + "<end name=\"end\"/>" + "</workflow-app>";
writeToFile(wfXml, workflowUri);
Configuration conf = new XConfiguration();
conf.set("nameNode", getNameNodeUri());
conf.set("jobTracker", getJobTrackerUri());
conf.set("foobarRef", "foobarRef");
conf.set("key", "job_prop_value");
conf.set(OozieClient.APP_PATH, workflowUri);
conf.set(OozieClient.USER_NAME, getTestUser());
conf.set("should.resolve", "resolved");
SubmitXCommand sc = new SubmitXCommand(conf);
final String jobId = sc.call();
new StartXCommand(jobId).call();
waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
return wfClient.getJobInfo(jobId).getStatus() == WorkflowJob.Status.KILLED;
}
});
String actionId = jobId + "@mr-node";
WorkflowActionBean action = WorkflowActionQueryExecutor.getInstance().get(WorkflowActionQueryExecutor.WorkflowActionQuery.GET_ACTION, actionId);
Element eAction = XmlUtils.parseXml(action.getConf());
Element eConf = eAction.getChild("configuration", eAction.getNamespace());
Configuration actionConf = new XConfiguration(new StringReader(XmlUtils.prettyPrint(eConf).toString()));
assertEquals("default-output-dir", actionConf.get("outputDir"));
assertEquals("BB", actionConf.get("bb"));
assertEquals("from_action", actionConf.get("cc"));
assertEquals("resolved", actionConf.get("should_resolve"));
assertEquals("default-foo-bar", actionConf.get("foo.bar"));
assertEquals("default-foo-bar", actionConf.get("foobarRef"));
assertEquals("default_value", actionConf.get("key"));
assertEquals(getNameNodeUri() + "/default-output-dir", actionConf.get("mixed"));
}
Aggregations