phunt commented on a change in pull request #787: ZOOKEEPER-3253: client should 
not send requests with cxid=-4, -2, or -1
URL: https://github.com/apache/zookeeper/pull/787#discussion_r261877616
 
 

 ##########
 File path: 
zookeeper-server/src/test/java/org/apache/zookeeper/test/ClientTest.java
 ##########
 @@ -868,4 +870,37 @@ public void testTryWithResources() throws Exception {
 
         Assert.assertFalse(zooKeeper.getState().isAlive());
     }
+
+    @Test
+    public void testCXidRollover() throws Exception {
+        TestableZooKeeper zk = null;
+        try {
+            zk = createClient();
+            zk.setXid(Integer.MAX_VALUE - 10);
+
+            zk.create("/testnode", "".getBytes(), Ids.OPEN_ACL_UNSAFE,
+                CreateMode.PERSISTENT);
+            for (int i = 0; i < 20; ++i) {
+                final CountDownLatch latch = new CountDownLatch(1);
+                final AtomicInteger rc = new AtomicInteger(0);
+                zk.setData("/testnode", "".getBytes(), -1,
+                    new AsyncCallback.StatCallback() {
+                        @Override
+                        public void processResult(int retcode, String path, 
Object ctx, Stat stat) {
+                            rc.set(retcode);
+                            latch.countDown();
+                        }
+                    }, null);
+                Assert.assertTrue("setData should complete within 5s",
+                    latch.await(5, TimeUnit.SECONDS));
 
 Review comment:
   this is generally an anti-pattern in the tests and leads to flakey tests. 
e.g. we can see on some test environments that are oversubscribed. I'd suggest 
something very large, e.g. 30 seconds or just using the session timeout.

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

Reply via email to