You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2013/06/18 23:12:02 UTC

[1/2] git commit: some additional functionality in testing code

Updated Branches:
  refs/heads/2.0.2-incubating c676e3e2d -> d9d0dc2fd
  refs/heads/CURATOR-35 [created] d9d0dc2fd


some additional functionality in testing code


Project: http://git-wip-us.apache.org/repos/asf/incubator-curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-curator/commit/6a26d4fa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-curator/tree/6a26d4fa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-curator/diff/6a26d4fa

Branch: refs/heads/2.0.2-incubating
Commit: 6a26d4fa3ff431bbc0a5a166e4f92e8b3691f0f7
Parents: c676e3e
Author: randgalt <ra...@apache.org>
Authored: Sat Jun 15 16:39:14 2013 -0700
Committer: randgalt <ra...@apache.org>
Committed: Sat Jun 15 16:39:14 2013 -0700

----------------------------------------------------------------------
 .../org/apache/curator/test/TestingCluster.java | 66 +++++++++++++++++---
 .../curator/test/TestingQuorumPeerMain.java     |  6 ++
 .../curator/test/TestingZooKeeperMain.java      |  7 +++
 .../curator/test/TestingZooKeeperServer.java    | 12 ++++
 .../apache/curator/test/ZooKeeperMainFace.java  |  3 +
 5 files changed, 85 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/6a26d4fa/curator-test/src/main/java/org/apache/curator/test/TestingCluster.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/TestingCluster.java b/curator-test/src/main/java/org/apache/curator/test/TestingCluster.java
index 442cb66..cd86b72 100644
--- a/curator-test/src/main/java/org/apache/curator/test/TestingCluster.java
+++ b/curator-test/src/main/java/org/apache/curator/test/TestingCluster.java
@@ -18,7 +18,12 @@
  */
 package org.apache.curator.test;
 
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
 import org.apache.zookeeper.ZooKeeper;
 import java.io.Closeable;
 import java.io.IOException;
@@ -26,6 +31,7 @@ import java.lang.reflect.Method;
 import java.net.InetSocketAddress;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
  * manages an internally running ensemble of ZooKeeper servers. FOR TESTING PURPOSES ONLY
@@ -37,7 +43,6 @@ public class TestingCluster implements Closeable
         ByteCodeRewrite.apply();
     }
 
-    private final QuorumConfigBuilder           builder;
     private final List<TestingZooKeeperServer>  servers;
 
     /**
@@ -58,7 +63,7 @@ public class TestingCluster implements Closeable
      */
     public TestingCluster(InstanceSpec... specs)
     {
-        this(ImmutableList.copyOf(specs));
+        this(listToMap(ImmutableList.copyOf(specs)));
     }
 
     /**
@@ -68,11 +73,25 @@ public class TestingCluster implements Closeable
      */
     public TestingCluster(Collection<InstanceSpec> specs)
     {
-        builder = new QuorumConfigBuilder(specs);
+        this(listToMap(specs));
+    }
+
+    /**
+     * Creates an ensemble using the given server specs
+     *
+     * @param specs map of an instance spec to its set of quorum instances. Allows simulation of an ensemble with instances
+     *              having different config peers
+     */
+    public TestingCluster(Map<InstanceSpec, Collection<InstanceSpec>> specs)
+    {
         ImmutableList.Builder<TestingZooKeeperServer> serverBuilder = ImmutableList.builder();
-        for ( int i = 0; i < specs.size(); ++i )
+        for ( Map.Entry<InstanceSpec, Collection<InstanceSpec>> entry : specs.entrySet() )
         {
-            serverBuilder.add(new TestingZooKeeperServer(builder, i));
+            List<InstanceSpec> instanceSpecs = Lists.newArrayList(entry.getValue());
+            int index = instanceSpecs.indexOf(entry.getKey());
+            Preconditions.checkState(index >= 0, entry.getKey() + " not found in specs");
+            QuorumConfigBuilder builder = new QuorumConfigBuilder(instanceSpecs);
+            serverBuilder.add(new TestingZooKeeperServer(builder, index));
         }
         servers = serverBuilder.build();
     }
