pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject [incubator-pulsar] branch master updated: [tests] Flaky Test ZooKeeperCacheTest#testChildrenCacheZnodeCreatedAfterCache (#2598)
Date Tue, 18 Sep 2018 09:18:22 GMT
This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 6c07c81   [tests] Flaky Test ZooKeeperCacheTest#testChildrenCacheZnodeCreatedAfterCache
(#2598)
6c07c81 is described below

commit 6c07c81bf85eaa6d2a23c026049c57305284876e
Author: Sijie Guo <guosijie@gmail.com>
AuthorDate: Tue Sep 18 02:18:17 2018 -0700

     [tests] Flaky Test ZooKeeperCacheTest#testChildrenCacheZnodeCreatedAfterCache (#2598)
    
    * [tests] Flaky Test ZooKeeperCacheTest#testChildrenCacheZnodeCreatedAfterCache
    
    *Motivation*
    
    The problem is zookeeper watcher notification is non-deterministic. That says if you create
N paths in zookeeper, you might receive
    x notification. x is between 1 and N. so the test is written in a very non-deterministic
way.
    
    ```
    java.lang.AssertionError: expected [1] but found [2]
    	at org.testng.Assert.fail(Assert.java:96)
    	at org.testng.Assert.failNotEquals(Assert.java:776)
    	at org.testng.Assert.assertEqualsImpl(Assert.java:137)
    	at org.testng.Assert.assertEquals(Assert.java:118)
    	at org.testng.Assert.assertEquals(Assert.java:652)
    	at org.testng.Assert.assertEquals(Assert.java:662)
    	at org.apache.pulsar.zookeeper.ZookeeperCacheTest.testChildrenCacheZnodeCreatedAfterCache(ZookeeperCacheTest.java:214)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
    	at org.testng.internal.InvokeMethodRunnable.runOne(InvokeMethodRunnable.java:54)
    	at org.testng.internal.InvokeMethodRunnable.run(InvokeMethodRunnable.java:44)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    ```
    
    *Changes*
    
    rewrite the test to make it more robust.
---
 .../test/java/org/apache/pulsar/zookeeper/ZookeeperCacheTest.java | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/pulsar-zookeeper-utils/src/test/java/org/apache/pulsar/zookeeper/ZookeeperCacheTest.java
b/pulsar-zookeeper-utils/src/test/java/org/apache/pulsar/zookeeper/ZookeeperCacheTest.java
index 09c3ea1..39f23ac 100644
--- a/pulsar-zookeeper-utils/src/test/java/org/apache/pulsar/zookeeper/ZookeeperCacheTest.java
+++ b/pulsar-zookeeper-utils/src/test/java/org/apache/pulsar/zookeeper/ZookeeperCacheTest.java
@@ -209,12 +209,14 @@ public class ZookeeperCacheTest {
             Thread.sleep(1);
         }
 
+        final int recvNotifications = notificationCount.get();
+
         assertEquals(cache.get(), new TreeSet<String>(Lists.newArrayList("z1")));
         assertEquals(cache.get("/test"), new TreeSet<String>(Lists.newArrayList("z1")));
-        assertEquals(notificationCount.get(), 1);
+        assertTrue(recvNotifications == 1 || recvNotifications == 2);
 
         zkClient.delete("/test/z1", -1);
-        while (notificationCount.get() < 2) {
+        while (notificationCount.get() < (recvNotifications + 1)) {
             Thread.sleep(1);
         }
 
@@ -230,7 +232,7 @@ public class ZookeeperCacheTest {
             // Ok
         }
 
-        assertEquals(notificationCount.get(), 2);
+        assertEquals(notificationCount.get(), (recvNotifications + 1));
     }
 
     @Test(timeOut = 10000)


Mime
View raw message