keith-turner commented on code in PR #5765:
URL: https://github.com/apache/accumulo/pull/5765#discussion_r2232138156


##########
test/src/main/java/org/apache/accumulo/test/zookeeper/ZooCacheIT.java:
##########
@@ -228,4 +237,94 @@ public void testGetChildren() throws Exception {
           && zooCache.childrenCached(base + "/test3") == false;
     });
   }
+
+  @Test
+  public void testZookeeperRestart() throws Exception {
+    final String root = Constants.ZROOT + UUID.randomUUID();
+    final String base = root + Constants.ZTSERVERS;
+    TestZooCache zooCache = new TestZooCache(zk, Set.of(base));
+
+    zrw.mkdirs(base);
+    zrw.putPersistentData(base + "/test2", new byte[] {1, 2, 3, 4}, 
ZooUtil.NodeExistsPolicy.FAIL);
+
+    assertArrayEquals(new byte[] {1, 2, 3, 4}, zooCache.get(base + "/test2"));
+    assertEquals(List.of("test2"), zooCache.getChildren(base));
+
+    long uc1 = zooCache.getUpdateCount();
+
+    assertTrue(zooCache.dataCached(base + "/test2"));
+    assertTrue(zooCache.childrenCached(base));
+
+    assertArrayEquals(new byte[] {1, 2, 3, 4}, zooCache.get(base + "/test2"));
+    assertEquals(List.of("test2"), zooCache.getChildren(base));
+
+    assertEquals(uc1, zooCache.getUpdateCount());
+
+    // restarting zookeeper should cause the cache to be cleared
+    szk.restart();
+
+    // clearing the cache should increment the update count
+    Wait.waitFor(() -> uc1 != zooCache.getUpdateCount());
+    // The data and children previously cached should no longer be cached
+    assertFalse(zooCache.dataCached(base + "/test2"));
+    assertFalse(zooCache.childrenCached(base));
+
+    assertArrayEquals(new byte[] {1, 2, 3, 4}, zooCache.get(base + "/test2"));
+    assertEquals(List.of("test2"), zooCache.getChildren(base));

Review Comment:
   Its possible that persistent watchers were reregistered.  Would be good to 
check that after the even that cleared the cache that updates to ZK will still 
eventually be seen.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to