@@ -84,7 +103,24 @@ public class TestingCluster implements Closeable
      */
     public Collection<InstanceSpec> getInstances()
     {
-        return builder.getInstanceSpecs();
+        Iterable<InstanceSpec> transformed = Iterables.transform
+        (
+            servers,
+            new Function<TestingZooKeeperServer, InstanceSpec>()
+            {
+                @Override
+                public InstanceSpec apply(TestingZooKeeperServer server)
+                {
+                    return server.getInstanceSpec();
+                }
+            }
+        );
+        return Lists.newArrayList(transformed);
+    }
+
+    public List<TestingZooKeeperServer> getServers()
+    {
+        return Lists.newArrayList(servers);
     }
 
     /**
@@ -95,7 +131,7 @@ public class TestingCluster implements Closeable
     public String   getConnectString()
     {
         StringBuilder       str = new StringBuilder();
-        for ( InstanceSpec spec : builder.getInstanceSpecs() )
+        for ( InstanceSpec spec : getInstances() )
         {
             if ( str.length() > 0 )
             {
@@ -211,13 +247,25 @@ public class TestingCluster implements Closeable
         return null;
     }
 
-    private static Collection<InstanceSpec> makeSpecs(int instanceQty)
+    private static Map<InstanceSpec, Collection<InstanceSpec>> makeSpecs(int instanceQty)
     {
         ImmutableList.Builder<InstanceSpec> builder = ImmutableList.builder();
         for ( int i = 0; i < instanceQty; ++i )
         {
             builder.add(InstanceSpec.newInstanceSpec());
         }
-        return builder.build();
+
+        return listToMap(builder.build());
+    }
+
+    private static Map<InstanceSpec, Collection<InstanceSpec>> listToMap(Collection<InstanceSpec> list)
+    {
+        ImmutableMap.Builder<InstanceSpec, Collection<InstanceSpec>> mapBuilder = ImmutableMap.builder();
+        for ( InstanceSpec spec : list )
+        {
+            mapBuilder.put(spec, list);
+        }
+
+        return mapBuilder.build();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/6a26d4fa/curator-test/src/main/java/org/apache/curator/test/TestingQuorumPeerMain.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/TestingQuorumPeerMain.java b/curator-test/src/main/java/org/apache/curator/test/TestingQuorumPeerMain.java
index 0048099..9f9f302 100644
--- a/curator-test/src/main/java/org/apache/curator/test/TestingQuorumPeerMain.java
+++ b/curator-test/src/main/java/org/apache/curator/test/TestingQuorumPeerMain.java
@@ -53,6 +53,12 @@ class TestingQuorumPeerMain extends QuorumPeerMain implements ZooKeeperMainFace
     }
 
     @Override
+    public QuorumPeer getQuorumPeer()
+    {
+        return quorumPeer;
+    }
+
+    @Override
     public void close() throws IOException
     {
         if ( quorumPeer != null )

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/6a26d4fa/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
index 21bc57f..2193acb 100644
--- a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
+++ b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java
@@ -23,6 +23,7 @@ import org.apache.zookeeper.server.ServerConfig;
 import org.apache.zookeeper.server.ZKDatabase;
 import org.apache.zookeeper.server.ZooKeeperServer;
 import org.apache.zookeeper.server.ZooKeeperServerMain;
+import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
 import java.io.IOException;
 import java.lang.reflect.Field;
@@ -67,6 +68,12 @@ public class TestingZooKeeperMain extends ZooKeeperServerMain implements ZooKeep
         super.runFromConfig(serverConfig);
     }
 
+    @Override
+    public QuorumPeer getQuorumPeer()
+    {
+        throw new UnsupportedOperationException();
+    }
+
     @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
     @Override
     public void blockUntilStarted() throws Exception

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/6a26d4fa/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java
index b9e7dc1..be1a1b6 100644
--- a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java
+++ b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java
@@ -18,12 +18,14 @@
  */
 package org.apache.curator.test;
 
+import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
 import org.apache.zookeeper.server.quorum.QuorumPeerMain;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import java.io.Closeable;
 import java.io.IOException;
+import java.util.Collection;
 import java.util.concurrent.atomic.AtomicReference;
 
 /**
@@ -58,6 +60,16 @@ public class TestingZooKeeperServer extends QuorumPeerMain implements Closeable
         main = (configBuilder.size() > 1) ? new TestingQuorumPeerMain() : new TestingZooKeeperMain();
     }
 
+    public QuorumPeer getQuorumPeer()
+    {
+        return main.getQuorumPeer();
+    }
+
+    public Collection<InstanceSpec> getInstanceSpecs()
+    {
+        return configBuilder.getInstanceSpecs();
+    }
+
     public void     kill()
     {
         main.kill();

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/6a26d4fa/curator-test/src/main/java/org/apache/curator/test/ZooKeeperMainFace.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/ZooKeeperMainFace.java b/curator-test/src/main/java/org/apache/curator/test/ZooKeeperMainFace.java
index 946ac1a..6da29a4 100644
--- a/curator-test/src/main/java/org/apache/curator/test/ZooKeeperMainFace.java
+++ b/curator-test/src/main/java/org/apache/curator/test/ZooKeeperMainFace.java
@@ -18,6 +18,7 @@
  */
 package org.apache.curator.test;
 
+import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
 import java.io.Closeable;
 
