use of org.apache.oozie.BundleActionBean in project oozie by apache.
the class TestBundleActionQueryExecutor method testGetUpdateQuery.
public void testGetUpdateQuery() throws Exception {
EntityManager em = jpaService.getEntityManager();
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
BundleActionBean bundleAction = this.addRecordToBundleActionTable(job.getId(), "action1", 1, Job.Status.PREP);
// UPDATE_BUNDLE_ACTION_PENDING_MODTIME
Query query = BundleActionQueryExecutor.getInstance().getUpdateQuery(BundleActionQuery.UPDATE_BUNDLE_ACTION_PENDING_MODTIME, bundleAction, em);
assertEquals(query.getParameterValue("lastModifiedTime"), bundleAction.getLastModifiedTimestamp());
assertEquals(query.getParameterValue("pending"), bundleAction.getPending());
assertEquals(query.getParameterValue("bundleActionId"), bundleAction.getBundleActionId());
// UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME:
query = BundleActionQueryExecutor.getInstance().getUpdateQuery(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME_COORDID, bundleAction, em);
assertEquals(query.getParameterValue("status"), bundleAction.getStatus().toString());
assertEquals(query.getParameterValue("lastModifiedTime"), bundleAction.getLastModifiedTimestamp());
assertEquals(query.getParameterValue("pending"), bundleAction.getPending());
assertEquals(query.getParameterValue("coordId"), bundleAction.getCoordId());
assertEquals(query.getParameterValue("bundleActionId"), bundleAction.getBundleActionId());
// UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME_COORDID
query = BundleActionQueryExecutor.getInstance().getUpdateQuery(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME_COORDID, bundleAction, em);
assertEquals(query.getParameterValue("status"), bundleAction.getStatus().toString());
assertEquals(query.getParameterValue("lastModifiedTime"), bundleAction.getLastModifiedTimestamp());
assertEquals(query.getParameterValue("pending"), bundleAction.isPending() ? 1 : 0);
assertEquals(query.getParameterValue("coordId"), bundleAction.getCoordId());
assertEquals(query.getParameterValue("bundleActionId"), bundleAction.getBundleActionId());
em.close();
}
use of org.apache.oozie.BundleActionBean in project oozie by apache.
the class TestBundleActionQueryExecutor method testGet.
public void testGet() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
BundleActionBean bundleAction = this.addRecordToBundleActionTable(job.getId(), "action1", 1, Job.Status.PREP);
// GET_UNIGNORED_BUNDLE_ACTION_STATUS_PENDING_FOR_BUNDLE
BundleActionBean retBean = BundleActionQueryExecutor.getInstance().get(BundleActionQuery.GET_BUNDLE_UNIGNORED_ACTION_STATUS_PENDING_FOR_BUNDLE, bundleAction.getBundleId());
assertEquals(bundleAction.getCoordId(), retBean.getCoordId());
assertEquals(bundleAction.getStatusStr(), retBean.getStatusStr());
assertEquals(bundleAction.getPending(), retBean.getPending());
// GET_BUNDLE_ACTION
retBean = BundleActionQueryExecutor.getInstance().get(BundleActionQuery.GET_BUNDLE_ACTION, bundleAction.getBundleActionId());
assertEquals(bundleAction.getStatus(), retBean.getStatus());
}
use of org.apache.oozie.BundleActionBean in project oozie by apache.
the class TestBundleActionQueryExecutor method testGetSelectQuery.
public void testGetSelectQuery() throws Exception {
EntityManager em = jpaService.getEntityManager();
BundleActionBean bean = addRecordToBundleActionTable("test-bundle-id", "test-coord", 0, Job.Status.RUNNING);
Query query = null;
query = BundleActionQueryExecutor.getInstance().getSelectQuery(BundleActionQuery.GET_BUNDLE_ACTION, em, bean.getBundleId());
assertEquals(query.getParameterValue("bundleActionId"), bean.getBundleId());
query = BundleActionQueryExecutor.getInstance().getSelectQuery(BundleActionQuery.GET_BUNDLE_WAITING_ACTIONS_OLDER_THAN, em, (long) 100);
Date date = DateUtils.toDate((Timestamp) (query.getParameterValue("lastModifiedTime")));
assertTrue(date.before(Calendar.getInstance().getTime()));
query = BundleActionQueryExecutor.getInstance().getSelectQuery(BundleActionQuery.GET_BUNDLE_UNIGNORED_ACTION_STATUS_PENDING_FOR_BUNDLE, em, bean.getBundleId());
assertEquals(query.getParameterValue("bundleId"), bean.getBundleId());
}
use of org.apache.oozie.BundleActionBean in project oozie by apache.
the class TestBundleActionQueryExecutor method testInsert.
public void testInsert() throws Exception {
BundleActionBean bean = new BundleActionBean();
bean.setBundleActionId("test-oozie");
bean.setCoordName("testApp");
bean.setStatus(Job.Status.RUNNING);
BundleActionQueryExecutor.getInstance().insert(bean);
BundleActionBean retBean = BundleActionQueryExecutor.getInstance().get(BundleActionQuery.GET_BUNDLE_ACTION, "test-oozie");
assertEquals(retBean.getCoordName(), "testApp");
assertEquals(retBean.getStatus(), Job.Status.RUNNING);
}
use of org.apache.oozie.BundleActionBean in project oozie by apache.
the class TestBundleActionQueryExecutor method testGetList.
public void testGetList() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
this.addRecordToBundleActionTable(job.getId(), "coord1", 0, Job.Status.PREP);
this.addRecordToBundleActionTable(job.getId(), "coord2", 1, Job.Status.RUNNING);
this.addRecordToBundleActionTable(job.getId(), "coord3", 1, Job.Status.RUNNING);
List<BundleActionBean> bActions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_WAITING_ACTIONS_OLDER_THAN, (long) (1000 * 60));
assertEquals(0, bActions.size());
bActions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_WAITING_ACTIONS_OLDER_THAN, (long) (-1000 * 60));
assertEquals(2, bActions.size());
// GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE
List<BundleActionBean> retList = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
assertEquals(3, retList.size());
for (BundleActionBean bean : retList) {
assertTrue(bean.getCoordName().equals("coord1") || bean.getCoordName().equals("coord2") || bean.getCoordName().equals("coord3"));
}
}
Aggregations