helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject [09/33] helix git commit: Fix task framework unit test failure.
Date Wed, 17 Aug 2016 04:27:05 GMT
Fix task framework unit test failure.


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/1dad0b80
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/1dad0b80
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/1dad0b80

Branch: refs/heads/helix-0.6.x
Commit: 1dad0b805338a8dae72e0661ac1a803b30808623
Parents: be66024
Author: Lei Xia <lxia@linkedin.com>
Authored: Mon Mar 7 15:15:10 2016 -0800
Committer: Lei Xia <lxia@linkedin.com>
Committed: Tue Jul 5 14:45:18 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/helix/task/WorkflowContext.java    | 13 +++++++++++++
 .../apache/helix/integration/task/TaskTestUtil.java    |  3 ++-
 .../integration/task/TestRunJobsWithMissingTarget.java |  9 ++++-----
 3 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/1dad0b80/helix-core/src/main/java/org/apache/helix/task/WorkflowContext.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/task/WorkflowContext.java b/helix-core/src/main/java/org/apache/helix/task/WorkflowContext.java
index 5fc7e66..0e0a283 100644
--- a/helix-core/src/main/java/org/apache/helix/task/WorkflowContext.java
+++ b/helix-core/src/main/java/org/apache/helix/task/WorkflowContext.java
@@ -19,6 +19,7 @@ package org.apache.helix.task;
  * under the License.
  */
 
+import java.util.HashMap;
 import java.util.Map;
 import java.util.TreeMap;
 
@@ -82,6 +83,18 @@ public class WorkflowContext extends HelixProperty {
     return TaskState.valueOf(s);
   }
 
+  public Map<String, TaskState> getJobStates() {
+    Map<String, TaskState> jobStates = new HashMap<String, TaskState>();
+    Map<String, String> stateFieldMap = _record.getMapField(JOB_STATES);
+    if (stateFieldMap != null) {
+      for (Map.Entry<String, String> state : stateFieldMap.entrySet()) {
+        jobStates.put(state.getKey(), TaskState.valueOf(state.getValue()));
+      }
+    }
+
+    return jobStates;
+  }
+
   public void setStartTime(long t) {
     _record.setSimpleField(START_TIME, String.valueOf(t));
   }

http://git-wip-us.apache.org/repos/asf/helix/blob/1dad0b80/helix-core/src/test/java/org/apache/helix/integration/task/TaskTestUtil.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/task/TaskTestUtil.java
b/helix-core/src/test/java/org/apache/helix/integration/task/TaskTestUtil.java
index 011f532..422ec88 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/task/TaskTestUtil.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/task/TaskTestUtil.java
@@ -112,7 +112,8 @@ public class TaskTestUtil {
     Assert.assertNotNull(ctx, "Empty job context");
     TaskState jobState = ctx.getJobState(jobName);
     Assert.assertTrue(allowedStates.contains(jobState),
-        "expect job states: " + allowedStates + " actual job state: " + jobState);
+        "expect job " + jobName + " is in states: " + allowedStates + " actual job state:
"
+            + jobState + " all other job states in the workflow: " + ctx.getJobStates().entrySet());
   }
 
   public static void pollForEmptyJobState(final TaskDriver driver, final String workflowName,

http://git-wip-us.apache.org/repos/asf/helix/blob/1dad0b80/helix-core/src/test/java/org/apache/helix/integration/task/TestRunJobsWithMissingTarget.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/task/TestRunJobsWithMissingTarget.java
b/helix-core/src/test/java/org/apache/helix/integration/task/TestRunJobsWithMissingTarget.java
index 7eeb3f4..bd05f81 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/task/TestRunJobsWithMissingTarget.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/task/TestRunJobsWithMissingTarget.java
@@ -162,17 +162,17 @@ public class TestRunJobsWithMissingTarget extends ZkIntegrationTestBase
{
       currentJobNames.add(jobName);
     }
 
-    _setupTool.dropResourceFromCluster(CLUSTER_NAME, _test_dbs.get(2));
+    _setupTool.dropResourceFromCluster(CLUSTER_NAME, _test_dbs.get(1));
     _driver.start(queueBuilder.build());
 
-    String namedSpaceJob = String.format("%s_%s", queueName, currentJobNames.get(2));
+    String namedSpaceJob = String.format("%s_%s", queueName, currentJobNames.get(1));
     TaskTestUtil.pollForJobState(_driver, queueName, namedSpaceJob, TaskState.FAILED);
     TaskTestUtil.pollForWorkflowState(_driver, queueName, TaskState.FAILED);
 
     _driver.delete(queueName);
   }
 
-  @Test
+  @Test(dependsOnMethods = "testJobFailsWithMissingTarget")
   public void testJobContinueUponParentJobFailure() throws Exception {
     String queueName = TestHelper.getTestMethodName();
 
@@ -191,7 +191,6 @@ public class TestRunJobsWithMissingTarget extends ZkIntegrationTestBase
{
     }
 
     _driver.start(queueBuilder.build());
-    _setupTool.dropResourceFromCluster(CLUSTER_NAME, _test_dbs.get(1));
 
     String namedSpaceJob1 = String.format("%s_%s", queueName, currentJobNames.get(1));
     TaskTestUtil.pollForJobState(_driver, queueName, namedSpaceJob1, TaskState.FAILED);
@@ -202,7 +201,7 @@ public class TestRunJobsWithMissingTarget extends ZkIntegrationTestBase
{
     _driver.delete(queueName);
   }
 
-  @Test
+  @Test(dependsOnMethods = "testJobContinueUponParentJobFailure")
   public void testJobFailsWithMissingTargetInRunning() throws Exception {
     String queueName = TestHelper.getTestMethodName();
 


Mime
View raw message