geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject geode git commit: GEODE-1793 LocatorDUnitTest.testStartTwoLocatorsOneWithSSLAndTheOtherNonSSL
Date Fri, 03 Mar 2017 21:51:09 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-1793 [created] 866dc5ca1


GEODE-1793 LocatorDUnitTest.testStartTwoLocatorsOneWithSSLAndTheOtherNonSSL

This was a product issue.  When the locator using plain-text sockets is
contacted by a TcpClient using SSL the locator often just closes the socket.
On some platforms this causes a SSLHandshakeException but on others it
just causes a "SocketException: connection reset".  Writing some text to
the socket forces the TcpClient to get a SSLException (which is the superclass
of SSLHandshakeException).

The test class is still marked as Flaky due to GEODE-2542.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/866dc5ca
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/866dc5ca
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/866dc5ca

Branch: refs/heads/feature/GEODE-1793
Commit: 866dc5ca1583c5fab49ec96c48d261c0367427f3
Parents: 5ec0d47
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
Authored: Fri Mar 3 13:47:42 2017 -0800
Committer: Bruce Schuchardt <bschuchardt@pivotal.io>
Committed: Fri Mar 3 13:47:42 2017 -0800

----------------------------------------------------------------------
 .../internal/tcpserver/TcpClient.java           |   5 +-
 .../internal/tcpserver/TcpServer.java           |  15 +-
 .../geode/distributed/LocatorDUnitTest.java     | 159 ++-----------------
 3 files changed, 29 insertions(+), 150 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/866dc5ca/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpClient.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpClient.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpClient.java
index 47b5703..6b54170 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpClient.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpClient.java
@@ -25,6 +25,7 @@ import java.net.Socket;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.net.ssl.SSLException;
 import javax.net.ssl.SSLHandshakeException;
 
 import org.apache.logging.log4j.Logger;
