hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r794887 [2/2] - in /hadoop/zookeeper/trunk: ./ src/java/main/org/apache/zookeeper/ src/java/main/org/apache/zookeeper/server/ src/java/test/org/apache/zookeeper/ src/java/test/org/apache/zookeeper/server/ src/java/test/org/apache/zookeeper/...
Date Thu, 16 Jul 2009 22:09:41 GMT
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumBase.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumBase.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumBase.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumBase.java Thu Jul
16 22:09:40 2009
@@ -26,6 +26,7 @@
 import java.util.Set;
 
 import org.apache.log4j.Logger;
+import org.apache.zookeeper.PortAssignment;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
@@ -36,14 +37,32 @@
 
     File s1dir, s2dir, s3dir, s4dir, s5dir;
     QuorumPeer s1, s2, s3, s4, s5;
+    private int port1;
+    private int port2;
+    private int port3;
+    private int port4;
+    private int port5;
 
+    @Override
     protected void setUp() throws Exception {
         LOG.info("STARTING " + getName());
         setupTestEnv();
 
         JMXEnv.setUp();
 
-        hostPort = "127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183,127.0.0.1:2184,127.0.0.1:2185";
+        setUpAll();
+
+        port1 = PortAssignment.unique();
+        port2 = PortAssignment.unique();
+        port3 = PortAssignment.unique();
+        port4 = PortAssignment.unique();
+        port5 = PortAssignment.unique();
+        hostPort = "127.0.0.1:" + port1
+            + ",127.0.0.1:" + port2
+            + ",127.0.0.1:" + port3
+            + ",127.0.0.1:" + port4
+            + ",127.0.0.1:" + port5;
+        LOG.info("Ports are: " + hostPort);
 
         s1dir = ClientBase.createTmpDir();
         s2dir = ClientBase.createTmpDir();
@@ -60,27 +79,27 @@
         int initLimit = 3;
         int syncLimit = 3;
         HashMap<Long,QuorumServer> peers = new HashMap<Long,QuorumServer>();
-        peers.put(Long.valueOf(1), new QuorumServer(1, new InetSocketAddress("127.0.0.1",
3181)));
-        peers.put(Long.valueOf(2), new QuorumServer(2, new InetSocketAddress("127.0.0.1",
3182)));
-        peers.put(Long.valueOf(3), new QuorumServer(3, new InetSocketAddress("127.0.0.1",
3183)));
-        peers.put(Long.valueOf(4), new QuorumServer(4, new InetSocketAddress("127.0.0.1",
3184)));
-        peers.put(Long.valueOf(5), new QuorumServer(5, new InetSocketAddress("127.0.0.1",
3185)));
-
-        LOG.info("creating QuorumPeer 1");
-        s1 = new QuorumPeer(peers, s1dir, s1dir, 2181, 0, 1, tickTime, initLimit, syncLimit);
-        assertEquals(2181, s1.getClientPort());
-        LOG.info("creating QuorumPeer 2");
-        s2 = new QuorumPeer(peers, s2dir, s2dir, 2182, 0, 2, tickTime, initLimit, syncLimit);
-        assertEquals(2182, s2.getClientPort());
-        LOG.info("creating QuorumPeer 3");
-        s3 = new QuorumPeer(peers, s3dir, s3dir, 2183, 0, 3, tickTime, initLimit, syncLimit);
-        assertEquals(2183, s3.getClientPort());
-        LOG.info("creating QuorumPeer 4");
-        s4 = new QuorumPeer(peers, s4dir, s4dir, 2184, 0, 4, tickTime, initLimit, syncLimit);
-        assertEquals(2184, s4.getClientPort());
-        LOG.info("creating QuorumPeer 5");
-        s5 = new QuorumPeer(peers, s5dir, s5dir, 2185, 0, 5, tickTime, initLimit, syncLimit);
-        assertEquals(2185, s5.getClientPort());
+        peers.put(Long.valueOf(1), new QuorumServer(1, new InetSocketAddress("127.0.0.1",
port1 + 1000)));
+        peers.put(Long.valueOf(2), new QuorumServer(2, new InetSocketAddress("127.0.0.1",
port2 + 1000)));
+        peers.put(Long.valueOf(3), new QuorumServer(3, new InetSocketAddress("127.0.0.1",
port3 + 1000)));
+        peers.put(Long.valueOf(4), new QuorumServer(4, new InetSocketAddress("127.0.0.1",
port4 + 1000)));
+        peers.put(Long.valueOf(5), new QuorumServer(5, new InetSocketAddress("127.0.0.1",
port5 + 1000)));
+
+        LOG.info("creating QuorumPeer 1 port " + port1);
+        s1 = new QuorumPeer(peers, s1dir, s1dir, port1, 0, 1, tickTime, initLimit, syncLimit);
+        assertEquals(port1, s1.getClientPort());
+        LOG.info("creating QuorumPeer 2 port " + port2);
+        s2 = new QuorumPeer(peers, s2dir, s2dir, port2, 0, 2, tickTime, initLimit, syncLimit);
+        assertEquals(port2, s2.getClientPort());
+        LOG.info("creating QuorumPeer 3 port " + port3);
+        s3 = new QuorumPeer(peers, s3dir, s3dir, port3, 0, 3, tickTime, initLimit, syncLimit);
+        assertEquals(port3, s3.getClientPort());
+        LOG.info("creating QuorumPeer 4 port " + port4);
+        s4 = new QuorumPeer(peers, s4dir, s4dir, port4, 0, 4, tickTime, initLimit, syncLimit);
+        assertEquals(port4, s4.getClientPort());
+        LOG.info("creating QuorumPeer 5 port " + port5);
+        s5 = new QuorumPeer(peers, s5dir, s5dir, port5, 0, 5, tickTime, initLimit, syncLimit);
+        assertEquals(port5, s5.getClientPort());
         LOG.info("start QuorumPeer 1");
         s1.start();
         LOG.info("start QuorumPeer 2");
@@ -93,6 +112,7 @@
         s5.start();
         LOG.info("started QuorumPeer 5");
 
+        LOG.info ("Closing ports " + hostPort);
         for (String hp : hostPort.split(",")) {
             assertTrue("waiting for server up",
                        ClientBase.waitForServerUp(hp,
@@ -159,14 +179,14 @@
 
     protected ZooKeeper createClient()
         throws IOException, InterruptedException
-        {
+    {
         return createClient(hostPort);
-        }
+    }
 
     protected ZooKeeper createClient(String hp)
         throws IOException, InterruptedException
-        {
+    {
         CountdownWatcher watcher = new CountdownWatcher();
         return createClient(watcher, hp);
-        }
+    }
 }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumQuotaTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumQuotaTest.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumQuotaTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumQuotaTest.java Thu
Jul 16 22:09:40 2009
@@ -34,8 +34,8 @@
  */
 
 public class QuorumQuotaTest extends QuorumBase {
-    private static final Logger LOG = Logger.getLogger(
-            QuorumQuotaTest.class);
+    private static final Logger LOG =
+        Logger.getLogger(QuorumQuotaTest.class);
 
     @Override
     protected void setUp() throws Exception {

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java Thu Jul
16 22:09:40 2009
@@ -20,8 +20,6 @@
 import java.io.IOException;
 import java.util.ArrayList;
 
-import junit.framework.TestCase;
-
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
@@ -32,20 +30,23 @@
 import org.junit.Before;
 import org.junit.Test;
 
-public class QuorumTest extends TestCase {
+public class QuorumTest extends QuorumBase {
     private static final Logger LOG = Logger.getLogger(QuorumTest.class);
     public static final long CONNECTION_TIMEOUT = ClientTest.CONNECTION_TIMEOUT;
-    private QuorumBase qb = new QuorumBase();
+
+    private final QuorumBase qb = new QuorumBase();
     private final ClientTest ct = new ClientTest();
-    
+
     @Before
     @Override
     protected void setUp() throws Exception {
-        qb.setUp();        
+        qb.setUp();
         ct.hostPort = qb.hostPort;
+        ct.setUpAll();
     }
-    
+
     protected void tearDown() throws Exception {
+        ct.tearDownAll();
         qb.tearDown();
     }
 
@@ -95,7 +96,7 @@
     {
         ct.testMutipleWatcherObjs();
     }
-    
+
     @Test
     /**
      * Connect to two different servers with two different handles using the same session
and
@@ -117,7 +118,7 @@
             fail("Should have lost the connection");
         } catch(KeeperException.SessionMovedException e) {
         }
-        
+
         ArrayList<ZooKeeper> toClose = new ArrayList<ZooKeeper>();
         toClose.add(zknew);
         // Let's just make sure it can still move
@@ -128,7 +129,7 @@
             toClose.add(zknew);
             zknew.create("/t-"+i, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
         }
-	for(ZooKeeper z: toClose) {
+    for(ZooKeeper z: toClose) {
             z.close();
         }
         zk.close();

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java Thu Jul
16 22:09:40 2009
@@ -28,6 +28,7 @@
 
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.PortAssignment;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooKeeper;
@@ -42,7 +43,8 @@
 public class RecoveryTest extends TestCase implements Watcher {
     protected static final Logger LOG = Logger.getLogger(RecoveryTest.class);
 
-    private static String HOSTPORT = "127.0.0.1:2344";
+    private static final String HOSTPORT =
+        "127.0.0.1:" + PortAssignment.unique();
 
     private volatile CountDownLatch startSignal;
 
@@ -72,14 +74,14 @@
         File tmpDir = ClientBase.createTmpDir();
 
         ClientBase.setupTestEnv();
-        ZooKeeperServer zs = new ZooKeeperServer(tmpDir, tmpDir, 3000);
+        ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
 
         int oldSnapCount = SyncRequestProcessor.getSnapCount();
         SyncRequestProcessor.setSnapCount(1000);
         try {
             final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
             NIOServerCnxn.Factory f = new NIOServerCnxn.Factory(PORT);
-            f.startup(zs);
+            f.startup(zks);
             LOG.info("starting up the the server, waiting");
 
             assertTrue("waiting for server up",
@@ -115,12 +117,12 @@
                        ClientBase.waitForServerDown(HOSTPORT,
                                           CONNECTION_TIMEOUT));
 
-            zs = new ZooKeeperServer(tmpDir, tmpDir, 3000);
+            zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
             f = new NIOServerCnxn.Factory(PORT);
 
             startSignal = new CountDownLatch(1);
 
-            f.startup(zs);
+            f.startup(zks);
 
             assertTrue("waiting for server up",
                        ClientBase.waitForServerUp(HOSTPORT,
@@ -153,12 +155,12 @@
                        ClientBase.waitForServerDown(HOSTPORT,
                                           ClientBase.CONNECTION_TIMEOUT));
 
-            zs = new ZooKeeperServer(tmpDir, tmpDir, 3000);
+            zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
             f = new NIOServerCnxn.Factory(PORT);
 
             startSignal = new CountDownLatch(1);
 
-            f.startup(zs);
+            f.startup(zks);
 
             assertTrue("waiting for server up",
                        ClientBase.waitForServerUp(HOSTPORT,
@@ -184,6 +186,8 @@
                     }
                 }
             }
+            zk.close();
+
             f.shutdown();
 
             assertTrue("waiting for server down",

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java
(original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java
Thu Jul 16 22:09:40 2009
@@ -25,21 +25,24 @@
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.server.NIOServerCnxn;
 import org.apache.zookeeper.server.ZooKeeperServer;
+import org.junit.Test;
 
 /**
- * this test fails quorum peers 
- * and then brings up one of the
- * node as a standalone server
+ * this test fails quorum peers and then brings up one of the node as
+ * a standalone server
  */
 public class RepeatStartupTest extends TestCase {
-    
+
     /** bring up 5 quorum peers and then shut them down
      * and then bring one of the nodes as server
-     * @throws Exception
+     *
+     * @throws Exception might be thrown here
      */
+    @Test
     public void testFail() throws Exception {
         QuorumBase qb = new QuorumBase();
         qb.setUp();
+
         System.out.println("Comment: the servers are at " + qb.hostPort);
         ZooKeeper zk = qb.createClient();
         zk.create("/test", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
@@ -50,14 +53,11 @@
         qb.shutdown(qb.s4);
         qb.shutdown(qb.s5);
         String hp = qb.hostPort.split(",")[0];
-        ZooKeeperServer zks = new ZooKeeperServer(qb.s1.getTxnFactory().getSnapDir(), 
+        ZooKeeperServer zks = new ZooKeeperServer(qb.s1.getTxnFactory().getSnapDir(),
                 qb.s1.getTxnFactory().getDataDir(), 3000);
         final int PORT = Integer.parseInt(hp.split(":")[1]);
-        NIOServerCnxn.Factory factory = null;
-        if (factory == null) {
-            factory = new NIOServerCnxn.Factory(PORT);
-        }
-        
+        NIOServerCnxn.Factory factory = new NIOServerCnxn.Factory(PORT);
+
         factory.startup(zks);
         System.out.println("Comment: starting factory");
         assertTrue("waiting for server up",
@@ -67,6 +67,6 @@
         assertTrue("waiting for server down",
                    ClientBase.waitForServerDown("127.0.0.1:" + PORT,
                                                 QuorumTest.CONNECTION_TIMEOUT));
-        System.out.println("Comment: shutting doen standalone");
+        System.out.println("Comment: shutting down standalone");
     }
 }
\ No newline at end of file

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java Thu Jul
16 22:09:40 2009
@@ -31,6 +31,7 @@
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.PortAssignment;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooKeeper;
@@ -45,13 +46,14 @@
 public class SessionTest extends TestCase implements Watcher {
     protected static final Logger LOG = Logger.getLogger(SessionTest.class);
 
-    private static final String HOSTPORT = "127.0.0.1:33299";
+    private static final String HOSTPORT = "127.0.0.1:" +
+            PortAssignment.unique();
     private NIOServerCnxn.Factory serverFactory;
-    
+
     private CountDownLatch startSignal;
 
     File tmpDir;
-    
+
     @Override
     protected void setUp() throws Exception {
         LOG.info("STARTING " + getName());
@@ -62,7 +64,7 @@
 
         ClientBase.setupTestEnv();
         ZooKeeperServer zs = new ZooKeeperServer(tmpDir, tmpDir, 3000);
-        
+
         final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
         serverFactory = new NIOServerCnxn.Factory(PORT);
         serverFactory.startup(zs);
@@ -211,31 +213,31 @@
             CONNECTION_TIMEOUT = oldTimeout;
         }
     }
-    
+
     /**
      * Make sure that we cannot have two connections with the same
      * session id.
-     * 
+     *
      * @throws IOException
      * @throws InterruptedException
      * @throws KeeperException
      */
     @Test
     public void testSessionMove() throws IOException, InterruptedException, KeeperException
{
-    	ZooKeeper zk = createClient();
-    	zk.getChildren("/", false);
-    	// This should stomp the zk handle
-    	ZooKeeper zknew = new DisconnectableZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this,
+        ZooKeeper zk = createClient();
+        zk.getChildren("/", false);
+        // This should stomp the zk handle
+        ZooKeeper zknew = new DisconnectableZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this,
                    zk.getSessionId(),
                    zk.getSessionPasswd());
-    	zknew.getChildren("/", false);
-    	try {
-    	    zk.getChildren("/", false);
-    	    fail("Should have lost the connection");
-    	} catch(KeeperException.ConnectionLossException e) {
-    	}
-    	zknew.close();
-    	zk.close();
+        zknew.getChildren("/", false);
+        try {
+            zk.getChildren("/", false);
+            fail("Should have lost the connection");
+        } catch(KeeperException.ConnectionLossException e) {
+        }
+        zknew.close();
+        zk.close();
     }
     @Test
     /**
@@ -269,7 +271,7 @@
 
         zk.close();
     }
-    
+
     private class DupWatcher extends CountdownWatcher {
         public LinkedList<WatchedEvent> states = new LinkedList<WatchedEvent>();
         public void process(WatchedEvent event) {

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SyncCallTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SyncCallTest.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SyncCallTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SyncCallTest.java Thu Jul
16 22:09:40 2009
@@ -25,8 +25,8 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.AsyncCallback.ChildrenCallback;
 import org.apache.zookeeper.AsyncCallback.StringCallback;
 import org.apache.zookeeper.AsyncCallback.VoidCallback;

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TestHammer.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TestHammer.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TestHammer.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TestHammer.java Thu Jul
16 22:09:40 2009
@@ -20,9 +20,9 @@
 
 import java.io.IOException;
 
+import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.AsyncCallback.VoidCallback;
-import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.ZooDefs.Ids;
 
 public class TestHammer implements VoidCallback {

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java Thu Jul
16 22:09:40 2009
@@ -29,6 +29,7 @@
 
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.PortAssignment;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooKeeper;
@@ -42,12 +43,12 @@
 
 public class UpgradeTest extends TestCase implements Watcher {
     private final static Logger LOG = Logger.getLogger(UpgradeTest.class);
-    private static String HOSTPORT = "127.0.0.1:2359";
-    ZooKeeperServer zks;
+
+    private static String HOSTPORT = "127.0.0.1:" + PortAssignment.unique();
     private static final File testData = new File(
             System.getProperty("test.data.dir", "build/test/data"));
     private CountDownLatch startSignal;
-    
+
     @Override
     protected void setUp() throws Exception {
         LOG.info("STARTING " + getName());
@@ -56,7 +57,7 @@
     protected void tearDown() throws Exception {
         LOG.info("FINISHED " + getName());
     }
-    
+
     /**
      * test the upgrade
      * @throws Exception
@@ -65,43 +66,46 @@
         File upgradeDir = new File(testData, "upgrade");
         UpgradeMain upgrade = new UpgradeMain(upgradeDir, upgradeDir);
         upgrade.runUpgrade();
-        zks = new ZooKeeperServer(upgradeDir, upgradeDir, 3000);
+        ZooKeeperServer zks = new ZooKeeperServer(upgradeDir, upgradeDir, 3000);
         SyncRequestProcessor.setSnapCount(1000);
         final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
         NIOServerCnxn.Factory f = new NIOServerCnxn.Factory(PORT);
         f.startup(zks);
         LOG.info("starting up the zookeeper server .. waiting");
-        assertTrue("waiting for server being up", 
-                ClientBase.waitForServerUp(HOSTPORT,CONNECTION_TIMEOUT));
+        assertTrue("waiting for server being up",
+                ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
         ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
         Stat stat = zk.exists("/", false);
         List<String> children = zk.getChildren("/", false);
         Collections.sort(children);
-        for (int i=0; i < 10; i++) {
+        for (int i = 0; i < 10; i++) {
             assertTrue("data tree sanity check",
-                    ("test-"+ i).equals(children.get(i)));
+                    ("test-" + i).equals(children.get(i)));
         }
         //try creating one node
-        zk.create("/upgrade","upgrade".getBytes(), Ids.OPEN_ACL_UNSAFE,
+        zk.create("/upgrade", "upgrade".getBytes(), Ids.OPEN_ACL_UNSAFE,
                 CreateMode.PERSISTENT);
         // check if its there
-        if (zk.exists("/upgrade",false) == null) {
+        if (zk.exists("/upgrade", false) == null) {
             assertTrue(false);
         }
+
+        zk.close();
+
         // bring down the server
         f.shutdown();
         assertTrue("waiting for server down",
                    ClientBase.waitForServerDown(HOSTPORT,
                            ClientBase.CONNECTION_TIMEOUT));
-        
+
     }
-    
+
     public void process(WatchedEvent event) {
         LOG.info("Event:" + event.getState() + " " + event.getType() + " " + event.getPath());
         if (event.getState() == KeeperState.SyncConnected
                 && startSignal != null && startSignal.getCount() > 0)
-        {              
-            startSignal.countDown();      
+        {
+            startSignal.countDown();
         }
     }
 }
\ No newline at end of file

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatchedEventTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatchedEventTest.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatchedEventTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatchedEventTest.java Thu
Jul 16 22:09:40 2009
@@ -21,12 +21,12 @@
 import java.util.EnumSet;
 
 import junit.framework.TestCase;
-import org.junit.Test;
 
+import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher.Event.EventType;
 import org.apache.zookeeper.Watcher.Event.KeeperState;
-import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.proto.WatcherEvent;
+import org.junit.Test;
 
 public class WatchedEventTest extends TestCase {
     

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherFuncTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherFuncTest.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherFuncTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherFuncTest.java Thu
Jul 16 22:09:40 2009
@@ -25,14 +25,14 @@
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.Watcher.Event.EventType;
 import org.apache.zookeeper.Watcher.Event.KeeperState;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.WatchedEvent;
 
 public class WatcherFuncTest extends ClientBase {
     private static class SimpleWatcher implements Watcher {

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java Thu Jul
16 22:09:40 2009
@@ -132,7 +132,7 @@
     /**
      * This test checks that watches for pending requests do not get triggered,
      * but watches set by previous requests do.
-     * 
+     *
      * @throws Exception
      */
     @Test
@@ -154,14 +154,14 @@
        Thread.sleep(50);
        zk2.close();
        stopServer();
-       watches[0].waitForDisconnected(3000);
+       watches[0].waitForDisconnected(60000);
        for(int i = COUNT/2; i < COUNT; i++) {
            watches[i] = new MyWatcher();
            cbs[i] = new MyStatCallback();
            zk.exists("/test", watches[i], cbs[i], count);
        }
        startServer();
-       watches[49].waitForConnected(4000);
+       watches[COUNT/2-1].waitForConnected(60000);
        assertEquals(null, zk.exists("/test", false));
        Thread.sleep(10);
        for(int i = 0; i < COUNT/2; i++) {
@@ -177,7 +177,7 @@
        assertEquals(COUNT, count[0]);
        zk.close();
     }
-    
+
     @Test
     public void testWatcherAutoResetWithGlobal() throws Exception {
         ZooKeeper zk = null;

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperQuotaTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperQuotaTest.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperQuotaTest.java
(original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperQuotaTest.java
Thu Jul 16 22:09:40 2009
@@ -19,6 +19,7 @@
 package org.apache.zookeeper.test;
 
 import java.io.IOException;
+
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperTestClient.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperTestClient.java?rev=794887&r1=794886&r2=794887&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperTestClient.java
(original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperTestClient.java
Thu Jul 16 22:09:40 2009
@@ -23,19 +23,17 @@
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 
-import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.Watcher.Event.EventType;
 import org.apache.zookeeper.KeeperException.Code;
+import org.apache.zookeeper.Watcher.Event.EventType;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.WatchedEvent;
-import org.junit.Test;
 
 public class ZooKeeperTestClient extends TestCase implements Watcher {
   protected String hostPort = "127.0.0.1:22801";
@@ -133,7 +131,7 @@
     if (stat == null) {
       fail("node " + nodeName + " should exist");
     }
-    System.out.println("Closing client with sessionid: 0x" 
+    System.out.println("Closing client with sessionid: 0x"
             + Long.toHexString(zk.getSessionId()));
     zk.close();
     zk = new ZooKeeper(hostPort, 10000, this);
@@ -262,7 +260,7 @@
 
     event = this.getEvent(10);
     if (event == null) {
-      throw new AssertionFailedError("First event was not delivered promptly");
+      throw new Error("First event was not delivered promptly");
     }
     if (!((event.getType() == EventType.NodeChildrenChanged &&
            event.getPath().equalsIgnoreCase(parentName)) ||
@@ -276,7 +274,7 @@
     event = this.getEvent(10);
 
     if (event == null) {
-      throw new AssertionFailedError("Second event was not delivered promptly");
+      throw new Error("Second event was not delivered promptly");
     }
     if (!((event.getType() == EventType.NodeChildrenChanged &&
         event.getPath().equalsIgnoreCase(parentName)) ||
@@ -364,7 +362,6 @@
     zk.close();
   }
 
-  @Test
   public void my_test_1() throws IOException,
           InterruptedException, KeeperException {
     enode_test_1();



Mime
View raw message