helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject [20/33] helix git commit: Add job dependency workflow test 1. Add an option to enable number of partion varies in TaskTestBase 2. Add new test for workflow test for parallel jobs testing.
Date Wed, 17 Aug 2016 04:27:16 GMT
Add job dependency workflow test
1. Add an option to enable number of partion varies in TaskTestBase
2. Add new test for workflow test for parallel jobs testing.


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

Branch: refs/heads/helix-0.6.x
Commit: ddc11f9aca9e3e525d517860006e1d5cbb91ddd4
Parents: be78a4f
Author: Junkai Xue <jxue@linkedin.com>
Authored: Wed Apr 20 16:33:50 2016 -0700
Committer: Lei Xia <lxia@linkedin.com>
Committed: Tue Jul 5 15:57:59 2016 -0700

----------------------------------------------------------------------
 .../helix/integration/task/TaskTestBase.java    | 24 +++++-
 .../task/TestWorkflowJobDependency.java         | 88 ++++++++++++++++++++
 2 files changed, 111 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/ddc11f9a/helix-core/src/test/java/org/apache/helix/integration/task/TaskTestBase.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/task/TaskTestBase.java
b/helix-core/src/test/java/org/apache/helix/integration/task/TaskTestBase.java
index 50baa14..d6cf9bd 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/task/TaskTestBase.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/task/TaskTestBase.java
@@ -1,5 +1,24 @@
 package org.apache.helix.integration.task;
 
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -31,6 +50,8 @@ public class TaskTestBase extends ZkIntegrationTestBase {
   protected int _numReplicas = 3;
   protected int _numDbs = 1;
 
+  protected Boolean _partitionVary = true;
+
   protected ClusterControllerManager _controller;
 
   protected HelixManager _manager;
@@ -60,9 +81,10 @@ public class TaskTestBase extends ZkIntegrationTestBase {
     // Set up target db
     if (_numDbs > 1) {
       for (int i = 0; i < _numDbs; i++) {
+        int varyNum = _partitionVary == true ? 10 * i : 0;
         String db = WorkflowGenerator.DEFAULT_TGT_DB + i;
         _setupTool
-            .addResourceToCluster(CLUSTER_NAME, db, _numParitions + 10 * i, MASTER_SLAVE_STATE_MODEL,
+            .addResourceToCluster(CLUSTER_NAME, db, _numParitions + varyNum, MASTER_SLAVE_STATE_MODEL,
                 IdealState.RebalanceMode.FULL_AUTO.toString());
         _setupTool.rebalanceStorageCluster(CLUSTER_NAME, db, _numReplicas);
         _testDbs.add(db);

http://git-wip-us.apache.org/repos/asf/helix/blob/ddc11f9a/helix-core/src/test/java/org/apache/helix/integration/task/TestWorkflowJobDependency.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/task/TestWorkflowJobDependency.java
b/helix-core/src/test/java/org/apache/helix/integration/task/TestWorkflowJobDependency.java
new file mode 100644
index 0000000..1ced40b
--- /dev/null
+++ b/helix-core/src/test/java/org/apache/helix/integration/task/TestWorkflowJobDependency.java
@@ -0,0 +1,88 @@
+package org.apache.helix.integration.task;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.helix.TestHelper;
+import org.apache.helix.task.JobConfig;
+import org.apache.helix.task.JobContext;
+import org.apache.helix.task.TaskState;
+import org.apache.helix.task.Workflow;
+import org.apache.helix.task.WorkflowContext;
+import org.apache.log4j.Logger;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Sets;
+
+public class TestWorkflowJobDependency extends TaskTestBase {
+  private static final Logger LOG = Logger.getLogger(TestWorkflowJobDependency.class);
+
+  @BeforeClass
+  public void beforeClass() throws Exception {
+    _numDbs = 5;
+    _numParitions = 1;
+    _partitionVary = false;
+    super.beforeClass();
+  }
+
+  @Test (enabled = false)
+  public void testWorkflowWithOutDependencies() throws InterruptedException {
+    String workflowName = TestHelper.getTestMethodName();
+
+    // Workflow setup
+    LOG.info("Start setup for workflow: " + workflowName);
+    Workflow.Builder builder = new Workflow.Builder(workflowName);
+
+    for (int i = 0; i < _numDbs; i++) {
+      // Let each job delay for 2 secs.
+      JobConfig.Builder jobConfig = new JobConfig.Builder().setCommand(MockTask.TASK_COMMAND)
+          .setTargetResource(_testDbs.get(i)).setTargetPartitionStates(Sets.newHashSet("SLAVE","MASTER"))
+          .setJobCommandConfigMap(WorkflowGenerator.DEFAULT_COMMAND_CONFIG);
+      String jobName = "job" + _testDbs.get(i);
+      builder.addJob(jobName, jobConfig);
+    }
+
+    // Start workflow
+    Workflow workflow = builder.build();
+    _driver.start(workflow);
+
+    // Wait until the workflow completes
+    TaskTestUtil.pollForWorkflowState(_driver, workflowName, TaskState.COMPLETED);
+    WorkflowContext workflowContext = _driver.getWorkflowContext(workflowName);
+    long startTime = workflowContext.getStartTime();
+    long finishTime = workflowContext.getFinishTime();
+
+    // Update the start time range.
+    for (String jobName : workflow.getJobConfigs().keySet()) {
+      JobContext context = _driver.getJobContext(jobName);
+      LOG.info(String
+          .format("JOB: %s starts from %s finishes at %s.", jobName, context.getStartTime(),
+              context.getFinishTime()));
+
+      // Find job start time range.
+      startTime = Math.max(context.getStartTime(), startTime);
+      finishTime = Math.min(context.getFinishTime(), finishTime);
+    }
+
+    // All jobs have a valid overlap time range.
+    Assert.assertTrue(startTime <= finishTime);
+  }
+}


Mime
View raw message