Repository: oozie Updated Branches: refs/heads/master 403e49a70 -> b4c600689
OOZIE-2167 TestCoordMaterializeTransitionXCommand fails (rkanter) Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/b4c60068 Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/b4c60068 Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/b4c60068 Branch: refs/heads/master Commit: b4c600689a06f168f368da9c342016f5c8642dd0 Parents: 403e49a Author: Robert Kanter <[email protected]> Authored: Fri Mar 13 10:27:48 2015 -0700 Committer: Robert Kanter <[email protected]> Committed: Fri Mar 13 10:27:48 2015 -0700 ---------------------------------------------------------------------- .../TestCoordMaterializeTransitionXCommand.java | 51 +++++++++++++++++--- release-log.txt | 1 + 2 files changed, 45 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oozie/blob/b4c60068/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java b/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java index 59b8b48..77f5518 100644 --- a/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java +++ b/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java @@ -574,7 +574,12 @@ public class TestCoordMaterializeTransitionXCommand extends XDataTestCase { CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job); new CoordMaterializeTransitionXCommand(job.getId(), 3600).call(); job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId())); - assertEquals(new Date(startTime.getTime() + TIME_IN_DAY * 3), job.getNextMaterializedTime()); + // If the startTime and endTime straddle a DST shift (the Coord is in "America/Los_Angeles"), then we need to adjust for + // that because startTime and endTime assume GMT + Date next = new Date(startTime.getTime() + TIME_IN_DAY * 3); + TimeZone tz = TimeZone.getTimeZone(job.getTimeZone()); + next.setTime(next.getTime() - getDSTOffset(tz, startTime, next)); + assertEquals(next, job.getNextMaterializedTime()); // test with hours, time should not pass the current time. startTime = new Date(new Date().getTime()); @@ -587,7 +592,12 @@ public class TestCoordMaterializeTransitionXCommand extends XDataTestCase { CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job); new CoordMaterializeTransitionXCommand(job.getId(), 3600).call(); job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId())); - assertEquals(new Date(startTime.getTime() + TIME_IN_DAY), job.getNextMaterializedTime()); + // If the startTime and endTime straddle a DST shift (the Coord is in "America/Los_Angeles"), then we need to adjust for + // that because startTime and endTime assume GMT + next = new Date(startTime.getTime() + TIME_IN_DAY); + tz = TimeZone.getTimeZone(job.getTimeZone()); + next.setTime(next.getTime() - getDSTOffset(tz, startTime, next)); + assertEquals(next, job.getNextMaterializedTime()); // for current job in min, should not exceed hour windows startTime = new Date(new Date().getTime()); @@ -599,7 +609,12 @@ public class TestCoordMaterializeTransitionXCommand extends XDataTestCase { CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job); new CoordMaterializeTransitionXCommand(job.getId(), 3600).call(); job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId())); - assertEquals(new Date(startTime.getTime() + TIME_IN_HOURS), job.getNextMaterializedTime()); + // If the startTime and endTime straddle a DST shift (the Coord is in "America/Los_Angeles"), then we need to adjust for + // that because startTime and endTime assume GMT + next = new Date(startTime.getTime() + TIME_IN_HOURS); + tz = TimeZone.getTimeZone(job.getTimeZone()); + next.setTime(next.getTime() - getDSTOffset(tz, startTime, next)); + assertEquals(next, job.getNextMaterializedTime()); // for current job in hour, should not exceed hour windows startTime = new Date(new Date().getTime()); @@ -611,7 +626,12 @@ public class TestCoordMaterializeTransitionXCommand extends XDataTestCase { CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job); new CoordMaterializeTransitionXCommand(job.getId(), 3600).call(); job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId())); - assertEquals(new Date(startTime.getTime() + TIME_IN_DAY), job.getNextMaterializedTime()); + // If the startTime and endTime straddle a DST shift (the Coord is in "America/Los_Angeles"), then we need to adjust for + // that because startTime and endTime assume GMT + next = new Date(startTime.getTime() + TIME_IN_DAY); + tz = TimeZone.getTimeZone(job.getTimeZone()); + next.setTime(next.getTime() - getDSTOffset(tz, startTime, next)); + assertEquals(next, job.getNextMaterializedTime()); } @@ -693,9 +713,12 @@ public class TestCoordMaterializeTransitionXCommand extends XDataTestCase { CoordSubmitXCommand sc = new CoordSubmitXCommand(conf); String jobId = sc.call(); - Date currentTime = new Date(); - Date startTime = org.apache.commons.lang.time.DateUtils.addMonths(currentTime, -3); - Date endTime = org.apache.commons.lang.time.DateUtils.addMonths(currentTime, 3); + Calendar cal = Calendar.getInstance(DateUtils.getOozieProcessingTimeZone()); + cal.add(Calendar.MONTH, -3); + Date startTime = cal.getTime(); + cal = Calendar.getInstance(DateUtils.getOozieProcessingTimeZone()); + cal.add(Calendar.MONTH, 3); + Date endTime = cal.getTime(); CoordinatorJobBean job = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, jobId); assertEquals(job.getLastActionNumber(), 0); @@ -928,4 +951,18 @@ public class TestCoordMaterializeTransitionXCommand extends XDataTestCase { return coordJob; } + + private long getDSTOffset(TimeZone tz, Date d1, Date d2) { + if (tz.inDaylightTime(d1) && !tz.inDaylightTime(d2)) { + Calendar cal = Calendar.getInstance(tz); + cal.setTime(d1); + return cal.get(Calendar.DST_OFFSET); + } + if (!tz.inDaylightTime(d1) && tz.inDaylightTime(d2)) { + Calendar cal = Calendar.getInstance(tz); + cal.setTime(d2); + return cal.get(Calendar.DST_OFFSET); + } + return 0; + } } http://git-wip-us.apache.org/repos/asf/oozie/blob/b4c60068/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index 9bd3af2..3c3a122 100644 --- a/release-log.txt +++ b/release-log.txt @@ -1,5 +1,6 @@ -- Oozie 4.2.0 release (trunk - unreleased) +OOZIE-2167 TestCoordMaterializeTransitionXCommand fails (rkanter) OOZIE-1964 Hive Server 2 action doesn't return Hadoop Job IDs (rkanter) OOZIE-2126 SSH action can be too fast for Oozie sometimes (rkanter) OOZIE-2142 Changing the JT whitelist causes running Workflows to stay RUNNING forever (rkanter)
