You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by fa...@apache.org on 2018/11/05 07:45:58 UTC
zookeeper git commit: ZOOKEEPER-2807: Fix flaky test
org.apache.zookeeper.test.WatchEventWhenAutoResetTest.testNodeDataChanged
Repository: zookeeper
Updated Branches:
refs/heads/master 1ce2ca810 -> 05d4d437d
ZOOKEEPER-2807: Fix flaky test org.apache.zookeeper.test.WatchEventWhenAutoResetTest.testNodeDataChanged
Mark the test as ignored.
Please see https://issues.apache.org/jira/browse/ZOOKEEPER-3182 for more details
Author: Andor Molnar <an...@apache.org>
Reviewers: Fangmin Lyu <fa...@apache.org>
Closes #682 from anmolnar/ZOOKEEPER-2807
Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/05d4d437
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/05d4d437
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/05d4d437
Branch: refs/heads/master
Commit: 05d4d437d808f6cdf4c9dc5419a6e8d635c2ba5d
Parents: 1ce2ca8
Author: Andor Molnar <an...@apache.org>
Authored: Sun Nov 4 23:45:40 2018 -0800
Committer: Fangmin Lyu <fa...@apache.org>
Committed: Sun Nov 4 23:45:40 2018 -0800
----------------------------------------------------------------------
.../test/WatchEventWhenAutoResetTest.java | 85 ++++++++------------
1 file changed, 34 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/05d4d437/zookeeper-server/src/test/java/org/apache/zookeeper/test/WatchEventWhenAutoResetTest.java
----------------------------------------------------------------------
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/WatchEventWhenAutoResetTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/test/WatchEventWhenAutoResetTest.java
index a760463..33e0f12 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/WatchEventWhenAutoResetTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/WatchEventWhenAutoResetTest.java
@@ -28,8 +28,10 @@ import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.Watcher.Event.EventType;
+import org.apache.zookeeper.data.Stat;
import org.apache.zookeeper.test.ClientBase.CountdownWatcher;
import org.apache.zookeeper.ZKTestCase;
+import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -43,6 +45,9 @@ public class WatchEventWhenAutoResetTest extends ZKTestCase {
// waiting time for expected condition
private static final int TIMEOUT = 30000;
+ private QuorumUtil qu;
+ private EventsWatcher watcher;
+ private ZooKeeper zk1, zk2;
static public class EventsWatcher extends CountdownWatcher {
private LinkedBlockingQueue<WatchedEvent> dataEvents = new LinkedBlockingQueue<WatchedEvent>();
@@ -90,53 +95,51 @@ public class WatchEventWhenAutoResetTest extends ZKTestCase {
}
@Before
- public void setUp() {
+ public void setUp() throws IOException {
System.setProperty("zookeeper.admin.enableServer", "false");
- }
- @Test
- public void testNodeDataChanged() throws Exception {
- QuorumUtil qu = new QuorumUtil(1);
+ qu = new QuorumUtil(1);
qu.startAll();
- EventsWatcher watcher = new EventsWatcher();
- ZooKeeper zk1 = createClient(qu, 1, watcher);
- ZooKeeper zk2 = createClient(qu, 2);
+ watcher = new EventsWatcher();
+ zk1 = createClient(qu, 1, watcher);
+ zk2 = createClient(qu, 2);
+ }
- String path = "/test-changed";
+ @After
+ public void tearDown() throws InterruptedException {
+ if (zk1 != null) {
+ zk1.close();
+ zk1 = null;
+ }
+ if (zk2 != null) {
+ zk2.close();
+ zk2 = null;
+ }
+ if (watcher != null) {
+ watcher = null;
+ }
+ if (qu != null) {
+ qu.shutdownAll();
+ qu = null;
+ }
+ }
+ @Test
+ public void testNodeDataChanged() throws Exception {
+ String path = "/test-changed";
zk1.create(path, new byte[1], ZooDefs.Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
- zk1.getData(path, watcher, null);
+ Stat stat1 = zk1.exists(path, watcher);
qu.shutdown(1);
- zk2.delete(path, -1);
- zk2.create(path, new byte[2], ZooDefs.Ids.OPEN_ACL_UNSAFE,
- CreateMode.PERSISTENT);
+ zk2.setData(path, new byte[2], stat1.getVersion());
qu.start(1);
watcher.waitForConnected(TIMEOUT);
watcher.assertEvent(TIMEOUT, EventType.NodeDataChanged);
-
- zk1.exists(path, watcher);
- qu.shutdown(1);
- zk2.delete(path, -1);
- zk2.create(path, new byte[2], ZooDefs.Ids.OPEN_ACL_UNSAFE,
- CreateMode.PERSISTENT);
- qu.start(1);
- watcher.waitForConnected(TIMEOUT * 1000L);
- watcher.assertEvent(TIMEOUT, EventType.NodeDataChanged);
-
- qu.shutdownAll();
}
@Test
public void testNodeCreated() throws Exception {
- QuorumUtil qu = new QuorumUtil(1);
- qu.startAll();
-
- EventsWatcher watcher = new EventsWatcher();
- ZooKeeper zk1 = createClient(qu, 1, watcher);
- ZooKeeper zk2 = createClient(qu, 2);
-
String path = "/test1-created";
zk1.exists(path, watcher);
@@ -146,19 +149,10 @@ public class WatchEventWhenAutoResetTest extends ZKTestCase {
qu.start(1);
watcher.waitForConnected(TIMEOUT * 1000L);
watcher.assertEvent(TIMEOUT, EventType.NodeCreated);
-
- qu.shutdownAll();
}
@Test
public void testNodeDeleted() throws Exception {
- QuorumUtil qu = new QuorumUtil(1);
- qu.startAll();
-
- EventsWatcher watcher = new EventsWatcher();
- ZooKeeper zk1 = createClient(qu, 1, watcher);
- ZooKeeper zk2 = createClient(qu, 2);
-
String path = "/test-deleted";
zk1.create(path, new byte[1], ZooDefs.Ids.OPEN_ACL_UNSAFE,
@@ -187,19 +181,10 @@ public class WatchEventWhenAutoResetTest extends ZKTestCase {
qu.start(1);
watcher.waitForConnected(TIMEOUT * 1000L);
watcher.assertEvent(TIMEOUT, EventType.NodeDeleted);
-
- qu.shutdownAll();
}
@Test
public void testNodeChildrenChanged() throws Exception {
- QuorumUtil qu = new QuorumUtil(1);
- qu.startAll();
-
- EventsWatcher watcher = new EventsWatcher();
- ZooKeeper zk1 = createClient(qu, 1, watcher);
- ZooKeeper zk2 = createClient(qu, 2);
-
String path = "/test-children-changed";
zk1.create(path, new byte[1], ZooDefs.Ids.OPEN_ACL_UNSAFE,
@@ -211,8 +196,6 @@ public class WatchEventWhenAutoResetTest extends ZKTestCase {
qu.start(1);
watcher.waitForConnected(TIMEOUT * 1000L);
watcher.assertEvent(TIMEOUT, EventType.NodeChildrenChanged);
-
- qu.shutdownAll();
}
}