use of org.apache.oozie.XException in project oozie by apache.
the class TestCoordUpdateXCommand method testCoordDefUnsupportedChange.
// test fail... trying to set unsupported field.
public void testCoordDefUnsupportedChange() throws Exception {
final XConfiguration conf = new XConfiguration();
conf.set("start", "2009-02-01T01:00Z");
conf.set("end", "2012-02-03T23:59Z");
conf.set("unit", "UTC");
conf.set("name", "NAME");
conf.set("throttle", "12");
conf.set("concurrency", "12");
conf.set("execution", "FIFO");
conf.set("timeout", "10");
String jobId = setupCoord(conf, "coord-update-test.xml");
Configuration newConf = new XConfiguration(conf.toProperties());
newConf.set("start", "2010-02-01T01:00Z");
try {
new CoordUpdateXCommand(false, newConf, jobId).call();
fail(" should not come here");
} catch (XException e) {
assertTrue(e.getMessage().contains("Start time can't be changed"));
}
newConf = new XConfiguration(conf.toProperties());
newConf.set("end", "2015-02-03T23:59Z");
try {
new CoordUpdateXCommand(false, newConf, jobId).call();
fail(" should not come here");
} catch (XException e) {
assertTrue(e.getMessage().contains("End time can't be changed"));
}
newConf = new XConfiguration(conf.toProperties());
newConf.set("name", "test");
try {
new CoordUpdateXCommand(false, newConf, jobId).call();
fail(" should not come here");
} catch (XException e) {
assertTrue(e.getMessage().contains("Coord name can't be changed"));
}
newConf = new XConfiguration(conf.toProperties());
newConf.set("unit", "America/New_York");
try {
new CoordUpdateXCommand(false, newConf, jobId).call();
fail(" should not come here");
} catch (XException e) {
assertTrue(e.getMessage().contains("TimeZone can't be changed"));
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class TestBundleChangeXCommand method testBundleChangeNegative1.
/**
* Negative Test : pause time is not a valid date
*
* @throws Exception
*/
public void testBundleChangeNegative1() throws Exception {
BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
String dateStr = "2099-01-01Ta1:00Z";
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetCmd);
assertEquals(job.getPauseTime(), null);
try {
new BundleJobChangeXCommand(job.getId(), "pausetime=" + dateStr).call();
fail("Should not reach here");
} catch (XException e) {
assertEquals(ErrorCode.E1317, e.getErrorCode());
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class TestCoordJobInfoGetJPAExecutor method testGetJobInfoForText.
public void testGetJobInfoForText() throws Exception {
CoordinatorJobBean coordinatorJob1 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
CoordinatorJobBean coordinatorJob2 = addRecordToCoordJobTable(CoordinatorJob.Status.KILLED, false, false);
coordinatorJob1.setAppName("oozie-coord1");
coordinatorJob2.setAppName("oozie-coord2");
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob1);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob2);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Map<String, List<String>> filter = new HashMap<String, List<String>>();
CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
CoordinatorJobInfo ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(2, ret.getCoordJobs().size());
filter.clear();
ArrayList<String> textList = new ArrayList<String>();
textList.add("tes");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 2);
textList.clear();
textList.add("oozie-coord1");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 1);
textList.clear();
textList.add("random");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 0);
textList.clear();
textList.add("oozie-coord");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 2);
textList.add("tes");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
try {
jpaService.execute(coordInfoGetCmd);
fail("CoordJobInfoGetJPAExecutor should have thrown E0302 exception.");
} catch (XException e) {
assertEquals(ErrorCode.E0302, e.getErrorCode());
assertEquals(e.getMessage(), "E0302: Invalid parameter [cannot specify multiple strings to search]");
}
// Update coord appName and validate text filter
coordinatorJob1.setAppName("updated-app-name1");
coordinatorJob2.setAppName("updated-app-name2");
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob1);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob2);
textList.clear();
textList.add("oozie-coord");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 0);
textList.clear();
textList.add("updated-app");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 2);
textList.clear();
textList.add("updated-app-name1");
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 1);
}
use of org.apache.oozie.XException in project oozie by apache.
the class TestWorkflowsJobGetJPAExecutor method testGetWFInfoForText.
public void testGetWFInfoForText() throws Exception {
WorkflowJobBean workflowJob1 = addRecordToWfJobTable(WorkflowJob.Status.PREP, WorkflowInstance.Status.PREP);
WorkflowJobBean workflowJob2 = addRecordToWfJobTable(WorkflowJob.Status.PREP, WorkflowInstance.Status.PREP);
workflowJob1.setAppName("wf-name-1");
workflowJob2.setAppName("wf-name-2");
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, workflowJob1);
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, workflowJob2);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Map<String, List<String>> filter = new HashMap<String, List<String>>();
List<String> list = new ArrayList<String>();
WorkflowsJobGetJPAExecutor wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 20);
WorkflowsInfo wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(2, wfInfo.getWorkflows().size());
WorkflowJobBean retBean = wfInfo.getWorkflows().get(0);
compareWf(workflowJob2, retBean);
list.add("wf-name");
filter.put(OozieClient.FILTER_TEXT, list);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 20);
wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(2, wfInfo.getWorkflows().size());
list.clear();
list.add("wf-name-1");
filter.put(OozieClient.FILTER_TEXT, list);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 20);
wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(1, wfInfo.getWorkflows().size());
list.add("extra-param");
filter.put(OozieClient.FILTER_TEXT, list);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 2);
try {
jpaService.execute(wfGetCmd);
fail("WorkflowsJobGetJPAExecutor should have thrown E0302 exception.");
} catch (XException e) {
assertEquals(ErrorCode.E0302, e.getErrorCode());
assertEquals(e.getMessage(), "E0302: Invalid parameter [cannot specify multiple strings to search]");
}
workflowJob1.setAppName("updated-name-1");
workflowJob2.setAppName("updated-name-2");
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, workflowJob1);
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, workflowJob2);
list.clear();
list.add("wf-name-1");
filter.put(OozieClient.FILTER_TEXT, list);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 20);
wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(0, wfInfo.getWorkflows().size());
list.clear();
list.add("updated-name");
filter.put(OozieClient.FILTER_TEXT, list);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 20);
wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(2, wfInfo.getWorkflows().size());
}
use of org.apache.oozie.XException in project oozie by apache.
the class TestWorkflowsJobGetJPAExecutor method testWfJobsGetWithCreatedTime.
public void testWfJobsGetWithCreatedTime() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
Date createdTime1 = DateUtils.parseDateUTC("2012-01-01T10:00Z");
Date createdTime2 = DateUtils.parseDateUTC("2012-02-01T10:00Z");
Date createdTime3 = DateUtils.parseDateUTC("2012-03-01T10:00Z");
Date createdTime4 = DateUtils.parseDateUTC("2012-04-01T10:00Z");
Date createdTime5 = org.apache.commons.lang.time.DateUtils.addHours(new Date(), -5);
WorkflowJobBean wrkJob = addRecordToWfJobTable(WorkflowJob.Status.PREP, WorkflowInstance.Status.PREP);
wrkJob.setCreatedTime(createdTime1);
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, wrkJob);
wrkJob = addRecordToWfJobTable(WorkflowJob.Status.PREP, WorkflowInstance.Status.PREP);
wrkJob.setCreatedTime(createdTime2);
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, wrkJob);
wrkJob = addRecordToWfJobTable(WorkflowJob.Status.PREP, WorkflowInstance.Status.PREP);
wrkJob.setCreatedTime(createdTime3);
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, wrkJob);
wrkJob = addRecordToWfJobTable(WorkflowJob.Status.PREP, WorkflowInstance.Status.PREP);
wrkJob.setCreatedTime(createdTime4);
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, wrkJob);
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, wrkJob);
wrkJob = addRecordToWfJobTable(WorkflowJob.Status.PREP, WorkflowInstance.Status.PREP);
wrkJob.setCreatedTime(createdTime5);
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW, wrkJob);
// filter 2012-02-01T00:00Z <= createdTimeStamp <= 2012-03-02T00:00Z
Map<String, List<String>> filter = new HashMap<String, List<String>>();
List<String> timeList = new ArrayList<String>();
timeList.add("2012-02-01T00:00Z");
filter.put(OozieClient.FILTER_CREATED_TIME_START, timeList);
timeList = new ArrayList<String>();
timeList.add("2012-03-02T00:00Z");
filter.put(OozieClient.FILTER_CREATED_TIME_END, timeList);
WorkflowsJobGetJPAExecutor wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
WorkflowsInfo wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(2, wfInfo.getWorkflows().size());
for (WorkflowJobBean jobBean : wfInfo.getWorkflows()) {
assertTrue(jobBean.getCreatedTime().equals(createdTime2) || jobBean.getCreatedTime().equals(createdTime3));
}
// createdTime specified in wrong format
filter = new HashMap<String, List<String>>();
timeList = new ArrayList<String>();
// not correct ISO8601_UTC_MASK format
timeList.add("2012-02-01T00:00");
filter.put(OozieClient.FILTER_CREATED_TIME_START, timeList);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
try {
wfInfo = jpaService.execute(wfGetCmd);
} catch (XException e) {
assertEquals(ErrorCode.E0302, e.getErrorCode());
}
// filter 2012-04-01T00:00Z <= createdTimeStamp
filter = new HashMap<String, List<String>>();
timeList = new ArrayList<String>();
timeList.add("2012-04-01T00:00Z");
filter.put(OozieClient.FILTER_CREATED_TIME_START, timeList);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(2, wfInfo.getWorkflows().size());
for (WorkflowJobBean jobBean : wfInfo.getWorkflows()) {
assertTrue(jobBean.getCreatedTime().equals(createdTime4) || jobBean.getCreatedTime().equals(createdTime5));
}
// filter 2012-02-01T00:00Z >= createdTimeStamp
filter = new HashMap<String, List<String>>();
timeList = new ArrayList<String>();
timeList.add("2012-02-01T00:00Z");
filter.put(OozieClient.FILTER_CREATED_TIME_END, timeList);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(1, wfInfo.getWorkflows().size());
assertTrue(wfInfo.getWorkflows().get(0).getCreatedTime().equals(createdTime1));
// when createdTimeStamp specified multiple times
filter = new HashMap<String, List<String>>();
timeList = new ArrayList<String>();
timeList.add("2012-02-01T00:00Z");
timeList.add("2012-04-01T00:00Z");
filter.put(OozieClient.FILTER_CREATED_TIME_END, timeList);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
try {
wfInfo = jpaService.execute(wfGetCmd);
} catch (XException e) {
assertEquals(ErrorCode.E0302, e.getErrorCode());
}
// filter createdTimeStamp > currentTime - 2 days
filter = new HashMap<String, List<String>>();
timeList = new ArrayList<String>();
timeList.add("-2d");
filter.put(OozieClient.FILTER_CREATED_TIME_START, timeList);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(1, wfInfo.getWorkflows().size());
assertTrue(wfInfo.getWorkflows().get(0).getCreatedTime().equals(createdTime5));
// filter createdTimeStamp > currentTime - 10 hour
filter = new HashMap<String, List<String>>();
timeList = new ArrayList<String>();
timeList.add("-10h");
filter.put(OozieClient.FILTER_CREATED_TIME_START, timeList);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(1, wfInfo.getWorkflows().size());
assertTrue(wfInfo.getWorkflows().get(0).getCreatedTime().equals(createdTime5));
// filter createdTimeStamp > currentTime - 600 min
filter = new HashMap<String, List<String>>();
timeList = new ArrayList<String>();
timeList.add("-600m");
filter.put(OozieClient.FILTER_CREATED_TIME_START, timeList);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(1, wfInfo.getWorkflows().size());
assertTrue(wfInfo.getWorkflows().get(0).getCreatedTime().equals(createdTime5));
// filter createdTimeStamp < currentTime - 3 days
filter = new HashMap<String, List<String>>();
timeList = new ArrayList<String>();
timeList.add("-3d");
filter.put(OozieClient.FILTER_CREATED_TIME_END, timeList);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(4, wfInfo.getWorkflows().size());
for (WorkflowJobBean jobBean : wfInfo.getWorkflows()) {
assertTrue(jobBean.getCreatedTime().equals(createdTime1) || jobBean.getCreatedTime().equals(createdTime2) || jobBean.getCreatedTime().equals(createdTime3) || jobBean.getCreatedTime().equals(createdTime4));
}
// filter createdTimeStamp < currentTime - 2 hours
filter = new HashMap<String, List<String>>();
timeList = new ArrayList<String>();
timeList.add("-2h");
filter.put(OozieClient.FILTER_CREATED_TIME_END, timeList);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(5, wfInfo.getWorkflows().size());
for (WorkflowJobBean jobBean : wfInfo.getWorkflows()) {
assertTrue(jobBean.getCreatedTime().equals(createdTime1) || jobBean.getCreatedTime().equals(createdTime2) || jobBean.getCreatedTime().equals(createdTime3) || jobBean.getCreatedTime().equals(createdTime4) || jobBean.getCreatedTime().equals(createdTime5));
}
// filter createdTimeStamp < currentTime - 60 min
filter = new HashMap<String, List<String>>();
timeList = new ArrayList<String>();
timeList.add("-60m");
filter.put(OozieClient.FILTER_CREATED_TIME_END, timeList);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
wfInfo = jpaService.execute(wfGetCmd);
assertNotNull(wfInfo);
assertEquals(5, wfInfo.getWorkflows().size());
for (WorkflowJobBean jobBean : wfInfo.getWorkflows()) {
assertTrue(jobBean.getCreatedTime().equals(createdTime1) || jobBean.getCreatedTime().equals(createdTime2) || jobBean.getCreatedTime().equals(createdTime3) || jobBean.getCreatedTime().equals(createdTime4) || jobBean.getCreatedTime().equals(createdTime5));
}
// when offset is in wrong format
filter = new HashMap<String, List<String>>();
timeList = new ArrayList<String>();
timeList.add("-5M");
filter.put(OozieClient.FILTER_CREATED_TIME_END, timeList);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
try {
wfInfo = jpaService.execute(wfGetCmd);
} catch (XException e) {
assertEquals(ErrorCode.E0302, e.getErrorCode());
}
// when offset is in wrong format
filter = new HashMap<String, List<String>>();
timeList = new ArrayList<String>();
timeList.add("5D");
filter.put(OozieClient.FILTER_CREATED_TIME_END, timeList);
wfGetCmd = new WorkflowsJobGetJPAExecutor(filter, 1, 10);
try {
wfInfo = jpaService.execute(wfGetCmd);
} catch (XException e) {
assertEquals(ErrorCode.E0302, e.getErrorCode());
}
}
Aggregations