FALCON-1044 FALCON-1044 Add tests for the change that start and end are 
compulsory parameters for
   all instance POST apis. Contributed by Karishma G


Project: http://git-wip-us.apache.org/repos/asf/falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/falcon/commit/08c213fc
Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/08c213fc
Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/08c213fc

Branch: refs/heads/master
Commit: 08c213fc6a59d3f9dc32d2e64c2dcfc24504428a
Parents: 87bff1f
Author: samarthg <[email protected]>
Authored: Wed Feb 25 10:56:00 2015 +0530
Committer: samarthg <[email protected]>
Committed: Wed Feb 25 10:56:00 2015 +0530

----------------------------------------------------------------------
 falcon-regression/CHANGES.txt                   |  3 +
 .../regression/ProcessInstanceKillsTest.java    | 63 ++++++++++++++++-
 .../regression/ProcessInstanceRerunTest.java    | 73 ++++++++++++++++++++
 .../regression/ProcessInstanceResumeTest.java   | 32 +++++++++
 .../regression/ProcessInstanceSuspendTest.java  | 23 +++++-
 5 files changed, 191 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/08c213fc/falcon-regression/CHANGES.txt
----------------------------------------------------------------------
diff --git a/falcon-regression/CHANGES.txt b/falcon-regression/CHANGES.txt
index fc3ae50..234f52f 100644
--- a/falcon-regression/CHANGES.txt
+++ b/falcon-regression/CHANGES.txt
@@ -46,6 +46,9 @@ Trunk (Unreleased)
    via Samarth Gupta)
 
   IMPROVEMENTS
+
+   FALCON-1044 Add tests for the change that start and end are compulsory 
parameters for 
+   all instance POST apis.(Karishma G via Samarth)
    
    FALCON-1034 Add test for FALCON-677 - wherein feed data and stats paths no 
longer default
    to /tmp/.(Karishma G via Samarth Gupta)

http://git-wip-us.apache.org/repos/asf/falcon/blob/08c213fc/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceKillsTest.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceKillsTest.java
 
b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceKillsTest.java
index 231a9ca..34dfce3 100644
--- 
a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceKillsTest.java
+++ 
b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceKillsTest.java
@@ -21,6 +21,7 @@ package org.apache.falcon.regression;
 import org.apache.falcon.regression.core.bundle.Bundle;
 import org.apache.falcon.entity.v0.EntityType;
 import org.apache.falcon.entity.v0.Frequency.TimeUnit;
+import org.apache.falcon.regression.core.enumsAndConstants.ResponseErrors;
 import org.apache.falcon.regression.core.helpers.ColoHelper;
 import org.apache.falcon.regression.core.util.TimeUtil;
 import org.apache.falcon.regression.core.util.HadoopUtil;
