You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by an...@apache.org on 2011/11/23 22:57:07 UTC

svn commit: r1205621 - in /incubator/oozie/trunk: core/src/main/java/org/apache/oozie/util/DateUtils.java core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java release-log.txt

Author: angeloh
Date: Wed Nov 23 21:57:06 2011
New Revision: 1205621

URL: http://svn.apache.org/viewvc?rev=1205621&view=rev
Log:
OOZIE-608 Fix test failure for testCoordChangeXCommand, testCoordChangeEndTime Unit

Modified:
    incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/DateUtils.java
    incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java
    incubator/oozie/trunk/release-log.txt

Modified: incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/DateUtils.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/DateUtils.java?rev=1205621&r1=1205620&r2=1205621&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/DateUtils.java (original)
+++ incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/DateUtils.java Wed Nov 23 21:57:06 2011
@@ -250,7 +250,7 @@ public class DateUtils {
 
     /**
      * Return the UTC date and time in W3C format down to second
-     * (yyyy-MM-ddTHH:mm:ssZ). i.e.: 1997-07-16T19:20:30Z
+     * (yyyy-MM-ddTHH:mmZ). i.e.: 1997-07-16T19:20:30Z
      *
      * @return the formatted time string.
      */
@@ -259,4 +259,18 @@ public class DateUtils {
         sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
         return sdf.format(date);
     }
+
+    /**
+     * Return the UTC date and time in W3C format down to second
+     * (yyyy-MM-ddTHH:mmZ). i.e.: 1997-07-16T19:20Z The input date is a
+     * long (Unix Time Stamp)
+     *
+     * @return the formatted time string.
+     */
+    public static String convertDateToString(long timeStamp) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
+        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+        return sdf.format(new Date(timeStamp));
+    }
+
 }

Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java?rev=1205621&r1=1205620&r2=1205621&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java Wed Nov 23 21:57:06 2011
@@ -55,10 +55,19 @@ public class TestCoordChangeXCommand ext
         super.tearDown();
     }
 
+    /**
+     * Testing the Coordinator Change Commands with different combination of
+     * "Change Value"
+     * Changing the end time to be 20 minutes after the current time
+     * Changing the pause time to be 10 minutes after the current time
+     *
+     * @throws Exception
+     */
+
     public void testCoordChangeXCommand() throws StoreException, CommandException {
         System.out.println("Running Test");
         String jobId = "0000000-" + new Date().getTime() + "-testCoordChangeXCommand-C";
-        // CoordinatorStore store = Services.get().get(StoreService.class).getStore(CoordinatorStore.class);
+
         try {
             addRecordToJobTable(jobId);
         }
@@ -66,37 +75,41 @@ public class TestCoordChangeXCommand ext
             ex.printStackTrace();
             fail("Exception thrown " + ex);
         }
-        new CoordChangeXCommand(jobId, "endtime=2011-12-01T05:00Z;concurrency=200").call();
+
+        String pauseTime = DateUtils.convertDateToString(new Date().getTime() + 10 * 60 * 1000);
+        String endTime = DateUtils.convertDateToString(new Date().getTime() + 20 * 60 * 1000);
+
+        new CoordChangeXCommand(jobId, "endtime=" + endTime + ";concurrency=200").call();
         try {
-            checkCoordJobs(jobId, DateUtils.parseDateUTC("2011-12-01T05:00Z"), 200, null, false);
+            checkCoordJobs(jobId, DateUtils.parseDateUTC(endTime), 200, null, false);
         }
         catch (Exception ex) {
             ex.printStackTrace();
             fail("Invalid date" + ex);
         }
 
-        new CoordChangeXCommand(jobId, "endtime=2011-12-01T05:00Z;concurrency=200;pausetime=2011-11-01T05:00Z").call();
+        String changeValue = "endtime=" + endTime + ";concurrency=200;pausetime=" + pauseTime;
+        new CoordChangeXCommand(jobId, changeValue).call();
         try {
-            checkCoordJobs(jobId, DateUtils.parseDateUTC("2011-12-01T05:00Z"), 200, DateUtils
-                    .parseDateUTC("2011-11-01T05:00Z"), true);
+            checkCoordJobs(jobId, DateUtils.parseDateUTC(endTime), 200, DateUtils.parseDateUTC(pauseTime), true);
         }
         catch (Exception ex) {
             ex.printStackTrace();
             fail("Invalid date" + ex);
         }
 
-        new CoordChangeXCommand(jobId, "endtime=2011-12-01T05:00Z;concurrency=200;pausetime=").call();
+        new CoordChangeXCommand(jobId, "endtime=" + endTime + ";concurrency=200;pausetime=").call();
         try {
-            checkCoordJobs(jobId, DateUtils.parseDateUTC("2011-12-01T05:00Z"), 200, null, true);
+            checkCoordJobs(jobId, DateUtils.parseDateUTC(endTime), 200, null, true);
         }
         catch (Exception ex) {
             ex.printStackTrace();
             fail("Invalid date" + ex);
         }
 
