geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jche...@apache.org
Subject incubator-geode git commit: GEODE-944 ServerLauncherJUnitTest fails when ISP redirects DNS failures
Date Fri, 19 Feb 2016 17:38:55 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop ab9cedf8f -> e51d1e447


GEODE-944 ServerLauncherJUnitTest fails when ISP redirects DNS failures

The LocatorLauncher and ServerLauncher will check if a bind address is
the address of the machine on which it is launching.


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

Branch: refs/heads/develop
Commit: e51d1e447776ff2190e216d16530ecd6541f9255
Parents: ab9cedf
Author: Jianxia Chen <jchen@pivotal.io>
Authored: Fri Feb 19 09:36:04 2016 -0800
Committer: Jianxia Chen <jchen@pivotal.io>
Committed: Fri Feb 19 09:36:04 2016 -0800

----------------------------------------------------------------------
 .../gemfire/distributed/LocatorLauncher.java    |  7 ++++-
 .../gemfire/distributed/ServerLauncher.java     |  9 +++++--
 .../distributed/LocatorLauncherJUnitTest.java   | 27 +++++++++++++++++---
 .../distributed/ServerLauncherJUnitTest.java    | 26 +++++++++++++++++--
 4 files changed, 61 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e51d1e44/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/LocatorLauncher.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/LocatorLauncher.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/LocatorLauncher.java
index d13dae5..b0be89f 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/LocatorLauncher.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/LocatorLauncher.java
@@ -1481,7 +1481,12 @@ public final class LocatorLauncher extends AbstractLauncher<String>
{
       else {
         try {
           this.bindAddress = InetAddress.getByName(bindAddress);
-          return this;
+          if (SocketCreator.isLocalHost(this.bindAddress)) {
+            return this;
+          }
+          else {
+            throw new IllegalArgumentException(bindAddress + " is not an address for this
machine.");
+          }
         }
         catch (UnknownHostException e) {
           throw new IllegalArgumentException(LocalizedStrings.Launcher_Builder_UNKNOWN_HOST_ERROR_MESSAGE

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e51d1e44/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/ServerLauncher.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/ServerLauncher.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/ServerLauncher.java
index 4a2ce52..f13bb73 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/ServerLauncher.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/ServerLauncher.java
@@ -1959,8 +1959,13 @@ public final class ServerLauncher extends AbstractLauncher<String>
{
       else {
         try {
           this.serverBindAddress = InetAddress.getByName(serverBindAddress);
-          this.serverBindAddressSetByUser = true;
-          return this;
+          if (SocketCreator.isLocalHost(this.serverBindAddress)) {
+            this.serverBindAddressSetByUser = true;
+            return this;
+          }
+          else {
+            throw new IllegalArgumentException(serverBindAddress + " is not an address for
this machine.");
+          }
         }
         catch (UnknownHostException e) {
           throw new IllegalArgumentException(LocalizedStrings.Launcher_Builder_UNKNOWN_HOST_ERROR_MESSAGE

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e51d1e44/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
index aa7e028..556bf4f 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
@@ -121,13 +121,34 @@ public class LocatorLauncherJUnitTest {
       new Builder().setBindAddress("badhostname.badcompany.bad");
     }
     catch (IllegalArgumentException expected) {
-      final String expectedMessage = LocalizedStrings.Launcher_Builder_UNKNOWN_HOST_ERROR_MESSAGE.toLocalizedString("Locator");
-      assertEquals(expectedMessage, expected.getMessage());
-      assertTrue(expected.getCause() instanceof UnknownHostException);
+      final String expectedMessage1 = LocalizedStrings.Launcher_Builder_UNKNOWN_HOST_ERROR_MESSAGE.toLocalizedString("Locator");
+      final String expectedMessage2 = "badhostname.badcompany.bad is not an address for this
machine.";
+      assertTrue(expected.getMessage().equals(expectedMessage1) || expected.getMessage().equals(expectedMessage2));
+      if (expected.getMessage().equals(expectedMessage1)) {
+        assertTrue(expected.getCause() instanceof UnknownHostException);
+      }
       throw expected;
     }
   }
 
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetBindAddressToNonLocalHost() {
+    try {
+      new Builder().setBindAddress("yahoo.com");
+    }
+    catch (IllegalArgumentException expected) {
+      final String expectedMessage = "yahoo.com is not an address for this machine.";
+      assertEquals(expectedMessage, expected.getMessage());
+      throw expected;
+    }
+  }
+  
+  @Test
+  public void testSetBindAddressToLocalHost() throws Exception {        
+    String host = InetAddress.getLocalHost().getHostName();            
+    new Builder().setBindAddress(host);
+  }
+  
   @Test
   public void testSetAndGetHostnameForClients() {
     final Builder builder = new Builder();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e51d1e44/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
index 7240daa..2de4589 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
@@ -245,11 +245,33 @@ public class ServerLauncherJUnitTest {
       new Builder().setServerBindAddress("badHostName.badCompany.com");
     }
     catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_UNKNOWN_HOST_ERROR_MESSAGE.toLocalizedString("Server"),
expected.getMessage());
-      assertTrue(expected.getCause() instanceof UnknownHostException);
+      final String expectedMessage1 = LocalizedStrings.Launcher_Builder_UNKNOWN_HOST_ERROR_MESSAGE.toLocalizedString("Server");
+      final String expectedMessage2 = "badHostName.badCompany.com is not an address for this
machine.";
+      assertTrue(expected.getMessage().equals(expectedMessage1) || expected.getMessage().equals(expectedMessage2));
+      if (expected.getMessage().equals(expectedMessage1)) {
+        assertTrue(expected.getCause() instanceof UnknownHostException);
+      }
       throw expected;
     }
   }
+  
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetServerBindAddressToNonLocalHost() {
+    try {
+      new Builder().setServerBindAddress("yahoo.com");
+    }
+    catch (IllegalArgumentException expected) {
+      final String expectedMessage = "yahoo.com is not an address for this machine.";
+      assertEquals(expectedMessage, expected.getMessage());
+      throw expected;
+    }
+  }
+  
+  @Test
+  public void testSetServerBindAddressToLocalHost() throws Exception {
+    String host = InetAddress.getLocalHost().getHostName();            
+    new Builder().setServerBindAddress(host);
+  }
 
   @Test
   public void testSetAndGetHostnameForClients() {


Mime
View raw message