[ 
https://issues.apache.org/jira/browse/GOBBLIN-1043?focusedWorklogId=383419&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-383419
 ]

ASF GitHub Bot logged work on GOBBLIN-1043:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Feb/20 07:32
            Start Date: 07/Feb/20 07:32
    Worklog Time Spent: 10m 
      Work Description: autumnust commented on pull request #2883: 
GOBBLIN-1043: Implement a Helix assigned participant check as a Commi…
URL: https://github.com/apache/incubator-gobblin/pull/2883#discussion_r376247504
 
 

 ##########
 File path: 
gobblin-cluster/src/test/java/org/apache/gobblin/cluster/HelixAssignedParticipantCheckTest.java
 ##########
 @@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+package org.apache.gobblin.cluster;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.helix.HelixManager;
+import org.apache.helix.HelixManagerFactory;
+import org.apache.helix.InstanceType;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableMap;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
+import com.typesafe.config.ConfigValueFactory;
+
+import org.apache.gobblin.cluster.suite.IntegrationBasicSuite;
+import org.apache.gobblin.commit.CommitStepException;
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.testing.AssertWithBackoff;
+
+
+public class HelixAssignedParticipantCheckTest {
+  private IntegrationJobSuite suite;
+  private HelixManager helixManager;
+  private Config helixConfig;
+
+  @BeforeClass
+  public void setUp()
+      throws Exception {
+    //Set up a Gobblin Helix cluster
+    suite = new IntegrationJobSuite();
+
+    helixConfig = suite.getManagerConfig();
+    String clusterName = 
helixConfig.getString(GobblinClusterConfigurationKeys.HELIX_CLUSTER_NAME_KEY);
+    String zkConnectString = 
helixConfig.getString(GobblinClusterConfigurationKeys.ZK_CONNECTION_STRING_KEY);
+    helixManager = HelixManagerFactory.getZKHelixManager(clusterName, 
"TestManager",
+        InstanceType.SPECTATOR, zkConnectString);
+
+    //Connect to the previously started Helix cluster
+    helixManager.connect();
+  }
+
+  @Test (groups = {"disabledOnTravis"})
+  //Test disabled on Travis because cluster integration tests are generally 
flaky on Travis.
+  public void testExecute() throws Exception {
+    suite.startCluster();
+
+    //Ensure that Helix has created a workflow
+    AssertWithBackoff.create().maxSleepMs(1000).backoffFactor(1).
+        assertTrue(ClusterIntegrationTest.isTaskStarted(helixManager, 
IntegrationJobSuite.JOB_ID), "Waiting for the job to start...");
+
+    //Instantiate config for HelixAssignedParticipantCheck
+    String helixJobId = Joiner.on("_").join(IntegrationJobSuite.JOB_ID, 
IntegrationJobSuite.JOB_ID);
+    helixConfig = 
helixConfig.withValue(GobblinClusterConfigurationKeys.HELIX_INSTANCE_NAME_KEY,
+        ConfigValueFactory.fromAnyRef(IntegrationBasicSuite.WORKER_INSTANCE_0))
+        .withValue(GobblinClusterConfigurationKeys.HELIX_JOB_ID_KEY, 
ConfigValueFactory.fromAnyRef(helixJobId))
+        .withValue(GobblinClusterConfigurationKeys.HELIX_PARTITION_ID_KEY, 
ConfigValueFactory.fromAnyRef(0));
+    HelixAssignedParticipantCheck check = new 
HelixAssignedParticipantCheck(helixConfig);
+
+    //Ensure that the SleepingTask is running
+    
AssertWithBackoff.create().maxSleepMs(100).timeoutMs(2000).backoffFactor(1).
+        
assertTrue(ClusterIntegrationTest.isTaskRunning(IntegrationJobSuite.TASK_STATE_FILE),"Waiting
 for the task to enter running state");
+
+    //Run the check. Ensure that the configured Helix instance is indeed the 
assigned participant
+    // (i.e. no exceptions thrown).
+    check.execute();
+
+    //Create Helix config with invalid partition num. Ensure 
HelixAssignedParticipantCheck fails.
+    helixConfig = 
helixConfig.withValue(GobblinClusterConfigurationKeys.HELIX_PARTITION_ID_KEY, 
ConfigValueFactory.fromAnyRef(1));
+    check = new HelixAssignedParticipantCheck(helixConfig);
+
+    try {
+      check.execute();
+      Assert.fail("Expected to throw CommitStepException");
+    } catch (CommitStepException e) {
+      //Do nothing; Expected to throw exception
 
 Review comment:
   Shall we do an assertion here to make sure the exception being caught is 
indeed `CommitStepException `?
 
----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 383419)
    Time Spent: 50m  (was: 40m)

> Implement a Helix assigned participant check as a CommitStep
> ------------------------------------------------------------
>
>                 Key: GOBBLIN-1043
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1043
>             Project: Apache Gobblin
>          Issue Type: Improvement
>          Components: gobblin-cluster
>    Affects Versions: 0.15.0
>            Reporter: Sudarshan Vasudevan
>            Assignee: Hung Tran
>            Priority: Major
>             Fix For: 0.15.0
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> In Gobblin Helix cluster, we encounter scenarios where a participant 
> continues to work on a Helix partition even after the partition has been 
> assigned by Helix to a different participant leading to duplicate 
> consumption. We implement a check where each Helix task checks if it is 
> indeed the currently assigned participant for the Helix partition. This check 
> is implemented as a CommitStep and can be used as an assertion before data 
> publish occurs. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to