@@ -28,4 +29,6 @@ public interface ZooKeeperMainFace extends Closeable
     public void blockUntilStarted() throws Exception;
 
     public void kill();
+
+    public QuorumPeer getQuorumPeer();
 }


[2/2] git commit: CURATOR-35 - added a full featured sync() method and deprecated the previous method

Posted by ra...@apache.org.
CURATOR-35 - added a full featured sync() method and deprecated the previous method


Project: http://git-wip-us.apache.org/repos/asf/incubator-curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-curator/commit/d9d0dc2f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-curator/tree/d9d0dc2f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-curator/diff/d9d0dc2f

Branch: refs/heads/2.0.2-incubating
Commit: d9d0dc2fdb63ae0f2754144a250348774454d701
Parents: 6a26d4f
Author: randgalt <ra...@apache.org>
Authored: Tue Jun 18 14:11:42 2013 -0700
Committer: randgalt <ra...@apache.org>
Committed: Tue Jun 18 14:11:42 2013 -0700

----------------------------------------------------------------------
 .../curator/framework/CuratorFramework.java     | 29 ++++--
 .../curator/framework/api/SyncBuilder.java      | 24 +++++
 .../framework/imps/CuratorFrameworkImpl.java    |  6 ++
 .../curator/framework/imps/SyncBuilderImpl.java | 92 ++++++++++++++++++++
 .../curator/framework/imps/TestFramework.java   | 31 +++++++
 5 files changed, 173 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/d9d0dc2f/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
index 0ca9b23..e49386e 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFramework.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.curator.framework;
 
 import org.apache.curator.CuratorZookeeperClient;
@@ -35,12 +36,12 @@ public interface CuratorFramework extends Closeable
     /**
      * Start the client. Most mutator methods will not work until the client is started
      */
-    public void     start();
+    public void start();
 
     /**
      * Stop the client
      */
-    public void     close();
+    public void close();
 
     /**
      * Returns the state of this instance
@@ -55,7 +56,7 @@ public interface CuratorFramework extends Closeable
      * @return true/false
      * @deprecated use {@link #getState()} instead
      */
-    public boolean  isStarted();
+    public boolean isStarted();
 
     /**
      * Start a create builder
@@ -73,7 +74,7 @@ public interface CuratorFramework extends Closeable
 
     /**
      * Start an exists builder
-     *
+     * <p/>
      * The builder will return a Stat object as if org.apache.zookeeper.ZooKeeper.exists() were called.  Thus, a null
      * means that it does not exist and an actual Stat object means it does exist.
      *
@@ -126,10 +127,19 @@ public interface CuratorFramework extends Closeable
     /**
      * Perform a sync on the given path - syncs are always in the background
      *
-     * @param path the path
+     * @param path                    the path
      * @param backgroundContextObject optional context
+     * @deprecated use {@link #sync()} instead
+     */
+    public void sync(String path, Object backgroundContextObject);
+
+    /**
+     * Start a sync builder. Note: sync is ALWAYS in the background even
+     * if you don't use one of the background() methods
+     *
+     * @return builder object
      */
-    public void     sync(String path, Object backgroundContextObject);
+    public SyncBuilder sync();
 
     /**
      * Returns the listenable interface for the Connect State
@@ -143,14 +153,14 @@ public interface CuratorFramework extends Closeable
      *
      * @return listenable
      */
-    public Listenable<CuratorListener>         getCuratorListenable();
+    public Listenable<CuratorListener> getCuratorListenable();
 
     /**
      * Returns the listenable interface for unhandled errors
      *
      * @return listenable
      */
-    public Listenable<UnhandledErrorListener>  getUnhandledErrorListenable();
+    public Listenable<UnhandledErrorListener> getUnhandledErrorListenable();
 
     /**
      * Returns a facade of the current instance that does _not_ automatically
@@ -172,6 +182,7 @@ public interface CuratorFramework extends Closeable
 
     /**
      * Return the current namespace or "" if none
+     *
      * @return namespace
      */
     public String getNamespace();
@@ -189,5 +200,5 @@ public interface CuratorFramework extends Closeable
      * @param path path to ensure
      * @return new EnsurePath instance
      */
-    public EnsurePath    newNamespaceAwareEnsurePath(String path);
+    public EnsurePath newNamespaceAwareEnsurePath(String path);
 }

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/d9d0dc2f/curator-framework/src/main/java/org/apache/curator/framework/api/SyncBuilder.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/api/SyncBuilder.java b/curator-framework/src/main/java/org/apache/curator/framework/api/SyncBuilder.java
new file mode 100644
index 0000000..6ae3586
--- /dev/null
+++ b/curator-framework/src/main/java/org/apache/curator/framework/api/SyncBuilder.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.curator.framework.api;
+
+public interface SyncBuilder extends
+    BackgroundPathable<Void>
+{
+}

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/d9d0dc2f/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
index 28cad83..c3b0992 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java
@@ -411,6 +411,12 @@ public class CuratorFrameworkImpl implements CuratorFramework
         internalSync(this, path, context);
     }
 
