You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/08/28 22:13:28 UTC

[GitHub] [helix] NealSun96 commented on a change in pull request #1329: Continue task pipeline if currentState is null

NealSun96 commented on a change in pull request #1329:
URL: https://github.com/apache/helix/pull/1329#discussion_r479555816



##########
File path: helix-core/src/test/java/org/apache/helix/integration/task/TestTaskCurrentStateNull.java
##########
@@ -0,0 +1,122 @@
+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.Map;
+import org.apache.helix.AccessOption;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.TestHelper;
+import org.apache.helix.ZkTestHelper;
+import org.apache.helix.model.CurrentState;
+import org.apache.helix.task.JobConfig;
+import org.apache.helix.task.TaskState;
+import org.apache.helix.task.TaskUtil;
+import org.apache.helix.task.Workflow;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.helix.zookeeper.impl.client.ZkClient;
+import org.apache.zookeeper.data.Stat;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * This test makes sure that controller will not be blocked if there exists null current states.
+ */
+public class TestTaskCurrentStateNull extends TaskTestBase {
+  protected HelixDataAccessor _accessor;
+
+  @BeforeClass
+  public void beforeClass() throws Exception {
+    _numPartitions = 1;
+    _numNodes = 1;
+    super.beforeClass();
+  }
+
+  @AfterClass()
+  public void afterClass() throws Exception {
+    super.afterClass();
+  }
+
+  @Test
+  public void testCurrentStateNull() throws Exception {
+    String workflowName1 = TestHelper.getTestMethodName() + "_1";
+    String workflowName2 = TestHelper.getTestMethodName() + "_2";
+
+    Workflow.Builder builder1 = new Workflow.Builder(workflowName1);
+    Workflow.Builder builder2 = new Workflow.Builder(workflowName2);
+
+    JobConfig.Builder jobBuilder1 = new JobConfig.Builder().setWorkflow(workflowName1)
+        .setNumberOfTasks(5).setNumConcurrentTasksPerInstance(100).setCommand(MockTask.TASK_COMMAND)
+        .setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "10000"));
+
+    JobConfig.Builder jobBuilder2 = new JobConfig.Builder().setWorkflow(workflowName2)
+        .setNumberOfTasks(1).setNumConcurrentTasksPerInstance(100).setCommand(MockTask.TASK_COMMAND)
+        .setJobCommandConfigMap(ImmutableMap.of(MockTask.JOB_DELAY, "10000"));
+
+    builder1.addJob("JOB0", jobBuilder1);
+    builder2.addJob("JOB0", jobBuilder2);
+
+    _driver.start(builder1.build());
+    _driver.start(builder2.build());
+
+    String namespacedJobName1 = TaskUtil.getNamespacedJobName(workflowName1, "JOB0");
+    String namespacedJobName2 = TaskUtil.getNamespacedJobName(workflowName2, "JOB0");
+
+    _driver.pollForJobState(workflowName1, namespacedJobName1, TaskState.IN_PROGRESS);
+    _driver.pollForJobState(workflowName2, namespacedJobName2, TaskState.IN_PROGRESS);
+
+    // Get the current states of Participant0
+    String instanceP0 = PARTICIPANT_PREFIX + "_" + (_startPort + 0);
+    ZkClient clientP0 = (ZkClient) _participants[0].getZkClient();
+    String sessionIdP0 = ZkTestHelper.getSessionId(clientP0);
+    String jobCurrentStatePath1 = "/" + CLUSTER_NAME + "/INSTANCES/" + instanceP0
+        + "/CURRENTSTATES/" + sessionIdP0 + "/" + namespacedJobName1;
+    String jobCurrentStatePath2 = "/" + CLUSTER_NAME + "/INSTANCES/" + instanceP0
+        + "/CURRENTSTATES/" + sessionIdP0 + "/" + namespacedJobName2;
+
+    // Read the current states of Participant0 and make sure they have been created
+    boolean isCurrentStateCreated = TestHelper.verify(() -> {
+      ZNRecord recordJob1 = _manager.getHelixDataAccessor().getBaseDataAccessor()
+          .get(jobCurrentStatePath1, new Stat(), AccessOption.PERSISTENT);
+      ZNRecord recordJob2 = _manager.getHelixDataAccessor().getBaseDataAccessor()
+          .get(jobCurrentStatePath2, new Stat(), AccessOption.PERSISTENT);
+      ZNRecord recordTask = _manager.getHelixDataAccessor().getBaseDataAccessor()

Review comment:
       This is the same as recordJob2?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org