@@ -91,7 +92,7 @@ public class ProcessInstanceKillsTest extends BaseTestClass {
     }
 
     /**
-     * Schedule process. Perform -kill action using only -start parameter. 
Check that action
+     * Schedule process. Perform -kill action for only one instance. Check 
that action
      * succeeded and only one instance was killed.
      *
      * @throws Exception
@@ -310,4 +311,64 @@ public class ProcessInstanceKillsTest extends 
BaseTestClass {
                 "?start=2010-01-02T01:00Z&end=2010-01-02T01:04Z");
         InstanceUtil.validateSuccess(r, bundles[0], WorkflowStatus.SUCCEEDED);
     }
+
+    /**
+     * Schedule process. Perform -kill action using only -start parameter. 
Check that action
+     * succeeded and only one instance was killed.
+     *
+     * @throws Exception
+     */
+    @Test(groups = {"singleCluster"})
+    public void testProcessInstanceKillWOEndParam() throws Exception {
+        bundles[0].setProcessValidity("2010-01-02T01:00Z", 
"2010-01-02T01:04Z");
+        bundles[0].setProcessConcurrency(1);
+        bundles[0].submitFeedsScheduleProcess(prism);
+        InstanceUtil.waitTillInstancesAreCreated(cluster, 
bundles[0].getProcessData(), 0);
+        OozieUtil.createMissingDependencies(cluster, EntityType.PROCESS, 
processName, 0);
+        InstanceUtil.waitTillInstanceReachState(clusterOC, processName, 1,
+                CoordinatorAction.Status.RUNNING, EntityType.PROCESS, 5);
+        InstancesResult r = 
prism.getProcessHelper().getProcessInstanceKill(processName,
+                "?start=2010-01-02T01:00Z");
+        InstanceUtil.validateError(r, ResponseErrors.UNPARSEABLE_DATE);
+    }
+
+    /**
+     * Schedule process. Perform -kill action using only -end parameter. Check 
that action
+     * succeeded and only one instance was killed.
+     *
+     * @throws Exception
+     */
+    @Test(groups = {"singleCluster"})
+    public void testProcessInstanceKillWOStartParam() throws Exception {
+        bundles[0].setProcessValidity("2010-01-02T01:00Z", 
"2010-01-02T01:04Z");
+        bundles[0].setProcessConcurrency(1);
+        bundles[0].submitFeedsScheduleProcess(prism);
+        InstanceUtil.waitTillInstancesAreCreated(cluster, 
bundles[0].getProcessData(), 0);
+        OozieUtil.createMissingDependencies(cluster, EntityType.PROCESS, 
processName, 0);
+        InstanceUtil.waitTillInstanceReachState(clusterOC, processName, 1,
+                CoordinatorAction.Status.RUNNING, EntityType.PROCESS, 5);
+        InstancesResult r = 
prism.getProcessHelper().getProcessInstanceKill(processName,
+                "?end=2010-01-02T01:01Z");
+        InstanceUtil.validateError(r, ResponseErrors.UNPARSEABLE_DATE);
+    }
+
+    /**
+     * Schedule process. Perform -kill action without start or end params. 
Check that action
+     * succeeded and only one instance was killed.
+     *
+     * @throws Exception
+     */
+    @Test(groups = {"singleCluster"})
+    public void testProcessInstanceKillWOParams() throws Exception {
+        bundles[0].setProcessValidity("2010-01-02T01:00Z", 
"2010-01-02T01:04Z");
+        bundles[0].setProcessConcurrency(1);
+        bundles[0].submitFeedsScheduleProcess(prism);
+        InstanceUtil.waitTillInstancesAreCreated(cluster, 
bundles[0].getProcessData(), 0);
+        OozieUtil.createMissingDependencies(cluster, EntityType.PROCESS, 
processName, 0);
+        InstanceUtil.waitTillInstanceReachState(clusterOC, processName, 1,
+                CoordinatorAction.Status.RUNNING, EntityType.PROCESS, 5);
+        InstancesResult r = 
prism.getProcessHelper().getProcessInstanceKill(processName,
+                null);
+        InstanceUtil.validateError(r, ResponseErrors.UNPARSEABLE_DATE);
+    }
 }

http://git-wip-us.apache.org/repos/asf/falcon/blob/08c213fc/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceRerunTest.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceRerunTest.java
 
b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceRerunTest.java
index 1b1b6ca..0ae9f6f 100644
--- 
a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceRerunTest.java
+++ 
b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceRerunTest.java
@@ -21,6 +21,7 @@ package org.apache.falcon.regression;
 import org.apache.falcon.regression.core.bundle.Bundle;
 import org.apache.falcon.entity.v0.EntityType;
 import org.apache.falcon.entity.v0.Frequency.TimeUnit;
+import org.apache.falcon.regression.core.enumsAndConstants.ResponseErrors;
 import org.apache.falcon.regression.core.helpers.ColoHelper;
 import org.apache.falcon.regression.core.util.InstanceUtil;
 import org.apache.falcon.regression.core.util.OozieUtil;
