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/04/01 07:27:59 UTC

[GitHub] [helix] kaisun2000 commented on a change in pull request #924: WIP: fix ZkHelixPropertyStore loses Zookeeper notification issue

kaisun2000 commented on a change in pull request #924: WIP: fix ZkHelixPropertyStore loses Zookeeper notification issue
URL: https://github.com/apache/helix/pull/924#discussion_r401407845
 
 

 ##########
 File path: helix-core/src/test/java/org/apache/helix/store/zk/TestZkHelixPropertyStore.java
 ##########
 @@ -88,6 +92,57 @@ public void afterClass() {
     deleteCluster(getShortClassName());
   }
 
+  @Test
+  public void testSessionExpirationWithSharedZkClient() throws Exception {
+    /*
+    This test is to make sure SharedZkClient would work with
+    HelixPropertyStore when session expiration happens. More specifically
+    HelixPropertyStore would register all the callbacks after session
+    expiration.
+     */
+    String subRoot = _root + "/" + "localCallback";
+    List<String> subscribedPaths = new ArrayList<>();
+    subscribedPaths.add(subRoot);
+
+    ZkSerializer serializer = new ZNRecordSerializer();
+    ZkHelixPropertyStore<ZNRecord> store =
+        new ZkHelixPropertyStore<>(ZK_ADDR, serializer, subRoot, subscribedPaths);
+
+    TestListener listener = new TestListener();
+    store.subscribe("/", listener);
+
+    // test dataCreate callbacks
+    listener.reset();
+    setNodes(store, 'a', true);
+
+    // kill the session to make sure shared zkClient re-installs watcher
+    // Note, current shared ZkClient does not issue new session. Thus, we need
+    // kill _zkConnectionManager's session. Otherwise, ZkTestHelper.expireSesson
+    // would not work.
+    SharedZkClient sharedClient = (SharedZkClient) store.getTestZkClient();
+    HelixZkClient  testClient =  sharedClient.getConnectionManager();
+    ZkTestHelper.expireSession(testClient);
+
+
+    // kill the session one more time to cover Shared ZkClient resetting flag
+    // indicating first time synconnect happened.
+    ZkTestHelper.expireSession(testClient);
+
+    listener.reset();
+    int expectDeleteNodes = 1 + firstLevelNr + firstLevelNr * secondLevelNr;
+    store.remove("/", 0);
+    // wait until all callbacks have been received
+    for (int i = 0; i < 10; i++) {
+      if (listener._deleteKeys.size() == expectDeleteNodes)
+        break;
+      Thread.sleep(500);
 
 Review comment:
   New approach use TestHelper.verifyWithTimeout().

----------------------------------------------------------------
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


With regards,
Apache Git Services

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