use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestPurgeXCommand method testPurgeCoordWithWFChild1.
/**
* Test : The workflow should get purged, but the coordinator parent shouldn't get purged --> neither will get purged
*
* @throws Exception
*/
public void testPurgeCoordWithWFChild1() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean wfAction = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob.getId(), "SUCCEEDED", 0);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(wfAction.getId());
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(coordAction.getId());
wfJob = jpaService.execute(wfJobGetCmd);
wfAction = jpaService.execute(wfActionGetCmd);
coordJob = jpaService.execute(coordJobGetCmd);
coordAction = jpaService.execute(coordActionGetCmd);
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction.getStatus());
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction.getStatus());
new PurgeXCommand(7, getNumDaysToNotBePurged(coordJob.getLastModifiedTime()), 1, 10).call();
try {
jpaService.execute(coordJobGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Job should not have been purged");
}
try {
jpaService.execute(coordActionGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action should not have been purged");
}
try {
jpaService.execute(wfJobGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job should not have been purged");
}
try {
jpaService.execute(wfActionGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action should not have been purged");
}
}
use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestPurgeXCommand method testPurgeBundleWithCoordChildWithWFChildWithSubWF2.
/**
* Test : The subworkflow, workflow, and coordinator should not get purged, but the bundle parent should get purged --> none
* will get purged
*
* @throws Exception
*/
public void testPurgeBundleWithCoordChildWithWFChildWithSubWF2() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobBean bundleJob = addRecordToBundleJobTable(Job.Status.SUCCEEDED, DateUtils.parseDateOozieTZ("2011-01-01T01:00Z"));
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean wfAction = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
WorkflowJobBean subwfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
WorkflowActionBean subwfAction = addRecordToWfActionTable(subwfJob.getId(), "1", WorkflowAction.Status.OK);
CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob.getId(), "SUCCEEDED", 0);
BundleActionBean bundleAction = addRecordToBundleActionTable(bundleJob.getId(), coordJob.getId(), coordJob.getAppName(), 0, Job.Status.SUCCEEDED);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(wfAction.getId());
WorkflowJobGetJPAExecutor subwfJobGetCmd = new WorkflowJobGetJPAExecutor(subwfJob.getId());
WorkflowActionGetJPAExecutor subwfActionGetCmd = new WorkflowActionGetJPAExecutor(subwfAction.getId());
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(coordAction.getId());
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(bundleJob.getId());
BundleActionGetJPAExecutor bundleActionGetCmd = new BundleActionGetJPAExecutor(bundleJob.getId(), coordJob.getAppName());
wfJob = jpaService.execute(wfJobGetCmd);
wfAction = jpaService.execute(wfActionGetCmd);
subwfJob = jpaService.execute(subwfJobGetCmd);
subwfAction = jpaService.execute(subwfActionGetCmd);
coordJob = jpaService.execute(coordJobGetCmd);
coordAction = jpaService.execute(coordActionGetCmd);
bundleJob = jpaService.execute(bundleJobGetCmd);
bundleAction = jpaService.execute(bundleActionGetCmd);
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob.getStatus());
assertEquals(WorkflowAction.Status.OK, subwfAction.getStatus());
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction.getStatus());
assertEquals(BundleJobBean.Status.SUCCEEDED, bundleJob.getStatus());
assertEquals(BundleJobBean.Status.SUCCEEDED, bundleAction.getStatus());
new PurgeXCommand(getNumDaysToNotBePurged(wfJob.getEndTime()), getNumDaysToNotBePurged(coordJob.getLastModifiedTime()), 7, 10).call();
try {
jpaService.execute(bundleJobGetCmd);
} catch (JPAExecutorException je) {
fail("Bundle Job should not have been purged");
}
try {
jpaService.execute(bundleActionGetCmd);
} catch (JPAExecutorException je) {
fail("Bundle Action should not have been purged");
}
try {
jpaService.execute(coordJobGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Job should not have been purged");
}
try {
jpaService.execute(coordActionGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action should not have been purged");
}
try {
jpaService.execute(wfJobGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job should not have been purged");
}
try {
jpaService.execute(wfActionGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action should not have been purged");
}
try {
jpaService.execute(subwfJobGetCmd);
} catch (JPAExecutorException je) {
fail("SubWorkflow Job should not have been purged");
}
try {
jpaService.execute(subwfActionGetCmd);
} catch (JPAExecutorException je) {
fail("SubWorkflow Action should not have been purged");
}
}
use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestPurgeXCommand method testPurgeBundleWithCoordChildWithWFChild2.
/**
* Test : The workflow and coordinator should not get purged, but the bundle parent should get purged --> none will get purged
*
* @throws Exception
*/
public void testPurgeBundleWithCoordChildWithWFChild2() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobBean bundleJob = addRecordToBundleJobTable(Job.Status.SUCCEEDED, DateUtils.parseDateOozieTZ("2011-01-01T01:00Z"));
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean wfAction = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob.getId(), "SUCCEEDED", 0);
BundleActionBean bundleAction = addRecordToBundleActionTable(bundleJob.getId(), coordJob.getId(), coordJob.getAppName(), 0, Job.Status.SUCCEEDED);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(wfAction.getId());
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(coordAction.getId());
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(bundleJob.getId());
BundleActionGetJPAExecutor bundleActionGetCmd = new BundleActionGetJPAExecutor(bundleJob.getId(), coordJob.getAppName());
wfJob = jpaService.execute(wfJobGetCmd);
wfAction = jpaService.execute(wfActionGetCmd);
coordJob = jpaService.execute(coordJobGetCmd);
coordAction = jpaService.execute(coordActionGetCmd);
bundleJob = jpaService.execute(bundleJobGetCmd);
bundleAction = jpaService.execute(bundleActionGetCmd);
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction.getStatus());
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction.getStatus());
assertEquals(BundleJobBean.Status.SUCCEEDED, bundleJob.getStatus());
assertEquals(BundleJobBean.Status.SUCCEEDED, bundleAction.getStatus());
new PurgeXCommand(getNumDaysToNotBePurged(wfJob.getEndTime()), getNumDaysToNotBePurged(coordJob.getLastModifiedTime()), 7, 10).call();
try {
jpaService.execute(bundleJobGetCmd);
} catch (JPAExecutorException je) {
fail("Bundle Job should not have been purged");
}
try {
jpaService.execute(bundleActionGetCmd);
} catch (JPAExecutorException je) {
fail("Bundle Action should not have been purged");
}
try {
jpaService.execute(coordJobGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Job should not have been purged");
}
try {
jpaService.execute(coordActionGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Action should not have been purged");
}
try {
jpaService.execute(wfJobGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Job should not have been purged");
}
try {
jpaService.execute(wfActionGetCmd);
} catch (JPAExecutorException je) {
fail("Workflow Action should not have been purged");
}
}
use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestCoordActionInputCheckXCommand method testNoDatasetDependency.
/**
* This test verifies that for a coordinator with no input dependencies
* action is not stuck in WAITING
*
* @throws Exception
*/
public void testNoDatasetDependency() throws Exception {
/*
* create coordinator job
*/
CoordinatorJobBean coordJob = new CoordinatorJobBean();
coordJob.setId("0000000" + new Date().getTime() + "-TestCoordActionInputCheckXCommand-C");
coordJob.setAppName("testApp");
coordJob.setAppPath("testAppPath");
coordJob.setStatus(CoordinatorJob.Status.RUNNING);
coordJob.setCreatedTime(new Date());
coordJob.setLastModifiedTime(new Date());
coordJob.setUser("testUser");
coordJob.setGroup("testGroup");
coordJob.setTimeZone("UTC");
coordJob.setTimeUnit(Timeunit.DAY);
coordJob.setMatThrottling(2);
try {
coordJob.setStartTime(DateUtils.parseDateOozieTZ("2009-02-01T23:59" + TZ));
coordJob.setEndTime(DateUtils.parseDateOozieTZ("2009-02-02T23:59" + TZ));
} catch (Exception e) {
e.printStackTrace();
fail("Could not set Date/time");
}
XConfiguration jobConf = new XConfiguration();
jobConf.set(OozieClient.USER_NAME, getTestUser());
String confStr = jobConf.toXmlString(false);
coordJob.setConf(confStr);
String wfXml = IOUtils.getResourceAsString("wf-no-op.xml", -1);
writeToFile(wfXml, getFsTestCaseDir(), "workflow.xml");
String appXml = "<coordinator-app xmlns='uri:oozie:coordinator:0.2' name='NAME' frequency=\"1\" start='2009-02-01T01:00" + TZ + "' end='2009-02-03T23:59" + TZ + "' timezone='UTC' freq_timeunit='DAY' end_of_duration='NONE'>";
appXml += "<output-events>";
appXml += "<data-out name='LOCAL_A' dataset='local_a'>";
appXml += "<dataset name='local_a' frequency='7' initial-instance='2009-01-01T01:00" + TZ + "' timezone='UTC' freq_timeunit='DAY' end_of_duration='NONE'>";
appXml += "<uri-template>file://" + getFsTestCaseDir() + "/${YEAR}/${MONTH}/${DAY}</uri-template>";
appXml += "</dataset>";
appXml += "<start-instance>${coord:current(-3)}</start-instance>";
appXml += "<instance>${coord:current(0)}</instance>";
appXml += "</data-out>";
appXml += "</output-events>";
appXml += "<action>";
appXml += "<workflow>";
appXml += "<app-path>" + getFsTestCaseDir() + "/workflow.xml</app-path>";
appXml += "</workflow>";
appXml += "</action>";
appXml += "</coordinator-app>";
coordJob.setJobXml(appXml);
coordJob.setLastActionNumber(0);
coordJob.setFrequency("1");
coordJob.setConcurrency(1);
JPAService jpaService = Services.get().get(JPAService.class);
if (jpaService != null) {
try {
jpaService.execute(new CoordJobInsertJPAExecutor(coordJob));
} catch (JPAExecutorException e) {
throw new CommandException(e);
}
} else {
fail("Unable to insert the test job record to table");
}
new CoordMaterializeTransitionXCommand(coordJob.getId(), 3600).call();
/*
* check coord action READY
*/
new CoordActionInputCheckXCommand(coordJob.getId() + "@1", coordJob.getId()).call();
CoordinatorActionBean action = null;
try {
jpaService = Services.get().get(JPAService.class);
action = jpaService.execute(new CoordActionGetJPAExecutor(coordJob.getId() + "@1"));
} catch (JPAExecutorException se) {
fail("Action ID " + coordJob.getId() + "@1" + " was not stored properly in db");
}
// for no dataset dependency, action will proceed directly to start
// workflow synchronously after being READY (since n(actions) < concurrency)
assertEquals(CoordinatorAction.Status.RUNNING, action.getStatus());
action.setMissingDependencies("");
action.setStatus(CoordinatorAction.Status.WAITING);
action.setExternalId(null);
try {
jpaService = Services.get().get(JPAService.class);
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, action);
} catch (JPAExecutorException se) {
fail("Action ID " + coordJob.getId() + "@1" + " was not stored properly in db");
}
new CoordActionInputCheckXCommand(coordJob.getId() + "@1", coordJob.getId()).call();
try {
jpaService = Services.get().get(JPAService.class);
action = jpaService.execute(new CoordActionGetJPAExecutor(coordJob.getId() + "@1"));
} catch (JPAExecutorException se) {
fail("Action ID " + coordJob.getId() + "@1" + " was not stored properly in db");
}
// for no dataset dependency, action will proceed directly to start
// workflow synchronously after being READY (since n(actions) < concurrency)
assertEquals(CoordinatorAction.Status.RUNNING, action.getStatus());
}
use of org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor in project oozie by apache.
the class TestCoordActionInputCheckXCommand method testActionInputMissingDependencies.
/**
* Test to check that missing dependencies list starts from the first unavailable dependency in synchronous order
* @throws Exception
*/
public void testActionInputMissingDependencies() throws Exception {
String jobId = "0000000-" + new Date().getTime() + "-TestCoordActionInputCheckXCommand-C";
Date startTime = DateUtils.parseDateOozieTZ("2009-02-15T23:59" + TZ);
Date endTime = DateUtils.parseDateOozieTZ("2009-02-16T23:59" + TZ);
CoordinatorJobBean job = addRecordToCoordJobTable(jobId, startTime, endTime);
new CoordMaterializeTransitionXCommand(job.getId(), 3600).call();
// providing some of the dataset dirs required as per coordinator
// specification - /2009/02/19, /2009/02/12, /2009/02/05, /2009/01/29, /2009/01/22
createTestCaseSubDir("2009/02/19/_SUCCESS".split("/"));
createTestCaseSubDir("2009/01/29/_SUCCESS".split("/"));
new CoordActionInputCheckXCommand(job.getId() + "@1", job.getId()).call();
CoordinatorActionBean action = null;
try {
JPAService jpaService = Services.get().get(JPAService.class);
action = jpaService.execute(new CoordActionGetJPAExecutor(job.getId() + "@1"));
} catch (JPAExecutorException se) {
fail("Action ID " + job.getId() + "@1" + " was not stored properly in db");
}
// Missing dependencies recorded by the coordinator action after input check
String missDepsOrder = action.getMissingDependencies();
// Expected missing dependencies are /2009/02/12, /2009/02/05, /2009/01/29, and /2009/01/22.
int index = missDepsOrder.indexOf("/2009/02/19");
if (index >= 0) {
fail("Dependency should be available! current list: " + missDepsOrder);
}
// Case when /2009/01/29 exists but checking stops since dataset synchronously expected before i.e. /2009/02/05 is missing
index = missDepsOrder.indexOf("/2009/01/29");
if (index < 0) {
fail("Data should have been in missing dependency list! current list: " + missDepsOrder);
}
index = missDepsOrder.indexOf("/2009/02/05");
if (index < 0) {
fail("Data should have been in missing dependency list! current list: " + missDepsOrder);
}
}
Aggregations