zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mic...@apache.org
Subject svn commit: r1543281 - in /zookeeper/trunk: ./ src/java/test/org/apache/zookeeper/ src/java/test/org/apache/zookeeper/server/quorum/ src/java/test/org/apache/zookeeper/test/
Date Tue, 19 Nov 2013 01:03:44 GMT
Author: michim
Date: Tue Nov 19 01:03:43 2013
New Revision: 1543281

URL: http://svn.apache.org/r1543281
Log:
ZOOKEEPER-1815. Tolerate incorrectly set system hostname in tests (some one via michim)

Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/java/test/org/apache/zookeeper/ClientReconnectTest.java
    zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/Zab1_0Test.java
    zookeeper/trunk/src/java/test/org/apache/zookeeper/test/CnxManagerTest.java
    zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLEBackwardElectionRoundTest.java
    zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLELostMessageTest.java
    zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLENewEpochTest.java
    zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLEPredicateTest.java
    zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLERestartTest.java
    zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLETest.java
    zookeeper/trunk/src/java/test/org/apache/zookeeper/test/JMXEnv.java
    zookeeper/trunk/src/java/test/org/apache/zookeeper/test/NIOConnectionFactoryFdLeakTest.java

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1543281&r1=1543280&r2=1543281&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Tue Nov 19 01:03:43 2013
@@ -477,6 +477,9 @@ BUGFIXES:
   ZOOKEEPER-1812. ZooInspector reconnection always fails if first
   connection fails (Benjamin Jaton via phunt)
 
+  ZOOKEEPER-1815. Tolerate incorrectly set system hostname in tests
+  (some one via michim)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports,

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/ClientReconnectTest.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/ClientReconnectTest.java?rev=1543281&r1=1543280&r2=1543281&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/ClientReconnectTest.java (original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/ClientReconnectTest.java Tue Nov 19
01:03:43 2013
@@ -60,7 +60,7 @@ public class ClientReconnectTest extends
     public void testClientReconnect() throws IOException, InterruptedException {
         HostProvider hostProvider = mock(HostProvider.class);
         when(hostProvider.size()).thenReturn(1);
-        InetSocketAddress inaddr = new InetSocketAddress(1111);
+        InetSocketAddress inaddr = new InetSocketAddress("127.0.0.1", 1111);
         when(hostProvider.next(anyLong())).thenReturn(inaddr);
         ZooKeeper zk = mock(ZooKeeper.class);
         sc =  SocketChannel.open();
@@ -75,4 +75,4 @@ public class ClientReconnectTest extends
         Assert.assertTrue(countDownLatch.getCount() == 0);
         clientCnxn.close();
     }
-}
\ No newline at end of file
+}

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/Zab1_0Test.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/Zab1_0Test.java?rev=1543281&r1=1543280&r2=1543281&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/Zab1_0Test.java (original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/Zab1_0Test.java Tue Nov
19 01:03:43 2013
@@ -29,6 +29,7 @@ import java.io.FileReader;
 import java.io.IOException;
 import java.io.EOFException;
 import java.lang.reflect.Field;
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
@@ -309,8 +310,8 @@ public class Zab1_0Test {
 		}
     }
     static Socket[] getSocketPair() throws IOException {
-        ServerSocket ss = new ServerSocket();
-        ss.bind(null);
+        ServerSocket ss =
+            new ServerSocket(0, 50, InetAddress.getByName("127.0.0.1"));
         InetSocketAddress endPoint = (InetSocketAddress) ss.getLocalSocketAddress();
         Socket s = new Socket(endPoint.getAddress(), endPoint.getPort());
         return new Socket[] { s, ss.accept() };
@@ -464,8 +465,8 @@ public class Zab1_0Test {
             follower = createFollower(tmpDir, peer);
             peer.follower = follower;
             
-            ServerSocket ss = new ServerSocket();
-            ss.bind(null);
+            ServerSocket ss =
+                new ServerSocket(0, 50, InetAddress.getByName("127.0.0.1"));
             follower.setLeaderSocketAddress((InetSocketAddress)ss.getLocalSocketAddress());
             final Follower followerForThread = follower;
             
@@ -517,8 +518,8 @@ public class Zab1_0Test {
             observer = createObserver(tmpDir, peer);
             peer.observer = observer;
 
-            ServerSocket ss = new ServerSocket();
-            ss.bind(null);
+            ServerSocket ss =
+                new ServerSocket(0, 50, InetAddress.getByName("127.0.0.1"));
             observer.setLeaderSocketAddress((InetSocketAddress)ss.getLocalSocketAddress());
             final Observer observerForThread = observer;
 
@@ -1291,9 +1292,18 @@ public class Zab1_0Test {
         peer.initLimit = 2;
         peer.tickTime = 2000;
         
-        peers.put(0L, new QuorumServer(0, new InetSocketAddress(33221), new InetSocketAddress(33231),
new InetSocketAddress(33241)));
-        peers.put(1L, new QuorumServer(1, new InetSocketAddress(33223), new InetSocketAddress(33233),
new InetSocketAddress(33243))); 
-        peers.put(2L, new QuorumServer(2, new InetSocketAddress(33224), new InetSocketAddress(33234),
new InetSocketAddress(33245))); 
+        peers.put(0L, new QuorumServer(
+            0, new InetSocketAddress("127.0.0.1", 33221),
+               new InetSocketAddress("127.0.0.1", 33231),
+               new InetSocketAddress("127.0.0.1", 33241)));
+        peers.put(1L, new QuorumServer(
+            1, new InetSocketAddress("127.0.0.1", 33223),
+               new InetSocketAddress("127.0.0.1", 33233),
+               new InetSocketAddress("127.0.0.1", 33243)));
+        peers.put(2L, new QuorumServer(
+            2, new InetSocketAddress("127.0.0.1", 33224),
+               new InetSocketAddress("127.0.0.1", 33234),
+               new InetSocketAddress("127.0.0.1", 33245)));
         
         peer.setQuorumVerifier(new QuorumMaj(peers), false);
         peer.setCnxnFactory(new NullServerCnxnFactory());

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/test/CnxManagerTest.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/CnxManagerTest.java?rev=1543281&r1=1543280&r2=1543281&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/test/CnxManagerTest.java (original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/test/CnxManagerTest.java Tue Nov 19
01:03:43 2013
@@ -65,10 +65,13 @@ public class CnxManagerTest extends ZKTe
             peerQuorumPort[i] = PortAssignment.unique();
             peerClientPort[i] = PortAssignment.unique();
             peers.put(Long.valueOf(i),
-                    new QuorumServer(i,
-                            new InetSocketAddress(peerQuorumPort[i]),
-                    new InetSocketAddress(PortAssignment.unique()), 
-                    new InetSocketAddress(peerClientPort[i])));
+                new QuorumServer(i,
+                    new InetSocketAddress(
+                        "127.0.0.1", peerQuorumPort[i]),
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique()),
+                    new InetSocketAddress(
+                        "127.0.0.1", peerClientPort[i])));
             peerTmpdir[i] = ClientBase.createTmpDir();
         }
     }

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLEBackwardElectionRoundTest.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLEBackwardElectionRoundTest.java?rev=1543281&r1=1543280&r2=1543281&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLEBackwardElectionRoundTest.java
(original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLEBackwardElectionRoundTest.java
Tue Nov 19 01:03:43 2013
@@ -93,9 +93,10 @@ public class FLEBackwardElectionRoundTes
         for(int i = 0; i < count; i++) {
             int clientport = PortAssignment.unique();
             peers.put(Long.valueOf(i),
-                    new QuorumServer(i,
-                            new InetSocketAddress(clientport),
-                            new InetSocketAddress(PortAssignment.unique())));
+                new QuorumServer(i,
+                    new InetSocketAddress("127.0.0.1", clientport),
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique())));
             tmpdir[i] = ClientBase.createTmpDir();
             port[i] = clientport;
         }
