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

 ##########
 File path: 
helix-core/src/test/java/org/apache/helix/manager/zk/TestZkCacheAsyncOpSingleThread.java
 ##########
 @@ -37,6 +38,93 @@
 import org.testng.annotations.Test;
 
 public class TestZkCacheAsyncOpSingleThread extends ZkUnitTestBase {
+  @Test
+  public void testSessionExpirationWithSharedZkClient() throws Exception {
+    int CURSTATECNT = 10;
+    String className = TestHelper.getTestClassName();
+    String methodName = TestHelper.getTestMethodName();
+    String clusterName = className + "_" + methodName;
+
+    // init external base data accessor
+    HelixZkClient sharedZkclient = SharedZkClientFactory.getInstance()
+        .buildZkClient(new HelixZkClient.ZkConnectionConfig(ZK_ADDR));
+    sharedZkclient.setZkSerializer(new ZNRecordSerializer());
+    ZkBaseDataAccessor<ZNRecord> sharedBaseAccessor = new 
ZkBaseDataAccessor<>(sharedZkclient);
+
+    // init zkCacheBaseDataAccessor
+    String curStatePath = 
PropertyPathBuilder.instanceCurrentState(clusterName, "localhost_8901");
+    String extViewPath = PropertyPathBuilder.externalView(clusterName);
+
+    ZkBaseDataAccessor<ZNRecord> extBaseAccessor = new 
ZkBaseDataAccessor<>(_gZkClient);
+    extBaseAccessor.create(curStatePath, null, AccessOption.PERSISTENT);
+
+    List<String> zkCacheInitPaths = Arrays.asList(curStatePath, extViewPath);
+    ZkCacheBaseDataAccessor<ZNRecord> accessor =
+        new ZkCacheBaseDataAccessor<>(sharedBaseAccessor, null, null, 
zkCacheInitPaths);
+
+    boolean ret =
+        TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache, 
_gZkClient, true);
+    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
+
+    // create 10 current states using external base accessor
+    List<String> paths = new ArrayList<>();
+    List<ZNRecord> records = new ArrayList<>();
+    for (int i = 0; i < CURSTATECNT; i++) {
+      String path = PropertyPathBuilder
+          .instanceCurrentState(clusterName, "localhost_8901", "session_0", 
"TestDB" + i);
 
 Review comment:
   CurrentStates here only serves the purpose of some directory in zookeeper. 
This test has nothing to do with controller rebalancing logic.  Note, 
TestHelper.verifyZkCache only valid the data in zookeeper and propertycache for 
this currentstates path are the same. That is the gist of this test.
   
   Put it another way, using currentstate property builder is just a 
convenience. All the other test in this suite is like this.

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