-        new CoordChangeXCommand(jobId, "endtime=2011-12-01T05:00Z;pausetime=;concurrency=200").call();
+        new CoordChangeXCommand(jobId, "endtime=" + endTime + ";pausetime=;concurrency=200").call();
         try {
-            checkCoordJobs(jobId, DateUtils.parseDateUTC("2011-12-01T05:00Z"), 200, null, true);
+            checkCoordJobs(jobId, DateUtils.parseDateUTC(endTime), 200, null, true);
         }
         catch (Exception ex) {
             ex.printStackTrace();
@@ -212,19 +225,27 @@ public class TestCoordChangeXCommand ext
     }
 
     /**
-     * test end time change : pending should mark false if job is running with pending true
+     * test end time change : pending should mark false if job is running with
+     * pending true
+     * Changing the end time to be 40 minutes after the current time
+     * Changing the pause time to be 10 minutes after the current time
      *
      * @throws Exception
      */
     public void testCoordChangeEndTime() throws Exception {
-        Date start = DateUtils.parseDateUTC("2011-02-01T01:00Z");
-        Date end = DateUtils.parseDateUTC("2011-02-20T23:59Z");
-        final CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, true, true, 0);
+        Date startTime = new Date();
+        Date endTime = new Date(startTime.getTime() + (20 * 60 * 1000));
+
+        final CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime,
+                true, true, 0);
+
+        String pauseTime = DateUtils.convertDateToString(startTime.getTime() + 10 * 60 * 1000);
+        String newEndTime = DateUtils.convertDateToString(startTime.getTime() + 40 * 60 * 1000);
 
-        new CoordChangeXCommand(job.getId(), "endtime=2012-12-01T05:00Z;pausetime=2011-11-01T05:00Z").call();
+        new CoordChangeXCommand(job.getId(), "endtime=" + newEndTime + ";pausetime=" + pauseTime).call();
         try {
-            checkCoordJobs(job.getId(), DateUtils.parseDateUTC("2012-12-01T05:00Z"), null, DateUtils
-                    .parseDateUTC("2011-11-01T05:00Z"), true);
+            checkCoordJobs(job.getId(), DateUtils.parseDateUTC(newEndTime), null, DateUtils.parseDateUTC(pauseTime),
+                    true);
         }
         catch (Exception ex) {
             ex.printStackTrace();
@@ -239,8 +260,8 @@ public class TestCoordChangeXCommand ext
     }
 
     /**
-     * test pause time change : pending should mark false if job is running with pending true.
-     * two actions should be removed for pause time changes.
+     * test pause time change : pending should mark false if job is running with
+     * pending true. two actions should be removed for pause time changes.
      *
      * @throws Exception
      */
@@ -248,7 +269,7 @@ public class TestCoordChangeXCommand ext
         Date start = new Date();
         Date end = new Date(start.getTime() + (20 * 60 * 1000));
         Date pauseTime = new Date(start.getTime() + (10 * 60 * 1000));
-        String pauseTimeChangeStr = "pausetime="+ DateUtils.convertDateToString(pauseTime);
+        String pauseTimeChangeStr = "pausetime=" + DateUtils.convertDateToString(pauseTime);
         final CoordinatorJobBean job = addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status.RUNNING, start,
                 end, end, true, false, 4);
         addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
@@ -264,7 +285,8 @@ public class TestCoordChangeXCommand ext
         assertEquals(Job.Status.RUNNING, coordJob.getStatus());
         assertEquals(2, coordJob.getLastActionNumber());
 
-        CoordinatorActionBean actionBean = jpaService.execute(new CoordJobGetActionByActionNumberJPAExecutor(job.getId(), 3));
+        CoordinatorActionBean actionBean = jpaService.execute(new CoordJobGetActionByActionNumberJPAExecutor(job
+                .getId(), 3));
         assertNull(actionBean);
 
         actionBean = jpaService.execute(new CoordJobGetActionByActionNumberJPAExecutor(job.getId(), 4));
@@ -409,12 +431,14 @@ public class TestCoordChangeXCommand ext
                 Date d = job.getPauseTime();
                 if (pauseTime == null) {
                     if (d != null) {
-                        fail("Pausetime is not updated properly job_pause_time=" + d + ", expected_pause_time=" + pauseTime);
+                        fail("Pausetime is not updated properly job_pause_time=" + d + ", expected_pause_time="
+                                + pauseTime);
                     }
                 }
                 else {
                     if (d.compareTo(pauseTime) != 0) {
-                        fail("Pausetime is not updated properly job_pause_time=" + d + ", expected_pause_time=" + pauseTime);
+                        fail("Pausetime is not updated properly job_pause_time=" + d + ", expected_pause_time="
+                                + pauseTime);
                     }
                 }
             }

Modified: incubator/oozie/trunk/release-log.txt
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1205621&r1=1205620&r2=1205621&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Wed Nov 23 21:57:06 2011
@@ -1,5 +1,6 @@
 -- Oozie 3.2.0 release
 
+OOZIE-608 Fix test failure for testCoordChangeXCommand, testCoordChangeEndTime Unit
 OOZIE-610 Oozie system share lib should have jars per action type. (tucu)
 OOZIE-565 Make Oozie compile against Hadoop 0.23. (tucu)
 OOZIE-609 Oozie services fail to start with log enabled. (tucu)