+    @Override
+    public SyncBuilder sync()
+    {
+        return new SyncBuilderImpl(this);
+    }
+
     protected void internalSync(CuratorFrameworkImpl impl, String path, Object context)
     {
         BackgroundOperation<String> operation = new BackgroundSyncImpl(impl, context);

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/d9d0dc2f/curator-framework/src/main/java/org/apache/curator/framework/imps/SyncBuilderImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/SyncBuilderImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/SyncBuilderImpl.java
new file mode 100644
index 0000000..7c74abc
--- /dev/null
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/SyncBuilderImpl.java
@@ -0,0 +1,92 @@
+package org.apache.curator.framework.imps;
+
+import org.apache.curator.TimeTrace;
+import org.apache.curator.framework.api.BackgroundCallback;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.Pathable;
+import org.apache.curator.framework.api.SyncBuilder;
+import org.apache.zookeeper.AsyncCallback;
+import java.util.concurrent.Executor;
+
+public class SyncBuilderImpl implements SyncBuilder, BackgroundOperation<String>
+{
+    private final CuratorFrameworkImpl client;
+    private Backgrounding backgrounding = new Backgrounding();
+
+    public SyncBuilderImpl(CuratorFrameworkImpl client)
+    {
+        //To change body of created methods use File | Settings | File Templates.
+        this.client = client;
+    }
+
+    @Override
+    public Pathable<Void> inBackground()
+    {
+        // NOP always in background
+        return this;
+    }
+
+    @Override
+    public Pathable<Void> inBackground(Object context)
+    {
+        backgrounding = new Backgrounding(context);
+        return this;
+    }
+
+    @Override
+    public Pathable<Void> inBackground(BackgroundCallback callback)
+    {
+        backgrounding = new Backgrounding(callback);
+        return this;
+    }
+
+    @Override
+    public Pathable<Void> inBackground(BackgroundCallback callback, Object context)
+    {
+        backgrounding = new Backgrounding(callback, context);
+        return this;
+    }
+
+    @Override
+    public Pathable<Void> inBackground(BackgroundCallback callback, Executor executor)
+    {
+        backgrounding = new Backgrounding(callback, executor);
+        return this;
+    }
+
+    @Override
+    public Pathable<Void> inBackground(BackgroundCallback callback, Object context, Executor executor)
+    {
+        backgrounding = new Backgrounding(client, callback, context, executor);
+        return this;
+    }
+
+    @Override
+    public void performBackgroundOperation(final OperationAndData<String> operationAndData) throws Exception
+    {
+        final TimeTrace trace = client.getZookeeperClient().startTracer("SyncBuilderImpl-Background");
+        final String path = operationAndData.getData();
+        String adjustedPath = client.fixForNamespace(path);
+
+        AsyncCallback.VoidCallback voidCallback = new AsyncCallback.VoidCallback()
+        {
+            @Override
+            public void processResult(int rc, String path, Object ctx)
+            {
+                trace.commit();
+                CuratorEvent event = new CuratorEventImpl(client, CuratorEventType.SYNC, rc, path, path, ctx, null, null, null, null, null);
+                client.processBackgroundOperation(operationAndData, event);
+            }
+        };
+        client.getZooKeeper().sync(adjustedPath, voidCallback, backgrounding.getContext());
+    }
+
+    @Override
+    public Void forPath(String path) throws Exception
+    {
+        OperationAndData<String> operationAndData = new OperationAndData<String>(this, path, backgrounding.getCallback(), null);
+        client.processBackgroundOperation(operationAndData, null);
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/d9d0dc2f/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
index a3bf73b..f7ef6e9 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java
@@ -427,6 +427,37 @@ public class TestFramework extends BaseClassForTests
     }
 
     @Test
+    public void     testSyncNew() throws Exception
+    {
+        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
+        client.start();
+        try
+        {
+            client.create().forPath("/head");
+            Assert.assertNotNull(client.checkExists().forPath("/head"));
+
+            final CountDownLatch      latch = new CountDownLatch(1);
+            BackgroundCallback callback = new BackgroundCallback()
+            {
+                @Override
+                public void processResult(CuratorFramework client, CuratorEvent event) throws Exception
+                {
+                    if ( event.getType() == CuratorEventType.SYNC )
+                    {
+                        latch.countDown();
+                    }
+                }
+            };
+            client.sync().inBackground(callback).forPath("/head");
+            Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+        }
+        finally
+        {
+            client.close();
+        }
+    }
+
+    @Test
     public void     testBackgroundDelete() throws Exception
     {
         CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));