i3wangyi commented on a change in pull request #681: Integration test for 
controller connect and disconnect
URL: https://github.com/apache/helix/pull/681#discussion_r372651000
 
 

 ##########
 File path: 
helix-core/src/test/java/org/apache/helix/integration/controller/TestControllerLeadershipChange.java
 ##########
 @@ -30,19 +31,157 @@
 import org.apache.helix.InstanceType;
 import org.apache.helix.PropertyPathBuilder;
 import org.apache.helix.common.ZkTestBase;
+import org.apache.helix.integration.manager.ClusterControllerManager;
 import org.apache.helix.integration.manager.MockParticipantManager;
+import org.apache.helix.manager.zk.CallbackHandler;
+import org.apache.helix.manager.zk.client.HelixZkClient;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.LiveInstance;
 import org.apache.helix.monitoring.mbeans.MonitorDomainNames;
 import 
org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier;
 import org.apache.helix.tools.ClusterVerifiers.ZkHelixClusterVerifier;
 import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+
+/**
+ * Integration test on controller leadership on several phases given the test 
cluster:
+ *  1. When a standalone controller becomes the leader
+ *  2. When a standalone leader relinquishes the leadership
+ *  3. When the leader node relinquishes the leadership and the other 
controller takes it over
+ */
 public class TestControllerLeadershipChange extends ZkTestBase {
+  private final String CLASS_NAME = getShortClassName();
+  private final String CLUSTER_NAME = "TestCluster-" + CLASS_NAME;
+
+  @BeforeClass
+  public void beforeClass()
+      throws Exception {
+    super.beforeClass();
+    _gSetupTool.addCluster(CLUSTER_NAME, true);
+    _gSetupTool.addInstanceToCluster(CLUSTER_NAME, "TestInstance");
+    _gSetupTool.addResourceToCluster(CLUSTER_NAME, "TestResource", 10, 
"MasterSlave");
+  }
+
+  @AfterClass
+  public void afterClass() {
+    deleteCluster(CLUSTER_NAME);
+  }
 
   @Test
-  public void testMissingTopStateDurationMonitoring() throws Exception {
+  public void testControllerConnectThenDisconnect() {
+    ClusterControllerManager controller =
+        new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, "TestController");
+    long start = System.currentTimeMillis();
+    controller.syncStart();
+    verifyControllerIsLeader(controller);
+    System.out.println(System.currentTimeMillis() - start + "ms spent on 
becoming the leader");
+
+    start = System.currentTimeMillis();
+    controller.syncStop();
+    verifyControllerIsNotLeader(controller);
+    verifyZKDisconnected(controller);
+
+    System.out.println(
 
 Review comment:
   I do need these output of recording the time duration spent on L -> S and S 
-> L (to prove the improvements). Modify the console print to LOG so it won't 
be printed out at least during `mvn test`

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to