zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f..@apache.org
Subject svn commit: r1552447 - in /zookeeper/branches/branch-3.4: ./ src/java/test/org/apache/zookeeper/ src/java/test/org/apache/zookeeper/server/ src/java/test/org/apache/zookeeper/test/
Date Thu, 19 Dec 2013 22:36:09 GMT
Author: fpj
Date: Thu Dec 19 22:36:08 2013
New Revision: 1552447

URL: http://svn.apache.org/r1552447
Log:
ZOOKEEPER-1849. Need to properly tear down tests in various 
  cases (Germán via fpj)


Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/JUnit4ZKTestRunner.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/server/CRCTest.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ACLCountTest.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ACLTest.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/InvalidSnapshotTest.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/LoadFromLogTest.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/MaxCnxnsTest.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/OOMTest.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/PurgeTxnTest.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RecoveryTest.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RestoreCommittedLogTest.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/SessionTest.java

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Thu Dec 19 22:36:08 2013
@@ -199,9 +199,13 @@ BUGFIXES:
 
   ZOOKEEPER-1841. problem in QuorumTest (Germán via fpj)
 
-  ZOOKEEPER-1733. FLETest#testLE is flaky on windows boxes 
+  ZOOKEEPER-1733 FLETest#testLE is flaky oo.l windows boxes 
   (michim, Jeffrey Zhong via fpj)
 
+  ZOOKEEPER-1849. Need to properly tear down tests in various
+  cases (Germán via fpj) 
+
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1564. Allow JUnit test build with IBM Java

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/JUnit4ZKTestRunner.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/JUnit4ZKTestRunner.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/JUnit4ZKTestRunner.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/JUnit4ZKTestRunner.java
Thu Dec 19 22:36:08 2013
@@ -50,6 +50,14 @@ public class JUnit4ZKTestRunner extends 
             LOG.info("RUNNING TEST METHOD " + name);
             try {
                 super.evaluate();
+                Runtime rt = Runtime.getRuntime();
+                long usedKB = (rt.totalMemory() - rt.freeMemory()) / 1024;
+                LOG.info("Memory used {}", usedKB);
+                ThreadGroup tg = Thread.currentThread().getThreadGroup();
+                while (tg.getParent() != null) {
+                    tg = tg.getParent();
+                }
+                LOG.info("Number of threads {}", tg.activeCount());
             } catch (Throwable t) {
                 LOG.info("TEST METHOD FAILED " + name, t);
                 throw t;

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/server/CRCTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/server/CRCTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/server/CRCTest.java (original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/server/CRCTest.java Thu
Dec 19 22:36:08 2013
@@ -131,6 +131,7 @@ public class CRCTest extends ZKTestCase 
             zk.close();
         }
         f.shutdown();
+        zks.shutdown();
         Assert.assertTrue("waiting for server down",
                    ClientBase.waitForServerDown(HOSTPORT,
                            ClientBase.CONNECTION_TIMEOUT));

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ACLCountTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ACLCountTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ACLCountTest.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ACLCountTest.java
Thu Dec 19 22:36:08 2013
@@ -110,8 +110,8 @@ public class ACLCountTest extends ZKTest
           Assert.assertTrue(false);
         }
 
-        Assert.assertTrue(true);
-
+        f.shutdown();
+        zks.shutdown();
     }
 
 

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ACLTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ACLTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ACLTest.java (original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ACLTest.java Thu
Dec 19 22:36:08 2013
@@ -71,7 +71,7 @@ public class ACLTest extends ZKTestCase 
             }
         } finally {
             f.shutdown();
-
+            zks.shutdown();
             Assert.assertTrue("waiting for server down",
                     ClientBase.waitForServerDown(HOSTPORT,
                             ClientBase.CONNECTION_TIMEOUT));
@@ -122,6 +122,7 @@ public class ACLTest extends ZKTestCase 
         } finally {
             // now shutdown the server and restart it
             f.shutdown();
+            zks.shutdown();
             Assert.assertTrue("waiting for server down",
                     ClientBase.waitForServerDown(HOSTPORT, CONNECTION_TIMEOUT));
         }
