You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2022/04/06 00:52:15 UTC

[GitHub] [zookeeper] kezhuw commented on a diff in pull request #1852: ZOOKEEPER-4511: Fix flaky test FileTxnSnapLogMetricsTest.testFileTxnSnapLogMetrics

kezhuw commented on code in PR #1852:
URL: https://github.com/apache/zookeeper/pull/1852#discussion_r843373366


##########
zookeeper-server/src/test/java/org/apache/zookeeper/server/persistence/FileTxnSnapLogMetricsTest.java:
##########
@@ -43,38 +40,20 @@
 
     private static final Logger LOG = LoggerFactory.getLogger(FileTxnSnapLogMetricsTest.class);
 
-    CountDownLatch allCreatedLatch;
-
-    private class MockWatcher implements Watcher {
-
-        @Override
-        public void process(WatchedEvent e) {
-            LOG.info("all nodes created");
-            allCreatedLatch.countDown();
-        }
-
-    }
-
     @Test
     public void testFileTxnSnapLogMetrics() throws Exception {
-        SyncRequestProcessor.setSnapCount(100);
+        // disable automatic snapshot taking to leave writes in txn log
+        SyncRequestProcessor.setSnapCount(Integer.MAX_VALUE);
 
         QuorumUtil util = new QuorumUtil(1);
         util.startAll();
 
-        allCreatedLatch = new CountDownLatch(1);
-
         byte[] data = new byte[500];
-        // make sure a snapshot is taken and some txns are not in a snapshot
         ZooKeeper zk = ClientBase.createZKClient(util.getConnString());
         for (int i = 0; i < 150; i++) {
             zk.create("/path" + i, data, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
         }
 
-        if (null == zk.exists("/path149", new MockWatcher())) {

Review Comment:
   `zk.create` above is synchronous. `zk.exists` will return non null stat if I understand correct.



-- 
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: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org