Return-Path: X-Original-To: apmail-curator-commits-archive@minotaur.apache.org Delivered-To: apmail-curator-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D396611685 for ; Tue, 20 May 2014 15:32:04 +0000 (UTC) Received: (qmail 95659 invoked by uid 500); 20 May 2014 15:32:04 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 95597 invoked by uid 500); 20 May 2014 15:32:04 -0000 Mailing-List: contact commits-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list commits@curator.apache.org Received: (qmail 95413 invoked by uid 99); 20 May 2014 15:32:04 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 May 2014 15:32:04 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 243019380E5; Tue, 20 May 2014 15:32:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: randgalt@apache.org To: commits@curator.apache.org Date: Tue, 20 May 2014 15:32:12 -0000 Message-Id: <0f243145d89b4a34aaceabbafae8d116@git.apache.org> In-Reply-To: <666a240458a0428c861a04b737e356b8@git.apache.org> References: <666a240458a0428c861a04b737e356b8@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [10/13] git commit: Added more timing to tests Added more timing to tests Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/460a9b37 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/460a9b37 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/460a9b37 Branch: refs/heads/CURATOR-96 Commit: 460a9b373a7c58ec250b5045d4485ba3d0c726e6 Parents: 5dbd672 Author: randgalt Authored: Thu May 15 15:05:08 2014 -0500 Committer: randgalt Committed: Thu May 15 15:05:08 2014 -0500 ---------------------------------------------------------------------- .../nodes/TestPersistentEphemeralNode.java | 37 +++++++++----------- 1 file changed, 17 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/460a9b37/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java index 4ca487a..35cb9e8 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java @@ -20,7 +20,6 @@ package org.apache.curator.framework.recipes.nodes; import com.google.common.base.Throwables; import com.google.common.collect.Lists; -import org.apache.curator.utils.CloseableUtils; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.recipes.BaseClassForTests; @@ -30,7 +29,7 @@ import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.KillSession; import org.apache.curator.test.TestingServer; import org.apache.curator.test.Timing; -import org.apache.curator.utils.DebugUtils; +import org.apache.curator.utils.CloseableUtils; import org.apache.curator.utils.ZKPaths; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; @@ -55,6 +54,8 @@ public class TestPersistentEphemeralNode extends BaseClassForTests private final Collection curatorInstances = Lists.newArrayList(); private final Collection createdNodes = Lists.newArrayList(); + private final Timing timing = new Timing(); + @AfterMethod public void teardown() throws Exception { @@ -76,7 +77,6 @@ public class TestPersistentEphemeralNode extends BaseClassForTests { server.close(); - Timing timing = new Timing(); CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); try { @@ -124,7 +124,6 @@ public class TestPersistentEphemeralNode extends BaseClassForTests { server.close(); - Timing timing = new Timing(); CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); try { @@ -193,14 +192,13 @@ public class TestPersistentEphemeralNode extends BaseClassForTests public void testSettingData() throws Exception { PersistentEphemeralNode node = null; - Timing timing = new Timing(); CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); try { client.start(); node = new PersistentEphemeralNode(client, PersistentEphemeralNode.Mode.EPHEMERAL, PATH, "a".getBytes()); node.start(); - Assert.assertTrue(node.waitForInitialCreate(5, TimeUnit.SECONDS)); + Assert.assertTrue(node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS)); Assert.assertEquals(node.getActualPath(), PATH); Assert.assertEquals(client.getData().forPath(PATH), "a".getBytes()); @@ -266,7 +264,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests PersistentEphemeralNode node = new PersistentEphemeralNode(curator, PersistentEphemeralNode.Mode.EPHEMERAL, PATH, new byte[0]); node.start(); - node.waitForInitialCreate(5, TimeUnit.SECONDS); + node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS); String path = node.getActualPath(); node.close(); @@ -286,7 +284,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests node.start(); try { - node.waitForInitialCreate(5, TimeUnit.SECONDS); + node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS); assertNodeExists(observer, node.getActualPath()); // Register a watch that will fire when the node is deleted... @@ -296,7 +294,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests killSession(curator); // Make sure the node got deleted - assertTrue(deletedTrigger.firedWithin(10, TimeUnit.SECONDS)); + assertTrue(deletedTrigger.firedWithin(timing.forWaiting().seconds(), TimeUnit.SECONDS)); } finally { @@ -323,12 +321,12 @@ public class TestPersistentEphemeralNode extends BaseClassForTests killSession(curator); // Make sure the node got deleted... - assertTrue(deletedTrigger.firedWithin(10, TimeUnit.SECONDS)); + assertTrue(deletedTrigger.firedWithin(timing.forWaiting().seconds(), TimeUnit.SECONDS)); // Check for it to be recreated... Trigger createdTrigger = Trigger.created(); Stat stat = observer.checkExists().usingWatcher(createdTrigger).forPath(node.getActualPath()); - assertTrue(stat != null || createdTrigger.firedWithin(10, TimeUnit.SECONDS)); + assertTrue(stat != null || createdTrigger.firedWithin(timing.forWaiting().seconds(), TimeUnit.SECONDS)); } finally { @@ -346,7 +344,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests node.start(); try { - node.waitForInitialCreate(5, TimeUnit.SECONDS); + node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS); String path = node.getActualPath(); assertNodeExists(observer, path); @@ -360,12 +358,12 @@ public class TestPersistentEphemeralNode extends BaseClassForTests killSession(curator); // Make sure the node ended up getting deleted... - assertTrue(deletionTrigger.firedWithin(10, TimeUnit.SECONDS)); + assertTrue(deletionTrigger.firedWithin(timing.forWaiting().seconds(), TimeUnit.SECONDS)); // Now put a watch in the background looking to see if it gets created... Trigger creationTrigger = Trigger.created(); Stat stat = observer.checkExists().usingWatcher(creationTrigger).forPath(path); - assertTrue(stat != null || creationTrigger.firedWithin(10, TimeUnit.SECONDS)); + assertTrue(stat != null || creationTrigger.firedWithin(timing.forWaiting().seconds(), TimeUnit.SECONDS)); } } finally @@ -383,7 +381,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests node.start(); try { - node.waitForInitialCreate(5, TimeUnit.SECONDS); + node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS); String originalNode = node.getActualPath(); assertNodeExists(curator, originalNode); @@ -394,7 +392,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests // node that gets created is going to be exactly the same as the original. Trigger createdWatchTrigger = Trigger.created(); Stat stat = curator.checkExists().usingWatcher(createdWatchTrigger).forPath(originalNode); - assertTrue(stat != null || createdWatchTrigger.firedWithin(10, TimeUnit.SECONDS)); + assertTrue(stat != null || createdWatchTrigger.firedWithin(timing.forWaiting().seconds(), TimeUnit.SECONDS)); } finally { @@ -411,14 +409,14 @@ public class TestPersistentEphemeralNode extends BaseClassForTests node1.start(); try { - node1.waitForInitialCreate(5, TimeUnit.SECONDS); + node1.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS); String path1 = node1.getActualPath(); PersistentEphemeralNode node2 = new PersistentEphemeralNode(curator, PersistentEphemeralNode.Mode.EPHEMERAL_SEQUENTIAL, PATH, new byte[0]); node2.start(); try { - node2.waitForInitialCreate(5, TimeUnit.SECONDS); + node2.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS); String path2 = node2.getActualPath(); assertFalse(path1.equals(path2)); @@ -444,7 +442,7 @@ public class TestPersistentEphemeralNode extends BaseClassForTests node.start(); try { - node.waitForInitialCreate(5, TimeUnit.SECONDS); + node.waitForInitialCreate(timing.forWaiting().seconds(), TimeUnit.SECONDS); assertTrue(Arrays.equals(curator.getData().forPath(node.getActualPath()), data)); } finally @@ -466,7 +464,6 @@ public class TestPersistentEphemeralNode extends BaseClassForTests private CuratorFramework newCurator() throws IOException { - Timing timing = new Timing(); CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); client.start();