@@ -157,7 +158,7 @@ public class ACLTest extends ZKTestCase 
             zk.close();
         } finally {
             f.shutdown();
-    
+            zks.shutdown();
             Assert.assertTrue("waiting for server down",
                        ClientBase.waitForServerDown(HOSTPORT,
                                ClientBase.CONNECTION_TIMEOUT));

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java
Thu Dec 19 22:36:08 2013
@@ -99,6 +99,7 @@ public class ClientPortBindTest extends 
             zk.close();
         } finally {
             f.shutdown();
+            zks.shutdown();
 
             Assert.assertTrue("waiting for server down",
                        ClientBase.waitForServerDown(HOSTPORT,

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/InvalidSnapshotTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/InvalidSnapshotTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/InvalidSnapshotTest.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/InvalidSnapshotTest.java
Thu Dec 19 22:36:08 2013
@@ -107,6 +107,7 @@ public class InvalidSnapshotTest extends
             zk.close();
         }
         f.shutdown();
+        zks.shutdown();
         Assert.assertTrue("waiting for server down",
                    ClientBase.waitForServerDown(HOSTPORT,
                            ClientBase.CONNECTION_TIMEOUT));

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/LoadFromLogTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/LoadFromLogTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/LoadFromLogTest.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/LoadFromLogTest.java
Thu Dec 19 22:36:08 2013
@@ -115,6 +115,7 @@ public class LoadFromLogTest extends ZKT
         }while(itr.next());
 	
         Assert.assertTrue("processed all transactions. " + expectedZxid + " == " + TOTAL_TRANSACTIONS,
(expectedZxid == TOTAL_TRANSACTIONS));
+        zks.shutdown();
     }
 
 
@@ -366,6 +367,7 @@ public class LoadFromLogTest extends ZKT
 				+ " expected " + NUM_MESSAGES,
 				(children.length == NUM_MESSAGES));
 		f.shutdown();
+                zks.shutdown();
 	}
     
     /**
@@ -433,5 +435,6 @@ public class LoadFromLogTest extends ZKT
                 .waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
         
         f.shutdown();
+        zks.shutdown();
     }
 }
\ No newline at end of file

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/MaxCnxnsTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/MaxCnxnsTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/MaxCnxnsTest.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/MaxCnxnsTest.java
Thu Dec 19 22:36:08 2013
@@ -51,6 +51,7 @@ public class MaxCnxnsTest extends Client
         }
 
         public void run() {
+            SocketChannel sChannel = null;
             try {
                 /*
                  * For future unwary socket programmers: although connect 'blocks' it
@@ -58,7 +59,7 @@ public class MaxCnxnsTest extends Client
                  * you can not assume that all the sockets are connected at the end of
                  * this for loop.
                  */
-                SocketChannel sChannel = SocketChannel.open();
+                sChannel = SocketChannel.open();
                 sChannel.connect(new InetSocketAddress(host,port));
                 // Construct a connection request
                 ConnectRequest conReq = new ConnectRequest(0, 0,
@@ -97,6 +98,15 @@ public class MaxCnxnsTest extends Client
             catch (IOException io) {
                 // "Connection reset by peer"
             }
+            finally {
+                if (sChannel != null) {
+                    try {
+                        sChannel.close();
+                    }
+                    catch (Exception e) {
+                    }
+                }
+            }
         }
     }
 

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/OOMTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/OOMTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/OOMTest.java (original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/OOMTest.java Thu
Dec 19 22:36:08 2013
@@ -98,6 +98,7 @@ public class OOMTest extends ZKTestCase 
         hog.get(0)[0] = (byte) 1;
 
         f.shutdown();
+        zks.shutdown();
         Assert.assertTrue("waiting for server down",
                    ClientBase.waitForServerDown("127.0.0.1:" + PORT,
                                                 CONNECTION_TIMEOUT));

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/PurgeTxnTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/PurgeTxnTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/PurgeTxnTest.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/PurgeTxnTest.java
Thu Dec 19 22:36:08 2013
@@ -78,6 +78,7 @@ public class PurgeTxnTest extends ZKTest
             }
         }
         Assert.assertTrue("exactly 3 snapshots ", (numSnaps == 3));
