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

 ##########
 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:
   @kaisun2000 My understanding is, the current states created by this invalid 
session "session_0" would also be invalid. Can you help me understand if these 
invalid current states would work for this testing purpose? Thanks.

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