@@ -264,8 +265,8 @@ public class TcpClient {
     try {
       sock = socketCreator.connect(ipAddr.getAddress(), ipAddr.getPort(), timeout, null,
false);
       sock.setSoTimeout(timeout);
-    } catch (SSLHandshakeException e) {
-      throw new LocatorCancelException("Unrecognisable response received", e);
+    } catch (SSLException e) {
+      throw new LocatorCancelException("Unable to form SSL connection", e);
     }
 
     try {

http://git-wip-us.apache.org/repos/asf/geode/blob/866dc5ca/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
index 4265349..8f1b537 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
@@ -77,9 +77,9 @@ public class TcpServer {
    * <p>
    * This should be incremented if the gossip message structures change
    * <p>
-   * 1000 - gemfire 5.5 - using java serialization 1001 - 5.7 - using DataSerializable and
-   * supporting server locator messages. 1002 - 7.1 - sending GemFire version along with
-   * GOSSIP_VERSION in each request.
+   * 1000 - gemfire 5.5 - using java serialization<br>
+   * 1001 - 5.7 - using DataSerializable and supporting server locator messages.<br>
+   * 1002 - 7.1 - sending GemFire version along with GOSSIP_VERSION in each request.
    * <p>
    * with the addition of support for all old versions of clients you can no longer change
this
    * version number
@@ -89,7 +89,7 @@ public class TcpServer {
   // This GOSSIPVERSION is used in _getVersionForAddress request for getting GemFire version
of a
   // GossipServer.
   public final static int OLDGOSSIPVERSION = 1001;
-
+  
   private static/* GemStoneAddition */ final Map GOSSIP_TO_GEMFIRE_VERSION_MAP = new HashMap();
 
   // For test purpose only
@@ -360,6 +360,13 @@ public class TcpServer {
           versionOrdinal = (short) GOSSIP_TO_GEMFIRE_VERSION_MAP.get(gossipVersion);
         } else {
           // Close the socket. We can not accept requests from a newer version
+          try {
+            sock.getOutputStream().write("unknown protocol version".getBytes());
+            sock.getOutputStream().flush();
+          } catch (IOException e) {
+            log.debug("exception in sending reply to process using unknown protocol "
+                + gossipVersion, e);
+          }
           sock.close();
           return;
         }

http://git-wip-us.apache.org/repos/asf/geode/blob/866dc5ca/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java
index 37e8b5c..5812e74 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java
@@ -20,7 +20,6 @@ import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_NETWOR
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_TTL;
 import static org.apache.geode.distributed.ConfigurationProperties.MEMBER_TIMEOUT;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTHENTICATOR;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTH_INIT;
@@ -43,7 +42,6 @@ import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import org.apache.geode.distributed.internal.membership.gms.Services;
 import org.apache.geode.test.dunit.AsyncInvocation;
 import org.awaitility.Awaitility;
 import org.apache.geode.ForcedDisconnectException;
@@ -86,7 +84,6 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.geode.test.junit.categories.MembershipTest;
 import org.apache.geode.util.test.TestUtil;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -311,14 +308,14 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
   private Boolean startLocatorWithPortAndProperties(final int port, final Properties properties)
       throws IOException {
     try {
-      System.setProperty("p2p.joinTimeout", "5000"); // set a short join timeout. default
is 17000ms
+//      System.setProperty("p2p.joinTimeout", "5000"); // set a short join timeout. default
is 17000ms
       Locator.startLocatorAndDS(port, new File(""), properties);
     } catch (SystemConnectException e) {
       return Boolean.FALSE;
     } catch (GemFireConfigException e) {
       return Boolean.FALSE;
     } finally {
-      System.getProperties().remove("p2p.joinTimeout");
+//      System.getProperties().remove("p2p.joinTimeout");
     }
     return Boolean.TRUE;
   }
@@ -507,7 +504,6 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
     }
   }
 
-  @Ignore
   @Test
   public void testSSLEnabledLocatorDiesWhenConnectingToNonSSLLocator() {
     IgnoredException.addIgnoredException("Remote host closed connection during handshake");
@@ -640,10 +636,10 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
       throws IOException {
     Locator locator;
     try {
-      System.setProperty("p2p.joinTimeout", "5000"); // set a short join timeout. default
is 17000ms
+//      System.setProperty("p2p.joinTimeout", "5000"); // set a short join timeout. default
is 17000ms
       locator = Locator.startLocatorAndDS(port, new File(""), properties);
     } finally {
-      System.getProperties().remove("p2p.joinTimeout");
+//      System.getProperties().remove("p2p.joinTimeout");
     }
     return locator;
   }
@@ -1309,7 +1305,7 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
     bgexecLogger.info(addExpected);
 
     boolean exceptionOccurred = true;
-    String oldValue = (String) System.getProperties().put("p2p.joinTimeout", "15000");
+//    String oldValue = (String) System.getProperties().put("p2p.joinTimeout", "15000");
     try {
       DistributedSystem.connect(props);
       exceptionOccurred = false;
@@ -1326,11 +1322,11 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
       // if expected then add in a catch block for it above this catch
       org.apache.geode.test.dunit.Assert.fail("Failed with unexpected exception", ex);
     } finally {
-      if (oldValue == null) {
-        System.getProperties().remove("p2p.joinTimeout");
-      } else {
-        System.getProperties().put("p2p.joinTimeout", oldValue);
-      }
+//      if (oldValue == null) {
+//        System.getProperties().remove("p2p.joinTimeout");
+//      } else {
+//        System.getProperties().put("p2p.joinTimeout", oldValue);
+//      }
       bgexecLogger.info(removeExpected);
     }
 
@@ -1449,7 +1445,7 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
     DistributedTestUtils.deleteLocatorStateFile(port1);
     final String locators = NetworkUtils.getServerHostName(host) + "[" + port + "]";
 
-    vm0.invoke(getUniqueName() + 1, () -> getStartSBLocatorRunnable(port));
+    vm0.invoke(getUniqueName() + 1, () -> startSBLocator(port));
     try {
 
       final Properties props = new Properties();
@@ -1489,7 +1485,7 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
       // restart the locator to demonstrate reconnection & make disconnects faster
       // it should also regain the role of coordinator, so we check to make sure
       // that the coordinator has changed
-      vm0.invoke(getUniqueName() + "2", () -> getStartSBLocatorRunnable(port));
+      vm0.invoke(getUniqueName() + "2", () -> startSBLocator(port));
 
       final DistributedMember tempCoord = newCoord;
 
@@ -1532,20 +1528,6 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
 
   }
 
-  /**
-   * set a short locator refresh rate
-   */
-  public static void setShortRefreshWait() {
-    System.setProperty("p2p.gossipRefreshRate", "2000");
-  }
-
-  /**
-   * remove shortened locator refresh rate
-   */
-  public static void resetRefreshWait() {
-    System.getProperties().remove("p2p.gossipRefreshRate");
-  }
-
   public static boolean isSystemConnected() {
     DistributedSystem sys = InternalDistributedSystem.getAnyInstance();
     if (sys != null && sys.isConnected()) {
@@ -1817,117 +1799,6 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
   }
 
   /**
-   * Tests starting multiple locators in multiple VMs.
-   */
-  @Test
-  public void testMultipleMcastLocators() throws Exception {
-    disconnectAllFromDS();
-    IgnoredException.addIgnoredException("Could not stop  Distribution Locator"); // shutdown
timing
-    // issue in
-    // InternalLocator
-    Host host = Host.getHost(0);
-    VM vm0 = host.getVM(0);
-    VM vm1 = host.getVM(1);
-    VM vm2 = host.getVM(2);
-    VM vm3 = host.getVM(3);
-
-    final int[] freeTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
-    final int port1 = freeTCPPorts[0];
-    this.port1 = port1;
-    final int port2 = freeTCPPorts[1];
-    this.port2 = port2;
-    DistributedTestUtils.deleteLocatorStateFile(port1, port2);
-    final int mcastport = AvailablePort.getRandomAvailablePort(AvailablePort.MULTICAST);
-
-    final String host0 = NetworkUtils.getServerHostName(host);
-    final String locators = host0 + "[" + port1 + "]," + host0 + "[" + port2 + "]";
-    final String uniqueName = getUniqueName();
-
-    vm0.invoke(new SerializableRunnable("Start locator on " + port1) {
-      public void run() {
-        File logFile = new File("");
-        try {
-          Properties props = new Properties();
-          props.setProperty(MCAST_PORT, String.valueOf(mcastport));
-          props.setProperty(LOCATORS, locators);
-          props.setProperty(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
-          props.setProperty(MCAST_TTL, "0");
-          props.setProperty(ENABLE_NETWORK_PARTITION_DETECTION, "true");
-          props.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
-
-          addDSProps(props);
-          Locator.startLocatorAndDS(port1, logFile, null, props);
-        } catch (IOException ex) {
-          org.apache.geode.test.dunit.Assert.fail("While starting locator on port " + port1,
ex);
-        }
-      }
-    });
-    vm3.invoke("Start locator on " + port2, () -> {
-      File logFile = new File("");
-      try {
-        Properties props = new Properties();
-        props.setProperty(MCAST_PORT, String.valueOf(mcastport));
-        props.setProperty(LOCATORS, locators);
-        props.setProperty(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
-        props.setProperty(MCAST_TTL, "0");
-        props.setProperty(ENABLE_NETWORK_PARTITION_DETECTION, "true");
-        props.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
-        addDSProps(props);
-        Locator.startLocatorAndDS(port2, logFile, null, props);
-      } catch (IOException ex) {
-        org.apache.geode.test.dunit.Assert.fail("While starting locator on port " + port2,
ex);
-      }
-    });
-
-    SerializableRunnable connect = new SerializableRunnable("Connect to " + locators) {
-      public void run() {
-        Properties props = new Properties();
-        props.setProperty(MCAST_PORT, String.valueOf(mcastport));
-        props.setProperty(LOCATORS, locators);
-        props.setProperty(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
-        props.setProperty(MCAST_TTL, "0");
-        props.setProperty(ENABLE_NETWORK_PARTITION_DETECTION, "true");
-        addDSProps(props);
-        DistributedSystem.connect(props);
-      }
-    };
-    try {
-      vm1.invoke(connect);
-      vm2.invoke(connect);
-
-      Properties props = new Properties();
-      props.setProperty(MCAST_PORT, String.valueOf(mcastport));
-      props.setProperty(LOCATORS, locators);
-      props.setProperty(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
-      props.setProperty(MCAST_TTL, "0");
-      props.setProperty(ENABLE_NETWORK_PARTITION_DETECTION, "true");
-
-      addDSProps(props);
-      system = (InternalDistributedSystem) DistributedSystem.connect(props);
-
-      Awaitility.waitAtMost(WAIT2_MS, TimeUnit.MILLISECONDS)
-          .pollInterval(200, TimeUnit.MILLISECONDS).until(() -> {
-            try {
-              return system.getDM().getViewMembers().size() == 5;
-            } catch (Exception e) {
-              org.apache.geode.test.dunit.Assert.fail("unexpected exception", e);
-            }
-            return false; // NOTREACHED
-          });
-      system.disconnect();
-
-      vm1.invoke(() -> disconnectDistributedSystem());
-      vm2.invoke(() -> disconnectDistributedSystem());
-    } finally {
-      vm0.invoke(() -> stopLocator());
-      vm3.invoke(() -> stopLocator());
-      if (system != null) {
-        system.disconnect();
-      }
-    }
-  }
-
-  /**
    * Tests that a VM can connect to a locator that is hosted in its own VM.
    */
   @Test
@@ -2087,11 +1958,11 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
     }
   }
 
-  private void getStartSBLocatorRunnable(final int port) {
+  private void startSBLocator(final int port) {
     File logFile = new File("");
     try {
       System.setProperty(InternalLocator.LOCATORS_PREFERRED_AS_COORDINATORS, "true");
-      System.setProperty("p2p.joinTimeout", "1000");
+//      System.setProperty("p2p.joinTimeout", "1000");
       Properties locProps = new Properties();
       locProps.put(MCAST_PORT, "0");
       locProps.put(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
@@ -2101,7 +1972,7 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
       org.apache.geode.test.dunit.Assert.fail("While starting locator on port " + port, ex);
     } finally {
       System.getProperties().remove(InternalLocator.LOCATORS_PREFERRED_AS_COORDINATORS);
-      System.getProperties().remove("p2p.joinTimeout");
+//      System.getProperties().remove("p2p.joinTimeout");
     }
   }
 


Mime
View raw message