@@ -115,6 +116,78 @@ public class ProcessInstanceRerunTest extends 
BaseTestClass {
     }
 
     /**
+     * Schedule process. Kill some instances. Rerun some of these killed 
without using -start or
+     * -end parameters. Should fail.
+     *
+     * @throws Exception
+     */
+    @Test(groups = {"singleCluster"})
+    public void testProcessInstanceRerunKilledWOParams() throws Exception {
+        bundles[0].setProcessValidity("2010-01-02T01:00Z", 
"2010-01-02T01:26Z");
+        bundles[0].setOutputFeedLocationData(feedOutputPath);
+        bundles[0].setProcessConcurrency(5);
+        bundles[0].submitFeedsScheduleProcess(prism);
+        InstanceUtil.waitTillInstancesAreCreated(cluster, 
bundles[0].getProcessData(), 0);
+        OozieUtil.createMissingDependencies(cluster, EntityType.PROCESS, 
processName, 0);
+        InstanceUtil.waitTillInstanceReachState(clusterOC, processName, 5,
+                CoordinatorAction.Status.RUNNING, EntityType.PROCESS, 5);
+        InstancesResult r = 
prism.getProcessHelper().getProcessInstanceKill(processName,
+                start + "&end=2010-01-02T01:16Z");
+        InstanceUtil.validateResponse(r, 4, 0, 0, 0, 4);
+        r = prism.getProcessHelper().getProcessInstanceRerun(processName,
+                null);
+        InstanceUtil.validateError(r, ResponseErrors.UNPARSEABLE_DATE);
+    }
+
+    /**
+     * Schedule process. Kill some instances. Rerun some of these killed using 
only
+     * -end parameter. Should fail.
+     *
+     * @throws Exception
+     */
+    @Test(groups = {"singleCluster"})
+    public void testProcessInstanceRerunKilledWOStartParam() throws Exception {
+        bundles[0].setProcessValidity("2010-01-02T01:00Z", 
"2010-01-02T01:26Z");
+        bundles[0].setOutputFeedLocationData(feedOutputPath);
+        bundles[0].setProcessConcurrency(5);
+        bundles[0].submitFeedsScheduleProcess(prism);
+        InstanceUtil.waitTillInstancesAreCreated(cluster, 
bundles[0].getProcessData(), 0);
+        OozieUtil.createMissingDependencies(cluster, EntityType.PROCESS, 
processName, 0);
+        InstanceUtil.waitTillInstanceReachState(clusterOC, processName, 5,
+                CoordinatorAction.Status.RUNNING, EntityType.PROCESS, 5);
+        InstancesResult r = 
prism.getProcessHelper().getProcessInstanceKill(processName,
+                start + "&end=2010-01-02T01:16Z");
+        InstanceUtil.validateResponse(r, 4, 0, 0, 0, 4);
+        r = prism.getProcessHelper().getProcessInstanceRerun(processName,
+                "?end=2010-01-02T01:11Z");
+        InstanceUtil.validateError(r, ResponseErrors.UNPARSEABLE_DATE);
+    }
+
+    /**
+     * Schedule process. Kill some instances. Rerun some of these killed using 
only
+     * -start parameter. Should fail.
+     *
+     * @throws Exception
+     */
+    @Test(groups = {"singleCluster"})
+    public void testProcessInstanceRerunKilledWOEndParam() throws Exception {
+        bundles[0].setProcessValidity("2010-01-02T01:00Z", 
"2010-01-02T01:26Z");
+        bundles[0].setOutputFeedLocationData(feedOutputPath);
+        bundles[0].setProcessConcurrency(5);
+        bundles[0].submitFeedsScheduleProcess(prism);
+        InstanceUtil.waitTillInstancesAreCreated(cluster, 
bundles[0].getProcessData(), 0);
+        OozieUtil.createMissingDependencies(cluster, EntityType.PROCESS, 
processName, 0);
+        InstanceUtil.waitTillInstanceReachState(clusterOC, processName, 5,
+                CoordinatorAction.Status.RUNNING, EntityType.PROCESS, 5);
+        InstancesResult r = 
prism.getProcessHelper().getProcessInstanceKill(processName,
+                start + "&end=2010-01-02T01:16Z");
+        InstanceUtil.validateResponse(r, 4, 0, 0, 0, 4);
+        r = prism.getProcessHelper().getProcessInstanceRerun(processName,
+                start);
+        InstanceUtil.validateError(r, ResponseErrors.UNPARSEABLE_DATE);
+    }
+
+    /**
      * Schedule process. Kill all instances. Rerun them. Check that they were 
rerun.
      *
      * @throws Exception

http://git-wip-us.apache.org/repos/asf/falcon/blob/08c213fc/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceResumeTest.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceResumeTest.java
 
b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceResumeTest.java
index ecbc08e..f558cc5 100644
--- 
a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceResumeTest.java
+++ 
b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceResumeTest.java
@@ -201,11 +201,43 @@ public class ProcessInstanceResumeTest extends 
BaseTestClass {
     @Test(groups = {"singleCluster"})
     public void testProcessInstanceResumeNoParams() throws Exception {
         bundles[0].submitFeedsScheduleProcess(prism);
+        prism.getProcessHelper().getProcessInstanceSuspend(processName,
+            "?start=2010-01-02T01:00Z&end=2010-01-02T01:15Z");
         InstancesResult r = 
prism.getProcessHelper().getProcessInstanceResume(processName, null);
         InstanceUtil.validateError(r, ResponseErrors.UNPARSEABLE_DATE);
     }
 
     /**
+     * Attempt to perform -resume action without -end parameter. Should fail 
with an
+     + appropriate status code or message.
+     *
+     * @throws Exception
+     */
+    @Test(groups = {"singleCluster"})
+    public void testProcessInstanceResumeWOEndParam() throws Exception {
+        bundles[0].submitFeedsScheduleProcess(prism);
+        prism.getProcessHelper().getProcessInstanceSuspend(processName,
+            "?start=2010-01-02T01:00Z&end=2010-01-02T01:15Z");
+        InstancesResult r = 
prism.getProcessHelper().getProcessInstanceResume(processName, 
"?start=2010-01-02T01:00Z");
+        InstanceUtil.validateError(r, ResponseErrors.UNPARSEABLE_DATE);
+    }
+
+    /**
+     * Attempt to perform -resume action without -start parameter. Should fail 
with an
+     + appropriate status code or message.
+     *
+     * @throws Exception
+     */
+    @Test(groups = {"singleCluster"})
+    public void testProcessInstanceResumeWOStartParam() throws Exception {
+        bundles[0].submitFeedsScheduleProcess(prism);
+        prism.getProcessHelper().getProcessInstanceSuspend(processName,
+            "?start=2010-01-02T01:00Z&end=2010-01-02T01:15Z");
+        InstancesResult r = 
prism.getProcessHelper().getProcessInstanceResume(processName, 
"?end=2010-01-02T01:15Z");
+        InstanceUtil.validateError(r, ResponseErrors.UNPARSEABLE_DATE);
+    }
+
+    /**
      * Schedule process, remove it. Try to -resume it's instance. Attempt 
should fail with
      * an appropriate status code.
      *

http://git-wip-us.apache.org/repos/asf/falcon/blob/08c213fc/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceSuspendTest.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceSuspendTest.java
 
b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceSuspendTest.java
index e159d78..588355a 100644
--- 
a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceSuspendTest.java
+++ 
b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/ProcessInstanceSuspendTest.java
@@ -220,8 +220,27 @@ public class ProcessInstanceSuspendTest extends 
BaseTestClass {
     }
 
     /**
-     * Schedule process with number of instances running. Perform -suspend 
action using only -start
-     * parameter with value which points to expected last time of 
instantiation. Check that only
+     * Schedule process. Perform -suspend action using only -end parameter.
+     * Should fail with appropriate status message.
+     *
+     * @throws Exception
+     */
+    @Test(groups = {"singleCluster"})
+    public void testProcessInstanceSuspendOnlyEnd() throws Exception {
+        bundles[0].setProcessValidity("2010-01-02T01:00Z", 
"2010-01-02T01:11Z");
+        bundles[0].setProcessConcurrency(3);
+        bundles[0].submitFeedsScheduleProcess(prism);
+        OozieUtil.createMissingDependencies(cluster, EntityType.PROCESS, 
processName, 0);
+        InstanceUtil.waitTillInstanceReachState(clusterOC, processName, 3,
+                CoordinatorAction.Status.RUNNING, EntityType.PROCESS, 5);
+        InstancesResult r = 
prism.getProcessHelper().getProcessInstanceSuspend(processName,
+                "?end=2010-01-02T01:05Z");
+        InstanceUtil.validateError(r, ResponseErrors.UNPARSEABLE_DATE);
+    }
+
+    /**
+     * Schedule process with a number of instances running. Perform -suspend 
action using params
+     * such that they aim to suspend the last instance. Check that only
      * the last instance is suspended.
      *
      * @throws Exception

Reply via email to