@@ -156,4 +157,4 @@ public class FLEBackwardElectionRoundTes
         }
         
     }
-}
\ No newline at end of file
+}

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLELostMessageTest.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLELostMessageTest.java?rev=1543281&r1=1543280&r2=1543281&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLELostMessageTest.java (original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLELostMessageTest.java Tue Nov
19 01:03:43 2013
@@ -70,9 +70,10 @@ public class FLELostMessageTest extends 
         for(int i = 0; i < count; i++) {
             int clientport = PortAssignment.unique();
             peers.put(Long.valueOf(i),
-                    new QuorumServer(i,
-                            new InetSocketAddress(clientport),
-                            new InetSocketAddress(PortAssignment.unique())));
+                new QuorumServer(i,
+                    new InetSocketAddress("127.0.0.1", clientport),
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique())));
             tmpdir[i] = ClientBase.createTmpDir();
             port[i] = clientport;
         }

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLENewEpochTest.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLENewEpochTest.java?rev=1543281&r1=1543280&r2=1543281&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLENewEpochTest.java (original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLENewEpochTest.java Tue Nov 19
01:03:43 2013
@@ -157,9 +157,11 @@ public class FLENewEpochTest extends ZKT
           LOG.info("TestLE: " + getTestName()+ ", " + count);
           for(int i = 0; i < count; i++) {
               peers.put(Long.valueOf(i),
-                      new QuorumServer(i,
-                              new InetSocketAddress(PortAssignment.unique()),
-                      new InetSocketAddress(PortAssignment.unique())));
+                  new QuorumServer(i,
+                      new InetSocketAddress(
+                          "127.0.0.1", PortAssignment.unique()),
+                      new InetSocketAddress(
+                          "127.0.0.1", PortAssignment.unique())));
               tmpdir[i] = ClientBase.createTmpDir();
               port[i] = PortAssignment.unique();
           }

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLEPredicateTest.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLEPredicateTest.java?rev=1543281&r1=1543280&r2=1543281&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLEPredicateTest.java (original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLEPredicateTest.java Tue Nov
19 01:03:43 2013
@@ -62,9 +62,11 @@ public class FLEPredicateTest extends ZK
          */
         for(int i = 0; i < 3; i++) {
             peers.put(Long.valueOf(i),
-                    new QuorumServer(i,
-                            new InetSocketAddress(PortAssignment.unique()),
-                    new InetSocketAddress(PortAssignment.unique())));
+                new QuorumServer(i,
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique()),
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique())));
         }
 
         /*

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLERestartTest.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLERestartTest.java?rev=1543281&r1=1543280&r2=1543281&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLERestartTest.java (original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLERestartTest.java Tue Nov 19
01:03:43 2013
@@ -159,9 +159,11 @@ public class FLERestartTest extends ZKTe
         LOG.info("TestLE: " + getTestName()+ ", " + count);
         for(int i = 0; i < count; i++) {
             peers.put(Long.valueOf(i),
-                    new QuorumServer(i,
-                            new InetSocketAddress(PortAssignment.unique()),
-                    new InetSocketAddress(PortAssignment.unique())));
+                new QuorumServer(i,
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique()),
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique())));
             tmpdir[i] = ClientBase.createTmpDir();
             port[i] = PortAssignment.unique();
         }

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLETest.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLETest.java?rev=1543281&r1=1543280&r2=1543281&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLETest.java (original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLETest.java Tue Nov 19 01:03:43
2013
@@ -305,10 +305,13 @@ public class FLETest extends ZKTestCase 
         for(int i = 0; i < count; i++) {
             port[i] = PortAssignment.unique();
             peers.put(Long.valueOf(i),
-                    new QuorumServer(i,
-                            new InetSocketAddress("127.0.0.1", PortAssignment.unique()),
-                    new InetSocketAddress("127.0.0.1", PortAssignment.unique()),
-                    new InetSocketAddress("127.0.0.1", port[i])));
+                new QuorumServer(i,
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique()),
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique()),
+                    new InetSocketAddress(
+                        "127.0.0.1", port[i])));
             tmpdir[i] = ClientBase.createTmpDir();           
         }
 
@@ -410,10 +413,13 @@ public class FLETest extends ZKTestCase 
         for(sid = 0; sid < 3; sid++) {
             port[sid] = PortAssignment.unique();
             peers.put(Long.valueOf(sid),
-                    new QuorumServer(sid,
-                            new InetSocketAddress("127.0.0.1", PortAssignment.unique()),
-                    new InetSocketAddress("127.0.0.1", PortAssignment.unique()),
-                    new InetSocketAddress("127.0.0.1", port[sid])));
+                new QuorumServer(sid,
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique()),
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique()),
+                    new InetSocketAddress(
+                        "127.0.0.1", port[sid])));
             tmpdir[sid] = ClientBase.createTmpDir();          
         }
         // start 2 peers and verify if they form the cluster
@@ -467,9 +473,11 @@ public class FLETest extends ZKTestCase 
         ArrayList<QuorumPeer> peerList = new ArrayList<QuorumPeer>();
         for(sid = 0; sid < 3; sid++) {
             peers.put(Long.valueOf(sid),
-                    new QuorumServer(sid,
-                            new InetSocketAddress(PortAssignment.unique()),
-                    new InetSocketAddress(PortAssignment.unique())));
+                new QuorumServer(sid,
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique()),
+                    new InetSocketAddress(
+                        "127.0.0.1", PortAssignment.unique())));
             tmpdir[sid] = ClientBase.createTmpDir();
             port[sid] = PortAssignment.unique();
         }

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/test/JMXEnv.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/JMXEnv.java?rev=1543281&r1=1543280&r2=1543281&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/test/JMXEnv.java (original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/test/JMXEnv.java Tue Nov 19 01:03:43
2013
@@ -49,7 +49,7 @@ public class JMXEnv {
     public static void setUp() throws IOException {
         MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer();
         
-        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
+        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://127.0.0.1");
         cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
         cs.start();
 

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/test/NIOConnectionFactoryFdLeakTest.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/NIOConnectionFactoryFdLeakTest.java?rev=1543281&r1=1543280&r2=1543281&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/test/NIOConnectionFactoryFdLeakTest.java
(original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/test/NIOConnectionFactoryFdLeakTest.java
Tue Nov 19 01:03:43 2013
@@ -51,8 +51,9 @@ public class NIOConnectionFactoryFdLeakT
 
         for (int i = 0; i < 50; ++i) {
             NIOServerCnxnFactory factory = new NIOServerCnxnFactory();
-            factory.configure(new InetSocketAddress(PortAssignment.unique()),
-                    10);
+            factory.configure(
+                new InetSocketAddress(
+                    "127.0.0.1", PortAssignment.unique()), 10);
             factory.start();
             Thread.sleep(100);
             factory.shutdown();



Mime
View raw message