+        zks.shutdown();
     }
 
     public void process(WatchedEvent event) {

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RecoveryTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RecoveryTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RecoveryTest.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RecoveryTest.java
Thu Dec 19 22:36:08 2013
@@ -105,6 +105,7 @@ public class RecoveryTest extends ZKTest
             }
 
             f.shutdown();
+            zks.shutdown();
             Assert.assertTrue("waiting for server down",
                        ClientBase.waitForServerDown(HOSTPORT,
                                           CONNECTION_TIMEOUT));
@@ -142,6 +143,7 @@ public class RecoveryTest extends ZKTest
                 }
             }
             f.shutdown();
+            zks.shutdown();
 
             Assert.assertTrue("waiting for server down",
                        ClientBase.waitForServerDown(HOSTPORT,
@@ -181,6 +183,7 @@ public class RecoveryTest extends ZKTest
             zk.close();
 
             f.shutdown();
+            zks.shutdown();
 
             Assert.assertTrue("waiting for server down",
                        ClientBase.waitForServerDown(HOSTPORT,

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java
Thu Dec 19 22:36:08 2013
@@ -60,6 +60,7 @@ public class RepeatStartupTest extends Z
                    ClientBase.waitForServerUp("127.0.0.1:" + PORT,
                            QuorumTest.CONNECTION_TIMEOUT));
         factory.shutdown();
+        zks.shutdown();
         Assert.assertTrue("waiting for server down",
                    ClientBase.waitForServerDown("127.0.0.1:" + PORT,
                                                 QuorumTest.CONNECTION_TIMEOUT));

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RestoreCommittedLogTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RestoreCommittedLogTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RestoreCommittedLogTest.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/RestoreCommittedLogTest.java
Thu Dec 19 22:36:08 2013
@@ -70,6 +70,7 @@ public class RestoreCommittedLogTest ext
             zk.close();
         }
         f.shutdown();
+        zks.shutdown();
         Assert.assertTrue("waiting for server to shutdown",
                 ClientBase.waitForServerDown(HOSTPORT, CONNECTION_TIMEOUT));
 
@@ -80,6 +81,7 @@ public class RestoreCommittedLogTest ext
         int logsize = committedLog.size();
         LOG.info("committedLog size = " + logsize);
         Assert.assertTrue("log size != 0", (logsize != 0));
+        zks.shutdown();
     }
 
     public void process(WatchedEvent event) {

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/SessionTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/SessionTest.java?rev=1552447&r1=1552446&r2=1552447&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/SessionTest.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/test/SessionTest.java
Thu Dec 19 22:36:08 2013
@@ -57,6 +57,7 @@ public class SessionTest extends ZKTestC
             PortAssignment.unique();
     
     private ServerCnxnFactory serverFactory;
+    private ZooKeeperServer zs;
 
     private CountDownLatch startSignal;
 
@@ -71,7 +72,7 @@ public class SessionTest extends ZKTestC
         }
 
         ClientBase.setupTestEnv();
-        ZooKeeperServer zs = new ZooKeeperServer(tmpDir, tmpDir, TICK_TIME);
+        zs = new ZooKeeperServer(tmpDir, tmpDir, TICK_TIME);
 
         final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
         serverFactory = ServerCnxnFactory.createFactory(PORT, -1);
@@ -85,6 +86,7 @@ public class SessionTest extends ZKTestC
     @After
     public void tearDown() throws Exception {
         serverFactory.shutdown();
+        zs.shutdown();
         Assert.assertTrue("waiting for server down",
                    ClientBase.waitForServerDown(HOSTPORT,
                                                 CONNECTION_TIMEOUT));



Mime
View raw message