You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by al...@apache.org on 2020/09/16 03:53:15 UTC

[helix] branch master updated: Stabilize TestEnqueueJobs (#1346)

This is an automated email from the ASF dual-hosted git repository.

alizamus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/master by this push:
     new c7a5000  Stabilize TestEnqueueJobs  (#1346)
c7a5000 is described below

commit c7a50003d454b12878aa37795008fa1ef1e144da
Author: Ali Reza Zamani Zadeh Najari <an...@linkedin.com>
AuthorDate: Tue Sep 15 20:53:09 2020 -0700

    Stabilize TestEnqueueJobs  (#1346)
    
    In this commit, TestEnqueueJobs has been stabilized by stopping
    the queue before enqueuing a job and resuming it afterward.
    Also, instead of adding the jobs one by one, the batch job addition
    has been used.
---
 .../helix/integration/task/TestEnqueueJobs.java    | 39 +++++++++++++++++++---
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/helix-core/src/test/java/org/apache/helix/integration/task/TestEnqueueJobs.java b/helix-core/src/test/java/org/apache/helix/integration/task/TestEnqueueJobs.java
index d135e96..762864f 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/task/TestEnqueueJobs.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/task/TestEnqueueJobs.java
@@ -19,7 +19,9 @@ package org.apache.helix.integration.task;
  * under the License.
  */
 
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.List;
 import org.apache.helix.TestHelper;
 import org.apache.helix.integration.manager.ClusterControllerManager;
 import org.apache.helix.task.JobConfig;
@@ -75,10 +77,19 @@ public class TestEnqueueJobs extends TaskTestBase {
     JobConfig.Builder jobBuilder =
         new JobConfig.Builder().setTargetResource(WorkflowGenerator.DEFAULT_TGT_DB)
             .setCommand(MockTask.TASK_COMMAND).setMaxAttemptsPerTask(2);
+
+    List<String> jobNames = new ArrayList<>();
+    List<JobConfig.Builder> jobBuilders = new ArrayList<>();
+
     _driver.waitToStop(queueName, 5000L);
+
     for (int i = 0; i < 5; i++) {
-      _driver.enqueueJob(queueName, "JOB" + i, jobBuilder);
+      jobNames.add("JOB" + i);
+      jobBuilders.add(jobBuilder);
     }
+    // Add jobs as batch to the queue
+    _driver.enqueueJobs(queueName, jobNames, jobBuilders);
+
     _driver.resume(queueName);
 
     _driver.pollForJobState(queueName, TaskUtil.getNamespacedJobName(queueName, "JOB" + 4),
@@ -135,10 +146,18 @@ public class TestEnqueueJobs extends TaskTestBase {
             .setCommand(MockTask.TASK_COMMAND).setMaxAttemptsPerTask(2)
             .setJobCommandConfigMap(Collections.singletonMap(MockTask.JOB_DELAY, "10000"));
 
+    _driver.waitToStop(queueName, 5000L);
+
     // Add 4 jobs to the queue
+    List<String> jobNames = new ArrayList<>();
+    List<JobConfig.Builder> jobBuilders = new ArrayList<>();
     for (int i = 0; i < numberOfJobsAddedBeforeControllerSwitch; i++) {
-      _driver.enqueueJob(queueName, "JOB" + i, jobBuilder);
+      jobNames.add("JOB" + i);
+      jobBuilders.add(jobBuilder);
     }
+    _driver.enqueueJobs(queueName, jobNames, jobBuilders);
+
+    _driver.resume(queueName);
 
     // Wait until all of the enqueued jobs (Job0 to Job3) are finished
     for (int i = 0; i < numberOfJobsAddedBeforeControllerSwitch; i++) {
@@ -150,9 +169,13 @@ public class TestEnqueueJobs extends TaskTestBase {
     _controller.syncStop();
 
     // Add 3 more jobs to the queue which should run in parallel after the Controller is started
+    jobNames.clear();
+    jobBuilders.clear();
     for (int i = numberOfJobsAddedBeforeControllerSwitch; i < totalNumberOfJobs; i++) {
-      _driver.enqueueJob(queueName, "JOB" + i, jobBuilder);
+      jobNames.add("JOB" + i);
+      jobBuilders.add(jobBuilder);
     }
+    _driver.enqueueJobs(queueName, jobNames, jobBuilders);
 
     // Start the Controller
     String controllerName = CONTROLLER_PREFIX + "_0";
@@ -195,10 +218,18 @@ public class TestEnqueueJobs extends TaskTestBase {
             .setCommand(MockTask.TASK_COMMAND).setMaxAttemptsPerTask(2)
             .setJobCommandConfigMap(Collections.singletonMap(MockTask.JOB_DELAY, "1000"));
 
+    _driver.waitToStop(queueName, 5000L);
+
     // Add 4 jobs to the queue
+    List<String> jobNames = new ArrayList<>();
+    List<JobConfig.Builder> jobBuilders = new ArrayList<>();
     for (int i = 0; i < numberOfJobsAddedInitially; i++) {
-      _driver.enqueueJob(queueName, "JOB" + i, jobBuilder);
+      jobNames.add("JOB" + i);
+      jobBuilders.add(jobBuilder);
     }
+    _driver.enqueueJobs(queueName, jobNames, jobBuilders);
+
+    _driver.resume(queueName);
 
     // Wait until all of the enqueued jobs (Job0 to Job3) are finished
     for (int i = 0; i < numberOfJobsAddedInitially; i++) {